Skip to content

Type to search the docs and the model list.

Rate limits and retries

How 429 and 5xx errors work, and how to retry without making things worse.

Two different things can stop a request: a rate problem (too many requests too fast, or no spare capacity on a model right now) and a budget problem (the key or the account has no money left). Rate problems pass if you wait. Budget problems do not.

Limits

  • Per key: every API key has its own limits per minute, listed in Limits per key. A rate limit is not something you set in the console today. Write clients that cope with a 429 at any time.
  • Per model: a model that is short of capacity does not show up as a 429. You get a 502 (model_unavailable), which is also worth retrying. A 429 always comes from your own key: its request or token limit. It is the same for every model, so a models list is not tried further.
  • Size: uploaded images can be up to 20 MB each and audio files up to 25 MB (see Errors).
  • Time: a chat response has to start within about 90 seconds; image and audio models have their own limits, and the edge ends any response that has not started after 100 seconds. Use streaming for long chat answers and jobs for video and music.

Limits per key

Limits apply to each API key separately, not to your IP address or your whole account. Counts reset every minute. A short burst at the peak can occasionally get through slightly above the stated number, so treat the numbers as a guide for sizing your client, not as an exact meter. Chat, responses, messages and embeddings calls count against the first table:

Per API key, Limit per minute
Per API keyLimit per minute
Requests600
Tokens2,000,000

Image, image edit, speech and transcription requests, job creation and job reads have their own per-key limits:

Per API key, Limit per minute
Per API keyLimit per minute
Images, image edits, speech and transcription (requests)60
Creating video, audio and 3D jobs, counted together (new jobs)10
Reading jobs, GET /v1/jobs and GET /v1/jobs/{id} (job reads)600

Keys used in the console playground have lower limits than API keys. If you need higher limits for an API key, contact support at support@ewest.ai with your use case and the expected request rate.

What a limit response looks like

Going over a limit returns HTTP 429 with type rate_limit_error, code rate_limit_exceeded and a retry-after header: the number of seconds to wait. The body uses the usual error shape. On chat endpoints it is {"error": {"message": "Rate limit reached for this API key. Retry after the time in the retry-after header.", "type": "rate_limit_error", "param": null, "code": "rate_limit_exceeded"}}.

On image, audio, video and 3D job requests the message also names the limit, for example Rate limit reached for this API key: 10 new jobs per minute. Try again in 23 s. Branch on the status and the code, never on the message. Back off for the retry-after seconds, and poll jobs no faster than you need: a slower poll interval, or the job's event stream, keeps you well under the read limit.

Response headers

When a key has a request or token limit, responses on the chat endpoints can carry OpenAI's header names: x-ratelimit-limit-requests, x-ratelimit-remaining-requests and the matching -tokens headers. Read them if they are there, but do not require them: they can be missing, for example on streamed answers. A 429 for the key's limit carries retry-after, in seconds; the example below honours it.

Budget or rate? 402 versus 429

You see, It means, Retry?
You seeIt meansRetry?
402 insufficient_budgetThis key's budget is used up.No. Raise the budget or use another key.
402 insufficient_balanceThe organisation's prepaid balance is too low. Only returned once prepaid billing is enforced for your account.No. Add funds in the console.
429 rate_limit_errorThe key's own request or token limit.Yes, after the retry-after seconds.

A 402 is final: retrying a budget error never succeeds. A 429 is a rate problem and passes if you wait.

To check before a large request, GET /v1/key returns what the calling key may still spend: its budget, spend, remaining amount and limits, and the organisation's prepaid balance. It is free and sees only the key that calls it.

Retrying with backoff

  • Retry only 429 (rate), 500, 502, 503, 504 and network errors such as a dropped connection or a timeout. Never retry 400, 401, 402, 403 or 404.
  • Wait longer after each failure: for example 1 s, 2 s, 4 s, 8 s, up to a ceiling of 30 s.
  • Add jitter, a random part of each wait, so clients that failed together do not all come back together.
  • If a retry-after header is present, wait at least that long.
  • Stop after a few attempts (five is plenty) and report the error together with its x-request-id.
  • Set a client timeout of about 100 seconds, and stream long answers instead of waiting on one big response.
# curl retries 429 and 5xx on its own: it waits 1 s, 2 s, 4 s, ... and honours a retry-after
# header. It never retries a 402 (out of budget). The Python and JavaScript tabs add jitter and a time limit.
curl --retry 5 --retry-max-time 60 https://api.ewest.ai/v1/chat/completions \
  -H "Authorization: Bearer $EWEST_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "ewest/gemini-flash",
       "messages": [{"role": "user", "content": "Hello!"}]}'

The OpenAI and Anthropic client libraries already retry some errors with backoff, and they retry every 429, but never a 402. Check their retry setting before you add a second layer on top.

Async jobs: do not submit twice

Video and music requests create a job and answer 202. There is no idempotency key, so every accepted submit creates a new job, and a job that succeeds is billed. After an error response no billable job was started, so retrying that submit is safe (a failed, uncharged record may appear in GET /v1/jobs). The risky case is a lost connection or timeout after you sent the request, because you cannot tell whether it was accepted.

  • Before you resubmit after a lost response, call GET /v1/jobs and look for a recent job with the same model and prompt.
  • Keep the job id from the 202 response and poll or stream that job. Do not submit again just because a job is slow.
  • A job that ends as failed is not charged, so submitting a replacement is safe.
  • Retry the status call (GET /v1/jobs/{id}) freely, with the same backoff.

Responses: continuing a response that wasn't stored (store: false, or an id issued before eWest kept conversations) is a 400 with code previous_response_not_stored; send the full conversation in input. An unknown or deleted response id is a 404 with code not_found.