Skip to main content
POST
Create a guardrail

Authorizations

Authorization
string
header
required

API key as bearer token in Authorization header

Body

application/json
name
string
required

Name for the new guardrail

Required string length: 1 - 200
Example:

"My New Guardrail"

allowed_data_regions
enum<string>[] | null

Data regions through which requests governed by this guardrail must arrive. global is https://openrouter.ai, europe is https://eu.openrouter.ai, and us is https://us.openrouter.ai. Requests arriving through any other region are rejected. null leaves the ingress region unrestricted. When several guardrails apply (workspace default, member, API key), the effective regions are the intersection of every non-null value. An empty array is rejected.

Minimum array length: 1

An OpenRouter data region: global (https://openrouter.ai), europe (https://eu.openrouter.ai), or us (https://us.openrouter.ai)

Available options:
global,
europe,
us
Example:
allowed_models
string[] | null

Array of model identifiers (slug or canonical_slug accepted)

Minimum array length: 1
Example:
allowed_providers
string[] | null

List of allowed provider IDs

Minimum array length: 1
Example:
content_filter_builtins
object[] | null

Builtin content filters to apply. Every builtin slug supports "block", "redact", and the detect-only "flag" action.

Example:
content_filters
object[] | null

Custom regex content filters to apply to request messages

Example:
description
string | null

Description of the guardrail

Maximum string length: 1000
Example:

"A guardrail for limiting API usage"

enable_free_model_publication
boolean | null

Whether this guardrail allows free endpoints that publish prompts.

Example:

false

enable_free_model_training
boolean | null

Whether this guardrail allows free endpoints that train on request data.

Example:

true

enable_paid_model_training
boolean | null

Whether this guardrail allows paid endpoints that train on request data.

Example:

true

enforce_zdr
boolean | null
deprecated

Deprecated. Use enforce_zdr_anthropic, enforce_zdr_openai, enforce_zdr_google, enforce_zdr_xai, 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.

Example:

false

enforce_zdr_anthropic
boolean | null

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

Example:

false

enforce_zdr_google
boolean | null

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

Example:

false

enforce_zdr_openai
boolean | null

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

Example:

false

enforce_zdr_other
boolean | null

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

Example:

false

enforce_zdr_xai
boolean | null

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

Example:

false

ignored_models
string[] | null

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

Minimum array length: 1
Example:
ignored_providers
string[] | null

List of provider IDs to exclude from routing

Minimum array length: 1
Example:
include_byok_in_budgets
boolean

Whether BYOK (bring-your-own-key) inference spend counts toward this guardrail's limit_usd, in addition to OpenRouter credit spend. Defaults to false.

Example:

false

limit_usd
number<double> | null

Spending limit in USD. Must be provided together with reset_interval: a request that sets only one of the two is rejected with a 400.

Example:

50

reset_interval
enum<string> | null

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

Available options:
daily,
weekly,
monthly,
null
Example:

"monthly"

workspace_id
string<uuid>

The workspace to create the guardrail in. When omitted, the guardrail is created in the default workspace; if that default has been deleted, the request returns a 400 and you must pass workspace_id explicitly. This only places the guardrail in the workspace; the created guardrail enforces nothing for that workspace's traffic until it is assigned to API keys or members. To restrict all traffic in a workspace, update the workspace's default guardrail instead.

Example:

"0df9e665-d932-5740-b2c7-b52af166bc11"

Response

Guardrail created successfully

data
object
required

The created guardrail

Example: