# Rate limits

> How many requests and tokens a key and an account can use, and what a 429 reply tells you.

## Two limits

Limits apply to each key and to the account that owns it. A request is turned away when either one is used up. The account limit is shared by all of its keys.

| Limit | Per key | Per account |
|---|---|---|
| Requests per minute | 20 | 30 |
| Requests per day | 500 | 1,000 |
| Input tokens per minute | 40,000 | 60,000 |
| Output tokens per minute | 8,000 | 16,000 |

There is one early-access tier today. A key can send 20 requests per minute and 500 a day. Counting tokens is free and has its own limit of 100 a minute per key. Management endpoints, such as listing models and files, are limited to 60 a minute per key. Calls to the [batch](https://antarya.ai/docs/api/batches.md) endpoints count against the 60 a minute management limit; the requests inside a batch do not count against the chat limits. An account can have at most 5 batches in progress and 10,000 queued requests.

## Headers

Every reply carries the limit its endpoint is under: the chat requests-per-minute allowance for chat, the 100 a minute window for counting tokens, and the 60 a minute window for management endpoints such as sessions, files, models and batches.

| Header | Meaning |
|---|---|
| `ratelimit-limit` | The most requests allowed in the current window. |
| `ratelimit-remaining` | Requests left in the window. |
| `ratelimit-reset` | Seconds until the window resets. |
| `retry-after` | On a 429 only: seconds to wait before you try again. |

## When you reach a limit

The reply is a 429 with the usual error body and a `retry-after` header.

```bash
curl -i https://antarya.ai/v1/chat \
  -H "Authorization: Bearer $ANTARYA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"messages": [{"role": "user", "content": "Draft a reply that declines the meeting."}]}'
```

Output:

```
HTTP/1.1 429 Too Many Requests
retry-after: 20
ratelimit-remaining: 0

{
  "error": {
    "type": "rate_limit_error",
    "message": "Too many requests for this key. Retry after 20 seconds."
  },
  "request_id": "req_02"
}
```

The message names the limit that was hit, in the form "Too many {what} for this {key|account}. Retry after N seconds." Wait for `retry-after`, then send the request again. Spread large jobs over time, or send them as a [batch](https://antarya.ai/docs/api/batches.md), which has its own allowance.

## Ask for more

Open the Usage page on the platform to see how close you are to each limit. To raise a limit, send a request at [/contact](https://antarya.ai/contact) with your account, the limit you reach and the volume you expect.

## Next steps

- [Errors](https://antarya.ai/docs/api/errors.md): Every status and what to do about it.
- [Batches](https://antarya.ai/docs/api/batches.md): Send many requests without hitting a per-minute limit.
- [Chat](https://antarya.ai/docs/api/chat.md): The request these limits apply to.
