Configuring AI Guardrail Policies
AI guardrail policies let you screen the prompts and responses flowing through the AI Gateway for unsafe or unwanted content. This guide shows how to enable toxicity, bias, topic-block, and prompt-injection guardrails and choose what happens when each one triggers.
Before you begin
- ▸You'll need an account with permission to edit gateway policies — typically an administrator or security role.
- ▸Guardrails apply to traffic routed through the AI Gateway. Requests that bypass the gateway are not evaluated.
- ▸Changes apply to new requests shortly after you save. No redeploy is required.
Available guardrails
- ▸Toxicity — flags hateful, harassing, or abusive language in prompts and model output.
- ▸Bias — detects discriminatory or unfair content across protected attributes.
- ▸Topic block — restricts conversations from drifting into subjects you define (for example, legal or medical advice).
- ▸Prompt injection — catches attempts to override system instructions or exfiltrate hidden context.
Choosing an action
Each guardrail runs independently and you assign it one action:
- ▸Monitor — log the event but let the request through. Best for tuning.
- ▸Redact — mask the offending span and continue.
- ▸Block — reject the request and return a safe error to the caller.
Start new guardrails in Monitor mode for a few days, review what they catch, then promote them to Block once you're confident in the thresholds.
Enable a guardrail
- 1.Go to AI Gateway → Guardrails in the dashboard.
- 2.Select the policy you want to edit, or create one and scope it to an application or API key.
- 3.Toggle on Toxicity, Bias, Topic block, or Prompt injection.
- 4.For each enabled guardrail, set the sensitivity threshold and choose Monitor, Redact, or Block.
- 5.For Topic block, add the topics or keywords you want to disallow.
- 6.Click Save to apply the policy.
Configure with the API
You can also manage policies programmatically. The following is an illustrative payload; check your account's API reference for the exact field names your deployment supports:
{
"policy_name": "production-default",
"guardrails": {
"toxicity": { "enabled": true, "threshold": 0.8, "action": "block" },
"bias": { "enabled": true, "threshold": 0.7, "action": "redact" },
"topic_block": { "enabled": true, "topics": ["legal_advice"], "action": "block" },
"prompt_injection": { "enabled": true, "action": "block" }
}
}Review what fired
Every triggered guardrail is recorded with the matched category, action taken, and a snippet of the flagged content. Open AI Gateway → Activity to filter events by guardrail and refine your thresholds.
A high sensitivity threshold with Block can reject legitimate traffic. Watch your activity log after tightening a policy and adjust if false positives climb.
Need to route blocked traffic differently or alert on spikes? See AI Gateway routing rules.