guardrail_id on the key and
every /v1/* call made with that key is screened on the next request, with
no redeploy and no SDK change.
This page covers only the binding — how to attach, how resolution picks the
effective policy, and what the off-switch does. For the rule types, actions,
and stages, see the Guardrails reference.
1. Bind a guardrail per API key with guardrail_id
A guardrail is workspace-scoped, but enforcement is decided per key. Each
API key carries a
guardrail_id field. Point it at a guardrail and that key — and only that
key — is screened by that policy.
This lets one workspace run different policies on different keys:
- a production key bound to a strict
pii-blocker, - a staging key bound to a lighter
flag-onlypolicy, - an internal key with nothing attached.
https://api.orcarouter.ai/v1/chat/completions exactly as before.
The relay key (
sk-orca-…) is what your app sends. Attaching a guardrail
to it is a console / token-API action authenticated by your session — you
never configure a guardrail with the relay key itself.2. Attach it in the console
Configure the binding from the console (role-gated: editing keys and guardrails requires Developer+).Pick the guardrail
In the key editor, choose your guardrail from the Guardrail
dropdown. This sets
guardrail_id on the key.[EMAIL] and never the address — same call, no client change.
3. How resolution picks the effective guardrail
On every request, the gateway resolves exactly one effective guardrail (or none) in this order:1 — Explicit key attachment
1 — Explicit key attachment
If the key’s
guardrail_id points at a guardrail and that guardrail
exists and is enabled, it applies. An explicit attachment is
authoritative — it never silently falls back to the workspace default.2 — Workspace default
2 — Workspace default
If the key has no attachment (
guardrail_id is 0 / unset), the
workspace’s enabled default guardrail applies, if one is set.3 — Neither resolves
3 — Neither resolves
No enforcement. The request is byte-identical to a workspace that never
enabled the feature — nothing blocked, masked, or logged.
4. The off-switch: disable an attachment, no fallback
This is the part people miss. An explicit key attachment is its own authority — so disabling the attached guardrail turns enforcement OFF for that key, and it does not fall back to the workspace default.| Key state | What screens the request |
|---|---|
guardrail_id → enabled guardrail | that guardrail |
guardrail_id → disabled guardrail | nothing (no fallback) |
guardrail_id → deleted / missing | nothing (no fallback) |
guardrail_id = 0 / unset | workspace default, if any |
5. Detach or clear the binding
To stop screening a key with a specific guardrail, you have two distinct moves with different outcomes:- Clear the attachment — set the key’s
guardrail_idto0. The key now resolves to the workspace default (if one exists), or to none. - Disable the guardrail — flip the guardrail’s
enabledoff. Every key explicitly attached to it now resolves to none (per §4), while keys that were relying on it as the workspace default fall through to no enforcement.
6. What a screened request does (and doesn’t) cost
Once a guardrail resolves, its rules decide the request. The two outcomes worth knowing for a bound key:- A block returns HTTP 400 with error code
guardrail_blocked, naming the guardrail and the rule that fired. It costs no quota — an input-stage block fires before metering, an output-stage block refunds the pre-consumed quota — and it is marked skip-retry. - A mask rewrites the match to a typed tag (e.g.
[EMAIL]) and lets the request through sanitized; the upstream model never sees the original.
guardrail_blocked error
page for the exact response shape, and
Streaming coverage for how output
rules behave on streamed responses.
7. Where to go next
Create your first guardrail
Build the policy you’ll bind to a key.
Account default guardrail
Screen every key in the workspace at once.
Guardrails reference
Rule types, actions, stages, PII, judge, grounding.
Keys, policies & workspaces
How bindings are scoped across the gateway.
