POST /v2/agent_gateways/{id}/guardrails adds one. This guardrail masks Social Security numbers and email addresses before a request reaches the model:
Modes
Each guardrail runs in one or more of these modes, and each type runs in some of them:Scope
A guardrail withalways_on runs on every request. Any other guardrail runs on the requests that name it in guardrails:
Built-In Guardrails
These types run on the instance itself, with no outside service:
A
custom_code guardrail defines apply_guardrail(inputs, request_data, input_type). It reads the texts in inputs["texts"] and returns allow(), block(reason), or modify(texts=...):
Provider Guardrails
These types send the request to an outside service, and need an account with it:lakera (Lakera Guard), presidio (Microsoft Presidio), bedrock (Amazon Bedrock Guardrails), and azure_content_safety (Azure AI Content Safety). A provider’s API key and AWS keys are write-only. No response returns them, and an update sends them again with the whole settings.
Blocking and Masking
How a block reaches the agent depends on the guardrail:- A content filter or tool permission guardrail fails a model request with
400and its reason as the error message, such asContent blocked: us_ssn pattern detected. - A model judge fails it with
422andLLM judge rejected response: score below threshold. - A custom code guardrail answers the request with its reason in place of the model’s response.
- A block after a stream starts closes the stream before it completes.
- A blocked tool request returns a tool result with
isError: true.
123-45-6789 reaches the model as [US_SSN_REDACTED]. In a tool mode, it masks the tool’s arguments before they reach the server, or the tool’s result before it reaches the agent.