Skip to content
Mastering Claude

Home / The Claude API for builders

The Claude API for builders7 minApplication

Roles that hold, not a prefill that breaks

Prefilling the assistant turn, a practice that used to start Claude's response in its place, is now rejected with a 400 error on current models; a stable system instruction or a constrained output replace it.

Completing the start of Claude's response yourself, a practice called assistant turn prefilling, no longer works on current models. Technically, this practice added a final message of assistant role to the messages array, an unfinished partial content, expecting Claude to continue this started text. The server now returns an HTTP 400 error as soon as it receives such a message, before generation even begins.

The models affected by the rejection

The rejection affects Claude Opus 5, Claude Sonnet 5, Claude Fable 5.1, Claude Fable 5, as well as the Claude Opus 4.6, Claude Opus 4.7, Claude Opus 4.8 and Claude Sonnet 4.6 generations. The official migration guide is explicit on this point: prefilling assistant messages returns a 400 error on Claude Opus 4.7 and later models, Claude Opus 5 included, and recommends using structured outputs, a system instruction, or the output_config.format field instead. The rejection happens when the request is sent, which avoids paying for a generation that would not have happened anyway.

// Old practice, rejected with a 400 error on current models
{
  "model": "claude-sonnet-5",
  "max_tokens": 200,
  "messages": [
    { "role": "user", "content": "Réponds en JSON strict." },
    { "role": "assistant", "content": "{" }
  ]
}

What replaces prefilling

A stable system instruction produces the same result without touching the messages array. It is written once, outside that array, and applies to the whole request rather than to a single turn started by hand.

// Stable system instruction, no prefilling
{
  "model": "claude-sonnet-5",
  "system": "Réponds toujours en JSON strict, sans texte autour de l'objet.",
  "max_tokens": 200,
  "messages": [
    { "role": "user", "content": "Donne le statut du service." }
  ]
}

The output_config.format field, the other documented route, directly constrains the shape of the output rather than suggesting it through a text instruction; its detail lies outside the scope of this lesson. One single exception still stands, documented separately: claiming a fallback credit for a refusal accepts an echoed assistant message, a special case of refusal handling, not a general reopening of prefilling. The messages array otherwise keeps its own rule, described in the basic request structure: each turn in it alternates its role.

Figure 1

Three ways to fix the format of a response

Technique for steering the format of the responseRejected with a 400 error on current modelsDocumented as an official replacement
Prefilling the assistant turnYesNo
Stable system instructionNoYes
output_config.format fieldNoYes
The table cross-references three techniques against two criteria checked in the migration guide: rejection with a 400 error on current models, and the status of official documented replacement.
Calibrate it yourself

A developer adds an assistant-role message containing an opening brace, following a user message, in the messages array of a request sent to Claude Sonnet 5. The server returns a 400 error code before generation begins.

Write, in one sentence, what this situation establishes, and in one sentence what it does not establish.

What to remember
  • Prefilling the assistant turn returns an HTTP 400 error as soon as the last message with assistant role contains partial content meant to steer what follows.
  • The rejection affects Claude Opus 5, Claude Sonnet 5, Claude Fable 5.1, Claude Fable 5, and the Claude Opus 4.6 to 4.8 generations as well as Claude Sonnet 4.6.
  • The official migration guide names three replacements: structured outputs, a system instruction, or the output_config.format field.
  • A system instruction is written once outside the messages array and applies to the whole request, without depending on an assistant turn started by hand.
  • One single documented exception still stands, outside the scope of this practice: claiming a fallback credit for a refusal accepts an echoed assistant message.
Do this now

Open your project's code and look for any line that adds a partial assistant-role message to the end of the messages array before sending. Move the instruction it carried into a separate system field, then re-read the result without sending it.

Check the source

Every datable claim in this lesson links here to the public text behind it. A source that does not open proves nothing.