AI Azure Content Safety

AI License Required
Related Documentation
Made by
Kong Inc.
Supported Gateway Topologies
hybrid db-less traditional
Supported Konnect Deployments
hybrid cloud-gateways serverless
Compatible Protocols
grpc grpcs http https
Minimum Version
Kong Gateway - 3.7
Tags
#ai
AI Gateway Enterprise: This plugin is only available as part of our AI Gateway Enterprise offering.

The AI Azure Content Safety plugin allows administrators to enforce introspection with the Azure AI Content Safety service for all requests and responses handled by the AI Proxy plugin. The plugin 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.

Audit failures can be observed and reported on using the logging plugins.

This plugin extends the functionality of the AI Proxy plugin, and requires either AI Proxy or AI Proxy Advanced to be configured first. To set up AI Proxy quickly, see Get started with AI Gateway.

How it works

The AI Azure Content Safety plugin can be applied to:

  • Input data (requests)
  • Output data (responses) v3.12+
  • Both input and output data v3.12+

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

  1. The plugin intercepts the request and sends the request body to the Azure AI Content Safety service.
    1. 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 Proxy or AI Proxy Advanced plugin.
  3. On the way back, the plugin intercepts the response and sends the response body to the Azure AI Content Safety service. v3.12+
    1. 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.
 
sequenceDiagram
    autonumber
    participant Client
    participant Plugin as AI Azure Content Safety plugin
    participant Safety as Azure AI Content Safety service
    participant Proxy as AI Proxy/Advanced
    participant AI as Upstream AI Service
    
    Client->>Plugin: Send request
    Plugin->>Safety: Intercept & send request body
    Safety->>Safety: Check against moderation 
categories and blocklists Safety->>Plugin: Allow or block request Plugin->>Proxy: Forward allowed request Proxy->>AI: Process allowed request AI->>Proxy: Return AI response Proxy->>Plugin: Forward response Plugin->>Safety: Intercept & send response body Safety->>Safety: Check against moderation
categories and blocklists Safety->>Plugin: Allow or block response Plugin->>Client: Forward allowed response

Figure 1: Diagram showing the request and response flow with the AI Azure Content Safety plugin.

Format

This plugin works with all of the AI Proxy plugin’s route_type settings (excluding the preserve mode), and is able to compose an Azure Content Safety text check by compiling all chat history, or just the 'user' content.

Something wrong?

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!