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.

Each AI Policy is independent. To apply the same configuration across multiple entities, create separate Policies for each one. This ensures that deleting an entity deletes only its own Policies, not configurations shared with other parts of your gateway.

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

An AI Policy’s scope is determined by where it’s referenced. Each AI Policy is an independent configuration that applies at exactly one scope. To apply identical configuration in multiple places, create one AI Policy per target.

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.

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 a specific entity.

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

No. Each AI Policy is an independent configuration. To apply the same configuration to two AI Models, create two AI Policies with matching config, one per AI Model.

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. AI Gateway manages the AI Policy’s lifecycle alongside the entity it’s attached to.

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!