Guardrails Reference
Guardrails are expressed with two gateway-agnostic Custom Resource Definitions:
-
GuardrailProvider — a backend that implements a specific guardrail API contract.
-
Guard — a policy that binds a provider to a concrete inspection point (pre-call, post-call, during-call) with provider-specific configuration.
Gateway resources (for example AiGateway) reference one or more Guards in their spec.guardrails list.
How Guardrails Work
Two-tier model
GuardrailProvider and Guard separate transport from policy:
-
GuardrailProviderdeclares where and how to reach a backend service that implements a guardrail contract (Presidio, OpenAI Moderation, AWS Bedrock). One provider can back many guards. -
Guardbinds a provider to a concrete policy: when it runs (mode), and what configuration to apply (entity actions, score thresholds, language, …). Each guard targets exactly one provider.
This split lets a platform team operate one set of provider deployments while application teams own the per-gateway policies that reference them.
Runtime model
Gateway CRDs expose a uniform guardrails field — an ordered list of references to Guard resources. The owning gateway operator turns each reference into runtime configuration in two steps:
-
Resolution — the operator reads the referenced
Guardand itsproviderRef, then validates that the provider type is one it supports for that gateway. Missing references, unsupported provider types, and invalid configuration surface asReady=Falseconditions on theGuardand/or the gateway. Operators reconcile gateways when referencedGuardandGuardrailProviderresources change, so policy updates roll out automatically. -
Translation — the operator translates the resolved Guard plus provider into the gateway implementation’s native guardrail mechanism. The translation is implementation-specific:
-
The AI Gateway LiteLLM Operator writes a
guardrails:block into the LiteLLMConfigMap, with each entry carrying the resolved provider URL, score thresholds, and entity actions. -
The Tool Gateway Agentgateway Operator deploys a dedicated
guardrail-adapterworkload per Guard and wires the gateway’sAgentgatewayPolicyextProc.backendRefat it.
-
At request time, the gateway invokes the configured guardrail at the points selected by Guard.spec.mode (pre_call, post_call, during_call — see Guard modes). The provider returns the inspected payload with sensitive entities replaced (action MASK) or signals that the call should be rejected (BLOCK); the gateway applies the decision before forwarding traffic.
Cross-namespace references
Guard.spec.providerRef and the ObjectReference entries in <Gateway>.spec.guardrails both accept explicit namespace fields, defaulting to the referencing resource’s own namespace. This supports a layered layout:
-
Shared
GuardrailProviderresources in aguardrail-providersnamespace. -
Reusable
Guardresources in aguardsnamespace. -
Application gateways in their own namespaces, referencing both.
Gateway operators are granted RBAC to read Guard and GuardrailProvider resources cluster-wide.
Operator-specific behaviour
Translation, status conditions, and per-provider support vary by gateway operator. The Gateway Support Matrix below summarises what each operator implements today; for the full per-gateway behaviour see the operator’s own reference page.
GuardrailProvider
A GuardrailProvider describes where and how to reach a guardrail backend.
Per-policy tuning (which entities to catch, at which confidence, what to do with them) lives on the Guard, not on the provider.
Spec
| Field | Type | Description |
|---|---|---|
|
|
API contract implemented by this provider. One of |
|
object |
Configuration for |
|
object |
Configuration for |
|
object |
Configuration for |
presidio config
| Field | Type | Description |
|---|---|---|
|
URI (required) |
HTTP endpoint of the Presidio Analyzer service. Must be reachable from the gateway’s namespace. |
|
|
Optional API key for authenticated Presidio deployments. |
openaiModeration config
| Field | Type | Description |
|---|---|---|
|
URI |
Override the default |
|
|
Reference to the Secret key that contains the API key. |
Guard
A Guard binds a provider to a concrete policy and defines when the policy runs relative to the LLM or tool call.
Spec
| Field | Type | Description |
|---|---|---|
|
|
When the guard is applied. Each entry is one of |
|
|
Human-readable description. Documentation only; has no runtime effect. |
|
|
Reference to the |
|
object |
Guard-level configuration for OpenAI Moderation. |
|
object |
Guard-level configuration for AWS Bedrock Guardrails. |
|
object |
Guard-level configuration for Presidio. |
Guard modes
| Mode | What it inspects |
|---|---|
|
The outgoing payload before it reaches the LLM or tool server (prompt, tool call arguments). |
|
The payload returned from the LLM or tool server (response text, tool results) before it reaches the caller. |
|
Both the request and response. For protocols without a streaming body (for example MCP), this is equivalent to |
presidio guard config
| Field | Type | Description |
|---|---|---|
|
|
ISO language code for the content under inspection (for example |
|
|
Per-entity confidence cutoffs in the range |
|
|
Maps entity types to actions. |
Presidio entity types are documented at https://microsoft.github.io/presidio/supported_entities/.
Common examples: PERSON, EMAIL_ADDRESS, PHONE_NUMBER, CREDIT_CARD, IP_ADDRESS, IBAN_CODE, US_SSN.
Attaching Guards to Gateways
Gateway CRDs expose a uniform guardrails field — an ordered list of ObjectReference entries pointing at Guard resources. The gateway’s operator resolves each reference, loads the referenced GuardrailProvider, and configures the underlying gateway accordingly.
spec:
guardrails:
- name: pii-guard
namespace: guards
- name: toxic-language-guard
namespace: guards
The field is present on:
-
AiGateway.spec.guardrails -
AgentGateway.spec.guardrails -
ToolGateway.spec.guardrails
Gateway Support Matrix
| Gateway | Implementing operator | Supported provider types | Notes |
|---|---|---|---|
|
|
Generates LiteLLM |
|
|
agent-gateway-krakend-operator |
— |
Not yet implemented. The |
|
|
For each referenced |