Keep secrets and PII out of prompts with content rules
Add content rules to a guardrail so API keys, emails and card numbers are redacted or refused before a model sees them, then prove it with a dirty prompt.
14 min readLast reviewed October 19, 2026Verified against gateway chart 0.10.0
What you’ll have at the end
By the end you will have a guardrail whose content rules redact email addresses and refuse anything that looks like a live API key, bound to a service key. You will also have sent one deliberately dirty prompt through it and read what the caller sees, what the trace records, and which traffic the rules do not reach.
Before you begin
- A team on the Nautili dashboard with a gateway reporting in, hosted or self-hosted.
- A governance mode of
shadoworenforceon that gateway (GOVERNANCE_MODE). With the modeoff, the gate does not run, and content rules ride the gate's decision. - An ownerless service key from API keys under Access. Only service keys bind to a guardrail directly; a person's key follows their identity's guardrail.
curl, or Python 3 withopenai, or Node 20 withopenai.- Read Content rules once. This guide applies it and does not repeat every constraint.
Step 1: Know where a content rule runs
A guardrail has two halves. The governance half (budget, rate ceilings, model and provider access) is enforced by DevZero on every request, whoever's credential pays. The content half is the request-path scan this guide is about, and it runs in one of two places depending on the serving upstream.
| Path | When | Change lands in |
|---|---|---|
| PathThe gateway enforces locally | WhenThe serving upstream applies no guardrails of its own | Change lands inSeconds, with the decision cache |
| PathThe upstream enforces | WhenThe serving upstream can apply guardrails. DevZero projects your rules onto a guardrail object attached to your team's provisioned keys | Change lands inUp to 5 minutes, on the reconciliation sweep |
Either way the scan happens before the cache lookup and before the forward. A redaction rewrites the request body the gateway goes on to use, so the cache key, the prompt hash, the preview and the stored request body all see the redacted bytes. The consequence is that two requests that differ only in a redacted value share one cache entry.
Content rules read the request only. A model's answer is never scanned.
Step 2: Add the rules in the guardrail editor
Open Guardrails under Access, create a guardrail or edit one, and go to the Content filters step. Every detector shows an explicit action, and Off means the detector is absent from the saved guardrail.

