Python 88.3%
TypeScript 7.6%
Shell 4.1%
1// Multi-turn conversation (stateless: replay the history)2// STATUS: LIVE_VERIFIED 2026-09-18 with @anthropic-ai/sdk 0.126.0.3// Run: node --env-file=.env --experimental-strip-types examples/anthropic/messages/multi_turn.ts (ANTHROPIC_API_KEY read from env by the SDK)4import Anthropic from "@anthropic-ai/sdk";5import { appendFileSync } from "node:fs";67const client = new Anthropic();8const MODEL = "claude-haiku-4-5-20251001";9const log = (path: string, status: number, note: string) =>10 appendFileSync("reports/live-requests.jsonl", JSON.stringify({ ts: new Date().toISOString().replace(/\.\d+Z$/, "Z"), provider: "anthropic", method: "POST", path, status, est_cost_usd: 0.00005, note }) + "\n");11import type { MessageParam } from "@anthropic-ai/sdk/resources/messages";12const history: MessageParam[] = [13 { role: "user", content: "Remember the code word: PLUM." },14 { role: "assistant", content: "Noted." },15 { role: "user", content: "Reply with only the code word." },16];17const msg = await client.messages.create({ model: MODEL, max_tokens: 16, messages: history });18history.push({ role: "assistant", content: msg.content });19console.log(msg.content[0]?.type === "text" ? msg.content[0].text : "", "|", msg.stop_reason);20log("/v1/messages", 200, "example multi_turn.ts");21