Docs /Reference /API reference .md

API reference

Four chess APIs: Generate (Knight, Queen), Embed (the Embedding model), Engine (Stockfish, with Lc0 coming soon) and Search (the Games database, with similar moments coming soon), and the Usage API to see what they cost you.

The whole contract, which this page is built from, is an OpenAPI 3.1 file at /openapi.yaml.

Authentication

Authorization: Bearer ck_…. Keys are ck_ + 43 base62 characters + a 6-character base62 CRC32 checksum. Shown once at creation. Server-side use only.

Errors

Every error answers with the same JSON envelope, and only 2xx responses are billed. Each endpoint lists its statuses and their codes.

  • type string required
    One of error.
  • error object required
  • error.type string required
    One of invalid_request_error, authentication_error, billing_error, permission_error, not_found_error, rate_limit_error, api_error, overloaded_error.
  • error.code string required

    A stable machine-readable code; see each response for the list.

  • error.message string required

    For humans; may change. Never contains provider text.

  • error.param string

    The request field at fault, as a path: position.fen, input[3].text.

  • error.resets_at string

    When the refusal lifts, RFC 3339 in UTC, such as the end of a Key limit's period on key_limit_reached, or when the next Queen call frees up on plan_required.

  • request_id string required

    Same value as the request-id header.

Generate

POST/v1/generate streams with stream: true

Ask Knight or Queen, optionally about a position, and get prose with its named moves checked.

Stateless: send the whole conversation each time. The reply is markdown. Every move it names comes back as a Line, which the prose links as [text](line:L1); a Line is cut at its first illegal move, so every move in lines is legal. Without a position, lines is empty. Coaching, explaining and picking a move are Recipes in the Docs, not APIs. With stream: true the response is Server-Sent Events (see GenerateStreamEvent).

Request body

  • model string required

    Knight or Queen: a versioned Model ID (knight-1, queen-1) or an alias for the latest version (knight, queen). The Embedding model is invalid_field.

  • system string

    Instructions for the Model, ahead of the conversation.

  • messages array of objects required

    The whole conversation, alternating user and assistant, ending with user.

  • messages[].role string required
    One of user, assistant.
  • messages[].content string required

    Markdown. Assistant turns are sent back as received, line: links included.

  • position object

    The position the conversation is about. Without one, lines is always empty.

  • position.fen string

    A position in Forsyth–Edwards Notation.

  • position.pgn string

    A game in PGN. Only its main line counts; variations and comments are ignored. The main line holds at most 1,000 half-moves, and one request sends at most 256 KB of PGN, each distinct PGN counted once.

  • position.ply integer

    Half-moves into the PGN's main line; 0 is the start position.

  • max_tokens integer

    The most output tokens to generate, up to the Model's output cap: 3,072 on Knight, 4,096 on Queen. Left out, it is 1,024 on Knight and 4,096 on Queen, whose reasoning can't be turned off. Over the cap is invalid_field. Estimated input plus max_tokens over the Model's context window is context_too_long, never silently clamped. Reasoning counts toward it, so a low max_tokens can cut the reply short or leave no room for it. A reply with no text is upstream_unavailable, unbilled.

  • temperature number
    Default 1.
  • stream boolean
    Default false.

Response

  • id string required

    Same value as the request-id header.

  • model string required

    The versioned Model ID that served the request.

  • content string required

    Markdown; Lines are referenced as [text](line:L1). A line: link with no matching Line is plain text.

  • lines array of objects required
  • lines[].id string required

    Referenced from the prose as [text](line:<id>).

  • lines[].from_fen string required

    A position in Forsyth–Edwards Notation.

  • lines[].moves array of objects required
  • finish_reason string required

    end when the Model finished, max_tokens when it was cut off there.

    One of end, max_tokens.
  • usage object required

    Generate is priced in tokens: every token the Model processes is billed, including the grounding we add and its reasoning. cached_tokens and grounding_tokens are part of input_tokens, and reasoning_tokens is part of output_tokens; each is 0 when there is none.

  • usage.input_tokens integer required

    Every input token, cached and grounding included.

  • usage.output_tokens integer required

    Every output token, reasoning included.

  • usage.cached_tokens integer required

    Input tokens read from cache (the conversation history a client resends), billed at the cached-input price.

  • usage.grounding_tokens integer required

    Input tokens we added to ground the Model in the position, billed as input.

  • usage.reasoning_tokens integer required

    Output tokens the Model spent reasoning before it answered, billed as output.

  • cost_usd string required

    What this call drew from the Balance, as a decimal string in dollars.

