An AI Policy applies wherever you attach it.
An AI Policy with global: true applies to all AI Gateway traffic on the data plane.
An AI Policy without it applies only to the entities that reference it.
The available scopes are:
-
Global: Set global: true to apply the AI Policy to all AI Gateway traffic on the data plane. Non-AI traffic on the same data plane isn’t affected.
-
Entity-scoped: Reference the AI Policy from the policies array on an AI Model, AI Agent, AI MCP Server, AI Consumer, or AI Consumer Group entity. The AI 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.
Not every AI Policy type supports every scope.
For example, an ACL AI Policy doesn’t support AI Consumer or AI Consumer Group scopes.
AI Gateway rejects the request with an error when you attach an AI Policy at a scope its type doesn’t support.
Scope precedence determines which AI Policy runs when AI Policies of the same type apply to a request at more than one scope.
Only the most specific AI Policy runs.
From most to least specific scope, the order is:
- AI Consumer
- AI Consumer Group
- AI Model, AI Agent, or AI MCP Server
- Global
For example, if a global AI Rate Limiting Advanced Policy and one scoped to an AI Model both apply to a request, only the Model-scoped AI Policy runs.
Requests to other Models still use the global AI Policy.
Precedence for AI Consumer Groups
An AI Consumer can belong to several AI Consumer Groups, and more than one of those groups can have an AI Policy of the same type.
In that case, only one of those AI Policies runs.
AI Gateway sorts the AI Consumer’s groups by name and uses the AI Policy from the first group in that order that has one.
For example, if an AI Consumer is in the groups alpha and beta, and both have an AI Prompt Guard Policy, only the AI Policy on alpha runs.
The order in which you add the AI Consumer to the groups doesn’t change the result.
AI Gateway doesn’t guarantee this order, and it can change in a future release.
Attach at most one AI Policy of a given type to the same entity.
For details, see the FAQ.