One change
API usage primer for Claude
claude_api_primer
Nearest release: v2.1.236, 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.
claude_api_primer Changed · +8 / -8 lines
from line 21
### Basic request and response -<CodeGroup> +<CodeGroup exclude="shell:cURL, typescript, csharp, go, java, php, ruby"> ```bash CLI ant messages create \ --model claude-opus-5 \
from line 66
The Messages API is stateless, which means that you always send the full conversational history to the API. You can use this pattern to build up a conversation over time. Earlier conversational turns don't necessarily need to actually originate from Claude. You can use synthetic `assistant` messages. -<CodeGroup> +<CodeGroup exclude="shell:cURL, typescript, csharp, go, java, php, ruby"> ```bash CLI ant messages create <<'YAML' model: claude-opus-5
from line 105
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. </Note> -<CodeGroup> +<CodeGroup exclude="shell:cURL, typescript, csharp, go, java, php, ruby"> ```bash CLI ant messages create <<'YAML' model: claude-sonnet-4-5
from line 140
Claude can read both text and images in requests. Both `base64` and `url` source types are supported for images, along with the `image/jpeg`, `image/png`, `image/gif`, and `image/webp` media types. -<CodeGroup> +<CodeGroup exclude="shell:cURL, typescript, csharp, go, java, php, ruby"> ```bash CLI IMAGE_URL="https://platform.claude.com/docs/images/vision-example.jpg"
from line 260
When thinking is on, Claude creates `thinking` content blocks where it outputs its internal reasoning. The API response includes `thinking` content blocks, followed by `text` content blocks. -<CodeGroup> +<CodeGroup exclude="shell:cURL, typescript, csharp, go, java, php, ruby"> ```bash CLI ant messages create \ --transform content --format yaml <<'YAML'
from line 314
### Preserving thinking blocks -<CodeGroup> +<CodeGroup exclude="shell:cURL, typescript, csharp, go, java, php, ruby"> ```bash CLI # First request: capture the assistant content array (thinking + tool_use # blocks, signatures intact) as compact JSON.
from line 448
On older models that use manual extended thinking (Claude 4, 4.5, and Sonnet 4.6 models), enable interleaved thinking by adding the beta header `interleaved-thinking-2025-05-14` to your API request: -<CodeGroup> +<CodeGroup exclude="shell:cURL, typescript, csharp, go, java, php, ruby"> ```bash CLI ant beta:messages create --beta interleaved-thinking-2025-05-14 <<'YAML' model: claude-sonnet-4-6
from line 719
### Streaming with SDKs -<CodeGroup> +<CodeGroup exclude="shell:cURL, typescript, csharp, go, java, php, ruby"> ```bash CLI ant messages create --stream --format jsonl \ --model claude-opus-5 \