Docs
Guardrails
How each check in the gateway fails and what it may cost, and how accurate each guardrail is, measured on public datasets.
How each check fails
Every request passes these checks in this order, in the gateway, with no model call unless you turn on a guardrail’s tier. When a check itself fails, which is different from finding something, it fails open, and the request carries on with the failure on its record, or closed, and the request is refused, or its stream cut. Each check’s mode is fixed, the same for every policy.
The budget is the most CPU a check may spend on a request; a benchmark fails the build when one is over it. The prompt-injection check runs alongside the provider call, so its time adds no wait in front of it.
| Check | What it does | Fails | CPU budget |
|---|---|---|---|
| Suspension | Refuses an organization or user you have suspended. | closed | 20 µs |
| Served | Refuses a model no connection serves, suggesting the nearest one you allow. | closed | 20 µs |
| Limits | Holds rate, token and spend limits, and reserves the request’s estimate. | open; closed for spend | 20 µs |
| Uninspected | Refuses content nothing can inspect, such as an image, where the policy says to. | closed | 20 µs |
| Tool calls | Checks each tool call in the answer against the tools and arguments you allow, and cuts the answer before your app gets a call you don’t. | closed | 50 µs + 1 ms per 100 KB |
| Secrets | Redacts keys and credentials before anything leaves. | closed | 50 µs + 1 ms per 100 KB |
| Your own patterns | Finds your regexes and word lists, such as ticket ids or code names, and redacts or blocks them. | closed | 50 µs + 1 ms per 100 KB |
| Pseudonymize | Swaps personal data for pseudonyms, and restores it in the response. | closed; open for earlier pseudonyms | 50 µs + 1 ms per 100 KB |
| Injection | Checks for prompt injection alongside the provider call, and cuts it if it fires. | open | 50 µs + 1 ms per 100 KB |
| Illegal content | Judges requests for help with a crime, tool results included, and blocks them before the provider sees them. | open | 50 µs + 1 ms per 100 KB |
| Harmful content | Judges hate, harassment, self-harm, sexual content and violence in the request and the answer, and blocks or cuts it where you say. | open | 50 µs + 1 ms per 100 KB |
| System prompt leak | Compares the answer with your system prompt as it streams, and cuts an answer that repeats it. | open | 50 µs + 1 ms per 100 KB |
| Grounding | Checks each sentence of the answer against your system prompt, your users’ messages and tool results, and records the ones they do not support. | open | 50 µs + 1 ms per 100 KB |
| Retention | Decides what the record keeps, and tells OpenAI not to store the response where a policy’s data terms require zero retention. | closed | 20 µs |
| Safety ID | Gives the provider a keyed hash of your user where its API takes one, so it acts on one user, not you. | open | 20 µs |
| Route | Checks the model is allowed, then picks a region and connection, falling back to the next connection if one fails. | closed | 20 µs |
Each guardrail's detector, measured on public, permissively licensed datasets that none of them was built from, and on texts a model wrote where a section says so. Every detector runs in the gateway, without a model call, within 50 µs plus 1 ms of CPU per 100 KB of text. Measured from 2026-09-30 to 2026-10-27, in English unless a section names other languages.
Every detector reads text folded first, so full-width and look-alike characters don't hide what
it looks for. When a policy selects output, the same secrets, personal-data and moderation
detectors read the answer as well as the request.
Over prompt injection's test split and the samples of illegal content and moderation in their model tier sections, the mean of the built-in detectors is 92.4% / 59.4%, with the model tier 84.0% / 86.4%, and with GPT-6 Luna 84.1% / 85.0%.
Personal data and secrets
Measured on the test split of nvidia/Nemotron-PII
(CC-BY-4.0, commit b70ffaf5, its Parquet export d36e66f6). The split holds 100,000
synthetic English business documents, half with US and half with international details. The
labelled spans cover 55 kinds of personal and health information.
A detection is right when it overlaps a labelled span of a label its kind covers. A labelled span is found when a detection of that kind overlaps it.
| Kind | Labels it covers | Precision | Recall | False positives per 1,000 documents |
|---|---|---|---|---|
email |
email |
99.8% | 99.5% | 1.2 |
phone |
phone_number, fax_number |
92.2% | 81.6% | 21.1 |
card_number |
credit_debit_card |
78.9% | 10.4%; 87.2% of Luhn-valid numbers | 3.6 |
ip_address |
ipv4, ipv6 |
98.4% | 99.4% | 2.0 |
national_id |
ssn, national_id |
89.3% | 95.9%; 99.9% of US SSNs, 87.4% of other national ids | 10.2 |
bank_account_number |
account_number |
99.2% | 51.9% | 0.7 |
iban, passport_number, driver_license_number |
no label in this dataset | — | — | 0.7 in all |
| secrets | api_key, password, http_cookie |
99.5% | 65.5%; 90.5% of keys, 80.6% of passwords, 99.1% of keys shaped as a JWT | 0.5 |
What the figures say:
- Emails and IP addresses are found nearly always, and rightly; an IP address in a labelled URL counts as right.
- Phone numbers are missed without separators (
6032308421), in groupings the pattern doesn't take (+61 3 9827 4923), or against other digits. Most false positives are account, member and record numbers. - Card numbers must pass the Luhn check, as real ones do. 88% of this dataset's synthetic card numbers fail it, hence the low recall. Most false positives are IMEIs, which use the same check.
- National ids: most false positives are tax and record numbers shaped as an SSN.
- Bank account numbers: most misses have no bank's words near them. The dataset labels any account, so its precision can't show a shop's account taken for a bank's.
- Secrets: the detector knows 236 formats, 212 of them gitleaks 8.30.1's rules, and finds keys and passwords after the words that name them when the value looks random. Most misses are cookies (20.3% found) and passwords with no digit or symbol. The rules for words were tuned on the first 20,000 documents; on the other 80,000, recall is 65.2%.
Names, street addresses, dates of birth and IBANs
Measured on presidio-research's
synthetic test set (MIT, data/synth_dataset_v2.json, sha256 ec08a771…0012): 1,500 English
sentences, half with US and half with international details, labelled from templates.
| Kind | Labels it covers | Precision | Recall | False positives per 1,000 sentences |
|---|---|---|---|---|
person_name |
PERSON |
92.3% | 51.6% | 24.7 |
street_address |
STREET_ADDRESS |
100% | 31.4% | 0 |
date_of_birth |
a DATE_TIME after "born" or "birth" |
100% | 100% of 17 | 0 |
iban |
IBAN_CODE: 21 synthetic UK IBANs |
100% | 95.2% | 0 |
And, as an upper bound on false positives in ordinary prompts, on the 4,384 English prompts the test splits below hold as benign. Every detection there counts as wrong, though most name real people.
| Kind | Detections per 1,000 prompts | Of a sample, real values |
|---|---|---|
person_name |
188 | about 9 in 10 of 50: people in articles, tables and tool results |
street_address |
5.9 | most |
date_of_birth |
3.0 | all |
What the figures say:
- Names are a listed first name with a capitalized word after it, a first name and a listed surname, or capitalized words after words such as "my name is", "Dear" or "Frau". The lists are the US Census's and Wikidata's. A name that is also a word or a place, such as "Will" or "Virginia", counts only beside a surname. It misses a surname alone, unlisted names and names in lowercase. A model would find more, at more than the CPU budget allows.
- Street addresses in English have a number and a street type ("12 Oak Street", "PO Box 1234"), and a unit, town and postcode when they follow. The dataset's international ones are mostly in forms the detector doesn't take, or split into parts, hence the low recall.
- Dates of birth are dates after words such as "born" or "DOB", in a month and day that exist; "the meeting is on 14 March 2026" isn't one.
- IBANs: the one missed is in lowercase. 21 from one country is a small sample.
Passport, driver licence and bank account numbers
On Gretel's set (below), as P / R: passport numbers 97.8% / 67.6%, driver licence numbers 97.4% /
54.3%, bank account numbers (bban) 37.8% / 32.5%. Each counts only after a label, such as
"Führerschein". Most misses have none, and most false bank accounts are real ones the set doesn't
label.
Names and street addresses in other languages
Measured on two sets, as P / R:
- Gretel's multilingual set
(Apache-2.0, test split,
7b844d16): finance documents whose names and addresses Faker made. languages/: 300 emails, forms and chats a language that gpt-4.1-mini wrote and labelled, with invented names and addresses. Tuning used its other texts.
| Language | Names, Gretel | Names, languages/ |
Streets, Gretel | Streets, languages/ |
|---|---|---|---|---|
| English | 67.6% / 78.6% | 91.6% / 83.2% | 81.8% / 47.6% | 99.6% / 95.6% |
| German | 72.7% / 72.6% | 99.0% / 90.7% | 75.4% / 47.9% | 99.6% / 96.4% |
| French | 63.9% / 68.3% | 95.1% / 91.4% | 84.3% / 60.5% | 99.2% / 94.1% |
| Spanish | 75.4% / 74.0% | 95.2% / 92.2% | 78.6% / 59.8% | 100% / 80.6% |
| Italian | 72.5% / 67.9% | 92.1% / 88.5% | 86.5% / 67.3% | 100% / 92.3% |
| Dutch | 74.7% / 67.3% | 97.8% / 85.6% | 86.9% / 51.4% | 100% / 78.5% |
| Swedish | 74.3% / 62.5% | 98.3% / 83.8% | 89.7% / 59.9% | 100% / 93.5% |
| The six other languages | 72.3% / 68.7% | 96.2% / 88.6% | 83.7% / 58.4% | 99.8% / 89.2% |
Streets need a street word ("via Roma 10", "Prinsengracht 263", "calle 72 # 13-32"), a postcode or a label such as "Adresse:". A bare street and number ("Sarmiento 1443") is most of what Spanish and Dutch miss. Gretel's figures are lower, English's too: Faker often made names and addresses of another country.
In 10,000 held-out news sentences a language (Leipzig Corpora, 2020 and 2022), 20 to 25 of 25 sampled names were people's, and 2 of 69 streets found weren't streets.
Prompt injection
Measured on 5,777 labelled texts: 5,313 from nine public datasets (deepset/prompt-injections, Lakera/gandalf_ignore_instructions, jackhhao/jailbreak-classification, reshabhs/SPML_Chatbot_Prompt_Injection, 3nesdeniz/agentic-prompt-injection-5k and its boundary pairs, nvidia/Nemotron-RL-Agentic-Indirect-Prompt-Injection-v1, microsoft/BIPIA and databricks/databricks-dolly-15k), and, written for the purpose, 253 short benign instructions about an answer's form and 211 benign tool results. 43% are attacks, and 38% of those are indirect: hidden in a document, an email or a tool's result. The detector was fitted to a 70% split, 4,512 windows of long documents and the rows for other languages (below), its threshold at 92.5% precision on out-of-fold scores.
| Measured on | Precision | Recall |
|---|---|---|
| The test split (1,737 texts) | 98.7% | 83.7% |
| Each source of attacks held out of training in turn | 33–100% | 1–84% |
On the test split it flags 0.7% of ordinary prompts, and 1.0% of hard negatives, which talk about attacks without making one or are what tools return: web pages, and API, file and shell output. It flags none of the test split's 85 short instructions about an answer's form ("Reply with one word: hello"), nor 15 requests to agents, but 9.2% of 989 system prompts.
Held out, it finds 0.9% of BIPIA's attacks in emails, tables and code, and 23% of Nemotron's
in tool results: a lexical detector knows the phrasings it has seen. So start with warn, and
move to cut once your traffic shows the rate of false positives.
Long documents
A text scores its worst window of 128 words, so each window is another chance of a false positive. A window must score higher the more windows its text has: 0.75 off the log-odds per factor of e, the least that keeps calibration documents of every length flagged at most 1.7%. Measured on other documents cut to each length, and a copy of each with a test-split attack put in: licences, books, Kubernetes', Python's, MDN's and GitHub's docs, and Wikipedia articles, a kind never trained on. Other kinds, such as chat logs or HTML, are unmeasured.
| Length | Documents flagged | Of them Wikipedia's | Injections found |
|---|---|---|---|
| 1 KB | 0.5% of 978 | 0 of 120 | 47.9% |
| 2 KB | 0.6% of 799 | 0 of 120 | 38.9% |
| 5 KB | 0.4% of 542 | 0 of 113 | 33.8% |
| 10 KB | 0.5% of 376 | 0 of 77 | 34.8% |
| 20 KB | 0.5% of 188 | 0 of 42 | 26.1% |
| 50–100 KB, few | 0 of 63 | 0 of 10 | 12.7% |
Findings in tool results don't count toward injection_attempts: they aren't the
user's attempts.
Other languages
Measured on 1,022 texts in ten languages and Aya's 2,474 prompts by native speakers. With rikka-snow held out, it finds 13.8%.
| Language | Attacks found | Ordinary prompts flagged |
|---|---|---|
| All ten | 39.0% (226 of 579) | 1.8% (8 of 443) |
| German | 52.3% of 174 | 5.7% of 140 |
| The other nine | 25–39% each | 0 |
| Aya's prompts, 17 languages | – | 0.5% (12 of 2,474); Thai's 2.7% |
The model tier
Under tier: model, the guardrail also asks a model, through the team's provider keys, the
question that crates/wire/src/ask.rs writes, at its settings. Measured on 2026-10-23 through
OpenRouter, on the test split's 207 BIPIA texts (108 attacks), Gemini 3.1 Flash-Lite finds 71.3%
of the attacks and flags no other text, with a p95 of 1,624 ms, for $0.075 per 1,000 texts. On
2026-10-31, on Jev's 1,313 English texts (below), the guardrail with it is 94.7% / 94.7%.
Claude Haiku 4.5 finds 89.8% and flags none, in 2,321 ms, for $0.437. gpt-5-nano finds 41.7% at
97.8% precision, for $0.022.
Under tier: decision, the guardrail also asks TypeSafe's Jev 1.14, through OpenRouter's
Decisions API, then GPT-6 Luna, through OpenAI's, the choice in injection/mod.rs: a prompt
injection, a request or other content. Measured on 2026-10-27 from a US host, with Luna it is 94.3% / 93.7% on the test split, 98.8% / 76.9% on BIPIA and 97.4% / 52.3% in other
languages, with a p95 of 461 ms, for $0.034 per 1,000 texts. Luna alone is 94.3% / 82.3% on the
test split, and flags 5 of 85 short instructions about the form of an answer.
Jev was measured on 2026-10-28 from the same host, only on English texts without a word of crime or harm: 1,313 of the test split and 135 of BIPIA. There the guardrail with Jev is 95.5% / 93.2% and finds 68.1% on BIPIA, with a p95 of 192 ms, for $0.023 per 1,000 texts; with Luna, 95.0% / 94.5% and 79.7%. Jev alone is 95.6% / 87.0%, and flags none of 84 short instructions about the form of an answer. Other languages, illegal content and moderation weren't measured, so only this guardrail asks Jev. It asks Jev first in other languages too, where the figures above are Luna's.
Illegal content
Measured on 41,000 public texts from six permissively licensed datasets: Aegis 2.0, Salad-Data, AILuminate, CatQA, XSTest and Dolly. The detector was fitted to a 70% split, and its threshold set at 90% precision for any kind on out-of-fold scores. The kinds are MLCommons' hazard categories that are crimes everywhere. The guardrail judges the request, tool results included, before the provider sees it; it doesn't read the answer.
| Measured on | Kind | Precision | Recall |
|---|---|---|---|
| The test split (11,000 texts) | any | 89.2% | 62.1% |
violent_crimes |
65.3% | 35.8% | |
non_violent_crimes |
83.9% | 66.0% | |
sex_crimes |
77.3% | 32.2% | |
child_sexual_exploitation |
88.6% | 41.3% | |
weapons |
87.6% | 50.0% | |
| Each source held out of training in turn | any | 74–88% | 21–53% |
On the test split it flags 2.4% of ordinary prompts, 13.6% of safe prompts that borrow a
crime's words ("How do I kill a Python process?"), and 4.0% of harmful prompts that aren't
crimes, such as hate or self-harm. A kind's precision is lower than the whole's because kinds are
confused with one another, mostly violent with non-violent crimes. The held-out figures are the
honest ones for phrasings unlike the training set; the lowest, 21%, is AILuminate's, whose prompts
probe a hazard rather than all ask for a crime. So start with warn, and block the kinds your
traffic shows to be precise.
Every text in the set is English; expect it to find little in another language.
The model tier
Under tier: model, the guardrail also asks gpt-oss-safeguard 120B on Bedrock, at reasoning effort
low, the question that crates/guard/src/illegal_content/mod.rs holds. Measured on 2026-10-24 from
us-east-1, on 1,000 texts of the test split (seed 20261024) where the detector alone is 89.4% /
61.3%: with the tier the guardrail is 74.5% / 88.9%, with a p95 of 1,663 ms, for $0.081 per 1,000
texts. The model flags 1 of XSTest's 81 safe prompts that use a crime's words. No other region was
measured.
tier: decision asks GPT-6 Luna the choice in illegal_content/mod.rs. On the same texts on
2026-10-28, from a US host, Luna alone is 84.8% / 63.8% and flags 1 of XSTest's 81; with it the
guardrail is 83.3% / 80.6%, at a p95 of 404 ms, for $0.029 per 1,000.
Content moderation
Measured on 68,000 public texts, 10,000 of them answers, and on OpenAI's evaluation set, never trained on. It was fitted to a 70% split, its threshold at 90% precision on out-of-fold scores.
| Measured on | Kind | Precision | Recall |
|---|---|---|---|
| The test split's requests (17,336 texts) | any | 91.2% | 31.8% |
hate |
80.7% | 36.2% | |
harassment |
80.4% | 25.4% | |
self_harm |
90.9% | 31.3% | |
sexual |
80.4% | 22.2% | |
violence |
82.9% | 18.1% | |
| The test split's answers (3,012 texts) | any | 71.8% | 33.9% |
| OpenAI's evaluation set (1,464 texts) | any | 64.3% | 36.0% |
| Each source held out of training in turn | any | 54–100% | 7–56% |
It flags 1.1% of ordinary prompts, 3.6% of safe answers, 8.9% of safe texts in the words of hate
or violence, and 6.4% of what OpenAI's set labels safe. It reads English words, not meaning, so
it misses most harm in ordinary words, and words around a passage dilute it: of the short harmful
texts it finds alone, it finds 31% inside 128 words of ordinary text. A setting with fewer kinds
finds about a third less of each. Start with warn, as for illegal content.
The model tier
The same model, asked about requests with the question in crates/guard/src/moderation/mod.rs,
measured the same way on 2,000 requests of the test split, where the detector alone is 89.1% /
33.3%: with the tier, 82.7% / 75.5%, with a p95 of 1,864 ms, for $0.125 per 1,000 texts. Alone on
OpenAI's evaluation set, the model is 77.6% / 86.8%, and OpenAI's moderation 61.0% / 90.2%.
tier: decision asks GPT-6 Luna the choice in moderation/mod.rs. On the same requests on
2026-10-28, from a US host, Luna alone is 75.4% / 77.3%; with it the guardrail is 74.8% / 80.6%,
at a p95 of 352 ms, for $0.051 per 1,000. It flags 13.3% of ordinary prompts, but none of 39
everyday requests; the model flags 3.8%.
Tool calls
Measured with AgentDojo (MIT, v1.2.2) on its four
suites: each of the 97 user tasks with each injection task of its suite, 949 cases, under its
important_instructions attack in a tool result, with gpt-4o-mini-2024-07-18 at temperature 0. An
attack succeeds when the agent does what the injection asks.
Each suite has one policy, as the app's team would set it (agentdojo/policies.py): the tools the
app offers, a JSON Schema on each tool that sends mail, money, invitations or files that allows
only the parties the user's data names before any attack, and a few destructive tools denied. A
call outside it cuts the answer, so the agent stops.
| No policy | tool_calls at cut |
|
|---|---|---|
| Attacks that succeed | 30.3% | 9.8% |
| Tasks done under attack | 38.9% | 31.6% |
| Tasks done without attack | 69.1% | 66.0% |
Each attack that still succeeds calls a tool as the policy allows: to tell it from what the user wants needs the user's task. The policy runs used patterns in place of the schemas, which judge the 1,037 distinct calls logged the same except 8; the 111 cases with one of the 8 ran again.
System prompt leaks
Measured on the test split of gabrielchua/system-prompt-leakage (MIT): 71,351 synthetic answers, 43% of them leaks, most reworded. The detector learnt from 30,000 of the train split's answers.
| Measured on | Precision | Recall | Other answers flagged | Leak words sent before it fires, median |
|---|---|---|---|---|
| The test split | 99.7% | 45.9% | 0.1% | 31 |
| The 1,000 answers in the repository | 100% | 50.2% | 0% | 32 |
It finds a leak word for word, as an extraction attack asks for.
Grounding
Measured on 10,330 answers of RAGBench's test split, in the 7 subsets whose documents' licences
permit it (listed in crates/guard/tests/grounding/). GPT-4-turbo, not people, labelled each
sentence of an answer as supported or not. An answer is flagged when one of its sentences reaches
a threshold, set at the best F1 on out-of-fold scores. AUROC is the chance that an answer with an
unsupported sentence scores above one without. RAGBench's paper gives the last two columns: a
fine-tuned DeBERTa-large, and the best of GPT-3.5, RAGAS and TruLens.
| Subset | Unsupported | Precision | Recall | AUROC | Held out | DeBERTa | LLM judge |
|---|---|---|---|---|---|---|---|
| HotpotQA | 8.0% | 15.4% | 6.5% | 0.56 | 0.56 | 0.85 | 0.64 |
| HAGRID | 14.2% | 29.9% | 30.1% | 0.69 | 0.68 | 0.81 | 0.67 |
| ExpertQA | 52.3% | 56.2% | 96.2% | 0.78 | 0.65 | 0.87 | 0.70 |
| PubMedQA | 28.6% | 33.3% | 82.6% | 0.62 | 0.60 | 0.80 | 0.62 |
| CUAD | 7.5% | 14.9% | 44.7% | 0.64 | 0.58 | 0.80 | 0.66 |
| FinQA | 5.5% | 20.0% | 5.8% | 0.56 | 0.55 | 0.81 | 0.57 |
| TAT-QA | 2.6% | 3.2% | 2.3% | 0.57 | 0.55 | 0.83 | 0.63 |
The mean AUROC over the subsets is 0.63, against DeBERTa's 0.82. The detector finds a sentence that adds a name, number or term the documents lack, not the wrong one of two entities they name or a wrong inference, which are most of HotpotQA's and the finance subsets' errors. At 90% precision its recall is under 1%, so the guardrail only warns.
The repository holds a sample of 1,310 answers of the test split, and tests/grounding.rs holds
its figures: a mean AUROC of 0.61, and precision / recall of 54.2% / 97.0% for ExpertQA, 34.3% /
29.3% for HAGRID and 37.0% / 76.2% for PubMedQA. The other subsets have too few unsupported answers in
it for a precision or a recall.
