The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
feat(guardrails.tsx): show configured guardrails on proxy ui
Krrish Dholakiac7a3e5b4b2aa
diff --git a/litellm/proxy/_experimental/out/onboarding.html b/litellm/proxy/_experimental/out/onboarding.htmldeleted file mode 100644index 5d742a7a854..00000000000--- a/litellm/proxy/_experimental/out/onboarding.html+++ /dev/null@@ -1 +0,0 @@-<!DOCTYPE html><html id="__next_error__"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="preload" as="script" fetchPriority="low" href="/ui/_next/static/chunks/webpack-75a5453f51d60261.js"/><script src="/ui/_next/static/chunks/fd9d1056-f8f374bd771def60.js" async=""></script><script src="/ui/_next/static/chunks/117-2d8e84979f319d39.js" async=""></script><script src="/ui/_next/static/chunks/main-app-475d6efe4080647d.js" async=""></script><title>LiteLLM Dashboard</title><meta name="description" content="LiteLLM Proxy Admin UI"/><link rel="icon" href="/ui/favicon.ico" type="image/x-icon" sizes="16x16"/><meta name="next-size-adjust"/><script src="/ui/_next/static/chunks/polyfills-42372ed130431b0a.js" noModule=""></script></head><body><script src="/ui/_next/static/chunks/webpack-75a5453f51d60261.js" async=""></script><script>(self.__next_f=self.__next_f||[]).push([0]);self.__next_f.push([2,null])</script><script>self.__next_f.push([1,"1:HL[\"/ui/_next/static/media/a34f9d1faa5f3315-s.p.woff2\",\"font\",{\"crossOrigin\":\"\",\"type\":\"font/woff2\"}]\n2:HL[\"/ui/_next/static/css/86f6cc749f6b8493.css\",\"style\"]\n3:HL[\"/ui/_next/static/css/17e707d690fab559.css\",\"style\"]\n"])</script><script>self.__next_f.push([1,"4:I[12846,[],\"\"]\n6:I[19107,[],\"ClientPageRoot\"]\n7:I[12011,[\"665\",\"static/chunks/3014691f-6bdd9c4659caabcd.js\",\"42\",\"static/chunks/42-85111ce0453ddfcd.js\",\"755\",\"static/chunks/755-288e79da1358e7df.js\",\"250\",\"static/chunks/250-9fe99e6518e0255a.js\",\"461\",\"static/chunks/app/onboarding/page-c062a46fc186ad04.js\"],\"default\",1]\n8:I[4707,[],\"\"]\n9:I[36423,[],\"\"]\nb:I[61060,[],\"\"]\nc:[]\n"])</script><script>self.__next_f.push([1,"0:[\"$\",\"$L4\",null,{\"buildId\":\"XePrxHP98_zfLEaEqzmjZ\",\"assetPrefix\":\"/ui\",\"urlParts\":[\"\",\"onboarding\"],\"initialTree\":[\"\",{\"children\":[\"onboarding\",{\"children\":[\"__PAGE__\",{}]}]},\"$undefined\",\"$undefined\",true],\"initialSeedData\":[\"\",{\"children\":[\"onboarding\",{\"children\":[\"__PAGE__\",{},[[\"$L5\",[\"$\",\"$L6\",null,{\"props\":{\"params\":{},\"searchParams\":{}},\"Component\":\"$7\"}],null],null],null]},[null,[\"$\",\"$L8\",null,{\"parallelRouterKey\":\"children\",\"segmentPath\":[\"children\",\"onboarding\",\"children\"],\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L9\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":\"$undefined\",\"notFoundStyles\":\"$undefined\"}]],null]},[[[[\"$\",\"link\",\"0\",{\"rel\":\"stylesheet\",\"href\":\"/ui/_next/static/css/86f6cc749f6b8493.css\",\"precedence\":\"next\",\"crossOrigin\":\"$undefined\"}],[\"$\",\"link\",\"1\",{\"rel\":\"stylesheet\",\"href\":\"/ui/_next/static/css/17e707d690fab559.css\",\"precedence\":\"next\",\"crossOrigin\":\"$undefined\"}]],[\"$\",\"html\",null,{\"lang\":\"en\",\"children\":[\"$\",\"body\",null,{\"className\":\"__className_cf7686\",\"children\":[\"$\",\"$L8\",null,{\"parallelRouterKey\":\"children\",\"segmentPath\":[\"children\"],\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L9\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":[[\"$\",\"title\",null,{\"children\":\"404: This page could not be found.\"}],[\"$\",\"div\",null,{\"style\":{\"fontFamily\":\"system-ui,\\\"Segoe UI\\\",Roboto,Helvetica,Arial,sans-serif,\\\"Apple Color Emoji\\\",\\\"Segoe UI Emoji\\\"\",\"height\":\"100vh\",\"textAlign\":\"center\",\"display\":\"flex\",\"flexDirection\":\"column\",\"alignItems\":\"center\",\"justifyContent\":\"center\"},\"children\":[\"$\",\"div\",null,{\"children\":[[\"$\",\"style\",null,{\"dangerouslySetInnerHTML\":{\"__html\":\"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}\"}}],[\"$\",\"h1\",null,{\"className\":\"next-error-h1\",\"style\":{\"display\":\"inline-block\",\"margin\":\"0 20px 0 0\",\"padding\":\"0 23px 0 0\",\"fontSize\":24,\"fontWeight\":500,\"verticalAlign\":\"top\",\"lineHeight\":\"49px\"},\"children\":\"404\"}],[\"$\",\"div\",null,{\"style\":{\"display\":\"inline-block\"},\"children\":[\"$\",\"h2\",null,{\"style\":{\"fontSize\":14,\"fontWeight\":400,\"lineHeight\":\"49px\",\"margin\":0},\"children\":\"This page could not be found.\"}]}]]}]}]],\"notFoundStyles\":[]}]}]}]],null],null],\"couldBeIntercepted\":false,\"initialHead\":[null,\"$La\"],\"globalErrorComponent\":\"$b\",\"missingSlots\":\"$Wc\"}]\n"])</script><script>self.__next_f.push([1,"a:[[\"$\",\"meta\",\"0\",{\"name\":\"viewport\",\"content\":\"width=device-width, initial-scale=1\"}],[\"$\",\"meta\",\"1\",{\"charSet\":\"utf-8\"}],[\"$\",\"title\",\"2\",{\"children\":\"LiteLLM Dashboard\"}],[\"$\",\"meta\",\"3\",{\"name\":\"description\",\"content\":\"LiteLLM Proxy Admin UI\"}],[\"$\",\"link\",\"4\",{\"rel\":\"icon\",\"href\":\"/ui/favicon.ico\",\"type\":\"image/x-icon\",\"sizes\":\"16x16\"}],[\"$\",\"meta\",\"5\",{\"name\":\"next-size-adjust\"}]]\n5:null\n"])</script></body></html>\ No newline at end of filediff --git a/litellm/proxy/guardrails/guardrail_endpoints.py b/litellm/proxy/guardrails/guardrail_endpoints.pyindex b1919b45ef8..3b31c31a974 100644--- a/litellm/proxy/guardrails/guardrail_endpoints.py+++ b/litellm/proxy/guardrails/guardrail_endpoints.py@@ -79,9 +79,6 @@ async def list_guardrails():_guardrails_config = cast(Optional[list[dict]], config.get("guardrails"))if _guardrails_config is None:- raise HTTPException(- status_code=status.HTTP_404_NOT_FOUND,- detail={"error": "No guardrails found in config"},- )+ return _get_guardrails_list_response([])return _get_guardrails_list_response(_guardrails_config)diff --git a/ui/litellm-dashboard/src/app/page.tsx b/ui/litellm-dashboard/src/app/page.tsxindex 5894df2c71f..3a089bf8067 100644--- a/ui/litellm-dashboard/src/app/page.tsx+++ b/ui/litellm-dashboard/src/app/page.tsx@@ -25,7 +25,7 @@ import Usage from "@/components/usage";import CacheDashboard from "@/components/cache_dashboard";import { setGlobalLitellmHeaderName } from "@/components/networking";import { Organization } from "@/components/networking";-+import GuardrailsPanel from "@/components/guardrails";function getCookie(name: string) {const cookieValue = document.cookie.split("; ")@@ -309,6 +309,8 @@ export default function CreateKeyPage() {/>) : page == "budgets" ? (<BudgetPanel accessToken={accessToken} />+ ) : page == "guardrails" ? (+ <GuardrailsPanel accessToken={accessToken} />) : page == "general-settings" ? (<GeneralSettingsuserID={userID}diff --git a/ui/litellm-dashboard/src/components/guardrails.tsx b/ui/litellm-dashboard/src/components/guardrails.tsxnew file mode 100644index 00000000000..19af63233cf--- /dev/null+++ b/ui/litellm-dashboard/src/components/guardrails.tsx@@ -0,0 +1,74 @@+import React, { useState, useEffect } from "react";+import {+ Table,+ TableBody,+ TableCell,+ TableHead,+ TableHeaderCell,+ TableRow,+ Card,+ Text,+} from "@tremor/react";+import { getGuardrailsList } from "./networking";++interface GuardrailsPanelProps {+ accessToken: string | null;+}++interface GuardrailItem {+ name: string;+ mode: string;+ status: "always_on" | "per_request";+}++const GuardrailsPanel: React.FC<GuardrailsPanelProps> = ({ accessToken }) => {+ const [guardrailsList, setGuardrailsList] = useState<GuardrailItem[]>([]);++ useEffect(() => {+ if (!accessToken) {+ return;+ }++ const fetchGuardrails = async () => {+ try {+ const response = await getGuardrailsList(accessToken);+ setGuardrailsList(response);+ } catch (error) {+ console.error('Error fetching guardrails:', error);+ }+ };++ fetchGuardrails();+ }, [accessToken]);++ return (+ <div className="w-full mx-auto flex-auto overflow-y-auto m-8 p-2">+ <Card>+ <Text>Configured guardrails and their current status.</Text>+ <Table>+ <TableHead>+ <TableRow>+ <TableHeaderCell>Guardrail Name</TableHeaderCell>+ <TableHeaderCell>Mode</TableHeaderCell>+ <TableHeaderCell>Status</TableHeaderCell>+ </TableRow>+ </TableHead>++ <TableBody>+ {guardrailsList.map((guardrail: GuardrailItem, index: number) => (+ <TableRow key={index}>+ <TableCell>{guardrail.name}</TableCell>+ <TableCell>{guardrail.mode}</TableCell>+ <TableCell>+ {guardrail.status === 'always_on' ? 'Always On' : 'Per Request'}+ </TableCell>+ </TableRow>+ ))}+ </TableBody>+ </Table>+ </Card>+ </div>+ );+};++export default GuardrailsPanel;\ No newline at end of filediff --git a/ui/litellm-dashboard/src/components/leftnav.tsx b/ui/litellm-dashboard/src/components/leftnav.tsxindex 54668233d5c..4811f2d5b24 100644--- a/ui/litellm-dashboard/src/components/leftnav.tsx+++ b/ui/litellm-dashboard/src/components/leftnav.tsx@@ -67,7 +67,7 @@ const menuItems: MenuItem[] = [children: [{ key: "9", page: "caching", label: "Caching", icon: <DatabaseOutlined />, roles: all_admin_roles },{ key: "10", page: "budgets", label: "Budgets", icon: <BankOutlined />, roles: all_admin_roles },- { key: "11", page: "budgets", label: "Guardrails", icon: <SafetyOutlined />, roles: all_admin_roles },+ { key: "11", page: "guardrails", label: "Guardrails", icon: <SafetyOutlined />, roles: all_admin_roles },]},{