> ## Documentation Index
> Fetch the complete documentation index at: https://docs.aixy-gateway.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Rate limits

> Control model traffic per API key and across an organization.

Rate limits protect against bursts and agent loops. They complement
[hard budgets](/costs/budgets), which limit monetary spend. A request must satisfy both its
API-key limits and the organization's shared limits before reaching a model provider.

| Limit | What it controls |
| - | - |
| Requests per minute | Accepted model requests in a shared UTC minute. |
| Tokens per minute | Input and output token capacity reserved for accepted requests in that minute. |
| Concurrent requests | Active model requests, including streaming responses. |

Each limit is optional. Leave a field blank to remove that limit; leave all three blank to remove
the policy. A key with no individual policy still follows any configured organization limits.
Provider limits also continue to apply.
First activation applies to subsequent admissions; it does not reconstruct traffic served earlier
in the minute without a policy.

## Protect an API key

Open **API keys** from the account menu, then select **Rate limits** for a key you own. Set the
limits appropriate for that application and save. The policy belongs to the logical key, so
rotating its secret preserves both the policy and its current counters. Overlapping secret
versions share the same capacity.

## Set organization limits

Open **Cost control** in the organization view and use **Organization rate limits**. Users with
organization policy management permission can edit the limits. The organization's capacity is
shared across projects, users and keys, including traffic served by different gateway replicas.
Increasing a key's allowance cannot bypass the organization's ceiling.

## Prepare requests with token limits

TPM admission reserves a conservative token allowance before execution and reconciles it against
complete provider usage afterward. Generation requests need an explicit positive output-token
limit: `max_tokens` or `max_completion_tokens` for Chat Completions, `max_output_tokens` for
Responses, or `max_tokens` for Messages. A small TPM setting can reject a request even when
previous requests used fewer tokens:
the next request's reserved input and maximum output must fit together.

Requests whose token use cannot be bounded locally are rejected when a TPM limit applies.
Incomplete usage, interrupted streams and uncertain provider outcomes retain conservative
capacity for the admission minute. Rate-limit reservations are capacity safeguards, not provider
bills. A request admitted before the minute changes remains attributed to its admission minute.

Routing retries and classifier work reserve additional capacity. When their combined usage cannot
be reconciled completely, the conservative allowance remains charged for that minute.
The Aixy-managed routing classifier and decision API classifiers cannot enforce an output-token cap.
With a TPM policy, automatic routing uses its existing deterministic fallback. A customer-configured
Chat Completions classifier
with a bounded output remains available.

## Handle rejections

Aixy returns HTTP `429` with `Retry-After` when an applicable limit has no capacity. Wait for that
delay before retrying and keep retries bounded. A full concurrent-request limit can become
available as existing requests finish.

When Redis cannot verify configured limits, Aixy returns HTTP `503`; it does not silently grant
each replica its own allowance. Requests without a configured policy retain their normal admission
behavior. Rate limits apply to model execution; catalog lookups and usage reads do not consume
these allowances.

Once admitted under a concurrency limit, model execution has a maximum lifetime of 15 minutes by
default, including the complete stream. A request that reaches that lifetime ends with a timeout; this allows
capacity held by interrupted gateway instances to recover safely. Provider-backed token counting
follows request and concurrency rate limits and reserves input token capacity, while retaining its existing
exemption from hard budgets and monthly model-request quotas.

Use **Activity** to distinguish an Aixy rate-limit decision from a provider rate-limit response.
Changing a policy does not erase the current minute's counters.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.