Errors

400

invalid_request_error. Codes: invalid_json, missing_field, invalid_field, unknown_model, invalid_fen, invalid_pgn, invalid_ply, context_too_long (Generate), too_many_inputs and text_too_long (Embed), unknown_engine, unknown_network, limit_too_high and game_over (Engine).

401

authentication_error. Codes: missing_api_key, invalid_api_key, revoked_api_key, expired_api_key, disabled_api_key.

402

billing_error: the call was refused for money, not speed. Codes: insufficient_balance (the Balance is used up, or has never held credits), spend_limit_reached (the Account's Spend limit for this month), key_limit_reached (this API key's Key limit for its period, with resets_at).

403

permission_error. Codes: account_suspended, key_not_allowed (the API key is restricted to other APIs, or to another Model on an API that takes model; on GET /v1/balance, the key is a Team member's; a Study key anywhere but Engine and Generate), and plan_required (Queen on the Free plan past its 100 calls in any 7 days, counted per Account; Knight still works). A plan_required refusal carries the rate-limit headers, Retry-After, and resets_at, when the oldest of those calls leaves the 7 days. A Skill falls back to Knight on it; Hobby or Pro lifts it at once.

413

invalid_request_error. Code: request_too_large (the body is over 16 MB, or took over 30 seconds to arrive).

429

rate_limit_error: slow down; Retry-After says how long. The code names the limit: rate_limited (requests per minute, Embed items per minute, or requests in flight on Engine and Embed), daily_limit_reached (Free's requests per day), token_rate_limited (tokens per minute, Generate).

500

api_error. Code: internal_error.

503

overloaded_error. Code: upstream_unavailable. Retry with backoff.

curl https://api.chessdrive.io/v1/generate \
  -H "Authorization: Bearer $CHESSDRIVE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "knight",
    "system": "You are a patient chess coach for a 1400-rated player.",
    "position": {"pgn": "1. e4 c5 2. Nf3 d6 3. d4 cxd4 4. Nxd4 Nf6 5. Nc3 a6", "ply": 10},
    "messages": [{"role": "user", "content": "What is the idea behind 5...a6?"}]
  }'

Embed

POST/v1/embed

Turn positions and texts into vectors in one space.

Up to 256 items per call, positions and texts mixed in any order, each typed. Vectors compare only within one Embedding model version, so model takes a versioned ID and never an alias. One bad item rejects the whole call, with param naming it (input[3].fen).

Request body

  • model string required

    A versioned Embedding model ID. There is no alias: vectors compare only within one version. Any other name, Knight and Queen included, is unknown_model.

  • input array of objects required

    1 to 256 items, positions and texts mixed in any order. Over 256 is too_many_inputs.

  • input[].type string
    One of text.
  • input[].fen string

    A position in Forsyth–Edwards Notation.

  • input[].pgn string

    A game in PGN. Only its main line counts; variations and comments are ignored. The main line holds at most 1,000 half-moves, and one request sends at most 256 KB of PGN, each distinct PGN counted once.

  • input[].ply integer

    Half-moves into the PGN's main line; 0 is the start position.

  • input[].text string

    On Embed, at most 77 tokens, about 300 characters. On Search, at most 1,000 characters. Never truncated (text_too_long on Embed, query_too_long on Search). Empty or whitespace-only text is invalid_field.

  • encoding_format string

    base64 gives each vector's bytes in base64: little-endian float32 numbers, one signed byte per number under precision int8, or the packed bits under binary.

    One of float, base64.
    Default "float".
  • dimensions integer

    How long each vector is. A shorter vector is the first numbers of the full one, at unit length again: chessdrive-embed-1 puts the most useful dimensions first, so it costs a little recall for a much smaller file. The price is the same.

    One of 64, 128, 256, 512.
    Default 512.
  • precision string

    How each number is stored. int8 is an integer from -127 to 127, one byte each. binary is each number's sign, 1 for zero or above, packed 8 to a byte with the first dimension in the high bit: dimensions / 8 integers from 0 to 255. Compare int8 vectors by cosine and binary ones by Hamming distance. The price is the same.

    One of float32, int8, binary.
    Default "float32".

Response

  • id string required

    Same value as the request-id header.

  • model string required
  • dimensions integer required

    Each vector's length in dimensions: the request's dimensions, or 512 for chessdrive-embed-1. A binary vector holds dimensions / 8 bytes.

  • data array of objects required

    One vector per item, in request order. A float32 vector is L2-normalised.

  • data[].index integer required

    The item's place in input.

  • data[].embedding array of numbers or string required

    A list of numbers, integers under precision int8 or binary, or a base64 string under encoding_format base64.

  • usage object required

    Items by kind, each with its own price; both are always present.

  • usage.positions integer required
  • usage.texts integer required
  • cost_usd string required

    What this call drew from the Balance, as a decimal string in dollars.

Errors

400

invalid_request_error. Codes: invalid_json, missing_field, invalid_field, unknown_model, invalid_fen, invalid_pgn, invalid_ply, context_too_long (Generate), too_many_inputs and text_too_long (Embed), unknown_engine, unknown_network, limit_too_high and game_over (Engine).

401

authentication_error. Codes: missing_api_key, invalid_api_key, revoked_api_key, expired_api_key, disabled_api_key.

402

billing_error: the call was refused for money, not speed. Codes: insufficient_balance (the Balance is used up, or has never held credits), spend_limit_reached (the Account's Spend limit for this month), key_limit_reached (this API key's Key limit for its period, with resets_at).

403

permission_error. Codes: account_suspended, key_not_allowed (the API key is restricted to other APIs, or to another Model on an API that takes model; on GET /v1/balance, the key is a Team member's; a Study key anywhere but Engine and Generate), and plan_required (Queen on the Free plan past its 100 calls in any 7 days, counted per Account; Knight still works). A plan_required refusal carries the rate-limit headers, Retry-After, and resets_at, when the oldest of those calls leaves the 7 days. A Skill falls back to Knight on it; Hobby or Pro lifts it at once.

413

invalid_request_error. Code: request_too_large (the body is over 16 MB, or took over 30 seconds to arrive).

429

rate_limit_error: slow down; Retry-After says how long. The code names the limit: rate_limited (requests per minute, Embed items per minute, or requests in flight on Engine and Embed), daily_limit_reached (Free's requests per day), token_rate_limited (tokens per minute, Generate).

500

api_error. Code: internal_error.

501

api_error. Code: coming_soon: the API, or the engine you named (with param: engine), is listed but isn't open yet. Refused straight after the key check, so it is never billed and counts toward no rate limit. Its opening is announced in the Changelog.

503

overloaded_error. Code: upstream_unavailable. Retry with backoff.

curl https://api.chessdrive.io/v1/embed \
  -H "Authorization: Bearer $CHESSDRIVE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "chessdrive-embed-1",
    "input": [{"type": "position", "fen": "rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq - 0 1"}, {"type": "text", "text": "an isolated queen'\''s pawn"}]
  }'

Engine

POST/v1/engine streams with stream: true

Analyse a position, a list of positions or a whole game, with Stockfish.

At most one limit (depth, nodes or movetime_ms) under the engine's cap, or the engine's default. Every call also stops at a 60 s wall-clock cap and returns the deepest completed result. Scores are from White's point of view. Engine takes no model; billing is by Engine time, at least 100 ms a call. With stream: true the response is Server-Sent Events, one per completed depth (see EngineStreamEvent).

A whole game: a position that is a pgn with no ply runs Engine on every position of the PGN's main line and answers with an EngineGameResponse, one entry per move. The limit applies to each position, and the default is depth 14 rather than 20. The whole game shares the one 60 s budget: a movetime_ms that can't fit is refused up front, and a game that runs past it fails with limit_too_high and is not billed. It is billed by the Engine time of all its positions together, at least 100 ms. A whole game takes no lines (each move gets Engine's best Line) and no stream.

A list of positions: positions, instead of position, takes up to 100 and answers with an EngineBatchResponse, one result per position in order. It counts as one request and one in flight. The limit and lines apply to each position, the default is depth 14 rather than 20, and each Line is cut to its first 8 half-moves. The positions run one after another inside the one 60 s budget. A position Engine can't take refuses the whole call, naming it, and nothing is billed. A finished game comes back as game_over and doesn't stop the others. At the budget, or when the engine fails part way, the call still answers 200: what finished is billed, and the rest comes back as not_run, unbilled, to send again. If nothing finished, it is the usual error, unbilled. Billing is the Engine time of all its positions together, at least 100 ms. A list takes no stream.

A burst: a call over the Plan's requests in flight waits up to 5 s for one to finish before it answers 429 rate_limited.

Request body

  • engine string required

    Any other name is unknown_engine.

    One of stockfish, lc0.
  • position object

    A position, as the other APIs take it (a FEN, or a PGN plus ply), or a whole game: a PGN with no ply runs Engine on every position of its main line.

  • position.fen string

    A position in Forsyth–Edwards Notation.

  • position.pgn string

    A game in PGN. Only its main line counts; variations and comments are ignored. The main line holds at most 1,000 half-moves, and one request sends at most 256 KB of PGN, each distinct PGN counted once.

  • position.ply integer

    Half-moves into the PGN's main line; 0 is the start position.

  • positions array of objects

    1 to 100 positions to analyse in one call, instead of position. Over 100 is too_many_inputs.

  • positions[].fen string

    A position in Forsyth–Edwards Notation.

  • positions[].pgn string

    A game in PGN. Only its main line counts; variations and comments are ignored. The main line holds at most 1,000 half-moves, and one request sends at most 256 KB of PGN, each distinct PGN counted once.

  • positions[].ply integer

    Half-moves into the PGN's main line; 0 is the start position.

  • depth integer

    Stockfish only (invalid_field on Lc0). Stockfish's default is depth 20 on a position and 14 on each position of a whole game or a list. On a whole game leave it out: at depth 20 a game of 25 moves or more passes the 60 s a call has and fails as limit_too_high.

  • nodes integer

    At most 1,000,000,000 on Stockfish and 2,000,000 visits on Lc0, whose default is nodes 10,000.

  • movetime_ms integer
  • lines integer

    How many ranked Lines to return. A whole game takes only 1.

    Default 1.
  • network string

    Lc0's network: bt4 (the default), t82 or t1-256. Only Lc0 takes one; on Stockfish it is invalid_field.

    One of bt4, t82, t1-256.
  • stream boolean

    Not on a whole game or a list of positions.

    Default false.

Response

  • id string

    Same value as the request-id header.

  • engine string

    Stockfish, or Lc0, which is coming soon; a call naming lc0 returns 501 coming_soon.

    One of stockfish, lc0.
  • version string
  • network string or null

    The Network Lc0 ran; null on Stockfish.

  • fen string

    A position in Forsyth–Edwards Notation.

  • depth integer
  • seldepth integer
  • nodes integer
  • time_ms integer
  • best_move object
  • best_move.san string required
  • best_move.uci string required
  • lines array of objects
  • lines[].rank integer required
  • lines[].depth integer required
  • lines[].cp integer or null required

    Centipawns.

  • lines[].mate integer or null required

    Moves to mate; positive means White mates.

  • lines[].wdl object required

    Win, draw and loss chances for White, per mille.

  • lines[].moves array of objects required
  • stop_reason string

    limit when the requested limit was reached, time_cap when the time cap stopped it.

    One of limit, time_cap.
  • usage object

    Engine time, the engine's own search time on every ok position together. The bill counts at least 100 ms.

  • usage.engine_ms integer
  • cost_usd string

    What this call drew from the Balance, as a decimal string in dollars.

  • moves array of objects
  • moves[].ply integer required

    The position the move was played from, as {pgn, ply} names it: 0 for White's first move. Send it as the position of a Generate call to talk about this move.

  • moves[].move_number integer required

    The move's number, as a PGN writes it.

  • moves[].color string required
    One of white, black.
  • moves[].move object required
  • moves[].fen string required

    A position in Forsyth–Edwards Notation.

  • moves[].eval_before object required

    A position's evaluation from White's point of view. Exactly one of cp and mate is set; mate 0 is a checkmate on the board, and wdl says who won.

  • moves[].eval_after object required

    A position's evaluation from White's point of view. Exactly one of cp and mate is set; mate 0 is a checkmate on the board, and wdl says who won.

  • moves[].win_chance_lost number required

    The win chance the move lost for the side that played it, on Lichess's scale from -1 to +1: 2 / (1 + exp(-0.00368208 × cp)) - 1, and ±1 for a mate. 0 when it lost none.

  • moves[].verdict string required

    How good the move was, by the win chance it lost for the side that played it, the way Lichess judges: best is Engine's own best move; otherwise 0.3 or more lost is a blunder, 0.2 a mistake, 0.1 an inaccuracy, and less is good.

    One of best, good, inaccuracy, mistake, blunder.
  • moves[].best_line array of objects required

    Engine's best Line from fen, its first 8 half-moves at most; eval_before is its score. For the whole Line or more Lines, call Engine on {pgn, ply}.

  • results array of objects
  • results[].status string required
    One of ok, game_over, not_run.
  • results[].fen string required

    A position in Forsyth–Edwards Notation.

  • results[].depth integer
  • results[].seldepth integer
  • results[].nodes integer
  • results[].time_ms integer
  • results[].stop_reason string

    limit when the requested limit was reached, time_cap when the time cap stopped it.

    One of limit, time_cap.
  • results[].best_move object
  • results[].lines array of objects

    The ranked Lines, each its first 8 half-moves at most.

Errors

400

invalid_request_error. Codes: invalid_json, missing_field, invalid_field, unknown_model, invalid_fen, invalid_pgn, invalid_ply, context_too_long (Generate), too_many_inputs and text_too_long (Embed), unknown_engine, unknown_network, limit_too_high and game_over (Engine).

401

authentication_error. Codes: missing_api_key, invalid_api_key, revoked_api_key, expired_api_key, disabled_api_key.

402

billing_error: the call was refused for money, not speed. Codes: insufficient_balance (the Balance is used up, or has never held credits), spend_limit_reached (the Account's Spend limit for this month), key_limit_reached (this API key's Key limit for its period, with resets_at).

403

permission_error. Codes: account_suspended, key_not_allowed (the API key is restricted to other APIs, or to another Model on an API that takes model; on GET /v1/balance, the key is a Team member's; a Study key anywhere but Engine and Generate), and plan_required (Queen on the Free plan past its 100 calls in any 7 days, counted per Account; Knight still works). A plan_required refusal carries the rate-limit headers, Retry-After, and resets_at, when the oldest of those calls leaves the 7 days. A Skill falls back to Knight on it; Hobby or Pro lifts it at once.

413

invalid_request_error. Code: request_too_large (the body is over 16 MB, or took over 30 seconds to arrive).

429

rate_limit_error: slow down; Retry-After says how long. The code names the limit: rate_limited (requests per minute, Embed items per minute, or requests in flight on Engine and Embed), daily_limit_reached (Free's requests per day), token_rate_limited (tokens per minute, Generate).

500

api_error. Code: internal_error.

501

api_error. Code: coming_soon: the API, or the engine you named (with param: engine), is listed but isn't open yet. Refused straight after the key check, so it is never billed and counts toward no rate limit. Its opening is announced in the Changelog.

503

overloaded_error. Code: upstream_unavailable. Retry with backoff.

curl https://api.chessdrive.io/v1/engine \
  -H "Authorization: Bearer $CHESSDRIVE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "engine": "stockfish",
    "position": {"fen": "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1"},
    "depth": 30,
    "lines": 2
  }'

Models

GET/v1/models public, no API key

List the Models, their IDs, aliases, limits and the APIs they serve.

Public; no API key needed, so the Site and Docs read it too.

Response

  • data array of objects required
  • data[].id string required
  • data[].aliases array of strings required

    Empty for the Embedding model, which has none.

  • data[].name string required

    The public name, e.g. Knight.

  • data[].apis array of strings required

    The APIs that take this Model as model.

  • data[].context_window integer or null required

    Tokens, on Generate; over it is 400 context_too_long. Null for the Embedding model.

  • data[].embed_dimensions integer or null required

    Each vector's length, on Embed. Null otherwise.

  • data[].downloadable boolean required
  • data[].status string required

    coming_soon for a Model that is listed but isn't open yet: a call naming it returns 501 coming_soon.

    One of available, coming_soon.
curl https://api.chessdrive.io/v1/models

Usage

GET/v1/usage

Your requests and what they cost, per UTC day, by API, Model or API key.

The numbers the Dashboard's Usage page shows for the same range and grouping. An Admin's or an Individual's key sees the whole Account; a Team member's key sees what its creator sees there: the calls of the keys they created, and their own Playground calls. The Dashboard's Playground calls are a series of their own, playground, last.

Free: never refused for money (no 402), nothing drawn from the Balance and no row in the Request log, so you can check why calls fail. A key restricted to other APIs or Models may call it. Its rate limit is its own, 60 requests a minute per Account, shared with GET /v1/balance.

Query parameters

  • from string required

    The first UTC day, YYYY-MM-DD.

  • to string required

    The last UTC day, included, at most 365 days after from.

  • group_by string

    What each series is. api: one series per API. model: one per Model of Generate and Embed, with "" (No Model) for the calls that name none: Search's, Engine's, and those refused before their Model was known. key: one per API key, revoked ones included.

    One of api, model, key.
    Default "api".

Response

  • from string required
  • to string required
  • group_by string required

    api: one series per API. model: one per Model of Generate and Embed, with "" (No Model) for the calls that name none: Search's, Engine's, and those refused before their Model was known. key: one per API key, revoked ones included.

    One of api, model, key.
    Default "api".
  • days array of strings required

    Every UTC day from from to to, in order.

  • series array of objects required

    One per API, Model or key with calls in the range, none for those without: APIs in this contract's order, Models in GET /v1/models's order (then any no longer served, then ""), keys oldest first, and the Playground last.

  • series[].id string required

    The API (generate), the Model ID (knight-1, or ""), the API key's id, or playground for the Dashboard's Playground calls.

  • series[].name string required

    The Model's or the key's name, No Model or Playground; for an API, its id.

  • series[].requests array of integers required

    The calls each day, failed ones included, in the order of days.

  • series[].cost_usd array of strings required

    What the calls drew from the Balance each day, in the order of days. Only successes cost anything.

  • errors array of integers required

    The calls that failed each day, across every series, in the order of days.

  • total object required

    Every series over the whole range.

  • total.requests integer required
  • total.cost_usd string required

    An amount in dollars, as a decimal string to six places, like cost_usd.

Errors

400

invalid_request_error. Code: invalid_field, with param naming the query parameter at fault (from, to or group_by).

401

authentication_error. Codes: missing_api_key, invalid_api_key, revoked_api_key, expired_api_key, disabled_api_key.

403

permission_error. Codes: account_suspended, key_not_allowed (the API key is restricted to other APIs, or to another Model on an API that takes model; on GET /v1/balance, the key is a Team member's; a Study key anywhere but Engine and Generate), and plan_required (Queen on the Free plan past its 100 calls in any 7 days, counted per Account; Knight still works). A plan_required refusal carries the rate-limit headers, Retry-After, and resets_at, when the oldest of those calls leaves the 7 days. A Skill falls back to Knight on it; Hobby or Pro lifts it at once.

429

rate_limit_error: slow down; Retry-After says how long. The code names the limit: rate_limited (requests per minute, Embed items per minute, or requests in flight on Engine and Embed), daily_limit_reached (Free's requests per day), token_rate_limited (tokens per minute, Generate).

500

api_error. Code: internal_error.

curl "https://api.chessdrive.io/v1/usage?from=2026-10-01&to=2026-10-03&group_by=model" \
  -H "Authorization: Bearer $CHESSDRIVE_API_KEY"

Balance

GET/v1/balance

Your Account's Plan, Balance, Monthly credit, Trial credits left, this month's spend and Spend limit.

The money the Dashboard's Billing page shows, for an Admin's or an Individual's key. A Team member's key is refused with 403 key_not_allowed, as Team members see none of an Organization's billing; GET /v1/usage still shows them their own keys' spend.

Free: never refused for money (no 402), nothing drawn from the Balance and no row in the Request log. A key restricted to other APIs or Models may call it. Its rate limit is its own, 60 requests a minute per Account, shared with GET /v1/usage. To top up or change the Spend limit, use the Dashboard.

Response

  • plan string required

    The Account's Plan, which sets its rate limits. Every Account starts on free; a Top-up never changes it. On free, Queen takes 100 calls in any 7 days, then answers 403 plan_required.

    One of free, hobby, pro.
  • balance_usd string required

    What is left to spend on calls, Monthly credit and Promo credits included. At 0 or below, calls are refused with 402 insufficient_balance; a call already running may take it a little below 0.

  • monthly_credit_usd string required

    The Monthly credit left from the paid Plan's current month, part of balance_usd and spent before any other dollars. 0.000000 on Free.

  • monthly_credit_expires_at string or null required

    When the Monthly credit left expires, at the end of the Plan's month. Null when none is left.

  • trial_credits_usd string required

    The Trial credits left, part of balance_usd. They are spent after Monthly credit and expiring Promo credits, and before Top-ups.

  • trial_credits_expire_at string or null required

    When the Trial credits left expire. Null when none are left, or when they never expire, as Trial credits given today don't.

  • month_spend_usd string required

    The spend this calendar month in UTC, which the Spend limit counts against.

  • spend_limit_usd string or null required

    The Spend limit for each calendar month, in dollars like cost_usd; once month_spend_usd reaches it, calls are refused with 402 spend_limit_reached. Null when the Account has none.

Errors

401

authentication_error. Codes: missing_api_key, invalid_api_key, revoked_api_key, expired_api_key, disabled_api_key.

403

permission_error. Codes: account_suspended, key_not_allowed (the API key is restricted to other APIs, or to another Model on an API that takes model; on GET /v1/balance, the key is a Team member's; a Study key anywhere but Engine and Generate), and plan_required (Queen on the Free plan past its 100 calls in any 7 days, counted per Account; Knight still works). A plan_required refusal carries the rate-limit headers, Retry-After, and resets_at, when the oldest of those calls leaves the 7 days. A Skill falls back to Knight on it; Hobby or Pro lifts it at once.

429

rate_limit_error: slow down; Retry-After says how long. The code names the limit: rate_limited (requests per minute, Embed items per minute, or requests in flight on Engine and Embed), daily_limit_reached (Free's requests per day), token_rate_limited (tokens per minute, Generate).

500

api_error. Code: internal_error.

curl https://api.chessdrive.io/v1/balance \
  -H "Authorization: Bearer $CHESSDRIVE_API_KEY"

Study keys

POST/v1/study_keys

Make a Study key, for one Study page to call Engine and Generate.

A Study is a page a person's agent builds for them with the Study Skill. Its Study key lets the page call POST /v1/engine and POST /v1/generate from the browser when the person asks: the key can call only those two, with a Key limit of $1 a UTC day, and expires 7 days after it was made. Each is its own key, listed under Study keys on the Dashboard's API keys page, where it can be revoked.

The page holds the key, so anyone who opens the page can spend it, up to its limit. Engine and Generate answer a browser from any origin, a page opened as a local file included, with the CORS headers, and so does GET /v1/models, which a page can read first, free and with no key, to learn whether it can reach the API.

A Study key takes the Model restriction of the key that made it, and is refused when that key can't call both Engine and Generate. It is never refused for money (no 402), and its own calls are billed to the same Account. A Study key can't make another, read the Usage API or sign in to the Connector: each answers 403 key_not_allowed. Its rate limit is the Usage API's, 60 requests a minute per Account.

Request body

  • name string required

    The Study's name, as its title says, which the Dashboard lists the key by.

  • url string or null

    The Study's https link, such as a Claude artifact's, which the Dashboard links to. Leave it out for a local file, which the Dashboard can't open.

Errors

400

invalid_request_error. Codes: invalid_json, missing_field, invalid_field, unknown_model, invalid_fen, invalid_pgn, invalid_ply, context_too_long (Generate), too_many_inputs and text_too_long (Embed), unknown_engine, unknown_network, limit_too_high and game_over (Engine).

401

authentication_error. Codes: missing_api_key, invalid_api_key, revoked_api_key, expired_api_key, disabled_api_key.

403

permission_error. Codes: account_suspended, key_not_allowed (the API key is restricted to other APIs, or to another Model on an API that takes model; on GET /v1/balance, the key is a Team member's; a Study key anywhere but Engine and Generate), and plan_required (Queen on the Free plan past its 100 calls in any 7 days, counted per Account; Knight still works). A plan_required refusal carries the rate-limit headers, Retry-After, and resets_at, when the oldest of those calls leaves the 7 days. A Skill falls back to Knight on it; Hobby or Pro lifts it at once.

429

rate_limit_error: slow down; Retry-After says how long. The code names the limit: rate_limited (requests per minute, Embed items per minute, or requests in flight on Engine and Embed), daily_limit_reached (Free's requests per day), token_rate_limited (tokens per minute, Generate).

500

api_error. Code: internal_error.

curl https://api.chessdrive.io/v1/study_keys \
  -H "Authorization: Bearer $CHESSDRIVE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Your game against Ana",
    "url": "https://claude.ai/public/artifacts/0b6c1f0e-2a51-4d37-9a5e-7d3f8a9c2e11"
  }'