# Engine Analyse a position with Stockfish (Lc0 is coming soon) and get its evaluation in numbers and its best Lines, ranked. Stream each depth as it completes. `POST /v1/engine` runs a chess engine on a position and returns its evaluation and its best Lines. Set `engine` to `stockfish` (`lc0` is coming soon), choose how long it searches, and ask for up to five Lines. Engine runs no Model of ours, so it judges in numbers: centipawns, mate counts and win, draw and loss chances. When you want the position explained in words, ask [Generate](/docs/generate). To judge every move of a game in one call, send it [whole](#review-a-whole-game); to check many positions, send [a list](#check-a-list-of-positions); to have Knight explain the mistakes too, follow the [Review a game](/docs/recipes/review-a-game) Recipe; to score how well each side played, [Grade a game's accuracy](/docs/recipes/game-accuracy). **Where a search runs.** Engine earns its price on deep and bulk work: a whole game, a list of positions, several games at once, or a search at `depth` 20 or more, on engines faster than most laptops. One position at a shallower depth answers just as well on your own Stockfish, at no cost: [`chessdrive engine`](/docs/cli#engine) runs it there when Stockfish is installed, and says how to install it when it isn't. A Study page runs Stockfish in the browser for the position on view. ## 1. Analyse a position `engine` and `position`, or a list as `positions`, are required. `position` is a FEN, or a PGN with a `ply`, as on every API. Set at most one limit: `depth`, `nodes` or `movetime_ms`, under the [caps below](#limits-and-caps). Without one, Stockfish searches to `depth` 20. `lines` is how many Lines you want, ranked best first: 1 by default, at most 5. Engine takes no `model`. ```bash curl curl https://api.chessdrive.io/v1/engine \ -H "Authorization: Bearer $CHESSDRIVE_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "engine": "stockfish", "position": { "fen": "r1bqk2r/1pppbppp/p1n2n2/4p3/B3P3/5N2/PPPP1PPP/RNBQ1RK1 w kq - 4 6" }, "depth": 24, "lines": 3 }' ``` ```python Python import os import requests r = requests.post( "https://api.chessdrive.io/v1/engine", headers={"Authorization": f"Bearer {os.environ['CHESSDRIVE_API_KEY']}"}, json={ "engine": "stockfish", "position": {"fen": "r1bqk2r/1pppbppp/p1n2n2/4p3/B3P3/5N2/PPPP1PPP/RNBQ1RK1 w kq - 4 6"}, "depth": 24, "lines": 3, }, ) r.raise_for_status() print(r.json()["best_move"]["san"]) ``` ```js JavaScript const res = await fetch("https://api.chessdrive.io/v1/engine", { method: "POST", headers: { Authorization: `Bearer ${process.env.CHESSDRIVE_API_KEY}`, "Content-Type": "application/json", }, body: JSON.stringify({ engine: "stockfish", position: { fen: "r1bqk2r/1pppbppp/p1n2n2/4p3/B3P3/5N2/PPPP1PPP/RNBQ1RK1 w kq - 4 6" }, depth: 24, lines: 3, }), }); if (!res.ok) throw new Error(await res.text()); console.log((await res.json()).best_move.san); ``` ## 2. Read the Lines `best_move` is the first move of the top Line. Each Line in `lines` has its `rank`, the `depth` it was searched to, and its moves as `san` and `uci`. Its score is from White's point of view, whoever is to move: - `cp` is the evaluation in centipawns: +100 is about a pawn up for White, negative favours Black. - `mate`, when the engine sees a forced mate, is the number of moves to it: positive when White mates, negative when Black does. Exactly one of `cp` and `mate` is set; the other is null. - `wdl` is White's chances of a win, a draw and a loss, per mille, so they add up to 1,000. The response also echoes the `engine`, its `version` and `network`, the `fen` it analysed, how deep and wide it searched (`depth`, `seldepth`, `nodes`) and for how long (`time_ms`). `stop_reason` is `limit` when it reached your limit and `time_cap` when the [time cap](#limits-and-caps) stopped it first. ```json Response { "id": "req_01M4G2Q9C6TE3W7N5XKB8HJF0R", "engine": "stockfish", "version": "Stockfish 19", "network": null, "fen": "r1bqk2r/1pppbppp/p1n2n2/4p3/B3P3/5N2/PPPP1PPP/RNBQ1RK1 w kq - 4 6", "depth": 24, "seldepth": 33, "nodes": 9870000, "time_ms": 1840, "stop_reason": "limit", "best_move": { "san": "Re1", "uci": "f1e1" }, "lines": [ { "rank": 1, "depth": 24, "cp": 32, "mate": null, "wdl": { "win": 98, "draw": 880, "loss": 22 }, "moves": [ { "san": "Re1", "uci": "f1e1" }, { "san": "b5", "uci": "b7b5" }, { "san": "Bb3", "uci": "a4b3" }, { "san": "d6", "uci": "d7d6" }, { "san": "c3", "uci": "c2c3" }, { "san": "O-O", "uci": "e8g8" } ] }, { "rank": 2, "depth": 24, "cp": 24, "mate": null, "wdl": { "win": 80, "draw": 893, "loss": 27 }, "moves": [ { "san": "Qe2", "uci": "d1e2" }, { "san": "b5", "uci": "b7b5" }, { "san": "Bb3", "uci": "a4b3" }, { "san": "O-O", "uci": "e8g8" } ] }, { "rank": 3, "depth": 24, "cp": 17, "mate": null, "wdl": { "win": 64, "draw": 904, "loss": 32 }, "moves": [ { "san": "d3", "uci": "d2d3" }, { "san": "b5", "uci": "b7b5" }, { "san": "Bb3", "uci": "a4b3" }, { "san": "d6", "uci": "d7d6" } ] } ], "usage": { "engine_ms": 1840 }, "cost_usd": "0.002300" } ``` ## 3. Print the evaluation To show a score the way chess players read it, turn `cp` into pawns with a sign, and `mate` into M and the count. ```python Python import os import requests r = requests.post( "https://api.chessdrive.io/v1/engine", headers={"Authorization": f"Bearer {os.environ['CHESSDRIVE_API_KEY']}"}, json={ "engine": "stockfish", "position": {"fen": "r1bqk2r/1pppbppp/p1n2n2/4p3/B3P3/5N2/PPPP1PPP/RNBQ1RK1 w kq - 4 6"}, "depth": 24, "lines": 3, }, ) r.raise_for_status() def score(line): if line["mate"] is not None: return f"{'' if line['mate'] > 0 else '-'}M{abs(line['mate'])}" return f"{line['cp'] / 100:+.2f}" for line in r.json()["lines"]: print(line["rank"], score(line), " ".join(m["san"] for m in line["moves"])) ``` ```js JavaScript const res = await fetch("https://api.chessdrive.io/v1/engine", { method: "POST", headers: { Authorization: `Bearer ${process.env.CHESSDRIVE_API_KEY}`, "Content-Type": "application/json", }, body: JSON.stringify({ engine: "stockfish", position: { fen: "r1bqk2r/1pppbppp/p1n2n2/4p3/B3P3/5N2/PPPP1PPP/RNBQ1RK1 w kq - 4 6" }, depth: 24, lines: 3, }), }); if (!res.ok) throw new Error(await res.text()); const score = (line) => line.mate !== null ? `${line.mate > 0 ? "" : "-"}M${Math.abs(line.mate)}` : `${line.cp >= 0 ? "+" : ""}${(line.cp / 100).toFixed(2)}`; for (const line of (await res.json()).lines) { console.log(line.rank, score(line), line.moves.map((m) => m.san).join(" ")); } ``` ```text Output 1 +0.32 Re1 b5 Bb3 d6 c3 O-O 2 +0.24 Qe2 b5 Bb3 O-O 3 +0.17 d3 b5 Bb3 d6 ``` ## 4. Run Lc0 Lc0 guides its search with a large neural network: it looks at far fewer positions than Stockfish and judges each one more deeply, so the two often prefer different moves. Its limit is `nodes`, counted in visits, or `movetime_ms`; it takes no `depth`. Without a limit it searches 10,000 nodes. `network` picks the Lc0 Network. It is optional, and only Lc0 takes one: | `network` | Network | |---|---| | `bt4` | BT4-it332, the default and Lc0's recommended network | | `t82` | T82, an earlier main-run network | | `t1-256` | T1-256, a small network: more nodes per second, less knowledge in each | The response echoes the `network` it ran. ```bash curl curl https://api.chessdrive.io/v1/engine \ -H "Authorization: Bearer $CHESSDRIVE_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "engine": "lc0", "network": "bt4", "position": { "fen": "r1bqk2r/1pppbppp/p1n2n2/4p3/B3P3/5N2/PPPP1PPP/RNBQ1RK1 w kq - 4 6" }, "nodes": 100000, "lines": 2 }' ``` ```python Python import os import requests r = requests.post( "https://api.chessdrive.io/v1/engine", headers={"Authorization": f"Bearer {os.environ['CHESSDRIVE_API_KEY']}"}, json={ "engine": "lc0", "network": "bt4", "position": {"fen": "r1bqk2r/1pppbppp/p1n2n2/4p3/B3P3/5N2/PPPP1PPP/RNBQ1RK1 w kq - 4 6"}, "nodes": 100000, "lines": 2, }, ) r.raise_for_status() analysis = r.json() print(analysis["version"], analysis["network"], analysis["best_move"]["san"]) ``` ```js JavaScript const res = await fetch("https://api.chessdrive.io/v1/engine", { method: "POST", headers: { Authorization: `Bearer ${process.env.CHESSDRIVE_API_KEY}`, "Content-Type": "application/json", }, body: JSON.stringify({ engine: "lc0", network: "bt4", position: { fen: "r1bqk2r/1pppbppp/p1n2n2/4p3/B3P3/5N2/PPPP1PPP/RNBQ1RK1 w kq - 4 6" }, nodes: 100000, lines: 2, }), }); if (!res.ok) throw new Error(await res.text()); const analysis = await res.json(); console.log(analysis.version, analysis.network, analysis.best_move.san); ``` ## 5. Review a whole game Send a `pgn` with no `ply` and Engine runs on every position of its main line in one call: one entry per move, in order. A game review is then one call, or one tool call in an agent app, rather than one per position. Each entry has the move (`san` and `uci`), the `ply` it was played from, which is the `position` to send Generate when you want it explained, its `fen`, `eval_before` and `eval_after` from White's point of view, the `win_chance_lost` by the side that played it, its Move `verdict` and Engine's `best_line` from before it, up to 8 half-moves. The verdict is Lichess's: the win chance `2 / (1 + exp(−0.00368208 × cp)) − 1`, ±1 for a mate, and 0.1 of it lost is an `inaccuracy`, 0.2 a `mistake` and 0.3 a `blunder`; `best` is Engine's own move and anything else is `good`. A game that ends in mate has `eval_after` `mate` 0 on its last move, and `wdl` says who won. Your limit applies to each position; without one Stockfish searches each to `depth` 14, which reviews a 40-move game in about 10 to 15 seconds. The game shares a call's 60 seconds: a `movetime_ms` its positions can't fit is refused, and a game still running at 60 seconds fails with `limit_too_high` and costs nothing. Send a lower limit, or review the game in parts with `{pgn, ply}`. For a file of games, the [CLI](/docs/cli)'s `--games` sends them as many at once as your Plan allows. It is billed by the Engine time of all its positions together. A whole game takes no `lines` and no `stream`. The game below is Légal's trap from the [Review a game](/docs/recipes/review-a-game) Recipe; the response shows two of its twelve moves. ```bash curl curl https://api.chessdrive.io/v1/engine \ -H "Authorization: Bearer $CHESSDRIVE_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "engine": "stockfish", "position": { "pgn": "1. e4 e5 2. Nf3 d6 3. Bc4 Bg4 4. Nc3 g6 5. Nxe5 Bxd1 6. Bxf7+ Ke7" } }' ``` ```python Python import os import requests r = requests.post( "https://api.chessdrive.io/v1/engine", headers={"Authorization": f"Bearer {os.environ['CHESSDRIVE_API_KEY']}"}, json={ "engine": "stockfish", "position": {"pgn": "1. e4 e5 2. Nf3 d6 3. Bc4 Bg4 4. Nc3 g6 5. Nxe5 Bxd1 6. Bxf7+ Ke7"}, }, ) r.raise_for_status() for m in r.json()["moves"]: dots = "." if m["color"] == "white" else "..." print(f"{m['move_number']}{dots}{m['move']['san']}", m["verdict"]) ``` ```js JavaScript const res = await fetch("https://api.chessdrive.io/v1/engine", { method: "POST", headers: { Authorization: `Bearer ${process.env.CHESSDRIVE_API_KEY}`, "Content-Type": "application/json", }, body: JSON.stringify({ engine: "stockfish", position: { pgn: "1. e4 e5 2. Nf3 d6 3. Bc4 Bg4 4. Nc3 g6 5. Nxe5 Bxd1 6. Bxf7+ Ke7" }, }), }); if (!res.ok) throw new Error(await res.text()); for (const m of (await res.json()).moves) { console.log(`${m.move_number}${m.color === "white" ? "." : "..."}${m.move.san}`, m.verdict); } ``` ```json Response { "id": "req_01M4G9K7R2WB8T3N5YQX0DHJ6F", "engine": "stockfish", "version": "Stockfish 19", "network": null, "moves": [ { "ply": 8, "move_number": 5, "color": "white", "move": { "san": "Nxe5", "uci": "f3e5" }, "fen": "rn1qkbnr/ppp2p1p/3p2p1/4p3/2B1P1b1/2N2N2/PPPP1PPP/R1BQK2R w KQkq - 0 5", "eval_before": { "cp": 227, "mate": null, "wdl": { "win": 994, "draw": 6, "loss": 0 } }, "eval_after": { "cp": 251, "mate": null, "wdl": { "win": 998, "draw": 2, "loss": 0 } }, "win_chance_lost": 0, "verdict": "best", "best_line": [ { "san": "Nxe5", "uci": "f3e5" }, { "san": "dxe5", "uci": "d6e5" }, { "san": "Qxg4", "uci": "d1g4" }, { "san": "Nc6", "uci": "b8c6" }, { "san": "d3", "uci": "d2d3" }, { "san": "Nf6", "uci": "g8f6" }, { "san": "Qg3", "uci": "g4g3" }, { "san": "Bg7", "uci": "f8g7" } ] }, { "ply": 9, "move_number": 5, "color": "black", "move": { "san": "Bxd1", "uci": "g4d1" }, "fen": "rn1qkbnr/ppp2p1p/3p2p1/4N3/2B1P1b1/2N5/PPPP1PPP/R1BQK2R b KQkq - 0 5", "eval_before": { "cp": 251, "mate": null, "wdl": { "win": 998, "draw": 2, "loss": 0 } }, "eval_after": { "cp": null, "mate": 2, "wdl": { "win": 1000, "draw": 0, "loss": 0 } }, "win_chance_lost": 0.568, "verdict": "blunder", "best_line": [ { "san": "dxe5", "uci": "d6e5" }, { "san": "Qxg4", "uci": "d1g4" }, { "san": "Nc6", "uci": "b8c6" }, { "san": "d3", "uci": "d2d3" }, { "san": "Nf6", "uci": "g8f6" }, { "san": "Qf3", "uci": "g4f3" }, { "san": "Bg7", "uci": "f8g7" }, { "san": "a4", "uci": "a2a4" } ] } ], "usage": { "engine_ms": 3568 }, "cost_usd": "0.004460" } ``` ## 6. Check a list of positions Send `positions` instead of `position` to analyse up to 100 positions in one call, each a FEN or a PGN with a `ply`. It is one request and one in flight, so checking a list doesn't take a burst of calls, and it's much faster and cheaper than separate calls: at `depth` 10, 100 positions take about 3 to 7 seconds and cost about $0.002. `results` holds one answer per position, in the order you sent them. Each has a `status`: | `status` | What it means | |---|---| | `ok` | Analysed, with the same fields as one position: `depth`, `best_move`, `lines` and the rest. Each Line stops at its first 8 half-moves. | | `game_over` | The position has no legal moves. It isn't analysed or billed, and doesn't stop the others. | | `not_run` | The call ended before this position. It isn't billed, so send it again. | Your limit and `lines` apply to each position; without a limit Stockfish searches each to `depth` 14. The positions run one after another inside a call's 60 seconds. A position that can't be read refuses the whole call and costs nothing, and the error's `param` names it, such as `positions[17].fen`. At 60 seconds, or if the engine fails part way, the call still answers 200: what finished is billed, and the rest comes back as `not_run`. If nothing finished, you get the usual error, and it costs nothing. It is billed by the Engine time of all its positions together. A list takes no `stream`. For more than 100, send calls of 100, up to your requests in flight at once, or use the [CLI](/docs/cli)'s `--positions`, which does that for you. ```bash curl curl https://api.chessdrive.io/v1/engine \ -H "Authorization: Bearer $CHESSDRIVE_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "engine": "stockfish", "positions": [ { "fen": "r1bqk2r/1pppbppp/p1n2n2/4p3/B3P3/5N2/PPPP1PPP/RNBQ1RK1 w kq - 4 6" }, { "pgn": "1. e4 e5 2. Nf3 d6 3. Bc4 Bg4", "ply": 6 } ], "depth": 10 }' ``` ```python Python import os import requests r = requests.post( "https://api.chessdrive.io/v1/engine", headers={"Authorization": f"Bearer {os.environ['CHESSDRIVE_API_KEY']}"}, json={ "engine": "stockfish", "positions": [ {"fen": "r1bqk2r/1pppbppp/p1n2n2/4p3/B3P3/5N2/PPPP1PPP/RNBQ1RK1 w kq - 4 6"}, {"pgn": "1. e4 e5 2. Nf3 d6 3. Bc4 Bg4", "ply": 6}, ], "depth": 10, }, ) for result in r.json()["results"]: print(result["status"], result["fen"], result.get("best_move", {}).get("san")) ``` ```js JavaScript const res = await fetch("https://api.chessdrive.io/v1/engine", { method: "POST", headers: { Authorization: `Bearer ${process.env.CHESSDRIVE_API_KEY}`, "Content-Type": "application/json", }, body: JSON.stringify({ engine: "stockfish", positions: [ { fen: "r1bqk2r/1pppbppp/p1n2n2/4p3/B3P3/5N2/PPPP1PPP/RNBQ1RK1 w kq - 4 6" }, { pgn: "1. e4 e5 2. Nf3 d6 3. Bc4 Bg4", ply: 6 }, ], depth: 10, }), }); for (const result of (await res.json()).results) { console.log(result.status, result.fen, result.best_move?.san); } ``` ```json Response { "id": "req_01J9Z6Q8F3", "engine": "stockfish", "version": "Stockfish 19", "network": null, "results": [ { "status": "ok", "fen": "r1bqk2r/1pppbppp/p1n2n2/4p3/B3P3/5N2/PPPP1PPP/RNBQ1RK1 w kq - 4 6", "depth": 10, "seldepth": 20, "nodes": 25176, "time_ms": 77, "stop_reason": "limit", "best_move": { "san": "Re1", "uci": "f1e1" }, "lines": [ { "rank": 1, "depth": 10, "cp": 44, "mate": null, "wdl": { "win": 96, "draw": 901, "loss": 3 }, "moves": [ { "san": "Re1", "uci": "f1e1" }, { "san": "b5", "uci": "b7b5" } ] } ] }, { "status": "ok", "fen": "rn1qkbnr/ppp2ppp/3p4/4p3/2B1P1b1/5N2/PPPP1PPP/RNBQK2R w KQkq - 2 4", "depth": 10, "seldepth": 11, "nodes": 12433, "time_ms": 83, "stop_reason": "limit", "best_move": { "san": "h3", "uci": "h2h3" }, "lines": [ { "rank": 1, "depth": 10, "cp": 73, "mate": null, "wdl": { "win": 258, "draw": 741, "loss": 1 }, "moves": [ { "san": "h3", "uci": "h2h3" }, { "san": "Bh5", "uci": "g4h5" } ] } ] } ], "usage": { "engine_ms": 160 }, "cost_usd": "0.000200" } ``` ## 7. Stream each depth A deep search can take seconds. With `"stream": true` the response is Server-Sent Events, so you can show the analysis improving as it runs: 1. `analysis_start`, with the request `id`, the `engine`, its `version` and `network`. 2. `depth`, once per completed depth, with the analysis so far: every field of the response except `stop_reason`, `usage` and `cost_usd`. 3. `analysis_end`, with the full response body. If something fails after the stream has started, an `error` event with the usual error body ends it, and the call is not billed. If you close the connection early, you are billed for the Engine time used until then, so a client can stop as soon as the analysis is good enough. ```bash curl curl -N https://api.chessdrive.io/v1/engine \ -H "Authorization: Bearer $CHESSDRIVE_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "engine": "stockfish", "stream": true, "position": { "fen": "r1bqk2r/1pppbppp/p1n2n2/4p3/B3P3/5N2/PPPP1PPP/RNBQ1RK1 w kq - 4 6" }, "depth": 24 }' ``` ```python Python import json import os import requests with requests.post( "https://api.chessdrive.io/v1/engine", headers={"Authorization": f"Bearer {os.environ['CHESSDRIVE_API_KEY']}"}, json={ "engine": "stockfish", "stream": True, "position": {"fen": "r1bqk2r/1pppbppp/p1n2n2/4p3/B3P3/5N2/PPPP1PPP/RNBQ1RK1 w kq - 4 6"}, "depth": 24, }, stream=True, ) as r: r.raise_for_status() event = None for raw in r.iter_lines(decode_unicode=True): if raw.startswith("event: "): event = raw[len("event: "):] elif raw.startswith("data: "): data = json.loads(raw[len("data: "):]) if event == "depth": print("depth", data["depth"], data["best_move"]["san"], data["lines"][0]["cp"]) elif event == "analysis_end": print("done:", data["stop_reason"], data["cost_usd"]) elif event == "error": raise RuntimeError(data["error"]["message"]) ``` ```js JavaScript const res = await fetch("https://api.chessdrive.io/v1/engine", { method: "POST", headers: { Authorization: `Bearer ${process.env.CHESSDRIVE_API_KEY}`, "Content-Type": "application/json", }, body: JSON.stringify({ engine: "stockfish", stream: true, position: { fen: "r1bqk2r/1pppbppp/p1n2n2/4p3/B3P3/5N2/PPPP1PPP/RNBQ1RK1 w kq - 4 6" }, depth: 24, }), }); if (!res.ok) throw new Error(await res.text()); const decoder = new TextDecoder(); let buffer = ""; let event = ""; for await (const chunk of res.body) { buffer += decoder.decode(chunk, { stream: true }); let end; while ((end = buffer.indexOf("\n")) >= 0) { const line = buffer.slice(0, end).trimEnd(); buffer = buffer.slice(end + 1); if (line.startsWith("event: ")) event = line.slice("event: ".length); if (!line.startsWith("data: ")) continue; const data = JSON.parse(line.slice("data: ".length)); if (event === "depth") console.log("depth", data.depth, data.best_move.san, data.lines[0].cp); if (event === "analysis_end") console.log("done:", data.stop_reason, data.cost_usd); if (event === "error") throw new Error(data.error.message); } } ``` ```text Events event: analysis_start data: {"id":"req_01M4G3D2H8VA5Q9R1ZTN6CKX4E","engine":"stockfish","version":"Stockfish 19","network":null} event: depth data: {"id":"req_01M4G3D2H8VA5Q9R1ZTN6CKX4E","engine":"stockfish","version":"Stockfish 19","network":null,"fen":"r1bqk2r/1pppbppp/p1n2n2/4p3/B3P3/5N2/PPPP1PPP/RNBQ1RK1 w kq - 4 6","depth":1,"seldepth":2,"nodes":42,"time_ms":1,"best_move":{"san":"Re1","uci":"f1e1"},"lines":[{"rank":1,"depth":1,"cp":41,"mate":null,"wdl":{"win":121,"draw":861,"loss":18},"moves":[{"san":"Re1","uci":"f1e1"}]}]} event: depth data: {"id":"req_01M4G3D2H8VA5Q9R1ZTN6CKX4E","engine":"stockfish","version":"Stockfish 19","network":null,"fen":"r1bqk2r/1pppbppp/p1n2n2/4p3/B3P3/5N2/PPPP1PPP/RNBQ1RK1 w kq - 4 6","depth":2,"seldepth":3,"nodes":131,"time_ms":1,"best_move":{"san":"Re1","uci":"f1e1"},"lines":[{"rank":1,"depth":2,"cp":36,"mate":null,"wdl":{"win":110,"draw":870,"loss":20},"moves":[{"san":"Re1","uci":"f1e1"},{"san":"b5","uci":"b7b5"}]}]} event: analysis_end data: {"id":"req_01M4G3D2H8VA5Q9R1ZTN6CKX4E","engine":"stockfish","version":"Stockfish 19","network":null,"fen":"r1bqk2r/1pppbppp/p1n2n2/4p3/B3P3/5N2/PPPP1PPP/RNBQ1RK1 w kq - 4 6","depth":24,"seldepth":33,"nodes":9870000,"time_ms":1840,"stop_reason":"limit","best_move":{"san":"Re1","uci":"f1e1"},"lines":[{"rank":1,"depth":24,"cp":32,"mate":null,"wdl":{"win":98,"draw":880,"loss":22},"moves":[{"san":"Re1","uci":"f1e1"},{"san":"b5","uci":"b7b5"},{"san":"Bb3","uci":"a4b3"},{"san":"d6","uci":"d7d6"}]}],"usage":{"engine_ms":1840},"cost_usd":"0.002300"} ``` ## Limits and caps Send at most one limit. Each engine has its own caps, and a value over one is a 400 `limit_too_high`, never quietly lowered. | Limit | Stockfish | Lc0 | |---|---|---| | `depth` | 1 to 50 | Not taken | | `nodes` | Up to 1,000,000,000 | Up to 2,000,000 visits | | `movetime_ms` | Up to 60,000 | Up to 60,000 | | Without a limit | `depth` 20, or 14 on each position of a whole game or a list | `nodes` 10,000 | A search runs to your limit, with no lower cap of ours. The one other limit is time: a search that hasn't reached its limit at 60 seconds stops with `stop_reason` `time_cap`, and returns the deepest analysis it completed. The default `depth` 20 ends with `stop_reason` `limit`. Each call runs Stockfish 19 with 2 threads and 256 MiB of hash to itself, whatever else is running. That searches about 1 million nodes per second in openings and middlegames, and up to about 2 million in simple endgames (measured October 2026). The default `depth` 20 takes about a second from the starting position, and a 60-second search reaches about depth 37. | Code | When | |---|---| | `unknown_engine` | An `engine` we don't run. | | `coming_soon` | `lc0`, until it opens. | | `unknown_network` | A `network` Lc0 doesn't have. | | `limit_too_high` | A limit over the engine's cap, or a whole game that doesn't fit a call's 60 seconds. | | `invalid_field` | Two limits, `depth` on Lc0, `network` on Stockfish, `lines` outside 1 to 5, or a `model`; `lines` or `stream` on a whole game; `stream` on a list; both `position` and `positions`. | | `game_over` | The side to move has no legal moves: the position is mate or stalemate. In a list, that position's `status` instead. | | `too_many_inputs` | More than 100 `positions`. | | `invalid_fen`, `invalid_pgn`, `invalid_ply` | A position that can't be read, or a whole game with no moves. | ## Engine time Engine is billed by Engine time: how long the engine searched for your call, not counting any time it waited for a free engine. `usage.engine_ms` reports it, and each engine has its own price per hour on [Pricing](/pricing). Every call is billed for at least 100 ms of Engine time, and a [list](#check-a-list-of-positions) or a whole game counts as one call. A shallow search that took 40 ms still shows `"engine_ms": 40` in `usage`, and is billed as 100 ms; `cost_usd` is always the amount actually drawn. Failed calls are free. Each search has an engine to itself. Engine limits how many of your calls run at once on each engine. A call over that limit waits up to 5 seconds for one to finish, so a short burst just takes turns, then gets a 429 `rate_limited` with `Retry-After`. Its responses report the limit in `x-ratelimit-limit-concurrent` and `x-ratelimit-remaining-concurrent`, next to the usual requests-per-minute headers; a call refused before the rate limits are checked, such as a 400, carries none of them.