# Rate limits

Page: https://galatea.co/api/docs/rate-limits

Limits apply per key and per organization, over the last minute. Headers say how much is left and how long until more is.

A request over a limit gets the status 429 and the code rate_limit_exceeded. The response carries Retry-After, in whole seconds, and the headers below, which give the ceiling, what is left and how long the wait is.

The error body names the ceiling that was hit, so you can tell what to change without guessing: requests per minute (a key's own, or the organization's), tokens per minute, or requests in flight. The last of those is the concurrency cap and answers with the code concurrency_limit_exceeded, because the organization has as many answers being generated as it may have at once. Every ceiling is per organization and an administrator can raise it, so a limit that is too tight for a real workload is worth reporting rather than working around.

- Retry-After: wait this many whole seconds before the next request. It is measured, not guessed: it is the moment the ceiling that refused admits another request, and it is the same number as that ceiling's reset header. A caller that waits it gets in.
- x-ratelimit-limit-requests and x-ratelimit-limit-tokens: the request and token ceilings that applied to this request.
- x-ratelimit-remaining-requests and x-ratelimit-remaining-tokens: what is left in each over the last minute.
- x-ratelimit-reset-requests and x-ratelimit-reset-tokens: how long until that ceiling admits another request, as a duration such as 1s or 1m1s, rounded up to the next whole second. It is 0s while the ceiling has room, and it is a duration, not a timestamp.
- x-ratelimit-limit-concurrent, x-ratelimit-remaining-concurrent and x-ratelimit-reset-concurrent: the requests in flight cap, the slots still free, and how long until one frees.
- When the router applied a limit of its own, a 402, 429 or 503 may carry X-RateLimit-Limit, X-RateLimit-Remaining and X-RateLimit-Reset instead. There the reset is a unix timestamp in seconds, when known.

A ceiling is a window, not a refill. A limit of 60 requests a minute means at most 60 requests in any minute, a parallel burst included, so a client that sends 60 at once is refused the 61st rather than being allowed the burst and the next minute's refill on top of it.

## When the platform turns its limits off

The platform has one switch that turns its rate limits off for every organization at once. While it is off, no request is refused for a request rate, a token rate or a request in flight, and a response carries no x-ratelimit-* headers at all, because there is no ceiling to report a headroom against. An abuse hold, a suspended account, a credit balance and a key's own credit cap are separate decisions and still apply. Turning the switch back on restores every organization's own ceilings exactly as they were, so a ceiling recorded before the switch was turned off is the ceiling in force when it is turned back on.

## While an answer is streaming

A refusal before the first token is the HTTP status itself, with Retry-After and the headers above, so an SDK retries it the way it retries any 429. After the first token the status has already been sent as 200, so a limit or a failure ends the stream instead: the last event is one data frame whose JSON is the same error object, for example {"error": {"message": ..., "type": "rate_limit_error", "code": "rate_limit_exceeded"}}, and then data: [DONE]. A frame has no headers, so the wait is written into the message: it ends with Retry in N seconds.

The tokens that did arrive are billed, and the failure is recorded against the request the same way a completed answer is. Nothing is replayed: retrying means sending the request again, which is the one thing a stream cannot do for itself.

A request that finds no free replica answers 503 with the code no_capacity. Retry it after a short wait. The OpenAI SDKs retry 429 and 5xx by default, with backoff.
