1. In the messages array, the final entry uses the "assistant" role and contains partial text (the prefix). 2. The model treats this text as the beginning of its own reply and generates the continuation directly from it. 3. The prefix conditions the probability distribution of subsequent tokens, so the first characters (e.g. {, [Name], a heading) impose format and tone. 4. Documentation example: for a multiple-choice question you prefill "The best answer is (" and the model continues, e.g. "B)". 5. Prefill applies only to the last assistant turn; earlier assistant turns in the conversation are unaffected.
Language models often add unnecessary preambles, drift from the required output format, break the assigned role, or refuse unnecessarily — making deterministic, machine-parseable output hard to obtain. Prefill gives direct control over the start of the reply without fine-tuning.
Partial text placed in the final assistant-role message, from which the model continues generating.
Official
Tokens generated by the model immediately after the prefix, conditioned on its content.
Prefilling the last assistant turn returns a 400 error on Claude 4.6+ and Mythos Preview.
Prefill constrains part of the model's response, so a poorly chosen prefix can force an incorrect structure or content.
Prefill works only when the prefix is in the final assistant message; earlier turns do not use it.
The Claude Messages API enables continuing a response from a partial assistant-role message — the technical basis of prefill.
Anthropic documents prefill in its prompt-engineering guide as a way to control format, skip preambles, and maintain a role.
Per current Anthropic documentation, last-turn assistant prefill is unsupported on Claude 4.6+ and Mythos Preview (400 error); recommended alternatives are Structured Outputs, system-prompt instructions, and tool calling.
The exact characters seeded as the start of the reply; they determine the format and direction of the continuation.
Prefill works only when the prefix is in the final assistant-role message.
Prefill availability depends on the model — earlier Claude models support it, while Claude 4.6+ and Mythos Preview return a 400 error.
Prefill is a prompt/API-level technique, independent of the hardware running inference.