Guardrails
Rules that hold even when someone makes a mistake.
A cap on a key limits only that key. A guardrail is a rule you can put on the whole account, a workspace, a member or a key, and the strictest rule wins.
What guardrails do
- Budget: a spending ceiling per day, week or month.
- Allowed models: a list of permitted models, or a list of forbidden ones.
- Sensitive data: detecting sensitive information and your own words, with three responses: Block, Mask or Log only.
- Prompt injection: detecting text that tries to change the model's instructions.
- Key lifetime: the longest a new key in the account may live.
A ban at any layer is enough, and every cap applies at once.
Test before you switch on
For sensitive data, start with Log only and watch Recent triggers for a few days. If it catches the right things, move it to Mask or Block. That keeps good requests from getting stuck.
The guardrail wizard opens from the Create menu and takes about a minute. For any key, you can see which rules apply to it.
When a guardrail refuses a request
| Code | Means |
|---|---|
guardrail_blocked | A content rule refused the request. The message names the category only, never the text |
model_not_allowed_by_guardrail | This model isn't allowed in this account |
guardrail_budget_exceeded | A guardrail's budget is full |
The id of the guardrail that refused is in the X-IranRouter-Guardrail header.
Your first guardrail0 of 3 steps
- Go to Guardrails and press New guardrail.
- Set a daily spending cap for the whole account.
- Turn it on or off from that same list.
What you learned
- A guardrail applies to the account, a workspace, a member or a key.
- The strictest rule wins.
- Test with Log only first.
Keep your place
Sign in to the panel and each lesson and your path are saved, so you continue from the same spot on any device.