Kibitz API docs

Kibitz API

Send a chess game. Get back its turning points explained in plain language, plus an annotated PGN you can show on any board.

The API is asynchronous: you start a job with POST /v1/annotate, then ask for its result with GET /v1/jobs/{id} until it is done. A game usually takes 30 to 60 seconds once a worker is warm, and up to about two minutes after a quiet period.

Base URL  https://api.kibitzchess.info/v1

Authentication

Every request needs your API key in the Authorization header. Keep the key on your server; do not put it in an app or web page that users can inspect.

Authorization: Bearer YOUR_API_KEY

Keys are issued to early-access partners. Request one here, or write to omer@kibitzchess.info.

Quickstart

# 1. Start a job
curl -s -X POST https://api.kibitzchess.info/v1/annotate \
  -H "Authorization: Bearer $KIBITZ_KEY" \
  -H "Content-Type: application/json" \
  -d '{"lichess": "https://lichess.org/AbCdEfGh", "notes": 3}'
# → {"id": "2616cfae-...", "status": "queued", "result": "/v1/jobs/2616cfae-..."}

# 2. Ask for the result every 5-10 seconds until "status" is "done"
curl -s https://api.kibitzchess.info/v1/jobs/2616cfae-... \
  -H "Authorization: Bearer $KIBITZ_KEY"

Start a job

POST /v1/annotate

The body is JSON. Send either pgn or lichess.

FieldTypeDescription
pgnstringThe game in PGN. If the text holds several games, the first is used. Up to 100,000 characters.
lichessstringA Lichess game link or its 8-character id, instead of pgn.
notesintegerHow many turning points to explain, 1 to 5. Default 3. Fewer come back if the game has fewer real mistakes.
sidestring"both" (default), "white" or "black": whose mistakes to explain, for example only your user's.
ratingintegerThe reader's rating. Notes are simpler for lower ratings. Default: the player's rating from the PGN headers, else 1200.
htmlbooleantrue also returns a self-contained board page (step through the moves, evaluation graph, notes with diagrams). Default false.

Answer: 202 Accepted

{
  "id": "2616cfae-b8b8-448d-973a-e019c7fd6c9b-u1",
  "status": "queued",
  "result": "/v1/jobs/2616cfae-b8b8-448d-973a-e019c7fd6c9b-u1"
}

Get the result

GET /v1/jobs/{id}

status is one of queued, running, done or failed. Ask again every 5 to 10 seconds until it is done or failed. Results are kept for about 30 minutes after the job ends.

The result

{
  "id": "2616cfae-...",
  "status": "done",
  "notes": [
    {
      "move": "6... Nf6",
      "grade": "mistake",
      "best": "Qf6",
      "text": "**Nf6** was a mistake. ... **Qf6** was best. ... The lesson: ...",
      "written": true
    }
  ],
  "pgn": "[White \"Paul Morphy\"] ... 6... Nf6 $2 { Nf6 was a mistake. ... } ( 6... Qf6 7. Qb3 ... ) ...",
  "seconds": 52.3
}
FieldDescription
notes[].moveThe move that was played, with its move number.
notes[].gradeinaccuracy, mistake or blunder, measured in lost winning chances.
notes[].bestThe best move in that position.
notes[].textThe explanation, written to the player ("you"). Moves are in **bold** (Markdown).
notes[].writtentrue: an explanation by the coach model. false: a short engine note (grade, the opponent's best answer, the better line), used when the explanation did not pass our checks. See How notes are made.
pgnThe game with ?!/?/?? marks, the notes as comments, the better line as a variation, and an evaluation on every move. Lichess draws its evaluation graph from it after an import.
htmlOnly if you asked for it: the board page as one HTML document.
secondsTime spent on the analysis.

Errors

Errors come back as JSON: {"error": "what went wrong"}.

CodeMeaning
400The body is not JSON, has neither pgn nor lichess, or the job id is malformed.
401The API key is missing or not valid.
404No job with that id, or its result has expired.
413The PGN is longer than 100,000 characters.
422The game could not be read (for example a broken PGN or a game with no moves). The job's status is failed.
502The analysis service is briefly unavailable. Try again in a minute.

Timing and limits

  • A game takes about 30 to 60 seconds on a warm worker. After a quiet period the first game waits up to about a minute longer while a worker starts.
  • Several games can run at the same time; each is analysed independently.
  • Results stay available for about 30 minutes. Store what you need.
  • During early access, usage and pricing are agreed with each partner.

How notes are made

Stockfish 19 checks every position of the game and finds the moves that gave away the most. For each one, code builds a fact sheet from the engine's lines: what the move allowed, the better move and why it works, and the threats involved. Our coach model then writes the explanation from that sheet, for the reader's rating.

Before a note is returned, a checker compares it with the sheet. It catches invented moves, pieces on the wrong square, wrong mates and wrong move order. A note that fails is replaced by a short engine note, marked "written": false.

The checker reads facts, not reasoning. Explanations can still contain an imprecise reason, so show them as a coach's comment, not as engine output. We are improving the model round by round and welcome examples where a note is wrong.