Evaluation, Testing & Quality

Output Consistency on Current Claude Models Without Prefill

For years, the trick for forcing Claude into a format was to pre-write the start of its answer. On current models that door is closed — and the replacements are, for most purposes, stronger.

Claude 3P 101 · Updated July 2026 · Unofficial guide

"Prefilling" means starting the assistant's turn for it — sending, say, an opening { so the model has no choice but to continue in JSON. Anthropic's consistency documentation still describes the technique, but it now carries a decisive note: prefilling is not supported on Claude Fable 5, Claude Mythos 5, Claude Mythos Preview, Claude Opus 4.8, Claude Opus 4.7, Claude Opus 4.6, or Claude Sonnet 4.6 — and per the migration guide, assistant prefilling returns a 400 error on Claude Sonnet 5 as well. If your pipeline enforces formats with prefill, a model upgrade will break it loudly. Here is what the documentation says to use instead, roughly in order of enforcement strength.

1. Structured outputs — when the format must be guaranteed

Anthropic's guidance is unambiguous: "If you need Claude to always output valid JSON that conforms to a specific schema, use Structured Outputs instead of the prompt engineering techniques below." Structured outputs are an API feature, not a prompt trick — you supply a schema and the platform constrains generation to it. This is categorically better than prefill ever was: prefill nudged the model toward JSON; structured outputs guarantee schema-valid JSON.

Availability is good across the third-party platforms: structured outputs are generally available on Amazon Bedrock and Vertex AI, and in beta on Microsoft Foundry. See the structured outputs article for the request shape and strict tool use for the tool-calling variant.

2. Explicit format instructions — the everyday workhorse

For formats short of guaranteed JSON — markdown reports, XML-tagged sections, fixed templates — the first documented technique is to precisely specify the desired output format in the prompt, and the migration guide's recommended prefill replacement is exactly this: structured outputs where supported, or system-prompt format instructions. "Precisely" is the operative word: name the format, show the skeleton, and state what must not appear (preamble, commentary, code fences). Vague format asks produce drifting outputs; a literal template rarely does. Current Claude generations are notably literal about instruction-following, which works in your favor here.

3. Few-shot examples — training by demonstration

The same page recommends constraining outputs with examples, noting "This trains Claude's understanding better than abstract instructions." Two or three input/output pairs demonstrating your exact format — including one awkward case, such as an input with missing fields — anchor the format more firmly than a paragraph of rules. Examples cost input tokens on every call, but prompt caching largely neutralizes that on repeated calls (see prompt cache mechanics).

4. Prompt chaining — consistency through decomposition

For complex tasks, the docs recommend chaining prompts: break the task into subtasks so that "Each subtask gets Claude's full attention, reducing inconsistency errors." A generate-then-format chain is a common pattern — one call solves the problem in free text, a second call (often on a cheaper model such as Haiku 4.5) converts it into the target format, ideally with structured outputs on the second step. Two further documented supports: retrieval, to ground responses in a fixed information set, and — for character or persona consistency in chat — a system-prompt role plus "a list of common scenarios and expected responses," which the docs describe as training Claude to handle diverse situations without breaking character.

TechniqueGuarantee levelBest for
Structured outputsSchema-valid, enforced by the APIJSON for machines to parse
Format instructionsStrong adherence, not enforcedHuman-readable formats
Few-shot examplesStrong adherence, not enforcedNuanced or fiddly formats
Prompt chainingDepends on final stepComplex multi-part tasks
Verify, don't trust: whichever technique you use, put a format check in your eval suite — a code-based grader that parses the output is cheap and catches drift the moment a prompt or model changes. See code-based grading.

Where to go next

For the full list of models that reject prefill and the migration story, read prefill deprecation. For format-control prompt patterns in depth, see output format control.

Sources