diff --git a/litellm/proxy/_lazy_openapi_snapshot.json b/litellm/proxy/_lazy_openapi_snapshot.json index dba2b2428aa..f19e0438e08 100644 --- a/litellm/proxy/_lazy_openapi_snapshot.json +++ b/litellm/proxy/_lazy_openapi_snapshot.json @@ -10543,6 +10543,11 @@ ], "title": "Created At" }, + "enabled": { + "default": true, + "title": "Enabled", + "type": "boolean" + }, "guardrail_definition_location": { "$ref": "#/components/schemas/GUARDRAIL_DEFINITION_LOCATION", "default": "config" @@ -12992,6 +12997,42 @@ "title": "RegisterGuardrailResponse", "type": "object" }, + "SetGuardrailEnabledRequest": { + "properties": { + "enabled": { + "title": "Enabled", + "type": "boolean" + } + }, + "required": [ + "enabled" + ], + "title": "SetGuardrailEnabledRequest", + "type": "object" + }, + "SetGuardrailEnabledResponse": { + "properties": { + "enabled": { + "title": "Enabled", + "type": "boolean" + }, + "guardrail_id": { + "title": "Guardrail Id", + "type": "string" + }, + "guardrail_name": { + "title": "Guardrail Name", + "type": "string" + } + }, + "required": [ + "guardrail_id", + "guardrail_name", + "enabled" + ], + "title": "SetGuardrailEnabledResponse", + "type": "object" + }, "TestCustomCodeGuardrailRequest": { "description": "Request model for testing custom code guardrails.", "properties": { @@ -14927,6 +14968,64 @@ ] } }, + "/guardrails/{guardrail_id}/enabled": { + "patch": { + "description": "Turn a guardrail off or back on at runtime without editing or deleting it\n\nWorks for guardrails defined in config.yaml as well as ones created in the DB.\nA disabled guardrail stays registered but skips every request until it is\nre-enabled. The state is persisted, so it survives restarts and applies to\nall proxy instances sharing the DB.\n\nExample Request:\n```bash\ncurl -X PATCH \"http://localhost:4000/guardrails/123e4567-e89b-12d3-a456-426614174000/enabled\" \\\n -H \"Authorization: Bearer \" \\\n -H \"Content-Type: application/json\" \\\n -d '{\"enabled\": false}'\n```\n\nExample Response:\n```json\n{\n \"guardrail_id\": \"123e4567-e89b-12d3-a456-426614174000\",\n \"guardrail_name\": \"headroom-compression\",\n \"enabled\": false\n}\n```", + "operationId": "set_guardrail_enabled_guardrails__guardrail_id__enabled_patch", + "parameters": [ + { + "in": "path", + "name": "guardrail_id", + "required": true, + "schema": { + "title": "Guardrail Id", + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/SetGuardrailEnabledRequest" + } + } + }, + "required": true + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/SetGuardrailEnabledResponse" + } + } + }, + "description": "Successful Response" + }, + "422": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } + } + }, + "description": "Validation Error" + } + }, + "security": [ + { + "APIKeyHeader": [] + } + ], + "summary": "Set Guardrail Enabled", + "tags": [ + "guardrails" + ] + } + }, "/guardrails/{guardrail_id}/info": { "get": { "description": "Get detailed information about a specific guardrail by ID\n\n\ud83d\udc49 [Guardrail docs](https://docs.litellm.ai/docs/proxy/guardrails/quick_start)\n\nExample Request:\n```bash\ncurl -X GET \"http://localhost:4000/guardrails/123e4567-e89b-12d3-a456-426614174000/info\" \\\n -H \"Authorization: Bearer \"\n```\n\nExample Response:\n```json\n{\n \"guardrail_id\": \"123e4567-e89b-12d3-a456-426614174000\",\n \"guardrail_name\": \"my-bedrock-guard\",\n \"litellm_params\": {\n \"guardrail\": \"bedrock\",\n \"mode\": \"pre_call\",\n \"guardrailIdentifier\": \"ff6ujrregl1q\",\n \"guardrailVersion\": \"DRAFT\",\n \"default_on\": true\n },\n \"guardrail_info\": {\n \"description\": \"Bedrock content moderation guardrail\"\n },\n \"created_at\": \"2023-11-09T12:34:56.789Z\",\n \"updated_at\": \"2023-11-09T12:34:56.789Z\"\n}\n```", diff --git a/ui/litellm-dashboard/src/lib/http/schema.d.ts b/ui/litellm-dashboard/src/lib/http/schema.d.ts index 6c2311a0ed9..9ba086677f0 100644 --- a/ui/litellm-dashboard/src/lib/http/schema.d.ts +++ b/ui/litellm-dashboard/src/lib/http/schema.d.ts @@ -6616,6 +6616,48 @@ export interface paths { patch: operations["patch_guardrail_guardrails__guardrail_id__patch"]; trace?: never; }; + "/guardrails/{guardrail_id}/enabled": { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + get?: never; + put?: never; + post?: never; + delete?: never; + options?: never; + head?: never; + /** + * Set Guardrail Enabled + * @description Turn a guardrail off or back on at runtime without editing or deleting it + * + * Works for guardrails defined in config.yaml as well as ones created in the DB. + * A disabled guardrail stays registered but skips every request until it is + * re-enabled. The state is persisted, so it survives restarts and applies to + * all proxy instances sharing the DB. + * + * Example Request: + * ```bash + * curl -X PATCH "http://localhost:4000/guardrails/123e4567-e89b-12d3-a456-426614174000/enabled" \ + * -H "Authorization: Bearer " \ + * -H "Content-Type: application/json" \ + * -d '{"enabled": false}' + * ``` + * + * Example Response: + * ```json + * { + * "guardrail_id": "123e4567-e89b-12d3-a456-426614174000", + * "guardrail_name": "headroom-compression", + * "enabled": false + * } + * ``` + */ + patch: operations["set_guardrail_enabled_guardrails__guardrail_id__enabled_patch"]; + trace?: never; + }; "/guardrails/{guardrail_id}/info": { parameters: { query?: never; @@ -27822,6 +27864,11 @@ export interface components { GuardrailInfoResponse: { /** Created At */ created_at?: string | null; + /** + * Enabled + * @default true + */ + enabled: boolean; /** @default config */ guardrail_definition_location: components["schemas"]["GUARDRAIL_DEFINITION_LOCATION"]; /** Guardrail Id */ @@ -35839,6 +35886,20 @@ export interface components { /** Timeout */ timeout?: number | null; }; + /** SetGuardrailEnabledRequest */ + SetGuardrailEnabledRequest: { + /** Enabled */ + enabled: boolean; + }; + /** SetGuardrailEnabledResponse */ + SetGuardrailEnabledResponse: { + /** Enabled */ + enabled: boolean; + /** Guardrail Id */ + guardrail_id: string; + /** Guardrail Name */ + guardrail_name: string; + }; /** * ShadowEvalJobResponse * @description A shadow-eval job over one or more targets, each with its own budget and stop state; @@ -48838,6 +48899,41 @@ export interface operations { }; }; }; + set_guardrail_enabled_guardrails__guardrail_id__enabled_patch: { + parameters: { + query?: never; + header?: never; + path: { + guardrail_id: string; + }; + cookie?: never; + }; + requestBody: { + content: { + "application/json": components["schemas"]["SetGuardrailEnabledRequest"]; + }; + }; + responses: { + /** @description Successful Response */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["SetGuardrailEnabledResponse"]; + }; + }; + /** @description Validation Error */ + 422: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["HTTPValidationError"]; + }; + }; + }; + }; get_guardrail_info_guardrails__guardrail_id__info_get: { parameters: { query?: never;