Docs /Recipes /Pick a move .md

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: 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 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.

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." }]
  }'