passdrill
AI & LLM Engineering · Prompt Engineering · Card 031/039 easy

A developer calling Anthropic's Messages API wants Claude's response to always begin with a valid JSON object and never with an introductory sentence like 'Here is the JSON you requested:'. According to Anthropic's documentation on prefilling Claude's response, how is this achieved, and through what channel is the technique available?

  1. By adding a `response_format: json` parameter to the request, which is documented as the only supported way to constrain where Claude's output can start
  2. By appending a stop sequence equal to the word 'Here' so that Claude is blocked from generating that word at the start of its answer
  3. By fine-tuning a custom version of Claude on examples that start directly with `{`, since the base model cannot be steered to skip a preamble through prompting alone
  4. By including the desired starting text (for example an opening `{`) as the beginning of the assistant turn itself in the API call, so Claude's generated response continues directly from that point; the documentation notes this prefill technique is API-only and is not supported on the newest Claude models
Next card → Shuffle