Set these for this guide, then save and assign the guardrail to your service key from its Assignments dialog. A service key is issued with a guardrail of its own, named after the key, and that binding outranks the team default, so marking this guardrail the team default does not reach the key by itself.
| Rule | Action | Why |
|---|---|---|
Ruleemail | Actionredact | WhyA customer email in a prompt is useful context without the address itself |
Rulecredit-card | Actionblock | WhyChecksum-validated, so a block rarely misfires |
RuleCustom pattern sk-live-[A-Za-z0-9]+, label [API_KEY] | Actionblock | WhyA live key never belongs in a prompt |
The builtin detector slugs are email, phone, ssn, credit-card, ip-address, person-name, address and prompt-injection. One action per detector; a second entry for the same slug is rejected. Custom patterns are RE2, up to 1000 characters, up to 100 per list, each with an optional label of up to 100 characters. A pattern that does not compile is rejected when you save; one the gateway still cannot compile refuses the request at enforcement time rather than being skipped.
The same document over the API, trimmed to the content fields:
scan_scope is user_only or all_messages, and only prompt-injection accepts it. Empty leaves the engine default, which is all messages; the wizard offers All messages (sent as empty) and User messages only. Sending it on any other slug is rejected.
Step 3: Decide between block, redact and flag
| Action | Caller sees | Trace records |
|---|---|---|
| Actionblock | Caller sees403 and an error body. The request never reaches a model. | Trace recordsguardrail_outcome = blocked, entity types such as EMAIL, CREDIT_CARD, CUSTOM |
| Actionredact | Caller seesAn ordinary success. Each match replaced with the detector's placeholder before the forward. | Trace recordsguardrail_outcome = redacted |
| Actionflag | Caller seesAn ordinary success and an unchanged request. | Trace recordsguardrail_outcome = flagged |
Where the gateway enforces locally, the placeholders are [EMAIL], [PHONE], [SSN], [CREDIT_CARD] and [IP_ADDRESS]. A custom pattern's label is honoured only where the upstream enforces; locally every custom pattern redacts to [REDACTED] and reports the entity CUSTOM.
When rules overlap, the strongest outcome wins. A prompt that trips a redact rule and a block rule is blocked, and the row records blocked. Upstream, a team's guardrails are unioned onto one provisioned key with block winning over redact, which is why content rules are effectively team-wide there.
Step 4: Send a deliberately dirty prompt
The prompt below carries a fake key that matches the custom pattern and an email that matches the builtin detector. Because block beats redact, expect a refusal.
The gateway scans the body, the custom pattern matches, and the request stops before any provider is called. Tokens and cost on the row are zero.
Verify
Where the gateway enforces locally, the refusal looks like this (headers trimmed to the ones that matter):
The body names the entity types that fired and never the matched text. x-should-retry: false tells SDKs not to retry, because the content will not become acceptable by waiting.
Where the upstream enforces, the status is still 403 but the body is the gateway's upstream-failure envelope, with "type": "upstream_error", "code": "upstream_content_blocked" and a dz_upstream object naming the upstream and its status. Branch on the status, not the code, if your client must handle both.
Now remove the key from the prompt and send it again with only the email. The response is an ordinary 200, and the model received jane.doe@example.com as [EMAIL]. The only evidence is in telemetry. Open Traces under Usage, find the row by the X-Dz-Request-Id you received, and open it. The visibility notice reads "A content filter redacted this prompt before it was stored: EMAIL."
In the telemetry row itself the columns are guardrail_outcome (blocked, redacted or flagged, empty when nothing fired), guardrail_entity_types (the categories) and guardrail_id. A trace with an empty outcome is not a clean bill of health on its own: the notice distinguishes "we looked and nothing fired" from "we could not check," and says so when the outcome could not be read.
Two things you cannot read from a row. Which enforcer ran, because both paths write the same columns. And the matched text, because the upstream's echo of it is never parsed, logged or stored.
Options
content_status
Saving rules is not the same as enforcing them. The Guardrails table shows the content half's own status beside the rule count, and the API returns it as content_status.state with a message and last_synced_at.
| State | Badge | Meaning |
|---|---|---|
| Statenot_applicable | Badgenone | MeaningNo content rules configured |
| Statedisabled | BadgeFilters off | MeaningThe content half is switched off for this installation |
| Stateunbound | BadgeNot enforced | MeaningRules exist but nothing to attach them to: no managed-custody enrollment, or the guardrail is unassigned or disabled. They enforce nothing |
| Statepending | BadgeApplying… | MeaningRules changed and the projection has not converged yet |
| Stateactive | BadgeFiltering | MeaningProjected and enforcing |
| Stateerror | BadgeFilter error | MeaningThe last projection attempt failed; message carries the reason |
While pending, the previous rules keep applying upstream. Switching a detector from block to redact keeps blocking until the badge reads Filtering. Where the gateway enforces locally, a change lands with the decision cache instead, so a guardrail can be Applying… upstream and already enforcing on a local path.
Scan scope for prompt injection
With user_only the detector reads user messages only; with all_messages or empty it reads system and assistant turns too. Prompt injection, person names and postal addresses are model-scored upstream and have no local implementation. A guardrail that names one of them, served on an upstream where the gateway enforces locally, is refused with 400 unsupported_capability rather than forwarded unfiltered:
The same code and status are returned when a custom pattern does not compile, or when a redaction would break the JSON body.
Keep the original inside your network
Content rules redact what the provider sees. Whether the original ever leaves your network is a separate, per-deployment decision. A self-hosted gateway defaults to a content-free telemetry uplink: full request and response bodies, prompt and response previews, extracted user prompt text and tool-call argument summaries are blanked before upload, while token counts, costs, latencies, hashes, tool names, attribution and the guardrail outcome columns still upload. The gateway's own cache and originals stay in your cluster.
The environment variable is LLM_TELEMETRY_CONTENT_UPLINK. It is env-only, never dashboard-managed, and a change takes effect on restart. Set true to upload content; that restores the features that read prompt text (Model Trials and anything else that needs the stored body) at the cost of prompt and response text leaving the VPC. A hosted gateway keeps the uplink on, because bodies already transit DevZero infrastructure.
Pair the two: content rules so the provider never receives the secret, and a content-free uplink so DevZero never receives the original. What your team stores for its own traces is then governed by prompt retention, which decides what is kept and for how long. Where the gateway enforces locally, the stored prompt is the redacted one; where the upstream enforces, the stored prompt is what your client sent.
Troubleshooting
| Symptom | Cause | Fix |
|---|---|---|
Symptom403 with "code": "content_blocked" on a prompt you expected to pass | CauseA block rule matched. The message lists the entity types in parentheses | FixRead the types. Promote the rule to flag, read the flagged rows, then tighten the pattern |
Symptom403 with "code": "upstream_content_blocked" | CauseThe serving upstream applied your projected rules | FixSame as above. The dz_upstream object names the upstream |
Symptom400 with "code": "unsupported_capability" and "cannot be enforced locally" | CauseA rule names person-name, address or prompt-injection and the serving upstream has no engine of its own | FixRoute the guardrail's traffic to an upstream that applies guardrails, or drop the model-scored detector |
Symptom400 with "code": "unsupported_capability" and "does not compile" | CauseA custom pattern is not valid RE2 | FixFix the pattern; the request is refused rather than forwarded unfiltered |
Symptom400 with "code": "unsupported_capability" and "no upstream this request can be served on applies them" | CauseThe rules are delegated and no eligible path applies them | FixCheck the routing profile's provider lists against the upstreams that enforce content rules |
SymptomResponse is 200 and nothing looks different | CauseThe matching rule is redact or flag, which are invisible by design | FixRead the trace. The visibility notice and guardrail_outcome carry the result |
| SymptomBadge reads Not enforced | Causecontent_status is unbound: the guardrail is unassigned or disabled, or the team has no managed-custody enrollment | FixAssign the guardrail to a service key or mark it the team default |
| SymptomBadge stays on Applying… | CauseThe projection has not converged. It sweeps every 5 minutes | FixWait one sweep. If it turns to Filter error, read content_status.message |
| SymptomBadge reads Filter error | CauseThe last projection attempt failed; the status carries the upstream's message | FixFix what the message names, usually a pattern the upstream rejected, and save again |
| SymptomRules pass on one key and are bypassed on another | CauseThe second key forwards on your own upstream account (Tier 1 BYOK) to the upstream that applies guardrails itself | FixConfigure equivalent filters in that provider account |
| SymptomSaving rejects a duplicate detector | CauseOne action per detector; a second entry for the same slug is refused | FixRemove the duplicate |
| SymptomPrompt text appears in the Nautili dashboard from a self-hosted gateway | CauseLLM_TELEMETRY_CONTENT_UPLINK is pinned true | FixSet config.telemetryContentUplink: false or leave it null, then restart the pods |
Next steps
- Guardrails overview, for the binding ladder and why guardrails never stack.
- Content rules, for every constraint and the coverage gaps stated in full.
- Governance rules, for the half DevZero enforces on every request.
- Self-hosting, for the chart settings, including the telemetry uplink.
- Request headers, for
X-Dz-Session-IdandX-Dz-Request-Id, which make a trace findable. - Govern LLM traffic with guardrails, for the budget, rate ceiling and model access half of the same guardrail.
- Self-host the Nautili gateway with Helm, for the full picture of what leaves your network.