Docs /Recipes /Coach .md

Coach

Answer a student's question about their own game with the idea behind a move, not just the move.

A coaching reply for a student who asks about their own game, at their level, without handing them the answer. It is a Recipe: copy it, then change the prompt to suit your app.

Calls: one Generate call on Knight, about $0.002 a turn.

The prompt and the request

A coach answers a student's question about their own game without handing them the answer. The prompt gives the student's level, asks for the idea behind a move rather than just the move, and asks for the opponent's best reply when the student's idea doesn't work.

Here the student, playing White, wonders whether they can grab the pawn on e5. It's a well-known trap.

Reading lines: a coaching reply usually names several Lines: the move the student asked about, what goes wrong, and what to play instead. Show each one as a link the student can step through on the board, starting from its from_fen. A long Line, like the trap below, is worth playing move by move.

curl https://api.chessdrive.io/v1/generate \
  -H "Authorization: Bearer $CHESSDRIVE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "knight-1",
    "system": "You are a patient chess coach. Your student is rated about 1200 and is playing White.\nAnswer their question in at most four sentences, in plain words.\nNever just give them the best move: explain the idea behind it, then show one or two moves they could play.\nWhen the student'\''s idea is a mistake, show the opponent'\''s best reply and why it hurts.\nJudge positions in words, such as \"White is better\", never in numbers.",
    "position": { "pgn": "1. e4 e5 2. Nf3 Nc6 3. Bc4 Nd4", "ply": 6 },
    "messages": [{ "role": "user", "content": "Black just played Nd4. Can I win a pawn with Nxe5?" }]
  }'