Decide which layer the policy belongs to
Three settings can refuse or shape a request, and they sit at different levels.
Use a guardrail when several keys should share one rule set, such as every
production key. Use a key’s own limit for a single key that has no shared
policy. A guardrail does not change the workspace setting for keys it does not
govern.
Set the policy
Only an owner or an admin can create or change a guardrail. Every member can see the guardrails and which keys they govern.- Open Guardrails in the dashboard sidebar, between Keys and BYOK.
- Create the guardrail with the rules the screen can write today: a name, a spend cap with a daily, weekly or monthly period, the zero-data-retention choice, and any sensitive-data detectors. The other rules appear under “Coming soon” and cannot be set from the dashboard yet.
- Attach it to the keys it should govern. You can attach from the guardrail’s card or from the key’s row on the Keys screen. A key can have at most one guardrail, so detach the old one first if a key already has one.
Know what a blocked request returns
A request that breaks a rule is refused before any provider sees it. Nothing is charged and no credit is held. The error uses the usual envelope, and the message names the guardrail that set the rule, so a developer can tell the workspace which rule to change. Your client should branch on the HTTP status and thecode, not on the message
text. The codes are listed in full on
Guardrails. The four you are
most likely to meet are:
When two rules would both refuse a request, the first one in the fixed order
wins: which providers may serve the key, then injection patterns, then
sensitive-data detectors, then the token ceiling and the spend cap. A request
refused for an earlier rule will not show the later one until the earlier one
is fixed.
A refused request can also be a platform problem rather than a policy problem.
If a rule cannot be read when the request arrives, the request is refused with
HTTP 503 and a code ending in
_unreadable, instead of being served with the
rule skipped. The message says nothing was sent. Re-saving the guardrail
republishes its rules, which clears the condition.
Error shapes and retry guidance for the rest of the API are on
Errors.
Find the block in Activity
Refused requests are ordinary rows on the Activity screen, not hidden and not grouped. To find the blocks on a key:- Open Activity and filter by the key’s model or date as needed.
- Set the outcome filter to refused. The rows show the refusal beside the key and the model, and the charge reads zero.
- Open one row to see the single request view, which keeps the exact code. Use the request id from the response header or the error body to reach the same row directly.
Fix a policy after a false positive
A false positive is a request the guardrail refused that should have been served. Work out which rule refused it before changing anything: the code in Activity, or the error the caller received, names the rule, and the message names the guardrail. Then pick the smallest change that lets the request through.- Spend cap. Raise the amount or change the period on the guardrail’s card, or turn the cap off. Saving replaces the whole guardrail, and every attached key picks up the change before the save is reported as done.
- Zero data retention. Set the guardrail’s privacy choice to workspace default or off, if the key should not require retention-only providers.
- Sensitive-data detectors. Switch off the detector that matched, on the guardrail’s edit form.
- Injection patterns and allow lists. These cannot be edited on the screen yet. Until they can, detaching the key from the guardrail lifts all of its rules from that key, and the key then runs on its own limits. Detach it from the guardrail’s card or from the key’s row on the Keys screen, and re-attach once the rule is changed in a supported place.
Next
Guardrails
Every rule, what it does to a request, and the codes a caller sees.
Set up guardrails
Each control on the Guardrails screen, step by step.
View activity
Finding refused requests and opening one request in full.
Errors
The envelope every refusal is shaped as.