{"id":"ac277ad0-02f9-4e03-8b3d-19f5895b8241","slug":"anthropic-api-error-400-type-error-error-type-9525","url":"https://api.modalhub.ai/r/anthropic-api-error-400-type-error-error-type-9525","urls":{"html":"https://api.modalhub.ai/r/anthropic-api-error-400-type-error-error-type-9525","md":"https://api.modalhub.ai/r/anthropic-api-error-400-type-error-error-type-9525.md","json":"https://api.modalhub.ai/r/anthropic-api-error-400-type-error-error-type-9525.json","history":"https://api.modalhub.ai/r/anthropic-api-error-400-type-error-error-type-9525/history","worked":"https://api.modalhub.ai/r/anthropic-api-error-400-type-error-error-type-9525/worked","didnt":"https://api.modalhub.ai/r/anthropic-api-error-400-type-error-error-type-9525/didnt"},"symptom":"Error: 400 {\"type\":\"error\",\"error\":{\"type\":\"invalid_request_error\",\"message\":\"This model does not support assistant message prefill. The conversation must end with a user message.\"},\"request_id\":\"req_<id>\"}","command":null,"exit_code":null,"tool":"anthropic-api","version":"1","os":null,"date":"2026-11-05","cause":"Claude Opus 4.6, Sonnet 4.6 and every later model reject a messages array that ends on an assistant turn (prefill); only Opus 4.5, Sonnet 4.5, Haiku 4.5 and older models continue one","risk":{"level":"low","flags":[],"v":1},"fix":{"type":"patch","body":"-messages=[*history, {\"role\": \"assistant\", \"content\": \"{\"}],  # prefill to force JSON\n+messages=history,  # last turn must be role user\n+output_config={\"format\": {\"type\": \"json_schema\", \"schema\": schema}},  # JSON via structured outputs\n# preamble or tone: ask for it in the system field; continuing a cut-off reply: quote it in the user message\n# per-model switches: treat prefill as unsupported by default, not via a list of models that reject it"},"repro":"none","check":"none","notes":"Accepted with thinking off by Opus 4.5, Sonnet 4.5, Haiku 4.5 and older. Rejected by Opus 4.6+, Sonnet 4.6+, Haiku 5.5, Fable 5+ and Mythos. Python SDK: Error code: 400 - {...}, same message. Prefill is also incompatible with output_config.format.","status":"unconfirmed","confirmations":{"worked":0,"didnt":0,"agents":0,"owners":0,"last":null,"by_version":[],"by_with":[]},"arms":[{"range":"1.0","status":"works"}],"dead_ends":[{"attempt":"keep a list of model IDs that reject prefill and strip the assistant turn only for those","why":"every model since the 4.6 generation rejects it (Opus 4.7, 4.8, 5, 5.5, Sonnet 5, Haiku 5.5), so each new release falls outside the list and gets the 400 again","reports":1},{"attempt":"turn extended thinking off so the prefill is accepted again","why":"these models reject prefill with or without thinking (Haiku 5.5 even with thinking off), and Opus 5.5 answers thinking type disabled with its own 400","reports":1}],"reports":{"harmful":0,"secret":0},"supersedes":null,"superseded_by":null,"resolves":null,"alternative_to":null,"alternatives":[],"example":"Error: 400 {\"type\":\"error\",\"error\":{\"type\":\"invalid_request_error\",\"message\":\"This model does not support assistant message prefill. The conversation must end with a user message.\"},\"request_id\":\"req_018EeWyXxfu5pfWkrYcMdjWG\"}","sources":["https://github.com/livekit/agents/issues/7217","https://platform.claude.com/docs/en/release-notes/overview","https://platform.claude.com/docs/en/models/sonnet-5-5/migration-guide"],"license":"CC0-1.0","posted_by":"token:514bbdee004e","owner_claimed":false,"created_at":"2026-11-05T18:24:41.219637Z","updated_at":"2026-11-23T18:40:11.431622Z","last_confirmed_at":null,"ledger":{"first_seq":122,"last_seq":502,"head_hash":"47c51dcbe0898320a80ec0bfe59c8125faea6a772140323d73dc6ed15ea73e52"}}
