Appearance
Guardrail Templates
Templates are ready-made guardrail bundles (PII masking, prompt-injection blocking, and so on) that you switch on from policy.yaml. At start-up the gateway adds the ones you use to the LiteLLM config as guardrails, a policy and attachments, so LiteLLM's own guardrail engine does the work.
yaml
templates:
- {use: pii-baseline, scope: all} # everyone
- {use: prompt-injection, teams: ["claims-*"]} # teams by alias (wildcards allowed)
- {use: claims-phi, keys: [alice]} # keys by aliasscope is all, or use teams, keys or models.
Server only
Templates need the proxy. The in-process SDK ignores them and logs policy.yaml switches on guardrail templates; they need the proxy and are ignored by the in-process SDK.
Built-in templates
| Id | What it does |
|---|---|
pii-baseline | Masks emails, phone numbers and US social security numbers; blocks card numbers and API keys. |
pii-strict | Baseline plus passports, IBANs, street addresses, IP addresses and national identifiers (masked); cards and keys blocked. |
prompt-injection | Blocks jailbreaks, system-prompt extraction, data-exfiltration and malicious-code requests (keyword based, no outside service). |
secrets-block | Refuses prompts that contain an AWS key, GitHub token, Slack token or generic API key. |
harmful-content | Blocks requests about self-harm, violence, illegal weapons and child safety. |
bias-and-discrimination | Blocks requests for biased or discriminatory content. |
no-professional-advice | Blocks prompts that ask for legal, medical or financial advice. |
sql-injection | Blocks prompts that look like SQL injection. |
claims-phi | For healthcare claims teams: masks identifiers and blocks bulk member data, PHI disclosure and prior-authorisation gaming. A technical control, not a compliance certification. |
List what is available on your deployment with GET /admin/v1/policy-templates.
Blocked requests
A blocked request returns 400 with the reason, for example:
text
Content blocked: aws_access_key pattern detected
Content blocked: prompt_injection_system_prompt conditional match 'reveal + system prompt' detected (severity: high)Your own templates
A template is a YAML file with a title, description, complexity and the LiteLLM guardrails it needs. Put it in a directory and set GATEWAY_TEMPLATES_DIR; a template there wins over a built-in with the same id.