# Rate limits How many calls each Model, Search and engine take on each Plan, the headers that report them, and what to do with a 429 or a 403 plan_required. Rate limits keep the API fast for everyone. They apply per Account, to all its API keys together, and each Model, Search and engine has its own: a burst of Queen calls never slows your Knight calls. Your Account's **Plan** sets its limits. Every Account starts on **Free**; **Hobby** and **Pro** are the paid Plans, and a move between Plans applies at once. Buying a Top-up doesn't change the Plan. ## The limits | Limit for | Requests per minute (Free / Hobby / Pro) | Calls capped (Free only) | Also (Free / Hobby / Pro) | |---|---|---|---| | Knight (`knight-1`) | 20 / 150 / 1,500 | 1,000 a day | 150,000 / 1,000,000 / 10,000,000 tokens per minute | | Queen (`queen-1`) | 20 / 30 / 300 | 100 in any 7 days | 160,000 / 250,000 / 2,500,000 tokens per minute | | `chessdrive-embed-1` | 60 / 150 / 1,500 | 500 a day | 9,000 / 30,000 / 100,000 items per minute, 2 / 4 / 12 requests in flight, and 256 items per call | | Search | 20 / 150 / 1,500 | 250 a day | | | Stockfish | 20 / 150 / 1,500 | 200 a day for Stockfish and Lc0 together | 6 / 6 / 18 requests in flight | | Lc0 | 5 / 30 / 300 | (shared with Stockfish) | 1 / 2 / 2 requests in flight | Hobby and Pro have no caps on calls. If you need more than the Pro limits, write to contact@edgecaselabs.dev with what you're building. The Usage API, `GET /v1/usage` and `GET /v1/balance`, has a limit of its own: 60 requests a minute per Account on every Plan, the two together, and no daily cap. It never uses up the limits above. - **Tokens per minute** (Generate) count each call's estimated input when it starts, then correct to the tokens it actually processed, input and output, when it ends. A long answer can use more than what was left, and the calls after it wait until the minute catches up. - **Items per minute** (Embed) count positions and texts, so one call of 256 items uses as much as 256 calls of one. - **Requests in flight** (Engine and Embed) count the calls still running. An analysis ends when its limit is reached or at the 60-second cap, whichever comes first, and an Embed call when its vectors come back. An Engine call over them waits up to 5 seconds for one to end before it gets a 429; an Embed call gets the 429 at once. A [list of positions](/docs/engine#check-a-list-of-positions) or a whole game is one request and one in flight. ## The headers Every call that reaches the rate-limit step reports the requests-per-minute limit for what it called, on success and on refusal alike (200, 402, 403 `plan_required`, 429 and 5xx). A call refused earlier, for a bad request (400), a key (401) or another permission (403), carries none. | Header | Meaning | |---|---| | `x-ratelimit-limit-requests` | Requests per minute allowed. | | `x-ratelimit-remaining-requests` | Requests left this minute. | | `x-ratelimit-reset-requests` | Seconds until the requests-per-minute allowance is full again. | | `x-ratelimit-limit-concurrent` | Engine and Embed only: requests allowed in flight. | | `x-ratelimit-remaining-concurrent` | Engine and Embed only: requests you may still start while yours run. | | `Retry-After` | On a 429 or a 403 `plan_required` only: seconds to wait before retrying. | The other limits, tokens and items per minute and the caps on calls, don't have headers of their own: they speak when they refuse a call, in its code. ## A 429 means wait A call over a limit is refused with `429` and a `rate_limit_error`, never billed. Its code names the limit it hit: | Code | Limit | Clears | |---|---|---| | `rate_limited` | Requests per minute, Embed's items per minute, Embed's requests in flight, or Engine's requests in flight after a 5-second wait. | Within the minute, or when one of your running analyses or Embed calls ends. | | `token_rate_limited` | Generate's tokens per minute. | Within the minute. | | `daily_limit_reached` | Free's requests per day. | At midnight UTC, or at once when the Account moves to Hobby or Pro. | Wait the `Retry-After` seconds, then send the same call again. Don't retry in a tight loop: until then, every retry is refused too. ## A 403 `plan_required` means Queen needs a paid Plan On Free, Queen takes 100 calls in any 7 days, counted per Account across all its API keys and Connections. Every call that gets past the rate limit counts, whether it then succeeds or fails; a call refused before it doesn't. The 101st is refused with `403`, a `permission_error` and the code `plan_required`, never billed. Its `resets_at` and `Retry-After` say when the oldest of those calls leaves the 7 days and frees one. Knight still works. A Skill or an agent that gets `plan_required` should go on with Knight, or tell its user that Hobby lifts the cap. Moving the Account to Hobby or Pro lifts it at once. A **402 is not a rate limit**. It means the call was refused for money: the Balance is used up, or the Spend limit or the Key limit is reached. Waiting won't clear it, except a Key limit at its reset; a top-up or a raised limit will. See [Errors](/docs/errors). ## Retry after a 429 Honour `Retry-After` and give up after a few tries. curl does this itself with `--retry`; in code, a small loop does. ```bash curl curl https://api.chessdrive.io/v1/generate \ --retry 3 \ -H "Authorization: Bearer $CHESSDRIVE_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "knight", "messages": [{ "role": "user", "content": "Name one opening for White." }] }' ``` ```python Python import os import time import requests def generate(body, tries=4): for attempt in range(tries): r = requests.post( "https://api.chessdrive.io/v1/generate", headers={"Authorization": f"Bearer {os.environ['CHESSDRIVE_API_KEY']}"}, json=body, ) if r.status_code != 429 or attempt == tries - 1: return r time.sleep(int(r.headers.get("retry-after", "1"))) r = generate({ "model": "knight", "messages": [{"role": "user", "content": "Name one opening for White."}], }) print(r.status_code, r.headers.get("x-ratelimit-remaining-requests"), r.json()) ``` ```js JavaScript async function generate(body, tries = 4) { for (let attempt = 0; ; attempt++) { const res = await fetch("https://api.chessdrive.io/v1/generate", { method: "POST", headers: { Authorization: `Bearer ${process.env.CHESSDRIVE_API_KEY}`, "Content-Type": "application/json", }, body: JSON.stringify(body), }); if (res.status !== 429 || attempt === tries - 1) return res; const wait = Number(res.headers.get("retry-after") ?? "1"); await new Promise((resolve) => setTimeout(resolve, wait * 1000)); } } const res = await generate({ model: "knight", messages: [{ role: "user", content: "Name one opening for White." }], }); console.log(res.status, res.headers.get("x-ratelimit-remaining-requests"), await res.json()); ```