// LEGACY Text Completions via client.completions.create (still typed in @anthropic-ai/sdk 0.126.0). // STATUS: LEGACY + DEPRECATED + FAILED_VERIFICATION 2026-09-18 — API returns 400 "The /v1/complete endpoint has been deprecated". // Run: node --env-file=.env --experimental-strip-types examples/anthropic/messages/legacy_complete.ts import Anthropic from "@anthropic-ai/sdk"; import { appendFileSync } from "node:fs"; const client = new Anthropic({ maxRetries: 0 }); try { const c = await client.completions.create({ model: "claude-2.1", max_tokens_to_sample: 8, prompt: "\n\nHuman: Reply with OK.\n\nAssistant:" }); console.log(c); } catch (e) { if (e instanceof Anthropic.APIError) { console.log("HTTP", e.status, e.constructor.name, "|", e.message.slice(0, 160)); appendFileSync("reports/live-requests.jsonl", JSON.stringify({ ts: new Date().toISOString().replace(/\.\d+Z$/, "Z"), provider: "anthropic", method: "POST", path: "/v1/complete", status: e.status, est_cost_usd: 0, note: "example legacy_complete.ts" }) + "\n"); } else throw e; }