AI Azure Content Safety Policy

Related Documentation
Made by
Kong Inc.
Incompatible with
on-prem
Minimum Version
AI Gateway - 2.0
Tags
Previous Versions of this page

The AI Azure Content Safety Policy allows administrators to enforce introspection with the Azure AI Content Safety service for all requests and responses handled by the AI Model entity. This Policy enables configurable thresholds for the different moderation categories and you can specify an array set of pre-configured blocklist IDs from your Azure Content Safety instance.

You can observe and report on audit failures using the AI logging Policies.

How it works

The AI Azure Content Safety Policy can be applied to:

  • Input data (requests)
  • Output data (responses)
  • Both input and output data

Here’s how it works if you apply it to both requests and responses:

  1. The AI Azure Content Safety Policy intercepts the request and sends the request body to the Azure AI Content Safety service.
    • The Azure AI Content Safety service analyzes the request against configured moderation categories and allows or blocks the request.
  2. If allowed, the request is forwarded upstream with the AI Model entity.
  3. On the way back, the Policy intercepts the response and sends the response body to the Azure AI Content Safety service.
    • The Azure AI Content Safety service analyzes the response against configured moderation categories and allows or blocks the response.
  4. If allowed, the response is forwarded to the client.

TLS verification

config.ssl_verify is enabled by default. The AI Azure Content Safety Policy verifies the TLS certificate when connecting to the Azure Content Safety service. To disable this, set ssl_verify: false.

Logging

The AI Azure Content Safety Policy emits structured log data for every inspected request and response. For the full list of log fields, see the AI Gateway audit log reference.

To log the raw content of blocked requests and responses, enable config.log_blocked_content. When enabled, the blocked prompt or response body appears under ai.proxy.azure-content-safety.input_faulty_prompt and ai.proxy.azure-content-safety.output_faulty_response in the log entry.

Format

This Policy works with all of the AI Model entity’s model.capabilities settings, and is able to compose an Azure Content Safety text check by compiling all chat history, or just the 'user' content.

Forward proxy support

Set config.proxy on this entity to route its outbound requests through an HTTP forward proxy. Use this in network-isolated deployments where AI Gateway cannot open direct connections to LLM providers or auxiliary services.

The proxy record is identical for AI Model, AI MCP Server, and supported AI Policy entities. Existing capabilities such as load balancing, health checking, streaming, WebSocket, and HTTP/2 continue to work when the proxy is active.

For the full field reference, traffic flow, and limitations, see Forward proxy support.

Help us make these docs great!

Kong Developer docs are open source. If you find these useful and want to make them better, contribute today!