# Rate limits and errors

Rate limits apply per API key. A model at capacity answers 429 with Retry-After. Errors use the OpenAI format.

Rate limits apply per API key. You can set a requests per minute limit and a tokens per minute limit on each key. A key with no limit set gets no x-ratelimit headers.

When you go over a limit, or when a model is at capacity right now, the API answers 429 at once and does not queue your request. Wait for the Retry-After header, then try again.

| Header | Meaning |
| --- | --- |
| x-ratelimit-limit-requests | Requests allowed per minute for your API key. Sent only when the key has a requests limit. |
| x-ratelimit-remaining-requests | Requests left in the current minute window. Sent only when the key has a requests limit. |
| x-ratelimit-reset-requests | Time until the requests window resets, such as 42s. |
| x-ratelimit-limit-tokens | Tokens allowed per minute for your API key. Sent only when the key has a tokens limit. |
| x-ratelimit-remaining-tokens | Tokens left in the current minute window. Sent only when the key has a tokens limit. |
| x-ratelimit-reset-tokens | Time until the tokens window resets, such as 42s. |
| x-clod-fallback | Set when your request was served by a fallback model. The value names it. |
| x-clod-cache | hit or miss, when Cache identical responses is on for the project. |
| x-clod-api-version | Request header. Send 1 to get the older response shape on /v1/chat/completions and /v1/models. |
| retry-after | On 429 and 503: seconds to wait before you retry. |

Errors use the OpenAI format. 400 is a bad request, 401 a bad key, 402 no credit, 404 an unknown model or object, 429 a rate limit or a model at capacity, and 5xx a problem on our side. On 429 and 5xx, wait for retry-after and try again.

```json
{
  "error": {
    "message": "clod/kimi-k3p1-pro is at capacity right now, retry shortly",
    "type": "rate_limit_error",
    "code": "model_at_capacity"
  }
}
```

If you still depend on the older response shape (503 instead of 429 at capacity), send the header x-clod-api-version: 1.

```bash
curl https://api.clod.io/v1/chat/completions \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "x-clod-api-version: 1" \
  -H "Content-Type: application/json" \
  -d '{"model": "MODEL_NAME", "messages": [{"role": "user", "content": "Say hello."}]}'
```
