AI Budgets
An AI Budget is a reusable set of limits, attached to clients like a policy. Every client using the budget gets its own counters. Clients without a budget have no AI limits; profiles can add their own token cap.
Limits
| Limit | Meaning |
|---|---|
| Tokens per minute | Prompt plus completion tokens in the current minute. |
| Requests per minute | Model requests in the current minute. |
| Concurrent requests | Requests in flight at once. |
| Token quota | Tokens per day, 7 days or 30 days. |
| Spend quota | USD per day, 7 days or 30 days, from each model's pricing. |
| Per-model limits | Tighter tokens-per-minute and token quota for named models (the quota uses the budget's token period). |
0 means no limit. Periods are calendar windows in UTC. Counters are shared across gateway instances through Redis/KeyDB when it is configured.
A request is checked before it is sent (it is refused if a limit is already used up) and charged with its actual usage when it finishes, so one large request can take a client past a limit.
When a limit is reached
| On exceed | Behaviour |
|---|---|
| Block | Requests return 429 with Retry-After: rate_limit_exceeded for per-minute and concurrency limits, budget_exceeded for quotas and profile token caps. |
| Alert only | Requests continue; the request that reaches the limit is tagged budget_alert:<limit> in AI Logs. |
Alerts
Alert at sets quota percentages (for example 80, 100). The first request that takes a client past each one, once per period, sends a POST to the Budget alert webhook in AI Gateway › Settings:
{
"type": "ai_budget_alert",
"client_id": "6ae3...",
"client_name": "Payments",
"budget_name": "Payments team",
"limit": "token_quota",
"threshold_percent": 80,
"used": 812000,
"max": 1000000,
"at": "2026-10-29T10:00:00Z"
}
limit is token_quota, model_token_quota or money_quota (with used and max in millionths of a US dollar). Per-minute limits and profile token caps do not raise alerts. Delivery is best effort with a 5-second timeout and is not retried; the webhook URL is never logged.
Spend and budget usage
AI Gateway › Spend reports requests, errors, tokens and cost for the last 24 hours, 7 or 30 days, grouped by client, model, profile or provider, with each row's share of the total. Export CSV downloads the same report (spreadsheet formulas in names are neutralised).
Under Budget usage now, every client with an AI budget or profile token caps shows a meter per limit: what is used in the current window, the limit, and when the window resets. Meters turn amber at 80% and red at 100%.
The same data is available from the management API (GET /api/v1/ai/spend, GET /api/v1/ai/spend/export, GET /api/v1/ai/usage/clients/{id}, viewer role) and the Management MCP tools ai_spend_report and ai_client_usage.
Playground
Playground requests are logged but do not count against any client's budget.