Guardrail - Python SDK

Guardrail method reference

The Python SDK and docs are currently in beta. Report issues on GitHub.

Fields

FieldTypeRequiredDescriptionExample
allowed_modelsList[str]Array of model canonical_slugs (immutable identifiers)[
“openai/gpt-5.2-20251211”,
“anthropic/claude-4.5-opus-20251124”,
“deepseek/deepseek-r1-0528:free”
]
allowed_providersList[str]List of allowed provider IDs[
“openai”,
“anthropic”,
“google”
]
content_filter_builtinsList[components.ContentFilterBuiltinEntry]Builtin content filters applied to requests. Includes PII detectors and the regex-based prompt injection detector.[
{"action": "redact","label": "[EMAIL]","slug": "email"}
]
content_filtersList[components.ContentFilterEntry]Custom regex content filters applied to request messages[
{"action": "redact","label": "[API_KEY]","pattern": "\\b(sk-[a-zA-Z0-9]{48})\b”
}
]
created_atstr✔️ISO 8601 timestamp of when the guardrail was created2025-08-24T10:30:00Z
descriptionOptionalNullable[str]Description of the guardrailGuardrail for production environment
enforce_zdrOptionalNullable[bool]: warning: ** DEPRECATED **: This will be removed in a future release, please migrate away from it as soon as possible.

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.
false
enforce_zdr_anthropicOptionalNullable[bool]Whether to enforce zero data retention for Anthropic models. Falls back to enforce_zdr when not provided.false
enforce_zdr_googleOptionalNullable[bool]Whether to enforce zero data retention for Google models. Falls back to enforce_zdr when not provided.false
enforce_zdr_openaiOptionalNullable[bool]Whether to enforce zero data retention for OpenAI models. Falls back to enforce_zdr when not provided.false
enforce_zdr_otherOptionalNullable[bool]Whether to enforce zero data retention for models that are not from Anthropic, OpenAI, or Google. Falls back to enforce_zdr when not provided.false
idstr✔️Unique identifier for the guardrail550e8400-e29b-41d4-a716-446655440000
ignored_modelsList[str]Array of model canonical_slugs to exclude from routing[
“openai/gpt-4o-mini-2024-07-18”
]
ignored_providersList[str]List of provider IDs to exclude from routing[
“azure”
]
limit_usdOptionalNullable[float]Spending limit in USD100
namestr✔️Name of the guardrailProduction Guardrail
reset_intervalOptionalNullable[components.GuardrailInterval]Interval at which the limit resets (daily, weekly, monthly)monthly
updated_atOptionalNullable[str]ISO 8601 timestamp of when the guardrail was last updated2025-08-24T15:45:00Z
workspace_idstr✔️The workspace ID this guardrail belongs to.0df9e665-d932-5740-b2c7-b52af166bc11