API usage primer for Claude changedclaude_api_primer
Nearest release: v2.1.304, published under an hour after this site recorded the change. Shown because the two are within 24 hours of each other. Nothing here says the release caused the edit.
Recorded here
Lines+8added
Lines−71removed
From line
105
where the diff opens
First seen
14 Aug 2026
this site's first read of the page
Recorded edits19to this page, all time
The whole hunk
from line 105, old and new numbered
/
from line 105
105105You can prefill part of Claude's response in the last position of the input messages list. Use this technique to shape Claude's response. The following example uses `"max_tokens": 1` to get a single multiple choice answer from Claude.
106106
107107<Note>
108 Claude 4.6 and later models and Claude Mythos Preview do not support assistant message prefill; requests to those models must end with a user message. The examples below use a model that supports prefill.
108 Claude 4.6 and later models and Claude Mythos Preview do not support assistant message prefill; requests to those models must end with a user message. The following examples use a model that supports prefill.
109109</Note>
110110
111111<CodeGroup exclude="shell:cURL, typescript, csharp, go, java, php, ruby">
from line 145
145145
146146<CodeGroup exclude="shell:cURL, typescript, csharp, go, java, php, ruby">
147147 ```bash CLI
148 IMAGE_URL="https://platform.claude.com/docs/images/vision-example.jpg"
149
150148 # Option 1: Base64-encoded image (@ prefix auto-encodes binary files as base64)
151 curl -sSo vision-example.jpg "$IMAGE_URL"
149 curl -sSo vision-example.jpg https://platform.claude.com/docs/images/vision-example.jpg
152150
153151 ant messages create <<'YAML'
154152 model: claude-opus-5-5
from line 164
166164 YAML
167165
168166 # Option 2: URL-referenced image
169 ant messages create <<YAML
167 ant messages create <<'YAML'
170168 model: claude-opus-5-5
171169 max_tokens: 1024
172170 messages:
from line 173
175173 - type: image
176174 source:
177175 type: url
178 url: $IMAGE_URL
176 url: https://platform.claude.com/docs/images/vision-example.jpg
179177 - type: text
180178 text: What is in the above image?
181179 YAML
from line 270
272270
273271<CodeGroup exclude="shell:cURL, typescript, csharp, go, java, php, ruby">
274272 ```bash CLI
275 ant messages create --transform content --format yaml <<'YAML'
273 ant messages create <<'YAML'
276274 model: claude-opus-5-5
277275 max_tokens: 16000
278276 thinking:
from line 322
324322
325323### Preserving thinking blocks
326324
327<CodeGroup exclude="shell:cURL, typescript, csharp, go, java, php, ruby">
328 ```bash CLI
329 # First request: capture the assistant content array (thinking + tool_use
330 # blocks, signatures intact) as compact JSON.
331 ASSISTANT_CONTENT=$(ant messages create \
332 --transform content --format jsonl <<'YAML'
333 model: claude-opus-5-5
334 max_tokens: 16000
335 thinking:
336 type: adaptive
337 display: summarized
338 tools:
339 - name: get_weather
340 description: Get the current weather for a location.
341 input_schema:
342 type: object
343 properties:
344 location:
345 type: string
346 description: The city name.
347 required: [location]
348 messages:
349 - role: user
350 content: "What's the weather in Paris?"
351 YAML
352 )
353
354 TOOL_USE_ID=$(printf '%s' "$ASSISTANT_CONTENT" \
355 | jq -r '.[] | select(.type == "tool_use") | .id')
356
357 # Second request: pass the captured blocks back unchanged as the assistant
358 # message. The thinking block must accompany the tool_use block.
359 ant messages create <<YAML
360 model: claude-opus-5-5
361 max_tokens: 16000
362 thinking:
363 type: adaptive
364 display: summarized
365 tools:
366 - name: get_weather
367 description: Get the current weather for a location.
368 input_schema:
369 type: object
370 properties:
371 location:
372 type: string
373 description: The city name.
374 required: [location]
375 messages:
376 - role: user
377 content: "What's the weather in Paris?"
378 - role: assistant
379 content: $ASSISTANT_CONTENT
380 - role: user
381 content:
382 - type: tool_result
383 tool_use_id: $TOOL_USE_ID
384 content: "Current temperature: 72°F"
385 YAML
386 ```
387
325<CodeGroup exclude="shell:cURL, shell:CLI, typescript, csharp, go, java, php, ruby">
388326 ```python Python
389327 import anthropic
390328
from line 664
726664
727665<CodeGroup exclude="shell:cURL, typescript, csharp, go, java, php, ruby">
728666 ```bash CLI
729 ant messages create --stream --format jsonl \
667 ant messages create --stream \
730668 --model claude-opus-5-5 \
731669 --max-tokens 1024 \
732 --message '{role: user, content: "Hello"}' \
733 | jq -rj 'select(.delta.type? == "text_delta") | .delta.text'
670 --message '{role: user, content: "Hello"}'
734671 ```
735672
736673 ```python Python
No line in this hunk matches that.