Create a guardrail
Changed onCreate a new guardrail for the authenticated user. A newly created guardrail enforces nothing until it is assigned to API keys or organization members; workspace_id places the guardrail in a workspace but does not apply it to that workspace's traffic. To restrict all traffic in a workspace, update the workspace's default guardrail instead. Set allowed_data_regions to enforce In-Region Routing: governed requests must arrive through one of the listed OpenRouter domains and are rejected with a 403 otherwise. Management key required.
Request
- Base URL: https://openrouter.ai/api/v1
- URL: https://openrouter.ai/api/v1/guardrails
- Auth: HTTP bearer
Request body
Example request
{
"allowed_models": null,
"allowed_providers": [
"openai",
"anthropic",
"deepseek"
],
"content_filter_builtins": [
{
"action": "block",
"slug": "regex-prompt-injection"
}
],
"content_filters": null,
"description": "A guardrail for limiting API usage",
"enforce_zdr_anthropic": true,
"enforce_zdr_google": false,
"enforce_zdr_openai": true,
"enforce_zdr_other": false,
"enforce_zdr_xai": false,
"ignored_models": null,
"ignored_providers": null,
"limit_usd": 50,
"name": "My New Guardrail",
"reset_interval": "monthly"
}Response
Guardrail created successfully
Example response
{
"data": {
"allowed_models": null,
"allowed_providers": [
"openai",
"anthropic",
"google"
],
"content_filter_builtins": [
{
"action": "redact",
"label": "[EMAIL]",
"slug": "email"
}
],
"content_filters": null,
"created_at": "2025-08-24T10:30:00Z",
"description": "A guardrail for limiting API usage",
"enable_free_model_publication": false,
"enable_free_model_training": true,
"enable_paid_model_training": true,
"enforce_zdr": null,
"enforce_zdr_anthropic": true,
"enforce_zdr_google": false,
"enforce_zdr_openai": true,
"enforce_zdr_other": false,
"enforce_zdr_xai": false,
"id": "550e8400-e29b-41d4-a716-446655440000",
"ignored_models": null,
"ignored_providers": null,
"include_byok_in_budgets": false,
"limit_usd": 50,
"name": "My New Guardrail",
"reset_interval": "monthly",
"updated_at": null,
"workspace_id": "0df9e665-d932-5740-b2c7-b52af166bc11"
}
}Changes
- info
added the new optional request property
- info
added the optional property
/////to the response with the status
- info
- info
added the new optional request property
- info
added the optional property
/////to the response with the status
- info