Rate limits
Each key may make a set number of requests a minute. Nothing else is limited: not tokens, not requests in flight at once, not any one model.
The limit
Section titled “The limit”The limit is counted in requests a minute, for each key by itself. The default is 120. The limit that applies to a key is in the headers of every answer it gets, so read it there rather than assuming it.
It works as an allowance that refills, not as a window that resets. A key that has been quiet may send up to its whole limit at once; after that the allowance comes back steadily, one request every half second at 120 a minute.
The headers
Section titled “The headers”| Header | What it says |
|---|---|
x-ratelimit-limit-requests |
The key’s limit, in requests a minute |
x-ratelimit-remaining-requests |
How many requests the key can make right now |
retry-after |
On a 429: how many seconds until a request will pass |
The two x-ratelimit headers are on answers to a valid key, errors included. They are not on a 401, and not on calls that take no key, such as the list of models. Treat the remaining figure as a guide: it is close, not exact to the request.
What counts
Section titled “What counts”- Every request made with a valid key counts: each call to a model, each look at the balance, each ask for a video’s status or file.
- A request counts even when it then fails with 400, 402 or 404: it is counted before it is read.
- Reading the list of models does not count, and neither does a request with a missing or invalid key.
Over the limit
Section titled “Over the limit”A request over the limit answers 429 and is not charged.
HTTP/1.1 429 Too Many Requestsretry-after: 1x-ratelimit-limit-requests: 120x-ratelimit-remaining-requests: 0{ "error": { "message": "Rate limit exceeded for this API key. Please slow down.", "type": "rate_limit_error", "param": null, "code": "rate_limit_exceeded" }}Wait the number of seconds in retry-after and send it again. The OpenAI and Anthropic SDKs do this by themselves, a couple of times, before they raise an error. In your own client:
import os, time, requests
def ask(body, tries=5): for _ in range(tries): r = requests.post( "https://api.exoticrouter.com/v1/chat/completions", headers={"Authorization": f"Bearer {os.environ['EXOTIC_API_KEY']}"}, json=body, ) if r.status_code != 429: return r time.sleep(int(r.headers.get("retry-after", "1"))) return rasync function ask(body: unknown, tries = 5): Promise<Response> { let r!: Response; for (let i = 0; i < tries; i++) { r = await fetch("https://api.exoticrouter.com/v1/chat/completions", { method: "POST", headers: { Authorization: `Bearer ${process.env.EXOTIC_API_KEY}`, "Content-Type": "application/json", }, body: JSON.stringify(body), }); if (r.status !== 429) return r; await new Promise((done) => setTimeout(done, Number(r.headers.get("retry-after") ?? 1) * 1000)); } return r;}Working within the limit
Section titled “Working within the limit”- Use a key for each service. Limits are per key, so one busy job does not slow another.
- Spread a batch out rather than sending it in one burst: at 120 a minute, two requests a second run without ever meeting the limit.
- Poll slowly. Asking for a video’s status every ten seconds is plenty.
Where next
Section titled “Where next”- Errors: What each status means and what to do about it.
- Billing and balance: How a request is priced.