Guardrails
A guardrail rule screens requests before they leave the gateway, responses before they reach the caller, or both. Each rule has:- A direction:
input,output, orboth. - An action:
deny,redact, orlog. - A check: a regex pattern, or an external large language model (LLM) evaluator. An LLM evaluator is any HTTP endpoint that returns a
score, which the gateway compares to the rule’s threshold.
What the gateway scans
On input, the gateway scans user turns and tool results, so a personally identifiable information (PII) rule fires on file contents an agent sends back through a tool call. The gateway tags requests with tool results assource="tool_result" in the audit log.
Guardrail limits
- On streaming responses, output rules can only log. The response is already delivered by the time the gateway has the full text, so
denyandredactbecomelog. - The gateway checks text only. It skips images in multimodal requests.
- The gateway doesn’t scan system prompts, the Responses
instructionsfield, or earlier assistant turns. - The gateway doesn’t scan tool-call arguments the model generates, such as a URL, shell command, or SQL string.
- Each LLM evaluator rule adds a network round trip to every matching request. Use regex rules for high-volume checks.
Fallback routing
A fallback chain is an ordered list of aliases to try when the primary alias fails. Set it on the primary alias under Catalog > edit alias > Fallback chain. Links in the chain inherit the primary alias’s triggers and per-attempt timeout.Triggers
These triggers are all on by default:timeout, 5xx, 429, and budget_exhausted. Other 4xx errors, such as auth failures, guardrail denials, and malformed requests, don’t advance the chain.
How the gateway walks the chain
The gateway checks access on each link as if the caller had requested it directly, and skips links the caller can’t use. Each attempt gets its own usage log entry. A reply served by a fallback carriesX-LLM-Fallback-Reason and X-LLM-Fallback-Served-By headers. The Logs view can filter to fallback events.
Fallback limits
- Chains apply to
/v1/chat/completionsonly. - Fallback happens before the response starts. An error mid-stream goes to the caller.
- Streaming requests fall back only on a budget block, not on upstream errors.
Related
- LLM Gateway 2.0: what the gateway routes, its endpoints, and how callers make their first request.
- Control access, spend, and usage: the grants and budgets the gateway checks on each fallback link.
- Run batch jobs: how guardrails apply to each line in a batch.