Custom code guardrails
12 ready-made guardrails you can copy, customize and deploy on the LiteLLM AI Gateway to check requests and responses. See the custom code guardrails docs.
Security guardrails
- PII Detector: Detects and blocks personally identifiable information like SSNs, credit cards, and phone numbers
- PII Redactor: Redacts PII from inputs by replacing with [REDACTED] markers
- Prompt Injection Detector: Detects common prompt injection patterns and jailbreak attempts
- URL Validator: Validates and filters URLs in requests, blocking suspicious domains
- API Key Detector: Detects and blocks accidental API key exposure in prompts
Validation guardrails
- JSON Schema Validator: Validates that LLM responses conform to a specified JSON schema
- Word Count Limit: Enforces maximum word count on inputs or outputs
- Language Detector: Detects and optionally restricts content to specific languages
Content guardrails
- Code Detector: Detects code in responses and optionally blocks or flags certain languages
Formatting guardrails
- Response Formatter: Formats and cleans LLM responses (removes markdown, extra whitespace, etc.)
Moderation guardrails
- Toxic Content Filter: Filters toxic, offensive, or inappropriate content using keyword matching
Rate-limiting guardrails
- Rate Limit by User: Implements per-user rate limiting using request metadata