AI Consumers

What is an AI Consumer?

An AI Consumer is the AI Gateway entity that identifies an external client consuming or using the AI APIs you publish through AI Gateway. Consumers can represent applications, services, or users who interact with your AI Models, AI Agents, and AI MCP Servers.

AI Consumers are essential for controlling access to your AI APIs, tracking usage, and ensuring security. They are identified through authentication credentials (API keys or OAuth), allowing AI Gateway to authenticate requests and apply Consumer-specific controls. By creating AI Consumers and organizing them into AI Consumer Groups, you can manage access controls at scale, attach AI Policies for governance and security, and monitor token usage per Consumer.

Use cases for AI Consumers

Common use cases for enforcing controls at the AI Consumer level:

Use case

Description

Model access control Control which clients can access which AI Models, restricting access by team, application tier, or use case.
AI safety and guardrails Apply prompt validation, PII detection, and content filtering at the AI Consumer level using AI Policies.
Token and cost control Apply per-consumer rate limits and quotas to prevent token overages and control costs by AI Consumer tier.
AI request transformation Normalize or transform AI requests and responses per AI Consumer (for example, format prompts, inject system instructions, sanitize outputs).
Audit and compliance Track which clients are using which AI Models, monitor for policy violations, and maintain audit logs for compliance and analytics.

Manage AI Consumers

AI Consumers can be created and managed through:

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

For configuration examples and step-by-step setup instructions, see Set up an AI Consumer.

Authentication type

Choose an authentication method based on your deployment needs. Set the type field to declare which credential family AI Consumers will use:

Type

Use case

api-key Simple, stateless authentication for internal services or mobile apps using a shared secret.
oauth Federated identity with an external OIDC provider. AI Gateway accepts any standards-compliant OAuth 2.0 / OpenID Connect provider configured through the openid-connect auth strategy, or for MCP traffic through the AI MCP OAuth2 Policy. The AI Consumer’s own custom_id field maps to the OAuth provider’s user identifier (for example, an OIDC Client ID or sub claim).

api-key AI Consumers authenticate through one or more api-key Credentials created via the credentials endpoint. oauth AI Consumers don’t have Credentials. Set custom_id directly on the AI Consumer instead.

AI Consumer Group membership

To apply AI Policies and access controls to multiple AI Consumers at once, organize them into AI Consumer Groups. An AI Consumer can belong to multiple AI Consumer Groups, letting you manage access controls by team, application, or environment without duplicating configurations.

Manage AI Consumer Group membership through the AI Consumer Group entity.

Attach Policies

To enforce governance, security, or observability controls at the AI Consumer level, attach AI Policies. When an AI Consumer makes a request, AI Gateway applies any AI Policies attached to that AI Consumer before routing the request.

Attach an AI Policy by adding its name or id to the AI Consumer’s policies array. You can attach multiple AI Policies to a single AI Consumer. Each AI Policy runs independently, allowing you to layer controls for rate limiting, request validation, PII redaction, and other governance needs.

For supported policy types and how AI Policies attach to other entities, see the AI Policy entity reference or browse all available AI Policies in the AI policies hub.

Set up an AI Consumer

Create Consumer Credentials

After creating an api-key AI Consumer, create one or more Credentials for authentication. Credentials are managed through a separate endpoint and only support type: api-key. oauth AI Consumers authenticate through their custom_id field instead (see Set up an AI Consumer).

curl -X POST "https://us.api.konghq.com/v1/ai-gateways/$AI_GATEWAY_ID/consumers/$CONSUMER_ID/credentials" \
     --no-progress-meter --fail-with-body  \
     -H "Authorization: Bearer $KONNECT_TOKEN"\
     -H "Content-Type: application/json"\
     -H "Accept: application/json, application/problem+json" \
     --json '{
       "display_name": "Mobile App Key 1",
       "name": "mobile-app-key-1",
       "type": "api-key"
     }'

The response includes the generated api_key value. Store this securely; it cannot be retrieved later.

Schema

FAQs

The runtime entity is a regular Kong Consumer. The AI Gateway surface uses the AI Gateway entity convention (display_name, name, labels), requires an authentication type field, accepts inline AI Consumer Group assignment, and lets you reference AI Policies.

For type: api-key AI Consumers, credentials are managed through a separate credentials endpoint, not as a field on the Consumer. Create them via POST to /consumers/{id}/credentials. type: oauth AI Consumers don’t use this endpoint. See the next question.

The type declares how the AI Consumer authenticates. An api-key AI Consumer holds one or more api-key Credentials created through the credentials endpoint. An oauth AI Consumer has no Credentials. Instead, its own custom_id field is set (at creation or update time) to the identifier your OIDC provider issues (for example, a sub claim), and an authentication policy maps the incoming token to that AI Consumer.

Yes. An AI Consumer can be added to multiple AI Consumer Groups through the AI Consumer Group entity. See the AI Consumer Group entity reference.

Add the Policy’s name or id to the AI Consumer’s policies array. See the AI Policy entity reference.

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!