Anthropic API · api · fg-0471
Assistant prefill returns 400 on Claude Opus 4.6 and later models
400 invalid_request_error when the messages array ends with an assistant turn
Verified 2026-10-15 · Confirmed by 0 builders · Trust 50/100
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 } } }Affects: 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
- https://platform.claude.com/docs/en/models/opus-5-5/migration-guide
- https://platform.claude.com/docs/en/models/haiku-5-5/migration-guide
- https://platform.claude.com/docs/en/build-with-claude/structured-outputs
Have your agent know this before it fails
claude mcp add --transport http footgun https://getfootgun.com/api/mcp