The ai.promptGuard policy inspects LLM request prompts and/or model responses before they are forwarded. Guards can be applied to request (incoming user prompts) and response (model output) independently. Multiple guards can be chained in each list.
ai.promptGuard is part of the ai policy, which marks a route as LLM traffic:
Guard types
Each item in request[] or response[] is exactly one of the following guard types:
Regex
Webhook
OpenAI Moderation
Bedrock Guardrails
Google Model Armor
Inspect content using regular expression patterns. Supports both custom patterns and built-in named patterns for common PII types. Regex-based content guard. Action to take when a rule matches. Valid values: reject. A list of match rules. Each rule is either a builtin named pattern or a custom pattern. A built-in named pattern. Currently supported values include email. A custom regular expression string to match against message content. Example — reject requests containing PII: Forward content to an external HTTP service for inspection. The service returns an allow or deny decision. Webhook-based content guard. The external service to forward content to. One of service, host, or backend must be set. Hostname or IP address (with port) of the webhook service.
Reference to a named service. Namespace of the service.
Explicit backend reference. The backend must be defined in the top-level backends list.
A list of request headers to forward to the webhook service. Each entry matches by header name and optional value. Show forwardHeaderMatches fields
Example: Use the OpenAI Moderation API to classify content. OpenAI Moderation API-based content guard. Show openAIModeration fields
openAIModeration.model string
default: "omni-moderation-latest"
The moderation model to use. Defaults to omni-moderation-latest. openAIModeration.policies Backend connection policies for the OpenAI API (TLS, auth, headers, etc.). Supports the same policy fields as other backend connections.
Example: Use AWS Bedrock Guardrails to evaluate content. AWS Bedrock Guardrails-based content guard. Show bedrockGuardrails fields
bedrockGuardrails.guardrailIdentifier The unique identifier of the Bedrock guardrail to invoke. bedrockGuardrails.guardrailVersion The version of the guardrail (e.g. DRAFT or a version number). The AWS region where the guardrail is deployed. bedrockGuardrails.policies Backend policies for AWS authentication. When omitted, implicit AWS credential chain authentication is used.
Example: Use Google Cloud Model Armor to evaluate content. Google Cloud Model Armor-based content guard. Show googleModelArmor fields
googleModelArmor.templateId The Model Armor template ID to use. googleModelArmor.projectId The GCP project ID where Model Armor is configured. googleModelArmor.location string
default: "us-central1"
The GCP region. Defaults to us-central1. googleModelArmor.policies Backend policies for GCP authentication. When omitted, implicit GCP credential chain authentication is used.
Example:
Rejection configuration
Each guard entry can include a rejection block that customizes the HTTP response returned when the guard denies a request.
Configures the HTTP response sent to the client when the guard rejects a request. HTTP status code to return. Defaults to 403. Response body to send. Supports multi-line strings. Headers to add, set, or remove from the rejection response. Show rejection.headers fields
Headers to add to the rejection response.
Headers to set on the rejection response (overrides existing values). Header names to remove from the rejection response.
Guard chaining
Multiple guards can be listed under request[] or response[]. Guards are evaluated in order. If any guard rejects the content, the associated rejection response is returned immediately and subsequent guards are not evaluated.
The ai.promptGuard policy only applies to routes that process LLM traffic. The parent ai policy must be set on the route for prompt guard to take effect.