Review a game
Go through a finished game move by move. Engine judges every move, then Knight explains only the mistakes and blunders.
A move-by-move review of a finished game, with the worst moves explained in words. It is a Recipe: copy it, then change the prompt to suit your app.
Calls: one Engine call for the whole game, and one Generate call on Knight per mistake or blunder, about $0.02 a game.
The review
A game review goes through a finished game move by move, finds where each side went wrong, and explains the worst moves in words. It takes two APIs: Engine judges every move in numbers, then Generate explains only the mistakes and blunders, so you pay for words where they matter.
- Engine once on the whole game. Send the PGN with no
ply, and Engine reviews every move in one call, each position todepth14 unless you set a limit. Each move comes back with its evaluation before and after, its Moveverdictand Engine's best Line from before it. - The verdict is Lichess's. Each evaluation becomes a win chance from −1, Black wins, to +1, White wins:
2 / (1 + exp(−0.00368208 × cp)) − 1, and ±1 for a mate. A move that lost 0.1 of it for the side that played it is aninaccuracy, 0.2 amistakeand 0.3 ablunder;bestis Engine's own move, and the rest aregood.win_chance_losthas the number. - Generate on Knight for the mistakes and blunders only, at the move's
ply, the position it was played from, with Engine's best Line and its evaluation in the message, so the explanation starts from the right answer.
What one game costs: a 40-move game is one Engine call of about 80 positions at depth 14, about 10 s of Engine time or $0.008 on Stockfish, plus about 5 Knight turns, about $0.01: about $0.02 a game. The Estimator has it as Engine's "Review a game". A higher depth can find deeper mistakes but costs more Engine time, and the whole game must fit a call's 60 seconds; past that, review it in parts with {pgn, ply}. If you also grade the game's accuracy, reuse these same evaluations rather than calling Engine again.
The game below falls into Légal's trap: Black's 5...Bxd1 grabs the queen and gets mated. The curl tab shows the Engine call for the game and the Knight call for that one move; the Python and JavaScript tabs review the whole game: one Engine call for its 12 moves, and 2 Knight calls for its mistake and its blunder.
Reading lines: Knight's reply links the moves it names, starting from the position before the mistake. Show Engine's best Line beside it as the move to learn.
# Engine on the whole game: every move with its verdict and Engine's best Line.
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" }
}'
# 5...Bxd1, played from ply 9, is a blunder, so Knight explains it.
curl https://api.chessdrive.io/v1/generate \
-H "Authorization: Bearer $CHESSDRIVE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "knight-1",
"system": "You review a student'\''s chess game. The move they ask about was a mistake or a blunder.\nIn at most three sentences, in plain words, say what the move allowed and why the engine'\''s best move is better.\nUse the engine'\''s Line and evaluation you are given, and show the moves you name.\nJudge positions in words, such as \"Black is losing\", never in numbers.",
"position": { "pgn": "1. e4 e5 2. Nf3 d6 3. Bc4 Bg4 4. Nc3 g6 5. Nxe5 Bxd1 6. Bxf7+ Ke7", "ply": 9 },
"messages": [{ "role": "user", "content": "I played 5...Bxd1, a blunder. The engine'\''s best Line was dxe5 Qxg4 Nc6 d3 Nf6 Qf3 Bg7 a4, evaluated +2.51. What went wrong?" }]
}'