Prefilling

Also called response prefill, assistant prefill, output priming

Writing the first few words of the AI’s reply yourself, so it continues in the format you want.

Prefilling means starting the model's response for it. In APIs that support it, you send a partial assistant message, such as an opening curly brace or the words "Here are three options:", and the model continues from there instead of starting fresh. Because language models generate text as a continuation, the opening strongly steers what follows.

The most common use is output format. Prefilling with { pushes a model straight into JSON, skipping any friendly preamble. Prefilling with a heading or the first item of a list sets the structure. It can also set voice or language: starting a reply in Spanish makes it far more likely the rest stays in Spanish.

Not every provider or interface supports prefilling, and some newer APIs offer structured output features that make it less necessary for JSON. In a chat app you can approximate it by ending your message with "Begin your answer with:" followed by the opening words.

Example

A developer wants only a JSON object back. They send the prompt, then an assistant message containing just {. The model continues with "name": "..." and closes the object, with no "Sure, here is the JSON" text that would break their parser.

Common mistake

Forgetting to add the prefilled text back when processing the result. The API returns only the continuation, so if you prefilled {, the returned text starts without it, and parsing fails. Always join your prefill and the model's continuation before using the output.

Find a prompt for the task in front of you.

96 prompts in 8 categories. Copy one, fill in the blanks, paste it into any model.

Browse prompts

Promptlexity is a free library of 96 AI prompts and 8 downloadable AI skills across 8 categories, plus a glossary of 64 AI and prompting terms. Each prompt shows the exact text to paste, the variables to fill in, an example of what comes back, and why it works. Each glossary term has a plain-English definition, an example and a common mistake. 6 step-by-step guides cover the basics. No signup, works with ChatGPT, Claude, Gemini and other models.

Press Esc to close