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

# Errors and limits

> Error format, status codes and rate limits.

## Error format

Errors come in the shape of the format you called.

```json Chat Completions and Responses theme={null}
{
  "error": {
    "message": "Invalid or missing API key. Manage keys at https://app.aesoteric.ai/keys",
    "type": "invalid_request_error",
    "param": "key",
    "code": "invalid_api_key"
  }
}
```

```json Messages theme={null}
{
  "type": "error",
  "error": {
    "type": "authentication_error",
    "message": "Invalid or missing API key. Manage keys at https://app.aesoteric.ai/keys"
  }
}
```

The `message` says what went wrong and, where you can fix it, where to go.

A request that ends in an error is free. See [Billing](https://docs.aesoteric.ai/billing.md#failed-requests-are-free).

## Status codes

| Status | Meaning | What to do |
| - | - | - |
| `400` | The request is invalid, for example the input is longer than the chosen model's context, `max_tokens` is too large for the input, `n` is not 1, or it uses a field that isn't supported. | Fix the request as the message says. Retrying the same request won't help. |
| `401` | The API key is missing or invalid. | Check your key on the [API keys](https://app.aesoteric.ai/keys) page. |
| `402` | Your account can't pay for the request: there is no card or credit, a card payment is processing or due, the monthly budget is reached, the staking allowance is used up, or the key has reached its spending limit. | Follow the link in the message, usually to [Billing](https://app.aesoteric.ai/billing). |
| `403` | The account is suspended. | Retrying won't help. |
| `404` | No model with that id is served (`model_not_found` in Chat Completions and Responses, `not_found_error` in Messages). | Use a model id from [`GET /v1/models`](https://docs.aesoteric.ai/models). |
| `429` | A rate limit is reached. | Wait for the number of seconds in the `Retry-After` header, then retry. |
| `500`, `502`, `503` | A temporary failure. | Retry after a short wait. |

## Rate limits

Each account has two limits, shared by all of its keys:

* **Requests per minute.**
* **Requests at once**: how many requests can run at the same time.

Over either limit, a request is answered `429` with a `Retry-After` header, and costs nothing.

The limits rise with your account's tier, and your tier rises with what your account has paid in total. Staking doesn't change your tier. The [Models](https://app.aesoteric.ai/models#rate-limits) page lists each tier's limits and what unlocks it.

There is no limit on tokens per minute.

Counting tokens with `POST /v1/messages/count_tokens` has its own per-minute limit, equal to your requests per minute, so counts never use up requests.

## Output limits

A request can use at most the chosen model's context size, input and output together. If you set `max_tokens` (`max_output_tokens` in Responses) above what is left after the input, the request is answered `400` with the largest value allowed.


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