Why two policy layers is now a real design question
If you send traffic through OpenRouter and also run your own control plane, you already have two places that can refuse a request. Until recently the OpenRouter side was easy to ignore: one guardrail object carrying a budget, a model list and content filters. It is now split. OpenRouter's Guardrail Policies divide a guardrail into three separate policies, a budget, a model and provider access policy, and a content moderation policy, each assigned on its own to the members and API keys it should cover.1 Workspace budgets sit beside them as a separate, pooled cap.2
Your gateway has a version of most of these: budgets by organization, project, member and key,3 model allowlists by organization, project and key,4 and pattern checks on prompts and responses.5 Put the two stacks in series and every rule has a twin. That is fine until the twins disagree, or until someone edits one and forgets the other.
This article maps each OpenRouter setting to its gateway counterpart, lists where they duplicate or conflict, and ends with a recommendation: the gateway owns policy, and OpenRouter's settings are generated from it. It covers policy layering only. For routing behaviour and request screening, see OpenRouter screens every request.
What OpenRouter now enforces
The facts that matter for layering, all from OpenRouter's own documentation:
- Three policy types. Budget (a USD cap that resets daily, weekly or monthly), model and provider access (model and provider lists, Zero Data Retention per model group, data regions), and content moderation (prompt injection protection, sensitive info detection, custom content filters).1
- Two levels. Workspace-wide policies apply to every member and key in a workspace and cannot be overridden. A member or key policy can add restrictions but cannot loosen a workspace-wide one.1
- One policy per type per subject. A member or key has at most one policy of each type in a workspace.1
- Strictest wins. Allowed models and providers are the intersection across applicable policies, ZDR applies if any policy enforces it, filters from all policies are combined with block beating redact, and each budget is checked on its own.1
- Always-on settings. Account-wide privacy and provider settings apply on top of every policy, and individual API key limits still apply.1
- Workspace budgets. Up to four per workspace (daily, weekly, monthly, lifetime), available on every plan. When one is reached the request gets a 403.2
- Check order. A request is checked against workspace budgets first, then against every applicable guardrail budget.6
Data-region restrictions in guardrails need a Business or Enterprise plan.7
What your gateway enforces
The comparable gateway controls, using INFRO's documentation as the concrete example (other gateways differ in detail, but the shape is common):
- Budgets at organization, project, member and key scope. Every applicable blocking limit must allow the request, and key limits always block.3 A blocking budget admits a request only if its worst-case estimated cost fits the room left, and that worst case includes the most expensive model and provider the request could fall back to.3
- Model allowlists at organization, project and key scope. A model must satisfy every applicable list,
!entries block, and a denied model returns HTTP 403 with codemodel_not_allowed. Route targets and fallback models stay subject to the lists.4 - Guardrails on chat completion prompts and responses, plus the prompts of several media endpoints. Detection is pattern-based and can miss things, and tool definitions and image or audio parts are not inspected.5
The two stacks therefore combine the same way, by intersection, which is the good news. The bad news is that they measure and see different things.
Setting by setting: where the layers overlap
| Concern | OpenRouter | Gateway | Recommended owner |
|---|---|---|---|
| Per-person or per-key budget | Member and key budget policies | Member and key budgets | Gateway |
| Pooled team cap | Workspace budget | Organization or project budget | Gateway; OpenRouter as looser backstop |
| Model allowlist | Model and provider access policy | Org, project, key allowlists | Gateway; OpenRouter holds a superset |
| Provider allowlist, ZDR, data regions | Model and provider access policy | Not visible to the gateway | OpenRouter |
| Secrets and PII patterns | Content moderation policy | Guardrails | Gateway |
| Prompt and response logging | Input and output logging (beta) | Request traces | Gateway, OpenRouter off |
The rest of this section explains the rows where a conflict is likely.
Budgets: two meters, two clocks
Both layers cap spend, but they do not count the same number. OpenRouter's guardrail budgets count only spend billed through OpenRouter by default; BYOK inference counts only if you turn on the include-BYOK setting, and that setting is separate on each guardrail and on the workspace budget.6 When BYOK is counted, it uses OpenRouter's recorded inference-cost value, which is not necessarily what your provider invoices.6 The gateway's budget is an estimate too, computed from its own rate table, and it reserves worst-case room before the call.3
So the two figures drift, and the gateway will usually refuse earlier, because it holds a reservation for every in-flight request while OpenRouter only sees recorded spend. Windows differ as well: OpenRouter's workspace daily budget resets at midnight UTC and its weekly one on Monday,2 while the gateway's organization, project and member budgets follow the organization's budget cycle day.3 A month that ends on a different day in each layer produces a refusal that neither dashboard explains at first glance.
Identity: one gateway key looks like one person
This is the largest structural mismatch, and it is an inference from OpenRouter's documented behaviour rather than something either vendor states. OpenRouter's budget enforcement follows the key creator, not the person using the key: a shared admin-owned key draws against the admin's member budget, and per-person enforcement needs a key per person.6 If your gateway calls OpenRouter with one upstream key per environment, OpenRouter sees one identity. Its member and per-key tiers cannot tell your teams apart, because the gateway has already merged them. The only per-person or per-project limits that work are the ones in the gateway, which sees the project, the gateway key and the end-user id.
Model lists: ids and aliases
Model ids are the second source of conflict. OpenRouter slugs can be latest aliases: its quickstart uses ~openai/gpt-sol-latest, an alias that always resolves to the newest model in that family.8 A gateway allowlist matches catalog ids and vendor wildcards such as anthropic/*,4 and OpenRouter's own list matches its slugs. Check, with a test request, which id each layer matches against: the one your client sent, or the one the alias resolved to. An allowlist that approves an alias while the underlying model changes is the silent-swap problem from model aliases vs pinned snapshots, moved up a layer.
Content filters: same idea, different detectors
OpenRouter's content moderation policy offers regex-based prompt injection detection, sensitive info detection with NLP-based presets, and custom regex filters.7 Your gateway's detectors are fixed patterns with checksum tests where they exist.5 Run both and a prompt can be redacted by one and blocked by the other. Within OpenRouter, block beats redact;1 across layers, whichever fires first decides. If the gateway redacts an email to a placeholder, OpenRouter then inspects the placeholder, so the second layer sees less than it expects and its hit counts fall without anything having improved. Two detector sets also mean two false-positive profiles to tune. The general case for putting uniform checks where every application's traffic passes is in LLM guardrails at the gateway, which also notes that provider-side filters give you a different policy on each path.9
Logging: two copies, two retention rules
OpenRouter's input and output logging is a beta feature that stores prompts and completions on OpenRouter. Retention is a minimum of three months and may run longer at OpenRouter's discretion unless you request deletion, and org admins can read stored content for every request.10 It also does not apply to requests routed through the regional eu. or us. endpoints.10 Your gateway's trace logging has its own switch and retention window. With both on, the same prompt exists in two stores under two retention rules, and your data-retention answer to a security reviewer has to cover both. With a regional guardrail on, OpenRouter's copy silently disappears for some traffic while the gateway's does not. See a prompt and payload logging policy for what to log in the first place.
Where the layers conflict
Overlap is duplication. These are the cases where two correct configurations produce a wrong result.
- Permanent-looking 403s. An OpenRouter workspace budget refusal arrives as a 403 with a message naming the exceeded interval.2 That is a policy refusal, not an outage. Check that your gateway's failure rules do not retry it or fail over on it, and that your application does not show users a generic "provider down" message.
- Allowlist drift. A model added to the gateway allowlist but not to OpenRouter's list is approved by one layer and refused by the other. The user sees an error that the gateway's policy page says cannot happen.
- Silent loosening. OpenRouter documents that member and key policies cannot loosen a workspace-wide one.1 An admin who "raises one person's limit" in the gateway can raise nothing if the upstream cap is tighter.
- Dashboard edits against API-managed config. OpenRouter says changes made in Guardrail Policies do not flow back into guardrails, that the first edit of a migrated policy creates a copy with a new ID, and that if you keep changing the same rules through both surfaces the two drift apart.11 Its guardrail assignment responses carry a
managed_byfield (legacyorpolicies) and alegacy_policy_typeslist so you can tell which surface is in charge.11 - Counter semantics. Raising a member guardrail limit on OpenRouter does not reset its counter; the member is unblocked only if accumulated usage is below the new limit.6 An incident runbook that says "raise the cap" works differently in each layer.
- Fail-closed asymmetry. If the gateway cannot reach its database it refuses with 503 rather than serve unchecked.3 OpenRouter's limits give you no such statement in what I read, so do not assume the backstop behaves the same way.
The recommendation: the gateway is the source of truth
Pick one layer to hold the intent and make the other derive from it. The gateway is the better choice for four reasons.
- It sees identity that OpenRouter cannot: project, gateway key, environment, end user.
- It sees every upstream, so a rule written once holds when you fail over or add a provider. OpenRouter's rules only cover traffic that reaches OpenRouter.
- It applies one policy to every path, including direct model names, named routes and fallbacks.4
- Its configuration can be written as code. INFRO's model allowlists, for example, can be set as
model_allowliston organization settings, projects and gateway keys through its management API and Terraform provider.4
Then split ownership by what each layer can actually see:
- Gateway owns: per-member, per-key, per-project budgets; model allow and block lists; secret and PII checks; request logging and its retention; audit of who changed what.
- OpenRouter owns: provider allowlists, Zero Data Retention, safety-retention choices and data regions. They constrain choices OpenRouter makes after the handoff, which the gateway cannot observe.
- OpenRouter also holds, as backstops: a workspace budget above the gateway's cap, and a model list that is a superset of every gateway list.
A small job can keep the backstop in step with the gateway config. The endpoint and body below follow OpenRouter's documented workspace-budget API; the cap and headroom are the illustrative numbers above.
import os
import requests
HEADROOM = 1.25 # backstop sits above the gateway cap
GATEWAY_MONTHLY_CAP = 20_000 # read this from your gateway config as code
def sync_workspace_budget(workspace_id: str) -> None:
r = requests.put(
f"https://openrouter.ai/api/v1/workspaces/{workspace_id}/budgets/monthly",
headers={"Authorization": f"Bearer {os.environ['OPENROUTER_MGMT_KEY']}"},
json={
"limit_usd": round(GATEWAY_MONTHLY_CAP * HEADROOM),
# count BYOK inference too, or the cap is blind to it
"include_byok_in_budgets": True,
},
timeout=10,
)
r.raise_for_status()Two details from OpenRouter's docs shape this job. Budget limits must be strictly decreasing as the interval narrows (lifetime above monthly above weekly above daily), and the server rejects a request that breaks the ordering.2 And workspace budget resources are not currently available in OpenRouter's Terraform provider, so they go through the dashboard or Management API.6 That is another reason to drive them from a script rather than by hand.
A migration order that avoids a policy outage
- Inventory both stacks. List every OpenRouter budget, policy, default and assignment, and note which are
legacyand which arepoliciesmanaged.11 Do the same for gateway budgets, allowlists and guardrails. - Find the identity gap. Count how many distinct OpenRouter keys and creators your gateway uses. If it is one per environment, delete or loosen member and key tiers upstream, since they cannot discriminate.
- Loosen upstream first. Raise OpenRouter's budgets and widen its model list to a superset before you tighten the gateway, so the order of change never produces a refusal from the wrong layer.
- Turn off duplicate content filters on one side. Keep the gateway's, and keep OpenRouter's only if you have traffic that reaches it directly.
- Decide the log of record. Choose one store for prompts, switch the other off, and write down the retention. OpenRouter lets you include or exclude specific keys from input and output logging, with exclusions taking precedence,10 which helps for a staged turn-off.
- Pick one write path per policy type per workspace and stop writing through the other.11
- Alert on any OpenRouter-side policy refusal as a finding that the layers drifted.
Gateway-side controls in INFRO
INFRO is one example of the gateway layer described above: organization, project, member and key budgets on your own provider accounts,3 model allowlists with block entries,4 pattern guardrails,5 request traces with prompt logging off by default and a retention window you choose, an audit log of policy changes, and a management API for setting these as code. It does not replace OpenRouter's provider, ZDR or region controls, and it does not see which upstream provider OpenRouter picks. Read the spend controls (opens in a new tab), model allowlists (opens in a new tab) and guardrails (opens in a new tab) pages for the exact limits before relying on any of it.
