Skip to content

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 alias

scope 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 ​

IdWhat it does
pii-baselineMasks emails, phone numbers and US social security numbers; blocks card numbers and API keys.
pii-strictBaseline plus passports, IBANs, street addresses, IP addresses and national identifiers (masked); cards and keys blocked.
prompt-injectionBlocks jailbreaks, system-prompt extraction, data-exfiltration and malicious-code requests (keyword based, no outside service).
secrets-blockRefuses prompts that contain an AWS key, GitHub token, Slack token or generic API key.
harmful-contentBlocks requests about self-harm, violence, illegal weapons and child safety.
bias-and-discriminationBlocks requests for biased or discriminatory content.
no-professional-adviceBlocks prompts that ask for legal, medical or financial advice.
sql-injectionBlocks prompts that look like SQL injection.
claims-phiFor 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.

Copyright © 2026 elsai foundry.