KONG API AI Docs Start free

Developers

Usage per customer

If your app serves many customers, KONG API AI records usage per customer and lets you set a separate limit for each one.

When to use it

You build an app and have customers of your own. You want to know how many tokens each customer uses, and to stop a customer who goes over the agreed amount.

Customers and agents count as keys of your plan, not as members.

Easiest: one key per customer

In the console, create a key with the customer selected. Every request of that key is attributed to that customer. Nothing else to send.

One key for many customers

  1. In the console, open Customers, open a customer and choose Generate Token. The token is signed and valid for 15 minutes.
  2. Send the token in the X-GW-Customer header of each request.
Terminal
curl https://kongapiai.com/v1/chat/completions \
  -H "Authorization: Bearer $KONG_KEY" \
  -H "X-GW-Customer: $CUSTOMER_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"model": "MODEL_ID", "messages": [{"role": "user", "content": "Hello"}]}'

A limit for a customer

Each customer can have a monthly limit. At the limit, that customer's requests get 402; other customers keep running.

The limit counts only what is paid with KONG API AI credits. Usage on your own sources is not capped. See Limits and routing.

Turn a customer off

When a customer is turned off in the console, their requests get 403 with customer_disabled.