# OpenRouter guardrails vs gateway policy: which layer owns what?

URL: https://infro.io/blog/openrouter-guardrails-vs-gateway-policy-which-layer-owns-what
Author: INFRO Editorial (https://infro.io/blog/editorial)
Publisher: INFRO
Published: 2026-11-09
Last modified: 2026-11-09
Last reviewed: 2026-11-09 (next review due 2026-12-09)
Topic: Architecture and migration
Format: Comparison

> Keep every rule that depends on who is calling, which project, how much and what text in your gateway, and generate OpenRouter's policies from that same config as looser backstops. Leave to OpenRouter only what it alone can see: provider choice, ZDR and data regions.

Key takeaways:
- OpenRouter's guardrails are now three separate policies (budget, model and provider access, content moderation) plus workspace budgets; your gateway has its own versions of the first and third.
- Stacked layers combine strictly, so the tightest one wins, and a rule you forgot in one layer will refuse traffic the other layer allows.
- A gateway that calls OpenRouter with one key shows OpenRouter a single identity, so per-person and per-key rules belong in the gateway.
- Set OpenRouter's budgets and allowlists looser than the gateway's and treat any OpenRouter-side refusal as an alert that the layers drifted.
- Generate OpenRouter's settings from the gateway's config through the API and pick one write path per policy type, or the two will drift apart.

## 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](https://infro.io/blog/openrouter-screens-every-request-what-to-tell-your-security-reviewer).

## 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 code `model_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 |

Table: OpenRouter setting, its gateway counterpart, and the layer that should own it.

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](https://infro.io/blog/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](https://infro.io/blog/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](https://infro.io/blog/llm-prompt-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.

1. **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.
2. **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.
3. **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.
4. **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_by` field (`legacy` or `policies`) and a `legacy_policy_types` list so you can tell which surface is in charge.[11]
5. **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.
6. **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_allowlist` on 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.

> **Example: Illustrative numbers**
> Suppose the gateway's organization hard cap for the OpenRouter-bound projects is $20,000 a month. Set the OpenRouter monthly workspace budget at $25,000. Normally the gateway refuses first. If OpenRouter's limit is ever the one that fires, either the gateway is bypassed or a rate table is wrong, and either case deserves an alert. The 25% headroom is an assumption to tune against how far your estimates drift from OpenRouter's recorded figures.

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.

```python
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

1. **Inventory both stacks.** List every OpenRouter budget, policy, default and assignment, and note which are `legacy` and which are `policies` managed.[11] Do the same for gateway budgets, allowlists and guardrails.
2. **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.
3. **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.
4. **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.
5. **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.
6. **Pick one write path per policy type per workspace** and stop writing through the other.[11]
7. **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](https://infro.io/docs/org/spend-controls), [model allowlists](https://infro.io/docs/org/model-allowlists) and [guardrails](https://infro.io/docs/features/guardrails) pages for the exact limits before relying on any of it.

## Questions

### Do I need OpenRouter guardrails at all if my gateway enforces everything?

Keep a minimal set. Provider allowlists, Zero Data Retention and data-region restrictions act on choices OpenRouter makes after your gateway has handed the request over, so only OpenRouter can enforce them. Budgets and model lists there are a backstop for keys that bypass the gateway.

### Will editing a policy in the OpenRouter dashboard break my API-managed guardrails?

It can cause drift. OpenRouter documents that changes made in Guardrail Policies do not flow back to the original guardrail, and the first edit of a migrated policy creates a copy with a new ID. Choose one write path per policy type and workspace.

### Which layer should refuse a request that exceeds a budget?

The gateway, ahead of OpenRouter. Its refusal can carry your own error shape and attribution, and the OpenRouter limit then fires only when something has gone wrong, which is worth an alert.

## Sources

1. Guardrail Policies - Budget, Access, and Moderation Policies — OpenRouter. https://openrouter.ai/docs/guides/features/guardrails/policies (accessed 2026-11-09)
2. Workspace Budgets - Per-Workspace Spend Limits — OpenRouter. https://openrouter.ai/docs/guides/features/workspaces/workspace-budgets (accessed 2026-11-09)
3. Spend controls — INFRO. https://infro.io/docs/org/spend-controls (accessed 2026-11-09)
4. Model allowlists — INFRO. https://infro.io/docs/org/model-allowlists (accessed 2026-11-09)
5. Guardrails — INFRO. https://infro.io/docs/features/guardrails (accessed 2026-11-09)
6. Spend Controls - Budget and Guardrail Best Practices — OpenRouter. https://openrouter.ai/docs/guides/best-practices/spend-controls (accessed 2026-11-09)
7. Guardrails - Organization Spending and Access Controls — OpenRouter. https://openrouter.ai/docs/guides/features/guardrails (accessed 2026-11-09)
8. OpenRouter Quickstart Guide — OpenRouter. https://openrouter.ai/docs/quickstart (accessed 2026-11-09)
9. LLM guardrails at the gateway: checks before and after — INFRO. https://infro.io/blog/llm-guardrails-at-the-gateway (accessed 2026-11-09)
10. Input & Output Logging - Privately Store Prompts and Completions — OpenRouter. https://openrouter.ai/docs/guides/features/input-output-logging (accessed 2026-11-09)
11. Migrating to Guardrail Policies — OpenRouter. https://openrouter.ai/docs/guides/features/guardrails/policies-migration (accessed 2026-11-09)
