LiteLLM Guardrails
Overview
Fiddler implements the LiteLLM Generic Guardrail API spec, allowing you to plug Fiddler’s guardrails directly into a LiteLLM proxy gateway. Once configured, every LLM request routed through the proxy is checked by Fiddler before it reaches the model. Fiddler checks for:- Secrets — API keys, tokens, credentials, and connection strings in prompts
- PII — Personal identifiable information (names, emails, phone numbers, SSNs, credit cards, etc.)
How It Works
LiteLLM calls the Fiddler endpoint with the extracted text from the request (or response). Fiddler returns one of three actions:Supported Modes
Fiddler supports all three LiteLLM guardrail modes. Setmode in your proxy config to one or more of:
during_call runs the guardrail concurrently with the LLM call — the response is held until the check completes, but latency is hidden behind the LLM round-trip. Use it when you want lower end-to-end latency and don’t need input redaction (block-only is sufficient).mode: [pre_call, post_call] scans both input and output:
Supported Endpoints
The guardrail runs on all LiteLLM proxy endpoints that carry text content, including/v1/chat/completions (OpenAI format) and /v1/messages (Anthropic format). LiteLLM extracts text from the request and forwards it to the Fiddler endpoint regardless of the upstream provider format.
What Gets Scanned
- Free-text messages — user, assistant, and system messages. PII/secrets are redacted in place (e.g.
[REDACTED EMAIL_ADDRESS]). - Tool-call arguments — structured JSON in
tool_calls[].function.arguments. Detections are always blocked (cannot safely redact inside structured JSON — see Tool Call Handling).
Quick Start
Step 1: Configure LiteLLM
Add the Fiddler guardrail to your LiteLLMconfig.yaml:
/beta/litellm_basic_guardrail_api to api_base automatically. The full endpoint called will be https://<your-fiddler-instance>/v3/guardrails/litellm/beta/litellm_basic_guardrail_api.
Step 2: Start the proxy
Step 3: Verify
Send a request with a known secret:[REDACTED ANTHROPIC_API_KEY] before the request reaches the model.
Per-Request Control
Withdefault_on: true (the recommended config above), the guardrail runs on every request automatically. You can also control it per request.
Selective activation (default_on: false)
Set default_on: false in the proxy config, then activate the guardrail on individual requests by passing guardrails in the request body:
"guardrails": ["fiddler"] will bypass the guardrail entirely.
Check Behavior
Each check is configured entirely in the LiteLLM proxy’sadditional_provider_specific_params:
enabled(true/false) — whether the check runs at all.mode(redact/block) — what happens when a detection is found. Default isredactfor PII and secrets.thresholdandentities— detection sensitivity.
Secrets
Detects credentials, API keys, and tokens.PII
Detects personal identifiable information.
Entities checked by default include:
person, email, phone number, social security number, credit card number, bank account number, passport number, driver's license number, date of birth, address, ip address, iban, cvv, cvc, tax identification number, digital signature, license plate number, postal code, and more. For the complete list see the PII Detection tutorial.
Tool Call Handling
When an LLM’stool_calls contain PII or secrets, Fiddler always blocks rather than redacts.
Why: Tool call arguments are structured JSON that the downstream application will parse and execute. Replacing a value like an email address with [REDACTED EMAIL_ADDRESS] would cause send_email to attempt delivery to a nonsensical address — producing unpredictable behavior that is worse than blocking outright.
Example — blocked tool call:
Tool Results
Fiddler does not claim redaction coverage for tool results. Whether tool result content reaches the scanner depends on the LiteLLM gateway: LiteLLM must include the tool result in thetexts[] it forwards to Fiddler. This is not guaranteed for all gateway configurations or versions, and is known not to work on customer-managed or self-hosted gateways that do not extract role:tool / tool_result messages into texts[].
Additionally, tool results are typed as any in the GenAI semantic conventions — they can be plain strings, JSON objects, or arrays. Even when the text does reach the scanner, in-place character-span redaction on a serialized JSON payload is not safe if the downstream application re-parses the result as structured data.
For reliable protection against secrets in tool output, use mode: block on secrets and treat tool result content as untrusted.
Failure Mode
Two settings control what happens when the guardrail cannot complete a check — one at the LiteLLM proxy level, one at the Fiddler endpoint level. Both should be set for end-to-end fail-closed.unreachable_fallback (LiteLLM proxy)
Controls what happens when the Fiddler endpoint is unreachable (network error, HTTP 502/503/504).
This is a standard LiteLLM Generic Guardrail API setting.
failure_mode (Fiddler endpoint)
Controls what happens when an internal check fails to complete — an inference timeout, an inference server error, or an unexpected exception in the detection pipeline. The LiteLLM proxy cannot see these failures because the Fiddler endpoint still returns HTTP 200.
The default is
open for backward compatibility. For security-sensitive deployments, set failure_mode: closed. When both unreachable_fallback: fail_closed and failure_mode: closed are set, no request can bypass scanning — whether the failure is at the transport or detector level.Limits & Timeouts
Text Length
The maximum total text length scanned per request is controlled by theGUARDRAILS_MAX_TEXT_LENGTH environment variable on the Fiddler server (default: 50,000 characters). Messages are concatenated until this cap is reached; text beyond the cap is handled as follows:
Timeouts
The guardrail check has a single customer-facing timeout: the wall-clock deadline for the whole check pipeline — how long the endpoint blocks before returning. Set it per request viatimeout (seconds) in additional_provider_specific_params:
failure_mode — under open the request proceeds unscanned, under closed it is blocked.
The internal inference-call timeouts (
GUARDRAILS_GATEWAY_READ_TIMEOUT, default 10s, and GUARDRAILS_GATEWAY_CONN_TIMEOUT, default 3s) are server-side plumbing for the connection to the detection models. They are lower than the wall-clock timeout and are not part of the customer-facing config.Observed Behavior
Client-Facing Error Body
When a request is blocked, LiteLLM returns an error to the client. Your application should handle this shape:message field contains the blocked_reason from Fiddler’s response, prefixed by LiteLLM with the guardrail name. HTTP status is 400 on LiteLLM ≥ 1.88.0.
API Reference
Endpoint
Authorization: Bearer <your-fiddler-api-key>
Request
texts and tool_calls[].function.arguments are scanned by guardrail checks. The remaining fields are accepted for LiteLLM protocol compatibility.
Response
Fields withnull values are omitted from the wire (exclude_none=True). The response shape varies by action: