Loading
Live demos

Error: «This model does not support assistant message prefill»

This model does not support assistant message prefill. The conversation must end with a user message.

This 400 shows up when moving from Claude Sonnet 4.5 (or Haiku 4.5) to claude-sonnet-5-5: your code ends the conversation on an assistant message to «push» the reply’s format, and the new models no longer accept it. The conversation has to end on a user message.

Checked on

Example: the card of the model in the error

claude-sonnet-4-5 Anthropic

Shutdown date: 30 November 2026

Official replacement: claude-sonnet-5-5

What changes in your code

  • Change model to claude-sonnet-5-5 (or the replacement in the table).
  • Sonnet 5.5 thinks by default when you send no thinking. To answer without thinking first, as Sonnet 4.5 did, send thinking: {"type": "between_tools"} at low, medium or high effort. {"type": "disabled"} returns a 400.
  • Set output_config.effort explicitly, and raise max_tokens if thinking is on: it counts.
  • temperature, top_p and top_k set to a non-default value return a 400: remove them.
  • Prefill (ending the conversation on an assistant message) returns a 400: use structured outputs or describe the format in the prompt.
  • Read the reply by block type (type == "text"), not by position: a thinking block can come first.

Example code

Python
import anthropic
client = anthropic.Anthropic()  # reads ANTHROPIC_API_KEY from the environment

msg = client.messages.create(
    model="claude-sonnet-5-5",                       # was: "claude-sonnet-4-5"
    max_tokens=4096,
    thinking={"type": "between_tools"},  # no up-front thinking, as before
    output_config={"effort": "medium"},
    # no temperature, top_p or top_k: they return a 400
    messages=[{"role": "user", "content": "Hello"}],
)
text = "".join(b.text for b in msg.content if b.type == "text")
Node.js
import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic(); // reads ANTHROPIC_API_KEY from the environment

const msg = await client.messages.create({
  model: "claude-sonnet-5-5",                       // was: "claude-sonnet-4-5"
  max_tokens: 4096,
  thinking: { type: "between_tools" },  // no up-front thinking, as before
  output_config: { effort: "medium" },
  // no temperature, top_p or top_k: they return a 400
  messages: [{ role: "user", content: "Hello" }],
});
const text = msg.content.filter((b) => b.type === "text").map((b) => b.text).join("");

Sources: Anthropic · Model deprecations · Claude Sonnet 5.5 migration guide

More on this change →

We’ll email you before your model is switched off

One email 30 days before and another 7 days before the official date, with the replacement and what changes in the code. Free, no account, no marketing.

Which models does your app use?
More models (43)

Using more than one model? Paste your code into the free checker.

Open the checker

Got a whole repository? Check it at once from the terminal, with nothing to install:

npx -y github:ericc2005t/ai-model-sunset

The code, on GitHub →

Questions

How do I get the format I wanted, then?
If the prefill was to get JSON or a fixed format, use structured outputs (or a tool with fixed fields). If it set the tone or how the reply starts, describe it in the prompt.
Are there more errors like this when migrating?
Yes: non-default temperature, top_p or top_k, thinking: {"type": "disabled"}, thinking budgets (budget_tokens) and forcing a specific tool also return a 400 on Sonnet 5.5.

Rather I fix it for you? Model swap, €79; full migration, €290–490. I reply within 24 h with a fixed price.

Ask for the fix: I reply within 24 h

No calls and nothing to pay here. Tell me what your app runs on and what breaks: I reply in writing within 24 h with a fixed price and a timeline.

What you need