# Pick a move Have the Model play one move at a strength and in a style you choose, for a sparring partner or a bot with a personality. A move for your app to play, from a Model told how strong to be and how to play. It is a [Recipe](/docs/recipes): copy it, then change the prompt to suit your app. **Calls:** one Generate call on Knight a move, about $0.001, and one more only when it names no legal move. ## The prompt and the request To have the Model play, ask for one move and nothing else. The prompt sets the strength and the style, which makes this the Recipe for a sparring partner, a bot with a personality or a hint at a given level. For the objectively strongest move, ask [Engine](/docs/engine) instead. **Reading `lines`:** the move is `lines[0].moves[0]`. Play its `uci` on your board and ignore `content`. If `lines` is empty, the Model named no legal move: send the same request again, and if that fails too, fall back to Engine's `best_move`, so your game never stalls. ```text System prompt You are playing a casual game of chess as White, at about 1500 strength, with an attacking style. Reply with your move only, as a single linked move, and no other words. ``` ```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 playing a casual game of chess as White, at about 1500 strength, with an attacking style.\nReply with your move only, as a single linked move, and no other words.", "position": { "pgn": "1. e4 e5 2. Bc4 Nc6 3. Qh5 Nf6", "ply": 6 }, "messages": [{ "role": "user", "content": "Your move." }] }' ``` ```python Python import os import requests PLAYER = """You are playing a casual game of chess as White, at about 1500 strength, with an attacking style. Reply with your move only, as a single linked move, and no other words.""" r = requests.post( "https://api.chessdrive.io/v1/generate", headers={"Authorization": f"Bearer {os.environ['CHESSDRIVE_API_KEY']}"}, json={ "model": "knight-1", "system": PLAYER, "position": {"pgn": "1. e4 e5 2. Bc4 Nc6 3. Qh5 Nf6", "ply": 6}, "messages": [{"role": "user", "content": "Your move."}], }, ) r.raise_for_status() lines = r.json()["lines"] if lines: move = lines[0]["moves"][0] print("play", move["uci"], f"({move['san']})") else: print("no legal move: ask again, or ask Engine") ``` ```js JavaScript const PLAYER = `You are playing a casual game of chess as White, at about 1500 strength, with an attacking style. Reply with your move only, as a single linked move, and no other words.`; 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: PLAYER, position: { pgn: "1. e4 e5 2. Bc4 Nc6 3. Qh5 Nf6", ply: 6 }, messages: [{ role: "user", content: "Your move." }], }), }); if (!res.ok) throw new Error(await res.text()); const { lines } = await res.json(); if (lines.length) { const move = lines[0].moves[0]; console.log("play", move.uci, `(${move.san})`); } else { console.log("no legal move: ask again, or ask Engine"); } ``` ```json Response { "id": "req_01M4G6W8X4CQ2N7HT3RZ9BKD5M", "model": "knight-1", "content": "[Qxf7#](line:L1)", "lines": [ { "id": "L1", "from_fen": "r1bqkb1r/pppp1ppp/2n2n2/4p2Q/2B1P3/8/PPPP1PPP/RNB1K1NR w KQkq - 4 4", "moves": [ { "san": "Qxf7#", "uci": "h5f7", "fen": "r1bqkb1r/pppp1Qpp/2n2n2/4p3/2B1P3/8/PPPP1PPP/RNB1K1NR b KQkq - 0 4" } ] } ], "finish_reason": "end", "usage": { "input_tokens": 1240, "output_tokens": 9, "cached_tokens": 0, "grounding_tokens": 1190, "reasoning_tokens": 0 }, "cost_usd": "0.000964" } ```