# Limits and headers

## Limits

| Limit | Applies to | When exceeded |
|---|---|---|
| Requests per minute | The key and, separately, all keys of the account | `429 rate_limit_exceeded` |
| Concurrent requests | The account | `429 concurrency_limit_exceeded` |
| Concurrent chat requests with files | The account, one | `429 concurrency_limit_exceeded` with `details.lane: "files"` |
| Concurrent media generations | The account | Extra ones wait in `queued` |
| Spend limit | The key, if set in your account | `402 key_spend_limit_reached` |

The limits are generous and exist against runaway code, not as plans. Your current values: `GET /v1/key`, field `rate_limit`. Need more: contact [support](/support).

### How the request limit works

The quota refills continuously instead of resetting once a minute (GCRA): with a limit of 600 per minute, one request comes back every 100 ms. The burst allowance equals the per-minute quota, so after a pause up to 600 requests can go at once. The key's limit and the account's (all keys together) are checked together: a request spends quota only if it passes both. A refusal by the limit spends nothing.

On `429 rate_limit_exceeded` the `Retry-After` header is the exact time in seconds until the request would pass.

```http
RateLimit-Policy: "key";q=600;w=60, "user";q=1800;w=60
RateLimit: "key";r=599;t=1
x-ratelimit-limit-requests: 600
x-ratelimit-remaining-requests: 599
x-ratelimit-reset-requests: 1s
```

`RateLimit-Policy` lists both limits: `q` is the quota, `w` the window in seconds. `RateLimit` describes the limit that refused, or the tighter one when nothing refused: `r` is how many requests can go right now, `t` how many seconds until the quota is full again. `x-ratelimit-*` repeat the same in the OpenAI shape for SDKs.

## Response headers

| Header | When | Meaning |
|---|---|---|
| `x-request-id` | Always | Request id `req_...`: receipts, support |
| `request-id` | `/v1/messages` | The same as `x-request-id`, under Anthropic's name |
| `x-unitool-ignored-betas` | `/v1/messages` | `anthropic-beta` values that had no effect |
| `RateLimit-Policy`, `RateLimit` | After the key check | Request limits, see above |
| `x-ratelimit-limit-requests` | After the key check | Requests per minute |
| `x-ratelimit-remaining-requests` | After the key check | Requests that can go right now |
| `x-ratelimit-reset-requests` | After the key check | Time until the quota is full again, e.g. `1s` |
| `Retry-After` | 429, 503, generation 202 | Seconds to wait |
| `Deprecation`, `Sunset`, `Link` | Calls to a model being retired | See [Retiring models](/developers/models#retiring-models) |
| `x-should-retry` | `balance_held` | SDK hint whether to retry |
| `x-unitool-cost-tokens` | Non-streamed chat | The request's price in balance tokens |
| `x-unitool-output-capped` | Chat | `true`: the output limit was lowered to fit the balance |
| `x-unitool-ignored-params` | Chat | Accepted but unused parameters |
| `x-unitool-incomplete` | Non-streamed chat | Incomplete answer: `upstream_error`, `deadline`, `shutdown` |
| `Location` | Generation `202` | Where to poll |
| `Idempotent-Replayed` | Generations | `true`: an earlier generation was returned |
| `ETag` | `/v1/models` | For `If-None-Match` and a `304` |

## Request headers

| Header | Meaning |
|---|---|
| `Authorization: Bearer ut_live_...` | The key. `x-api-key` works too |
| `X-Client-Request-Id` | Your label for the request, up to 128 printable ASCII characters. Saved in the receipt as `client_request_id` |
| `Idempotency-Key` | For `POST /v1/generations`, see [Generations](/developers/generations#idempotency) |
| `Prefer: wait=N` | Wait for a finished generation up to N seconds, 60 at most |
| `If-None-Match` | For `/v1/models` |

## Request ids

Every answer, errors included, carries `x-request-id`. The same id is in `error.request_id`, in the chat answer id (`chatcmpl-...`) and in the receipt `GET /v1/requests/{id}`. Your own `X-Request-Id` is never used as the id, only saved as a client label.

## Retries

- 429, 503: wait `Retry-After` and retry.
- 500, 502, 504: retry with exponential backoff, 2 or 3 attempts.
- Retry generations only with the same `Idempotency-Key`, or you get a second paid generation.
- Chat has no idempotency: each retry is a separate paid request.
- Do not retry other 4xx without fixing the request.

## Versions

The version is in the path: `/v1`. Changes inside `v1` are additive only: new fields, models, error codes. Your code should skip fields it does not know. History is in the [Changelog](/developers/changelog).
