For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
ModelsChatRankingsDocs
DocsAPI ReferenceClient SDKsAgent SDKCookbookChangelog
DocsAPI ReferenceClient SDKsAgent SDKCookbookChangelog
  • API Guides
    • Overview
    • Streaming
    • Embeddings
    • Limits
    • Authentication
    • Parameters
    • Errors and Debugging
  • API Reference
      • GETList guardrails
      • POSTCreate a guardrail
      • GETGet a guardrail
      • DELDelete a guardrail
      • PATCHUpdate a guardrail
      • GETList key assignments for a guardrail
      • POSTBulk assign keys to a guardrail
      • POSTBulk unassign keys from a guardrail
      • GETList member assignments for a guardrail
      • POSTBulk assign members to a guardrail
      • POSTBulk unassign members from a guardrail
      • GETList all key assignments
      • GETList all member assignments
LogoLogo
ModelsChatRankingsDocs
API ReferenceGuardrails

Create a guardrail

POST
https://openrouter.ai/api/v1/guardrails
POST
/api/v1/guardrails
$curl -X POST https://openrouter.ai/api/v1/guardrails \
> -H "Authorization: Bearer <token>" \
> -H "Content-Type: application/json" \
> -d '{
> "name": "My New Guardrail",
> "allowed_models": null,
> "allowed_providers": [
> "openai",
> "anthropic",
> "deepseek"
> ],
> "description": "A guardrail for limiting API usage",
> "enforce_zdr_anthropic": true,
> "enforce_zdr_google": false,
> "enforce_zdr_openai": true,
> "enforce_zdr_other": false,
> "ignored_models": null,
> "ignored_providers": null,
> "limit_usd": 50,
> "reset_interval": "monthly"
>}'
1{
2 "data": {
3 "created_at": "2025-08-24T10:30:00Z",
4 "id": "550e8400-e29b-41d4-a716-446655440000",
5 "name": "My New Guardrail",
6 "workspace_id": "0df9e665-d932-5740-b2c7-b52af166bc11",
7 "allowed_models": null,
8 "allowed_providers": [
9 "openai",
10 "anthropic",
11 "google"
12 ],
13 "description": "A guardrail for limiting API usage",
14 "enforce_zdr_anthropic": true,
15 "enforce_zdr_google": false,
16 "enforce_zdr_openai": true,
17 "enforce_zdr_other": false,
18 "ignored_models": null,
19 "ignored_providers": null,
20 "limit_usd": 50,
21 "reset_interval": "monthly",
22 "updated_at": null,
23 "enforce_zdr": null
24 }
25}

Create a new guardrail for the authenticated user. Management key required.

Was this page helpful?
Previous

Get a guardrail

Next
Built with

Authentication

AuthorizationBearer
API key as bearer token in Authorization header

Request

This endpoint expects an object.
namestringRequired1-200 characters
Name for the new guardrail
allowed_modelslist of strings or nullOptional

Array of model identifiers (slug or canonical_slug accepted)

allowed_providerslist of strings or nullOptional
List of allowed provider IDs
content_filter_builtinslist of objects or nullOptional

Builtin content filters to apply. The “flag” action is only supported for “regex-prompt-injection”; PII slugs (email, phone, ssn, credit-card, ip-address, person-name, address) accept “block” or “redact” only.

content_filterslist of objects or nullOptional
Custom regex content filters to apply to request messages
descriptionstring or nullOptional<=1000 characters
Description of the guardrail
enforce_zdr_anthropicboolean or nullOptional

Whether to enforce zero data retention for Anthropic models. Falls back to enforce_zdr when not provided.

enforce_zdr_googleboolean or nullOptional

Whether to enforce zero data retention for Google models. Falls back to enforce_zdr when not provided.

enforce_zdr_openaiboolean or nullOptional

Whether to enforce zero data retention for OpenAI models. Falls back to enforce_zdr when not provided.

enforce_zdr_otherboolean or nullOptional

Whether to enforce zero data retention for models that are not from Anthropic, OpenAI, or Google. Falls back to enforce_zdr when not provided.

ignored_modelslist of strings or nullOptional

Array of model identifiers to exclude from routing (slug or canonical_slug accepted)

ignored_providerslist of strings or nullOptional
List of provider IDs to exclude from routing
limit_usddouble or nullOptional
Spending limit in USD
reset_intervalenumOptional

Interval at which the limit resets (daily, weekly, monthly)

Allowed values:
workspace_idstringOptionalformat: "uuid"
The workspace to create the guardrail in. Defaults to the default workspace if not provided.
enforce_zdrboolean or nullOptionalDeprecated

Deprecated. Use enforce_zdr_anthropic, enforce_zdr_openai, enforce_zdr_google, and enforce_zdr_other instead. When provided, its value is copied into any of those per-provider fields that are not explicitly specified on the request.

Response

Guardrail created successfully
dataobject
The created guardrail

Errors

400
Bad Request Error
401
Unauthorized Error
403
Forbidden Error
500
Internal Server Error