Skip to main content
The gateway rate limits requests per API key. When you exceed your limit, the gateway returns 429 with a rate_limit_error. This page covers the headers you get on every response, how to read a 429, and the retry policy the official SDKs use.

How limiting works

Rate limits are enforced per API key. Each request is checked against your key’s request budget over a rolling window. When the budget is exhausted, the gateway rejects the request with status 429 until the window resets.
Limits are enforced hierarchically across your key, model, and provider, so a request can be limited at any of those tiers.

Rate limit headers

Every response includes these headers, so you can track your budget without triggering a 429.
integer
The maximum number of requests allowed in the current window.
integer
The number of requests left in the current window.
integer
The number of seconds until the window resets and your remaining count is restored.
Watch X-RateLimit-Remaining. When it approaches 0, slow your request rate so you reset cleanly instead of hitting a 429.

The 429 response

When you exceed your limit, the gateway returns status 429 with a rate_limit_error. The response adds a Retry-After header telling you how many seconds to wait before retrying.
integer
Seconds to wait before retrying. On a 429, this matches X-RateLimit-Reset.
The request_id field (and the X-Request-Id header) identify the failed request. Include it when contacting support.
Retry 429 responses with exponential backoff. The official SDKs apply this automatically. If you call the API directly, use the same policy. The gateway retries on these status codes, plus connection errors: The backoff parameters are:
number
default:"500"
The first wait, in milliseconds, before the initial retry.
number
default:"30000"
The maximum wait, in milliseconds, between retries. Backoff never grows past this.
number
default:"1.5"
The multiplier applied to the interval after each attempt.
number
default:"120000"
The total time, in milliseconds, to keep retrying before giving up.
In practice: wait 500ms, then multiply each wait by 1.5, capping any single wait at 30s, and stop retrying after 120s total. Prefer the Retry-After value from a 429 when it is present.
Do not retry 4xx responses other than 429. A 400, 401, 402, or 404 will fail the same way on retry. Fix the request instead.

Manual backoff example

Reduce rate limit errors

1

Read the headers

Check X-RateLimit-Remaining on each response and throttle before you hit 0.
2

Honor Retry-After

On a 429, wait the number of seconds in Retry-After before the next attempt.
3

Back off exponentially

Retry only 429, 500, 502, and 503, growing the delay by 1.5 each time up to 30s.
4

Spread out load

Add jitter and avoid firing large bursts of concurrent requests at the same instant.

Next steps

Errors

Every error type, status code, and response shape.

Authentication

Create and send your API key as a Bearer token.