Response Prefill
Priming del asistente
Escrito por Darjus Kazakevic · revisado el
Start the reply yourself, and the preamble cannot happen.
Models like to open with a preamble: "Sure! Here's the JSON you asked for:", then a markdown fence, then the object. You can ask them not to. Or you can write the start of the reply yourself. Send a partial assistant message that contains “{”, and the model continues from there. The preamble is then impossible, not just discouraged.
It is the smallest technique in this category, and it has limits. It controls only the start of the reply. Support also varies by provider and by model. Some APIs continue a partial assistant message, others ignore or reject it, and many turn it off when built-in reasoning is on. Where it is missing, use an instruction or structured output.
En esencia — Control the first characters of the reply, and preambles, code fences and format drift at the start disappear in one move.
Cuándo recurrir a él
Recurre a él cuando
- Any reply parsed by code, to remove preambles and code fences
- Forcing a block to come first, such as a reasoning tag
- Continuing a format: the next table row, the next list item
Reconsidéralo cuando
- Your provider, or its reasoning mode, does not support it
- Chat replies to a person, where a natural opening is better
- Anywhere you would be writing content, not format
The parts
- The seed
- The partial assistant message you send: “{”, “<summary>”, “| Name |” or “1.”. Keep it short: enough to fix the format, not enough to choose the content.
- The forced shape
- What the seed makes impossible. Seed “{” and there is no route to a code fence or an apology. Seed <thinking> and the model must reason before it answers.
- The limit
- It shapes the start only. The model can still close the object and add a comment. Stop sequences (strings that end generation) and the contract handle the end.
Reglas de diseño
- Seed the format, not the content
- A seed of {"intent": fixes the shape and leaves the answer open. A seed of {"intent": "refund answers for the model, and that bias does not show in the output.
- Add the seed back before parsing
- The API returns only what the model wrote after your seed. Forgetting to put it back is the classic bug: the JSON parser fails on a body with no opening brace.
- Bound the end with a stop sequence
- Seed <summary> and stop on </summary>. The seed fixes the start and the stop sequence fixes the end, so nothing extra can appear on either side.
- Check support before you rely on it
- Some APIs reject a final assistant message, and reasoning modes often disable it. Fall back to "Begin your reply with {" or to structured output: weaker, but the same idea.
Errores habituales
- Forgetting to add the seed back before parsing
- Seeding so much that the answer is really yours
- Assuming it shapes the whole reply, not only its first tokens