What is 'prefilling' Claude's response in the API?
Select an answer to reveal the explanation.
Short Explanation
You're basically starting the sentence and asking Claude to finish it. Put the opening words in the assistant turn, and Claude continues naturally from there, following the pattern you set.
Full Explanation
Response prefilling involves ending the messages array with an assistant role message that contains the beginning of the desired response. Claude then continues generating from that starting point. This technique is powerful for enforcing output formats (for example, starting with '{' to get JSON), setting tone and style, bypassing preamble, and ensuring Claude stays in character. Example: the last message has role='assistant' and content='```json\n{', and Claude continues from there. The option about pre-populating the user's input field in a web interface before they type describes UI form pre-filling, not API response prefilling. The option about a caching technique that pre-loads the model's weights for faster startup describes model loading optimization, not response prefilling. The option about automatically filling in missing parameters in an API request with default values describes API default values, not response prefilling.