# 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](/docs/recipes): 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. ```text System prompt You are a patient chess coach. Your student is rated about 1200 and is playing White. Answer their question in at most four sentences, in plain words. Never just give them the best move: explain the idea behind it, then show one or two moves they could play. When the student's idea is a mistake, show the opponent's best reply and why it hurts. Judge positions in words, such as "White is better", never in numbers. ``` ```bash curl 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?" }] }' ``` ```python Python import os import requests COACH = """You are a patient chess coach. Your student is rated about 1200 and is playing White. Answer their question in at most four sentences, in plain words. Never just give them the best move: explain the idea behind it, then show one or two moves they could play. When the student's idea is a mistake, show the opponent's best reply and why it hurts. Judge positions in words, such as "White is better", never in numbers.""" r = requests.post( "https://api.chessdrive.io/v1/generate", headers={"Authorization": f"Bearer {os.environ['CHESSDRIVE_API_KEY']}"}, json={ "model": "knight-1", "system": COACH, "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?"}], }, ) r.raise_for_status() reply = r.json() print(reply["content"]) for line in reply["lines"]: print(line["id"], " ".join(m["san"] for m in line["moves"])) ``` ```js JavaScript const COACH = `You are a patient chess coach. Your student is rated about 1200 and is playing White. Answer their question in at most four sentences, in plain words. Never just give them the best move: explain the idea behind it, then show one or two moves they could play. When the student's idea is a mistake, show the opponent's best reply and why it hurts. Judge positions in words, such as "White is better", never in numbers.`; const res = await fetch("https://api.chessdrive.io/v1/generate", { method: "POST", headers: { Authorization: `Bearer ${process.env.CHESSDRIVE_API_KEY}`, "Content-Type": "application/json", }, body: JSON.stringify({ model: "knight-1", system: COACH, 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?" }], }), }); if (!res.ok) throw new Error(await res.text()); const reply = await res.json(); console.log(reply.content); for (const line of reply.lines) console.log(line.id, line.moves.map((m) => m.san).join(" ")); ``` ```json Response { "id": "req_01M4G4K7N2PX9D3WR5TB8QHC6A", "model": "knight-1", "content": "It looks like a free pawn, but it's a trap. After [Nxe5 Qg5!](line:L1) Black attacks your knight and the g2 pawn at once, and if you take on f7 as well, Black wins with a quick mate. Black's knight on d4 is strong but not yet a threat, so you can simply trade it with [Nxd4 exd4](line:L2) or [castle](line:L3) and keep developing. White is a little better either way.", "lines": [ { "id": "L1", "from_fen": "r1bqkbnr/pppp1ppp/8/4p3/2BnP3/5N2/PPPP1PPP/RNBQK2R w KQkq - 4 4", "moves": [ { "san": "Nxe5", "uci": "f3e5", "fen": "r1bqkbnr/pppp1ppp/8/4N3/2BnP3/8/PPPP1PPP/RNBQK2R b KQkq - 0 4" }, { "san": "Qg5", "uci": "d8g5", "fen": "r1b1kbnr/pppp1ppp/8/4N1q1/2BnP3/8/PPPP1PPP/RNBQK2R w KQkq - 1 5" }, { "san": "Nxf7", "uci": "e5f7", "fen": "r1b1kbnr/pppp1Npp/8/6q1/2BnP3/8/PPPP1PPP/RNBQK2R b KQkq - 0 5" }, { "san": "Qxg2", "uci": "g5g2", "fen": "r1b1kbnr/pppp1Npp/8/8/2BnP3/8/PPPP1PqP/RNBQK2R w KQkq - 0 6" }, { "san": "Rf1", "uci": "h1f1", "fen": "r1b1kbnr/pppp1Npp/8/8/2BnP3/8/PPPP1PqP/RNBQKR2 b Qkq - 1 6" }, { "san": "Qxe4+", "uci": "g2e4", "fen": "r1b1kbnr/pppp1Npp/8/8/2Bnq3/8/PPPP1P1P/RNBQKR2 w Qkq - 0 7" }, { "san": "Be2", "uci": "c4e2", "fen": "r1b1kbnr/pppp1Npp/8/8/3nq3/8/PPPPBP1P/RNBQKR2 b Qkq - 1 7" }, { "san": "Nf3#", "uci": "d4f3", "fen": "r1b1kbnr/pppp1Npp/8/8/4q3/5n2/PPPPBP1P/RNBQKR2 w Qkq - 2 8" } ] }, { "id": "L2", "from_fen": "r1bqkbnr/pppp1ppp/8/4p3/2BnP3/5N2/PPPP1PPP/RNBQK2R w KQkq - 4 4", "moves": [ { "san": "Nxd4", "uci": "f3d4", "fen": "r1bqkbnr/pppp1ppp/8/4p3/2BNP3/8/PPPP1PPP/RNBQK2R b KQkq - 0 4" }, { "san": "exd4", "uci": "e5d4", "fen": "r1bqkbnr/pppp1ppp/8/8/2BpP3/8/PPPP1PPP/RNBQK2R w KQkq - 0 5" } ] }, { "id": "L3", "from_fen": "r1bqkbnr/pppp1ppp/8/4p3/2BnP3/5N2/PPPP1PPP/RNBQK2R w KQkq - 4 4", "moves": [ { "san": "O-O", "uci": "e1g1", "fen": "r1bqkbnr/pppp1ppp/8/4p3/2BnP3/5N2/PPPP1PPP/RNBQ1RK1 b kq - 5 4" } ] } ], "finish_reason": "end", "usage": { "input_tokens": 1520, "output_tokens": 156, "cached_tokens": 0, "grounding_tokens": 1190, "reasoning_tokens": 0 }, "cost_usd": "0.001725" } ```