Guardrails let organizations control how their members and API keys can use OpenRouter. You can set spending limits, restrict which models and providers are available, and enforce data privacy policies.
Any existing account wide settings will continue to apply. Guardrails help enforce tighter restrictions for individual API keys or users.
To create and manage guardrails for your account or organization:
If you’re using an organization account, you must be an organization admin to create and manage guardrails.
Each guardrail can include any combination of:
Individual API key budgets still apply. The lower limit wins.
Guardrails can be assigned at multiple levels:
Only one guardrail can be directly assigned to a user or key. All of an organization member’s created API keys will implicitly follow that user’s guardrail assignment, even if the API Key is further restricted with its own guardrail assignment.
Account-wide privacy and provider settings are always enforced as a default guardrail. When additional guardrails apply to a request, they are combined using the following rules:
This means stricter rules always win when multiple guardrails apply. For example, if a member guardrail allows providers A, B, and C, but an API key guardrail only allows providers A and B, only providers A and B will be available for that key.
When viewing a guardrail, you can see an eligibility preview that shows which providers and models are available with that guardrail combined with your account settings. This helps you understand the effective restrictions before assigning the guardrail.
Guardrail budgets are enforced per-user and per-key, not shared across all users with that guardrail. When an API key makes a request, its usage counts toward both the key’s budget and the owning member’s budget.
Example 1: Member guardrail with $50/day limit
You assign a guardrail with a $50/day budget to three team members: Alice, Bob, and Carol. Each member gets their own $50/day allowance. If Alice spends $50, she is blocked, but Bob and Carol can still spend up to $50 each.
Example 2: API key usage accumulates to member usage
Alice creates two API keys, both assigned a guardrail with a $20/day limit. Key A spends $15 and Key B spends $10. Each key is within its own $20 limit, but Alice’s total member usage is $25. If Alice also has a member guardrail with a $20/day limit, her requests would be blocked because her combined usage ($25) exceeds the member limit ($20).
Example 3: Layered guardrails
Bob has a member guardrail with a $100/day limit. His API key has a separate guardrail with a $30/day limit. The key can only spend $30/day (its own limit), but Bob’s total usage across all his keys cannot exceed $100/day. Both limits are checked independently on each request.
Each guardrail can carry a list of custom content filter patterns. Every pattern is a regular expression with an associated action:
403 before it reaches the
model.Patterns are evaluated locally against every user message, so they add negligible latency to requests.
Patterns are JavaScript-flavoured regular expressions. The following common constructs are all supported:
[a-z], \d, \w, \s, …)*, +, ?, {n,m})foo|bar)(?:…))(?<name>…))^, $, \b)\., \(, \\, …)To keep evaluation fast and predictable across all requests, the following features are not allowed in new or edited patterns:
(?=…) and (?!…)(?<=…) and (?<!…)\1, \2, …) and named (\k<name>)(a+)+The API rejects offending patterns with an invalid_regex_pattern error
on create and on update.
When a guardrail’s runtime checks block a request — for example a content filter or prompt-injection detector — OpenRouter returns an HTTP 403 Forbidden response. Note that budget limits and allowlist restrictions also produce 403 responses, but only runtime content checks include openrouter_metadata stage details.
If you opt in to router metadata via the X-OpenRouter-Experimental-Metadata: enabled header, the 403 response also includes the full openrouter_metadata object with routing context and a pipeline array showing every guardrail stage that ran:
See Router Metadata — Error Responses and Errors — Guardrail Errors for the full response shapes and pipeline stage reference.
You can manage guardrails programmatically using the OpenRouter API. This allows you to create, update, delete, and assign guardrails to API keys and organization members directly from your code.
See the Guardrails API reference for available endpoints and usage examples.