KataGo Analysis API

Send a Go position, get back win rate, score lead and the engine's best moves. Runs the KataGo CPU build.

Quickstart

Base URL: https://your-server

curl -X POST https://your-server/v1/analyze \
  -H "Authorization: Bearer $KATAGO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"moves": [["B","Q16"],["W","D4"]], "komi": 7.5, "maxVisits": 100}'

Authentication

Every call to /v1/analyze needs an API key in the Authorization header:

Authorization: Bearer kg_XXXXXXXXXXXXXXXXXXXXXXXX

Keys are issued by the server operator. Keep yours secret; if it leaks, ask the operator to revoke it and issue a new one. Requests without a valid key return 401.

Analyze a position

POST/v1/analyze

The body is a JSON object describing the game. Only moves is usually needed; everything else has a default.

FieldTypeDefaultDescription
movesarray[]Moves played so far, in order, as ["B"|"W", coord]. Coordinates are GTP style ("D4", columns A–T skipping I) or "pass".
initialStonesarray[]Stones on the board before move 1, e.g. handicap: [["B","D4"],["B","Q16"]].
initialPlayerstring—"B" or "W"; who moves first when moves is empty.
rulesstring"chinese"chinese, japanese, korean, aga, tromp-taylor, new-zealand…
kominumber7.5Komi, in half-point steps.
boardXSize, boardYSizeint19Board size, 2–19.
maxVisitsint200Search effort, 1–1000. More visits means stronger but slower (CPU: roughly 50–150 visits/sec).
analyzeTurnsint[]final positionAnalyze several points in the game at once, e.g. [0, 10, 20] (max 50). One result per turn.
includeOwnershipboolfalseAdd a per-point territory estimate (−1 white … +1 black), row-major from the top-left.
includePolicyboolfalseAdd the raw neural-net move probabilities.
avoidMoves / allowMovesarray—Restrict the search. Same format as KataGo's analysis engine.

Response

A successful call returns 200 with one entry in results per analyzed turn:

{
  "results": [
    {
      "turnNumber": 2,
      "rootInfo": {
        "currentPlayer": "B",
        "winrate": 0.374,       // for Black, 0–1
        "scoreLead": -0.94,     // points Black is ahead (negative = White leads)
        "visits": 100
      },
      "moveInfos": [
        { "move": "C3",  "winrate": 0.381, "scoreLead": -0.80, "visits": 41, "order": 0,
          "pv": ["C3", "D3", "C4"] },
        { "move": "Q4",  "winrate": 0.372, "scoreLead": -1.02, "visits": 30, "order": 1, "pv": ["..."] }
      ]
    }
  ]
}

moveInfos is sorted by order (0 = engine's top choice). pv is the expected continuation. Win rate and score are from Black's perspective (the default reportAnalysisWinratesAs = BLACK).

Errors & limits

StatusMeaning
400Invalid JSON, unsupported field, or KataGo rejected the position (e.g. illegal move). Body: {"error": "..."}
401Missing or invalid API key.
413Body larger than 64 KB.
429More than 2 requests in flight for your key. Wait for one to finish.
504Analysis took longer than 120 s. Lower maxVisits or analyze fewer turns.

This server runs on a CPU, so requests are processed a few at a time. Set your HTTP client timeout to at least 130 s.

Health check

GET/health

No key needed. Returns {"status": "ok", "maxVisits": 1000} when the engine is running, 503 otherwise.

Try it

Your key is only sent to this server and is not stored.