AI Policies

Related Documentation
Minimum Version
AI Gateway - 2.0
Incompatible with
on-prem

What is an AI Policy?

Create an AI Policy when you want to add governance, security, transformation, or observability to AI Gateway traffic. For example:

To control access and verify identity, assign an AI Auth Strategy instead of an AI Policy.

For the complete set of available policy types and configurations, see the AI Policies hub.

Manage AI Policies

AI Policies are managed through:

  • Konnect UI
  • AI Gateway API: /v1/ai-gateways/{aiGatewayId}/policies
  • kongctl

For configuration examples and step-by-step setup instructions, see Set up a global AI Policy.

AI Policy scopes

Each AI Policy is an independent configuration that applies at exactly one scope.

The available scopes are:

  • Global: An AI Policy with no parent entity reference applies to all AI Gateway traffic on the data plane. Non-AI traffic on the same data plane isn’t affected.

  • Entity-scoped: Reference the policy from the policies array on an AI Model, AI Agent, AI MCP Server, AI Consumer, or AI Consumer Group entity. The policy applies at that entity’s scope.

To apply an identical configuration in multiple places, create an entity-scoped AI Policy and reference it in each entity’s configuration.

Set up a global AI Policy

An AI Policy specifies a type (like AI Sanitizer or AI Rate Limiting Advanced) and a config block that configures that behavior. AI Gateway applies the policy at the scope you choose: globally across all traffic, or scoped to the entities where it is referenced.

The following example creates a global AI PII Sanitizer Policy that runs for every AI Gateway Route. It anonymizes high-risk PII categories (email, phone, SSN, and credit cards) along with custom patterns for sensitive tokens like AWS API keys and GitHub tokens.

This Policy connects to an AI PII Anonymizer service at host/port (sanitizer-service.internal:8080 in this example) to perform the actual sanitization. Substitute the address of your own running instance. See AI PII Anonymizer service for image access and setup instructions.

Without a reachable service at that address, requests through this Policy will fail.

Schema

FAQs

Each AI Policy is an independent entity. You can apply the same AI Policy to multiple other entities by referencing the policy in each entity’s configuration.

An AI Policy is a policy configuration created through the AI Gateway entity surface instead of the classic /plugins endpoint. The runtime effect is the same: a policy attached at the appropriate scope.

Yes. Add the AI Policy’s name or id to the AI Consumer’s or AI Consumer Group’s policies array. The Policy runs when the AI Consumer is identified during a request, or when a member of the AI Consumer Group is identified.

Standalone AI Policies referenced from parent entities through a policies array are independent and aren’t deleted when a referencing parent is deleted. The reference is simply removed.

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!