Rate limits and errors
Each organization has rate limits. They protect the shared replicas and keep latency steady for all customers.
Limits of each plan#
| Plan | Requests each minute | Tokens each minute |
|---|---|---|
| Free | 60 | 200,000 |
| Pro | 600 | 2,000,000 |
| Enterprise | 6,000 | 20,000,000 |
The limits are for the organization, for all its keys together. The tokens are input and output tokens. The dashboard page Limits shows the limits of your plan.
Rate limit headers#
Each response tells you how much of the limit remains.
| Header | Meaning |
|---|---|
X-RateLimit-Limit-Requests | The requests each minute of your plan. |
X-RateLimit-Remaining-Requests | The requests that remain in this minute. |
X-RateLimit-Limit-Tokens | The tokens each minute of your plan. |
X-RateLimit-Remaining-Tokens | The tokens that remain in this minute. |
X-RateLimit-Reset | When the limit resets. |
A response with status 429 also has Retry-After, in seconds.
Size limits#
| Limit | Value |
|---|---|
| Request body, JSON endpoints | 10 MiB |
Request body, /v1/predict | 50 MiB |
| Request headers | 16 KiB |
| Messages in one chat request | 2,048 |
| Inputs in one embeddings request | 2,048 |
Above a size limit, the API returns status 413.
Spend limits and budgets#
The monthly spend limit stops all requests of the organization when it is reached. A budget stops the requests of one key or one deployment. See Cost control.
Errors#
Each error has a JSON body with error.code, error.message and error.request_id.
| Status | Code | What to do |
|---|---|---|
| 400 | invalid_request | Correct the request. The message names the problem. |
| 401 | invalid_api_key | Use a key that is valid and not revoked. |
| 402 | spend_limit_reached, budget_reached | Raise the limit or the budget, or wait for the next month. |
| 403 | permission_denied, org_suspended | Use a key with the necessary scope and a model in the key's model list. |
| 404 | not_found | Check the model ID or the deployment ID. |
| 413 | request_too_large | Make the request smaller. |
| 429 | rate_limited | Wait for the time in Retry-After, then send again. |
| 503 | warming, unavailable, auth_unavailable | A replica starts, or a service is busy. Send again after a few seconds. |
| 504 | upstream_timeout | The model did not answer in time. Send again. |
Send again safely#
- Send again only after 429, 503 and 504 errors, and after network errors.
- Wait for the time in
Retry-After. If there is no header, wait 1 second, then 2 seconds, then 4 seconds. - Stop after five attempts. Then examine the error.
- Keep
X-Request-Idof each failed request. Support needs it.