Guardrails

Update a guardrail

Changed on

Update an existing guardrail, or materialize an unconfigured workspace default guardrail. Collection fields use replace semantics: send the full desired set on every update. A workspace-scoped management key reaches only guardrails in its own workspace; any other guardrail returns 404. Management key required.

patch/guardrails/{id}

Request

  • Base URL
    https://openrouter.ai/api/v1
  • Auth
    HTTP bearer

Path parameters

id, string uuid required

The unique identifier of the guardrail to update

Example:550e8400-e29b-41d4-a716-446655440000

Request body

UpdateGuardrailRequest required
allow_provisional_providers, boolean nullable

Whether requests may use provisional providers, whose security practices have not been reviewed by OpenRouter. false excludes them. true and null never override an account that excludes them. Inherits the account setting when not provided.

allow_safety_retention_google, boolean nullable

Whether ZDR-only requests to google/* models may also use Safety Retention endpoints, which may retain prompts and responses from any request, only to prevent abuse, and do not use them for training. false allows only ZDR endpoints. A guardrail can only be more restrictive than the account setting. Inherits the account setting when not provided.

allow_safety_retention_openai, boolean nullable

Whether ZDR-only requests to openai/* models may also use Safety Retention endpoints, which may retain prompts and responses from any request, only to prevent abuse, and do not use them for training. false allows only ZDR endpoints. Applies only while OpenAI ZDR is on for the account or this guardrail; otherwise allow_safety_retention_other applies. Follows allow_safety_retention_other when null; on update, null clears a saved choice and omitting the field leaves it unchanged. While the account enforces ZDR for OpenAI or for other models, a guardrail can only be more restrictive than that account setting.

allow_safety_retention_other, boolean nullable

Whether ZDR-only requests to models outside the named providers (for example open-weight models on Vertex) may also use Safety Retention endpoints, which may retain prompts and responses from any request, only to prevent abuse, and do not use them for training. false allows only ZDR endpoints. A guardrail can only be more restrictive than the account setting. Inherits the account setting when not provided.

allowed_data_regions, GuardrailDataRegion[] nullable

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.

allowed_models, string[] nullable

Array of model identifiers (slug or canonical_slug accepted)

allowed_providers, string[] nullable

New list of allowed provider IDs

content_filter_builtins, ContentFilterBuiltinEntryInput[] nullable

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

content_filters, ContentFilterEntry[] nullable

Custom regex content filters to apply. Set to null to remove.

description, string nullable

New description for the guardrail

enable_free_model_publication, boolean nullable

Whether this guardrail allows free endpoints that publish prompts.

enable_free_model_training, boolean nullable

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

enable_paid_model_training, boolean nullable

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

enforce_first_party_harness_models, boolean nullable

Whether coding harnesses list only their vendor's own models: Codex lists OpenAI models and Claude Code and Claude Desktop list Anthropic models. Affects only the model list those harnesses request from GET /models; a model the client names directly is still routed. Any true across the workspace default, member, and API key guardrails applies.

enforce_zdr, boolean nullable

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.

enforce_zdr_anthropic, boolean nullable

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

enforce_zdr_google, boolean nullable

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

enforce_zdr_openai, boolean nullable

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

enforce_zdr_other, boolean nullable

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.

enforce_zdr_xai, boolean nullable

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

ignored_models, string[] nullable

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

ignored_providers, string[] nullable

List of provider IDs to exclude from routing

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. Omit to leave unchanged.

limit_usd, number double nullable

New spending limit in USD

name, string

New name for the guardrail

reset_interval, 'daily' | 'weekly' | 'monthly' | 'null' nullable

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

Example request

{
  "description": "Updated description",
  "limit_usd": 75,
  "name": "Updated Guardrail Name",
  "reset_interval": "weekly"
}

Response

Guardrail updated successfully

UpdateGuardrailResponse required
data, intersection required

The updated guardrail

Example response

{
  "data": {
    "allowed_models": null,
    "allowed_providers": [
      "openai"
    ],
    "content_filter_builtins": [
      {
        "action": "redact",
        "label": "[EMAIL]",
        "slug": "email"
      }
    ],
    "content_filters": null,
    "created_at": "2025-08-24T10:30:00Z",
    "description": "Updated description",
    "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": true,
    "enforce_zdr_openai": true,
    "enforce_zdr_other": true,
    "enforce_zdr_xai": true,
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "ignored_models": null,
    "ignored_providers": null,
    "include_byok_in_budgets": true,
    "limit_usd": 75,
    "name": "Updated Guardrail Name",
    "reset_interval": "weekly",
    "updated_at": "2025-08-24T16:00:00Z",
    "workspace_id": "0df9e665-d932-5740-b2c7-b52af166bc11"
  }
}

Changes

    • info

      added the new optional request property allow_safety_retention_openai

    • info

      added the optional property data/allOf[#/components/schemas/Guardrail]/allow_safety_retention_openai to the response with the status

    • info

      added the new optional request property allow_provisional_providers

    1 more change in this revision