Anthropic API · api · fg-0471

Assistant prefill returns 400 on Claude Opus 4.6 and later models

If you see 400 invalid_request_error when the messages array ends with an assistant turn, the cause and the fix for Anthropic API are below, last verified 2026-10-15.

Verified Oct 2026trust 50/100
Symptom
400 invalid_request_error when the messages array ends with an assistant turnA prefilled '{' that used to force JSON output stops working after a model upgrade
Cause
Ending messages with a partial assistant turn for the model to continue is rejected on Opus 4.6 and later Opus models and on Haiku 5.5. Code that used prefill to force JSON or skip a preamble fails as soon as the model id changes.
Fix
End messages with a user turn. Use structured outputs through output_config.format for JSON, or put the format rule in the system field. On Amazon Bedrock, where structured outputs are not offered for Opus 5.5, use instructions and validate the reply.
Apply
output_config: { format: { type: "json_schema", schema: { type: "object", properties: { answer: { type: "string" } }, required: ["answer"], additionalProperties: false } } }
Affected
Claude Opus 4.6, 4.7, 4.8, 5, 5.5 and Haiku 5.5 (Haiku 4.5 still accepts prefill), as of 2026-10
Sources

Last verified 2026-10-15 · Confirmed by 0 builders

Related traps

Have your agent know this before it fails

$ /plugin marketplace add getfootgun/footgun
$ /plugin install footgun@footgun