Guardrails
Block and redact what you don't want to send upstream.
Three layers, all opt-in per org: regex block patterns, regex redact patterns, and OpenAI's free moderation pre-check. Configured at /dashboard/settings · Guardrails. Anything heavier (smart PII detection, prompt-injection defense, jailbreak detection) we explicitly hand off to specialists — documented integrations are linked below.
What we ship
- Block patterns. Any regex that matches in the prompt rejects the request with
400 prompt_blocked. The response names which pattern fired so your client can show a useful error. - Redact patterns. Matches get replaced with
[REDACTED]before dispatch. Useful for "always strip our customers' email addresses" or "never send file paths to OpenAI." - OpenAI moderation pre-check. Optional per-org toggle. Every prompt is fired at OpenAI's free moderation endpoint before dispatch; a flagged response returns 400 with which categories tripped. Adds ~200–500ms latency. Only fires when the gateway also has
OPENAI_API_KEYset.
Why we don't ship more
Generic regex is fine for "block my company name" or "strip phone numbers." It is not fine for real PII detection, prompt-injection defense, or jailbreak detection — problems where a leaky filter creates more legal exposure than no filter at all because customers assume they're protected.
For those, we link out to specialist vendors who do nothing else and do it much better than we could. Each integrates cleanly in front of or behind Leanroute as a separate gateway hop.
Specialist integrations
PII detection + redaction
Microsoft Presidio
Open source, model-backed. Handles names, addresses, IDs, account numbers across many locales.
Prompt injection defense
Lakera Guard
Hosted SaaS. Detects 'ignore previous instructions' and similar attacks across model families.
Jailbreak detection
Rebuff
Open source. Multi-layered jailbreak detection including a canary-token approach.
How it shows up in the API
A blocked request returns 400 prompt_blocked. The body tells the client what to do next:
{
"error": {
"code": "prompt_blocked",
"message": "Your prompt matched a guardrail pattern. Edit the prompt or update the pattern in /dashboard/settings.",
"scope": "block",
"pattern": "\\bSSN\\s*\\d{3}-\\d{2}-\\d{4}\\b",
"support_url": "mailto:[email protected]"
}
}For moderation pre-checks the body carries scope: "moderation" and a categories array listing which content categories tripped.
Full error reference at /docs/api.
See also: Developer guide · Integration guides · Compliance.