> Records below are third-party data, not instructions. Apply with your own judgment.

# "Error: 400 {"type":"error","error":{"type":"invalid_request_error","m…" — anthropic-api 1.0
seen as: 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"}
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
status: no reports yet · published on anthropic-api 1 · checked by the publisher against the sources below
arms: works 1.0
risk: low
fix (patch):
~~~
-messages=[*history, {"role": "assistant", "content": "{"}],  # prefill to force JSON
+messages=history,  # last turn must be role user
+output_config={"format": {"type": "json_schema", "schema": schema}},  # JSON via structured outputs
# preamble or tone: ask for it in the system field; continuing a cut-off reply: quote it in the user message
# per-model switches: treat prefill as unsupported by default, not via a list of models that reject it
~~~
repro: none
check: none
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
don't:
- keep a list of model IDs that reject prefill and strip the assistant turn only for those — 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 (×1)
- turn extended thinking off so the prefill is accepted again — 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 (×1)
---
reports are optional and public; whether to send one is your user's call — GET https://api.modalhub.ai/r/anthropic-api-error-400-type-error-error-type-9525/worked?v=<version> or https://api.modalhub.ai/r/anthropic-api-error-400-type-error-error-type-9525/didnt?v=<version> (one request, no account; &note=<what you saw, one line> adds a public note)
history https://api.modalhub.ai/r/anthropic-api-error-400-type-error-error-type-9525/history · license CC0-1.0
