Guardrails
Protect your LLM usage with content guardrails that detect and block harmful content
Guardrails protect your organization by automatically detecting and blocking harmful content in LLM requests before they reach the model.
Guardrails are available on the Enterprise plan.
Overview
Guardrails run on every API request, scanning message content for:
- Security threats (prompt injection, jailbreak attempts)
- Sensitive data (PII, secrets, credentials)
- Policy violations (blocked terms, restricted topics)
When a violation is detected, you control what happens: block the request, redact the content, or log a warning.
Organization and Project Scopes
Guardrails are configured for the whole organization by default, and every project uses that configuration.
A project can opt out and define its own guardrails instead — useful when one application needs stricter or looser rules than the rest of the organization. Turn off Use organization guardrails in the project's Guardrails settings, and that project's configuration and custom rules fully replace the organization's for its traffic.
Exactly one scope is ever in force for a request:
| Project setting | What runs on that project's requests |
|---|---|
| Use organization guardrails on | The organization configuration and its custom rules |
| Use organization guardrails off | The project's own configuration and its custom rules only |
Opting out never inherits partially: the organization's custom rules stop applying to that project too, and the project starts with a copy of the organization's current settings so nothing is silently dropped at the moment you opt out. Other projects are unaffected either way.
Both pages state which scope wins. A project page names itself and, while it inherits, shows the organization settings read-only; the organization page lists any projects that override it, so it is clear those settings apply everywhere else.
Organization owners and admins manage the organization guardrails; project owners and admins manage a project's own guardrails.
What Gets Scanned
Guardrails run on /v1/chat/completions and on /v1/messages and /v1/responses, which use the same pipeline. They scan the request's messages before routing: text parts, tool results, and attached images, audio and files.
Rules that look for instructions (prompt injection, jailbreak, topic restrictions and classifier rules) skip system and developer messages, because the system prompt is yours. Rules that look for data (PII, secrets, blocked terms, regex, sensitive data, document leakage) scan every message, including the system prompt.
Detection Methods
- Pattern rules run inside the gateway with no extra latency or cost.
- ML classifier rules score the request with a calibrated decision model, Jev 1.14 by default. They catch paraphrased, obfuscated and non-English attempts that patterns miss.
Each request that has classifier rules enabled triggers one extra /v1/decisions request that answers every classifier question at once. It runs with the caller's API key, so it:
- is billed to your organization at the decision model's price, like any other request;
- appears in your activity logs as its own
/v1/decisionsrequest; - follows your project mode, API key and compliance settings. A project that only uses your own provider keys needs a key for the decision model's provider, or credits.
Pick the decision model under Classifier model in the guardrail settings. Any decision model works, optionally provider-prefixed (typesafe/jev-1.14.0). Default thresholds are tuned for Jev 1.14, so recheck them after switching.
The classifier only sees non-system messages, after redaction, so values redacted by PII or sensitive-data rules never reach it. If the classifier request fails (for example, insufficient credits), classifier rules are skipped for that request and pattern rules still apply.
Each classifier rule has a score threshold between 0 and 1 (default 0.8), set through the API: systemRules.<rule>.threshold for system rules, config.threshold for custom rules. Raise it to reduce false positives.
System Rules
Prompt Injection Detection
Detects attempts to override, replace or extract instructions, such as "ignore all previous instructions", fake [system] sections or "reveal your system prompt". Turn on Also score with the ML classifier to catch paraphrased and indirect injections, for example instructions hidden in a document or tool result.
Jailbreak Prevention
Detects attempts to bypass safety measures, such as DAN prompts, "developer mode" activation and requests to disable safety filters. The ML classifier option works as it does for prompt injection.
PII Detection
Detects personal data. Choose which entities to detect:
| Entity | Validation |
|---|---|
| Address format | |
| Phone | Grouping separators or a nearby phone keyword |
| Credit card | Issuer prefix, length and Luhn checksum |
| IBAN | ISO 13616 mod-97 checksum |
| SSN | Valid area, group and serial blocks |
| IP address | Not part of a version number |
| Passport | Nearby passport keyword |
| Driver's license | Nearby license keyword |
With the redact action, matches are replaced with placeholders such as [EMAIL_REDACTED] before the request is forwarded.
Secrets Detection
Detects private keys, AWS, GitHub, GitLab, Slack, Stripe, OpenAI, Anthropic, Google, npm, Hugging Face and SendGrid credentials, JWTs, bearer tokens, connection strings, and API keys or passwords assigned in code or config. Template values such as YOUR_API_KEY, ${OPENAI_API_KEY} or ********, git SHAs and hex digests are ignored. Supports redact.
File Restrictions
Checks images, audio and files attached to messages against the allowed types and the maximum size. Allowed types are MIME types (image/png, image/*) or file extensions (pdf); an empty list allows every type. Remote URLs are checked by their file extension and are not size-checked; a file whose type cannot be determined is only size-checked.
Document Leakage Prevention
Flags confidentiality markers such as "internal use only", "attorney-client privilege" or "under NDA". Disabled by default.
Harmful Content
Scores harassment, hate, illicit activity, self-harm, sexual content, sexual content involving minors and violence with the ML classifier. Disabled by default.
Actions
| Action | Behavior |
|---|---|
| Block | Reject the request with a content_policy_violation error (400) |
| Redact | Mask the matched content, then forward the request |
| Warn | Log the violation and forward the request unchanged |
Redact is available for PII, secrets, blocked terms, custom regex and sensitive data rules. The other rules can only block or warn.
A blocked request returns the matched rules:
{
"error": {
"message": "Request blocked by content policy: PII Detection (rule system:pii_detection, category pii)",
"type": "guardrail_violation",
"code": "content_policy_violation",
"violations": [
{
"rule_id": "system:pii_detection",
"rule_name": "PII Detection",
"category": "pii",
"action": "block"
}
]
}
}Custom Rules
Create custom rules on the organization or on a single project. The dashboard offers templates for common policies, such as blocking email addresses or keeping an assistant on topic.
Sensitive Data
Detects selected PII entities with the same validated detectors as PII detection, under its own action. For example, block email addresses while the PII rule redacts phone numbers.
Blocked Terms
Blocks specific words or phrases. Match by exact word, substring or regex, optionally case-sensitive.
Custom Regex
Matches patterns unique to your organization, such as internal codenames or customer identifiers. Patterns that could backtrack catastrophically are ignored.
Topic Restriction
Blocks requests about specific topics. By default, preset topics (politics, religion, violence, adult_content, illegal_activities, gambling, medical_advice, financial_advice) use keyword lists matched as whole words; other topics match as a phrase.
Turn on the ML classifier to judge topics by meaning instead. Classifier mode also supports allowed topics: anything outside them is a violation, which keeps a support assistant on topic.
ML Classifier
Describe what to detect in plain language, for example "The text asks for legal advice about the user's own situation." The classifier scores every request against it.
Testing Rules
Use the test endpoint in the dashboard API (POST /guardrails/test/{organizationId} or POST /guardrails/projects/{projectId}/test) to check text against the pattern rules. Classifier rules are reported as skipped there, because they run only on gateway requests.
Security Events Dashboard
Monitor all guardrail violations with a dedicated dashboard:
- Total violations — Overall count and trends
- By action — Breakdown of blocked, redacted, and warned
- By category — Which rules are being triggered
- Detailed logs — Individual violations with timestamps and matched patterns
Each rule records at most one violation per request. Matched values from PII, secrets and sensitive-data rules are stored redacted, and matched content is stored only when your organization retains request data.
How It Works
- Scope resolved — The project's own guardrails if it overrides, otherwise the organization's
- Pattern rules — Text and attachments are checked in the gateway
- Classifier rules — If any are enabled, one billed decision request scores the redacted conversation
- Action taken — Any blocking violation rejects the request; otherwise redactions are applied
- Violations logged — Every violation is recorded for the Security Events dashboard
- Request proceeds — The (possibly redacted) request is routed to the model
Best Practices
- Start with warnings — Enable rules in warn mode first to understand your traffic patterns
- Review violations — Check the Security Events dashboard regularly
- Tune custom rules — Adjust blocked terms and regex patterns based on false positives
- Layer defenses — Use multiple rule types together for comprehensive protection
Get Started
Guardrails are an Enterprise feature. Contact us to enable Enterprise for your organization.
How is this guide?
Last updated on