What this read moved
51–75 of 147This capture is too large to show at once. Changes 51-75 of 147 are below, significant first; the rest are on the following screens.
build-with-claude/prompt-engineering/claude-prompting-best-practices Changed · +22 / -17 lines
from line 4
44description: Comprehensive guide to prompt engineering techniques for Claude's latest models, covering clarity, examples, XML structuring, thinking, and agentic systems.
55---
66
7This is the reference for prompt engineering with current Claude models, including Claude Fable 5.1, Claude Mythos 5.1, Claude Fable 5, Claude Mythos 5, Claude Opus 5, Claude Opus 4.8, Claude Opus 4.7, Claude Opus 4.6, Claude Sonnet 5, Claude Sonnet 4.6, and Claude Haiku 4.5. The page is organized in three parts:
7This is the reference for prompt engineering with current Claude models, including Claude Fable 5.1, Claude Mythos 5.1, Claude Fable 5, Claude Mythos 5, Claude Opus 5.5, Claude Opus 5, Claude Opus 4.8, Claude Opus 4.7, Claude Opus 4.6, Claude Sonnet 5, Claude Sonnet 4.6, and Claude Haiku 4.5. The page is organized in three parts:
88
99* **[Model-specific guidance](https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/claude-prompting-best-practices#model-specific-guidance)** first: where a single model behaves differently and what to change in your prompt.
1010* **Techniques for all current models** after that: general principles, output and formatting, tool use, thinking, and agentic systems.
from line 11
1111* **Migration considerations** last, for prompts moving from earlier generations.
1212
1313<Tip>
14 For an overview of model capabilities, see the [models overview](https://platform.claude.com/docs/en/models/overview). For Claude Fable 5.1 capabilities and API changes, see [What's new in Claude Fable 5.1](https://platform.claude.com/docs/en/models/fable-5-1/whats-new-fable-5-1). For Claude Fable 5 capabilities and API changes, see [Introducing Claude Fable 5 and Claude Mythos 5](https://platform.claude.com/docs/en/models/fable-5/introducing-claude-fable-5-and-claude-mythos-5). For details on what's new in Claude Sonnet 5, see [What's new in Claude Sonnet 5](https://platform.claude.com/docs/en/models/sonnet-5/whats-new-sonnet-5). For details on what's new in Claude Opus 5, see [What's new in Claude Opus 5](https://platform.claude.com/docs/en/models/opus-5/whats-new-opus-5). For migration guidance, see the [Migration guide](https://platform.claude.com/docs/en/about-claude/models/migration-guide).
14 For an overview of model capabilities, see the [models overview](https://platform.claude.com/docs/en/models/overview). For Claude Fable 5.1 capabilities and API changes, see [What's new in Claude Fable 5.1](https://platform.claude.com/docs/en/models/fable-5-1/whats-new-fable-5-1). For Claude Fable 5 capabilities and API changes, see [Introducing Claude Fable 5 and Claude Mythos 5](https://platform.claude.com/docs/en/models/fable-5/introducing-claude-fable-5-and-claude-mythos-5). For details on what's new in Claude Sonnet 5, see [What's new in Claude Sonnet 5](https://platform.claude.com/docs/en/models/sonnet-5/whats-new-sonnet-5). For details on what's new in Claude Opus 5, see [What's new in Claude Opus 5](https://platform.claude.com/docs/en/models/opus-5/whats-new-opus-5). For migration guidance, see the [Migration guide](https://platform.claude.com/docs/en/about-claude/models/migration-guide). For Claude Opus 5.5, see [What's new in Claude Opus 5.5](https://platform.claude.com/docs/en/models/opus-5-5/whats-new-opus-5-5).
1515</Tip>
1616
1717## Model-specific guidance
from line 23
2323| Claude Fable 5.1 and Claude Mythos 5.1 | [Prompting Claude Fable 5.1](https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/prompting-claude-fable-5-1) | Differences from Claude Fable 5: effort levels, finishing long tasks, user-facing progress updates, passing thinking blocks back unchanged, tool-call batching in agent loops, search triggering at low effort, formatting, and writing density. |
2424| Claude Fable 5 and Claude Mythos 5 | [Prompting Claude Fable 5](https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/prompting-claude-fable-5) | Differences from Claude Opus 4.8: effort levels, instruction following, long-run progress claims, memory systems, and the `reasoning_extraction` refusal category. |
2525| Claude Sonnet 5 | [Prompting Claude Sonnet 5](https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/prompting-claude-sonnet-5) | Differences from Claude Sonnet 4.6: response length, effort and thinking-depth calibration, tool use triggering, literal instruction following, and design and frontend defaults. |
26| Claude Opus 5.5 | [Prompting Claude Opus 5.5](https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/prompting-claude-opus-5-5) | Differences from Claude Opus 5: effort calibration, prompts written for thinking disabled, user-facing progress updates, safeguard false positives, and tools for complex visual inputs. |
2627| Claude Opus 5 | [Prompting Claude Opus 5](https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/prompting-claude-opus-5) | Differences from prior Opus models: response length and verbosity, user-facing progress updates, written deliverable length, task scope and over-verification, subagent control, and self-correction. |
2728| Claude Opus 4.8 | [Prompting Claude Opus 4.8](https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/prompting-claude-opus-4-8) | Response length, effort and thinking-depth calibration, tool use triggering, literal instruction following, subagent control, and design and frontend defaults. |
2829
from line 110
109110 -H "x-api-key: $ANTHROPIC_API_KEY" \
110111 -H "anthropic-version: 2023-06-01" \
111112 -d '{
112 "model": "claude-opus-5",
113 "model": "claude-opus-5-5",
113114 "max_tokens": 1024,
114115 "system": "You are a helpful coding assistant specializing in Python.",
115116 "messages": [
from line 121
120121
121122 ```bash CLI
122123 ant messages create \
123 --model claude-opus-5 \
124 --model claude-opus-5-5 \
124125 --max-tokens 1024 \
125126 --system "You are a helpful coding assistant specializing in Python." \
126127 --message '{role: user, content: "How do I sort a list of dictionaries by key?"}'
from line 131
130131 client = anthropic.Anthropic()
131132
132133 message = client.messages.create(
133 model="claude-opus-5",
134 model="claude-opus-5-5",
134135 max_tokens=1024,
135136 system="You are a helpful coding assistant specializing in Python.",
136137 messages=[
from line 146
145146 const client = new Anthropic();
146147
147148 const message = await client.messages.create({
148 model: "claude-opus-5",
149 model: "claude-opus-5-5",
149150 max_tokens: 1024,
150151 system: "You are a helpful coding assistant specializing in Python.",
151152 messages: [{ role: "user", content: "How do I sort a list of dictionaries by key?" }]
from line 160
159160
160161 var parameters = new MessageCreateParams
161162 {
162 Model = Model.ClaudeOpus5,
163 Model = Model.ClaudeOpus5_5,
163164 MaxTokens = 1024,
164165 System = "You are a helpful coding assistant specializing in Python.",
165166 Messages =
from line 177
176177 client := anthropic.NewClient()
177178
178179 message, err := client.Messages.New(context.TODO(), anthropic.MessageNewParams{
179 Model: anthropic.ModelClaudeOpus5,
180 Model: anthropic.ModelClaudeOpus5_5,
180181 MaxTokens: 1024,
181182 System: []anthropic.TextBlockParam{
182183 {Text: "You are a helpful coding assistant specializing in Python."},
from line 196
195196 AnthropicClient client = AnthropicOkHttpClient.fromEnv();
196197
197198 MessageCreateParams params = MessageCreateParams.builder()
198 .model(Model.CLAUDE_OPUS_5)
199 .model(Model.CLAUDE_OPUS_5_5)
199200 .maxTokens(1024)
200201 .system("You are a helpful coding assistant specializing in Python.")
201202 .addUserMessage("How do I sort a list of dictionaries by key?")
from line 214
213214 messages: [
214215 ['role' => 'user', 'content' => 'How do I sort a list of dictionaries by key?']
215216 ],
216 model: 'claude-opus-5',
217 model: 'claude-opus-5-5',
217218 system: 'You are a helpful coding assistant specializing in Python.',
218219 );
219220
from line 225
224225 client = Anthropic::Client.new
225226
226227 message = client.messages.create(
227 model: "claude-opus-5",
228 model: "claude-opus-5-5",
228229 max_tokens: 1024,
229230 system: "You are a helpful coding assistant specializing in Python.",
230231 messages: [
from line 306
305306If you would like Claude to identify itself correctly in your application or use specific API strings:
306307
307308```text Sample prompt for model identity wrap
308The assistant is Claude, created by Anthropic. The current model is Claude Opus 5.
309The assistant is Claude, created by Anthropic. The current model is Claude Opus 5.5.
309310```
310311
311312For LLM-powered apps that need to specify model strings:
312313
313314```text Sample prompt for model string wrap
314When an LLM is needed, please default to Claude Opus 5 unless the user requests
315otherwise. The exact model string for Claude Opus 5 is claude-opus-5.
315When an LLM is needed, please default to Claude Opus 5.5 unless the user requests
316otherwise. The exact model string for Claude Opus 5.5 is claude-opus-5-5.
316317```
317318
318319## Output and formatting
from line 543
542543
543544Claude's latest models offer thinking capabilities that can be especially helpful for tasks involving reflection after tool use or complex multistep reasoning. You can guide its initial or interleaved thinking for better results.
544545
545Claude 4.6 and later models and Claude Mythos Preview use [adaptive thinking](https://platform.claude.com/docs/en/build-with-claude/thinking) (`thinking: {type: "adaptive"}`), where Claude dynamically decides when and how much to think. On Claude Fable 5.1, Claude Mythos 5.1, Claude Fable 5, and Claude Mythos 5, thinking is always on and adaptive thinking is the only mode. Claude calibrates its thinking based on two factors: the `effort` parameter and query complexity. Higher effort elicits more thinking, and more complex queries do the same. On easier queries that don't require thinking, the model responds directly. In internal evaluations, adaptive thinking reliably drives better performance than extended thinking. Consider moving to adaptive thinking.
546Claude 4.6 and later models and Claude Mythos Preview use [adaptive thinking](https://platform.claude.com/docs/en/build-with-claude/thinking) (`thinking: {type: "adaptive"}`), where Claude dynamically decides when and how much to think. On Claude Fable 5.1, Claude Mythos 5.1, Claude Fable 5, Claude Mythos 5, and Claude Opus 5.5, thinking is always on and adaptive thinking is the only mode. Claude calibrates its thinking based on two factors: the `effort` parameter and query complexity. Higher effort elicits more thinking, and more complex queries do the same. On easier queries that don't require thinking, the model responds directly. In internal evaluations, adaptive thinking reliably drives better performance than extended thinking. Consider moving to adaptive thinking.
546547
547548Use adaptive thinking for workloads that require agentic behavior such as multistep tool use, complex coding tasks, and long-horizon agent loops. Older models use manual [extended thinking](https://platform.claude.com/docs/en/build-with-claude/extended-thinking) with `budget_tokens`; see the [per-model configuration table](https://platform.claude.com/docs/en/build-with-claude/thinking-troubleshooting#supported-models) for which configuration each model accepts.
548549
from line 772
771772 ```
772773</CodeGroup>
773774
774If you are not using extended thinking, no changes are required. On Claude Opus 4.6 through Claude Opus 4.8 and Claude Sonnet 4.6, thinking is off when you omit the `thinking` parameter. On Claude Opus 5 and Claude Sonnet 5, thinking is on by default when you omit the `thinking` parameter. On Claude Opus 5, you can disable it only at effort `high` or lower. On Claude Fable 5.1, Claude Mythos 5.1, Claude Fable 5, and Claude Mythos 5, thinking is always on, regardless of whether you set the `thinking` parameter.
775If you are not using extended thinking, no changes are required. On Claude Opus 4.6 through Claude Opus 4.8 and Claude Sonnet 4.6, thinking is off when you omit the `thinking` parameter. On Claude Opus 5 and Claude Sonnet 5, thinking is on by default when you omit the `thinking` parameter. On Claude Opus 5, you can disable it only at effort `high` or lower. On Claude Fable 5.1, Claude Mythos 5.1, Claude Fable 5, Claude Mythos 5, and Claude Opus 5.5, thinking is always on, regardless of whether you set the `thinking` parameter.
775776
776777* **Prefer general instructions over prescriptive steps.** A prompt like "think thoroughly" often produces better reasoning than a hand-written step-by-step plan. Claude's reasoning frequently exceeds what a human would prescribe.
777778* **Multishot examples work with thinking.** Use `<thinking>` tags inside your few-shot examples to show Claude the reasoning pattern. It will generalize that style to its own extended thinking blocks.
from line 1081
10801081
108110826. **Tune anti-laziness prompting:** If your prompts previously encouraged the model to be more thorough or use tools more aggressively, dial back that guidance. Claude 4.6 models are more proactive and may overtrigger on instructions that were needed for previous models.
10821083
10837. **Pass thinking blocks back unchanged and keep history append-only:** Append each assistant turn exactly as the API returned it, thinking blocks included. On Claude Fable 5.1, [modifying the conversation before a thinking block](https://platform.claude.com/docs/en/build-with-claude/thinking#preserved-in-conversation) results in an error, or in the block being dropped if you opt into that: editing earlier messages, rebuilding `system` or `tools`, or summarizing older turns in place between requests invalidates every later thinking block, so move those changes to mid-conversation system messages and server-side context management. See [Keep the conversation history append-only](https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/prompting-claude-fable-5-1#keep-the-conversation-history-append-only).
10847. **Pass thinking blocks back unchanged and keep history append-only:** Append each assistant turn exactly as the API returned it, thinking blocks included. On Claude Fable 5.1 and Claude Opus 5.5, [modifying the conversation before a thinking block](https://platform.claude.com/docs/en/build-with-claude/thinking#preserved-in-conversation) results in an error, or in the block being dropped if you opt into that: editing earlier messages, rebuilding `system` or `tools`, or summarizing older turns in place between requests invalidates every later thinking block, so move those changes to mid-conversation system messages and server-side context management. See [Keep the conversation history append-only](https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/prompting-claude-fable-5-1#keep-the-conversation-history-append-only).
10841085
10851086For detailed migration steps, see the [Migration guide](https://platform.claude.com/docs/en/about-claude/models/migration-guide).
10861087
from line 1102
11011102
11021103 <Card title="Prompting Claude Sonnet 5" icon="terminal" href="https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/prompting-claude-sonnet-5">
11031104 Behavioral differences and prompting patterns for Claude Sonnet 5, covering effort, adaptive thinking defaults, tool use, and migration from Claude Sonnet 4.6.
1105 </Card>
1106
1107 <Card title="Prompting Claude Opus 5.5" icon="terminal" href="https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/prompting-claude-opus-5-5">
1108 Behavioral differences and prompting patterns for Claude Opus 5.5, covering effort calibration, thinking always on, progress updates, safeguard false positives, and visual inputs.
11041109 </Card>
11051110
11061111 <Card title="Prompting Claude Opus 5" icon="terminal" href="https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/prompting-claude-opus-5">
build-with-claude/search-results Changed · +18 / -18 lines
from line 797
797797 -H "anthropic-version: 2023-06-01" \
798798 -H "content-type: application/json" \
799799 -d '{
800 "model": "claude-opus-5",
800 "model": "claude-opus-5-5",
801801 "max_tokens": 1024,
802802 "messages": [
803803 {
from line 843
843843
844844 ```bash CLI
845845 ant messages create <<'YAML'
846 model: claude-opus-5
846 model: claude-opus-5-5
847847 max_tokens: 1024
848848 messages:
849849 - role: user
from line 884
884884
885885 # Provide search results directly in the user message
886886 response = client.messages.create(
887 model="claude-opus-5",
887 model="claude-opus-5-5",
888888 max_tokens=1024,
889889 messages=[
890890 MessageParam(
from line 931
931931
932932 // Provide search results directly in the user message
933933 const response = await client.messages.create({
934 model: "claude-opus-5",
934 model: "claude-opus-5-5",
935935 max_tokens: 1024,
936936 messages: [
937937 {
from line 979
979979 // Provide search results directly in the user message
980980 var response = await client.Messages.Create(new()
981981 {
982 Model = Model.ClaudeOpus5,
982 Model = Model.ClaudeOpus5_5,
983983 MaxTokens = 1024,
984984 Messages =
985985 [
from line 1015
10151015 client := anthropic.NewClient()
10161016
10171017 response, err := client.Messages.New(context.TODO(), anthropic.MessageNewParams{
1018 Model: anthropic.ModelClaudeOpus5,
1018 Model: anthropic.ModelClaudeOpus5_5,
10191019 MaxTokens: 1024,
10201020 Messages: []anthropic.MessageParam{
10211021 anthropic.NewUserMessage(
from line 1057
10571057 AnthropicClient client = AnthropicOkHttpClient.fromEnv();
10581058
10591059 MessageCreateParams params = MessageCreateParams.builder()
1060 .model(Model.CLAUDE_OPUS_5)
1060 .model(Model.CLAUDE_OPUS_5_5)
10611061 .maxTokens(1024L)
10621062 .addUserMessageOfBlockParams(List.of(
10631063 ContentBlockParam.ofSearchResult(
from line 1137
11371137 ]
11381138 ]
11391139 ],
1140 model: 'claude-opus-5',
1140 model: 'claude-opus-5-5',
11411141 );
11421142
11431143 echo json_encode($message, JSON_PRETTY_PRINT);
from line 1147
11471147 client = Anthropic::Client.new
11481148
11491149 message = client.messages.create(
1150 model: "claude-opus-5",
1150 model: "claude-opus-5-5",
11511151 max_tokens: 1024,
11521152 messages: [
11531153 {
from line 1310
13101310 -H "anthropic-version: 2023-06-01" \
13111311 -H "content-type: application/json" \
13121312 -d '{
1313 "model": "claude-opus-5",
1313 "model": "claude-opus-5-5",
13141314 "max_tokens": 1024,
13151315 "tools": [
13161316 {
from line 1391
13911391
13921392 ```bash CLI
13931393 ant messages create <<'YAML'
1394 model: claude-opus-5
1394 model: claude-opus-5-5
13951395 max_tokens: 1024
13961396 tools:
13971397 - name: search_knowledge_base
from line 1469
14691469 # Replay a conversation that provides search results both ways: the first
14701470 # user message carries a pre-fetched result, the tool result returns another
14711471 response = client.messages.create(
1472 model="claude-opus-5",
1472 model="claude-opus-5-5",
14731473 max_tokens=1024,
14741474 tools=[knowledge_base_tool],
14751475 messages=[
from line 1555
15551555 // Replay a conversation that provides search results both ways: the first
15561556 // user message carries a pre-fetched result, the tool result returns another
15571557 const response = await client.messages.create({
1558 model: "claude-opus-5",
1558 model: "claude-opus-5-5",
15591559 max_tokens: 1024,
15601560 tools: [knowledgeBaseTool],
15611561 messages: [
from line 1628
16281628 // user message carries a pre-fetched result, the tool result returns another
16291629 var response = await client.Messages.Create(new()
16301630 {
1631 Model = Model.ClaudeOpus5,
1631 Model = Model.ClaudeOpus5_5,
16321632 MaxTokens = 1024,
16331633 Tools =
16341634 [
from line 1726
17261726 // Replay a conversation that provides search results both ways: the first
17271727 // user message carries a pre-fetched result, the tool result returns another
17281728 response, err := client.Messages.New(context.TODO(), anthropic.MessageNewParams{
1729 Model: anthropic.ModelClaudeOpus5,
1729 Model: anthropic.ModelClaudeOpus5_5,
17301730 MaxTokens: 1024,
17311731 Tools: []anthropic.ToolUnionParam{knowledgeBaseTool},
17321732 Messages: []anthropic.MessageParam{
from line 1801
18011801 // Replay a conversation that provides search results both ways: the first
18021802 // user message carries a pre-fetched result, the tool result returns another
18031803 MessageCreateParams params = MessageCreateParams.builder()
1804 .model(Model.CLAUDE_OPUS_5)
1804 .model(Model.CLAUDE_OPUS_5_5)
18051805 .maxTokens(1024L)
18061806 .addTool(knowledgeBaseTool)
18071807 .addUserMessageOfBlockParams(List.of(
from line 1927
19271927 ]
19281928 ]
19291929 ],
1930 model: 'claude-opus-5',
1930 model: 'claude-opus-5-5',
19311931 );
19321932
19331933 echo json_encode($response, JSON_PRETTY_PRINT);
from line 1951
19511951 # Replay a conversation that provides search results both ways: the first
19521952 # user message carries a pre-fetched result, the tool result returns another
19531953 response = client.messages.create(
1954 model: "claude-opus-5",
1954 model: "claude-opus-5-5",
19551955 max_tokens: 1024,
19561956 tools: [knowledge_base_tool],
19571957 messages: [
build-with-claude/skills-guide Changed · +117 / -117 lines
from line 79
7979 -H "anthropic-version: 2023-06-01" \
8080 -H "content-type: application/json" \
8181 -d '{
82 "model": "claude-opus-5",
82 "model": "claude-opus-5-5",
8383 "max_tokens": 4096,
8484 "container": {
8585 "skills": [
from line 103
103103
104104 ```bash CLI
105105 ant messages create <<'YAML'
106 model: claude-opus-5
106 model: claude-opus-5-5
107107 max_tokens: 4096
108108 container:
109109 skills:
from line 123
123123 client = anthropic.Anthropic()
124124
125125 response = client.messages.create(
126 model="claude-opus-5",
126 model="claude-opus-5-5",
127127 max_tokens=4096,
128128 container={
129129 "skills": [{"type": "anthropic", "skill_id": "pptx", "version": "latest"}]
from line 139
139139 const client = new Anthropic();
140140
141141 const response = await client.messages.create({
142 model: "claude-opus-5",
142 model: "claude-opus-5-5",
143143 max_tokens: 4096,
144144 container: {
145145 skills: [
from line 170
170170
171171 var parameters = new MessageCreateParams
172172 {
173 Model = "claude-opus-5",
173 Model = "claude-opus-5-5",
174174 MaxTokens = 4096,
175175 Container = new ContainerParams
176176 {
from line 196
196196 client := anthropic.NewClient()
197197
198198 response, err := client.Messages.New(context.TODO(), anthropic.MessageNewParams{
199 Model: "claude-opus-5",
199 Model: "claude-opus-5-5",
200200 MaxTokens: 4096,
201201 Container: anthropic.MessageCreateParamsContainerUnion{
202202 OfContainers: &anthropic.ContainerParams{
from line 231
231231 AnthropicClient client = AnthropicOkHttpClient.fromEnv();
232232
233233 MessageCreateParams params = MessageCreateParams.builder()
234 .model(Model.CLAUDE_OPUS_5)
234 .model(Model.CLAUDE_OPUS_5_5)
235235 .maxTokens(4096L)
236236 .container(ContainerParams.builder()
237237 .addSkill(SkillParams.builder()
from line 257
257257 messages: [
258258 ['role' => 'user', 'content' => 'Create a presentation about renewable energy']
259259 ],
260 model: 'claude-opus-5',
260 model: 'claude-opus-5-5',
261261 container: [
262262 'skills' => [
263263 [
from line 279
279279 client = Anthropic::Client.new
280280
281281 message = client.messages.create(
282 model: "claude-opus-5",
282 model: "claude-opus-5-5",
283283 max_tokens: 4096,
284284 container: {
285285 skills: [
from line 324
324324 -H "anthropic-version: 2023-06-01" \
325325 -H "content-type: application/json" \
326326 -d '{
327 "model": "claude-opus-5",
327 "model": "claude-opus-5-5",
328328 "max_tokens": 4096,
329329 "container": {
330330 "skills": [
from line 364
364364 FILE_ID=$(ant messages create \
365365 --transform 'content.#.content.content.#.file_id|@flatten|0' \
366366 --raw-output <<'YAML'
367 model: claude-opus-5
367 model: claude-opus-5-5
368368 max_tokens: 4096
369369 container:
370370 skills:
from line 397
397397
398398 # Step 1: Use a Skill to create a file
399399 response = client.messages.create(
400 model="claude-opus-5",
400 model="claude-opus-5-5",
401401 max_tokens=4096,
402402 container={
403403 "skills": [{"type": "anthropic", "skill_id": "xlsx", "version": "latest"}]
from line 442
442442
443443 // Step 1: Use a Skill to create a file
444444 const response = await client.messages.create({
445 model: "claude-opus-5",
445 model: "claude-opus-5-5",
446446 max_tokens: 4096,
447447 container: {
448448 skills: [{ type: "anthropic", skill_id: "xlsx", version: "latest" }]
from line 485
485485 // Step 1: Use a Skill to create a file
486486 var parameters = new MessageCreateParams
487487 {
488 Model = "claude-opus-5",
488 Model = "claude-opus-5-5",
489489 MaxTokens = 4096,
490490 Container = new ContainerParams
491491 {
from line 537
537537
538538 // Step 1: Use a Skill to create a file
539539 response, err := client.Messages.New(context.TODO(), anthropic.MessageNewParams{
540 Model: "claude-opus-5",
540 Model: "claude-opus-5-5",
541541 MaxTokens: 4096,
542542 Container: anthropic.MessageCreateParamsContainerUnion{
543543 OfContainers: &anthropic.ContainerParams{
from line 619
619619
620620 // Step 1: Use a Skill to create a file
621621 MessageCreateParams params = MessageCreateParams.builder()
622 .model(Model.CLAUDE_OPUS_5)
622 .model(Model.CLAUDE_OPUS_5_5)
623623 .maxTokens(4096L)
624624 .container(ContainerParams.builder()
625625 .addSkill(SkillParams.builder()
from line 671
671671 messages: [
672672 ['role' => 'user', 'content' => 'Create an Excel file with a simple budget spreadsheet']
673673 ],
674 model: 'claude-opus-5',
674 model: 'claude-opus-5-5',
675675 container: [
676676 'skills' => [
677677 ['type' => 'anthropic', 'skillID' => 'xlsx', 'version' => 'latest']
from line 714
714714
715715 # Step 1: Use a Skill to create a file
716716 response = client.messages.create(
717 model: "claude-opus-5",
717 model: "claude-opus-5-5",
718718 max_tokens: 4096,
719719 container: {
720720 skills: [{ type: "anthropic", skill_id: "xlsx", version: "latest" }]
from line 949
949949 CONTAINER_ID=$(ant messages create \
950950 --transform container.id \
951951 --raw-output <<'YAML'
952 model: claude-opus-5
952 model: claude-opus-5-5
953953 max_tokens: 4096
954954 container:
955955 skills:
from line 964
964964
965965 # Continue conversation with same container
966966 ant messages create <<YAML
967 model: claude-opus-5
967 model: claude-opus-5-5
968968 max_tokens: 4096
969969 container:
970970 id: $CONTAINER_ID # Reuse container
from line 987
987987
988988 # First request creates container
989989 response1 = client.messages.create(
990 model="claude-opus-5",
990 model="claude-opus-5-5",
991991 max_tokens=4096,
992992 container={
993993 "skills": [{"type": "anthropic", "skill_id": "xlsx", "version": "latest"}]
from line 1012
10121012 ]
10131013
10141014 response2 = client.messages.create(
1015 model="claude-opus-5",
1015 model="claude-opus-5-5",
10161016 max_tokens=4096,
10171017 container={
10181018 "id": response1.container.id, # Reuse container
from line 1028
10281028
10291029 // First request creates container
10301030 const response1 = await client.messages.create({
1031 model: "claude-opus-5",
1031 model: "claude-opus-5-5",
10321032 max_tokens: 4096,
10331033 container: {
10341034 skills: [{ type: "anthropic", skill_id: "xlsx", version: "latest" }]
from line 1052
10521052 ];
10531053
10541054 const response2 = await client.messages.create({
1055 model: "claude-opus-5",
1055 model: "claude-opus-5-5",
10561056 max_tokens: 4096,
10571057 container: {
10581058 id: response1.container!.id, // Reuse container
from line 1069
10691069 // First request with a Skill
10701070 var parameters1 = new MessageCreateParams
10711071 {
1072 Model = "claude-opus-5",
1072 Model = "claude-opus-5-5",
10731073 MaxTokens = 4096,
10741074 Container = new ContainerParams
10751075 {
from line 1098
10981098
10991099 var parameters2 = new MessageCreateParams
11001100 {
1101 Model = "claude-opus-5",
1101 Model = "claude-opus-5-5",
11021102 MaxTokens = 4096,
11031103 Container = new ContainerParams
11041104 {
from line 1130
11301130 client := anthropic.NewClient()
11311131
11321132 response1, err := client.Messages.New(context.TODO(), anthropic.MessageNewParams{
1133 Model: "claude-opus-5",
1133 Model: "claude-opus-5-5",
11341134 MaxTokens: 4096,
11351135 Container: anthropic.MessageCreateParamsContainerUnion{
11361136 OfContainers: &anthropic.ContainerParams{
from line 1164
11641164 assistantText := strings.Join(textParts, "\n")
11651165
11661166 response2, err := client.Messages.New(context.TODO(), anthropic.MessageNewParams{
1167 Model: "claude-opus-5",
1167 Model: "claude-opus-5-5",
11681168 MaxTokens: 4096,
11691169 Container: anthropic.MessageCreateParamsContainerUnion{
11701170 OfContainers: &anthropic.ContainerParams{
from line 1207
12071207 AnthropicClient client = AnthropicOkHttpClient.fromEnv();
12081208
12091209 MessageCreateParams params1 = MessageCreateParams.builder()
1210 .model(Model.CLAUDE_OPUS_5)
1210 .model(Model.CLAUDE_OPUS_5_5)
12111211 .maxTokens(4096L)
12121212 .container(ContainerParams.builder()
12131213 .addSkill(SkillParams.builder()
from line 1223
12231223 Message response1 = client.messages().create(params1);
12241224
12251225 MessageCreateParams params2 = MessageCreateParams.builder()
1226 .model(Model.CLAUDE_OPUS_5)
1226 .model(Model.CLAUDE_OPUS_5_5)
12271227 .maxTokens(4096L)
12281228 .container(ContainerParams.builder()
12291229 .id(response1.container().get().id())
from line 1256
12561256 messages: [
12571257 ['role' => 'user', 'content' => 'Create a sample sales dataset and analyze it']
12581258 ],
1259 model: 'claude-opus-5',
1259 model: 'claude-opus-5-5',
12601260 container: [
12611261 'skills' => [
12621262 ['type' => 'anthropic', 'skillID' => 'xlsx', 'version' => 'latest']
from line 1280
12801280 $response2 = $client->messages->create(
12811281 maxTokens: 4096,
12821282 messages: $messages,
1283 model: 'claude-opus-5',
1283 model: 'claude-opus-5-5',
12841284 container: [
12851285 'id' => $response1->container->id,
12861286 'skills' => [
from line 1299
12991299 client = Anthropic::Client.new
13001300
13011301 response1 = client.messages.create(
1302 model: "claude-opus-5",
1302 model: "claude-opus-5-5",
13031303 max_tokens: 4096,
13041304 container: {
13051305 skills: [{ type: "anthropic", skill_id: "xlsx", version: "latest" }]
from line 1323
13231323 ]
13241324
13251325 response2 = client.messages.create(
1326 model: "claude-opus-5",
1326 model: "claude-opus-5-5",
13271327 max_tokens: 4096,
13281328 container: {
13291329 id: response1.container.id,
from line 1353
13531353 -H "anthropic-version: 2023-06-01" \
13541354 -H "content-type: application/json" \
13551355 -d '{
1356 "model": "claude-opus-5",
1356 "model": "claude-opus-5-5",
13571357 "max_tokens": 4096,
13581358 "container": {
13591359 "skills": [
from line 1385
13851385 -H "anthropic-version: 2023-06-01" \
13861386 -H "content-type: application/json" \
13871387 -d "{
1388 \"model\": \"claude-opus-5\",
1388 \"model\": \"claude-opus-5-5\",
13891389 \"max_tokens\": 4096,
13901390 \"container\": {
13911391 \"id\": \"$CONTAINER_ID\",
from line 1408
14081408
14091409 # Initial request: capture the full JSON response to a temp file
14101410 ant messages create > "$RESP" <<'YAML'
1411 model: claude-opus-5
1411 model: claude-opus-5-5
14121412 max_tokens: 4096
14131413 container:
14141414 skills:
from line 1429
14291429 CONTAINER_ID=$(jq -r '.container.id' "$RESP")
14301430
14311431 ant messages create > "$RESP" <<YAML
1432 model: claude-opus-5
1432 model: claude-opus-5-5
14331433 max_tokens: 4096
14341434 container:
14351435 id: $CONTAINER_ID
from line 1451
14511451 max_retries = 10
14521452
14531453 response = client.messages.create(
1454 model="claude-opus-5",
1454 model="claude-opus-5-5",
14551455 max_tokens=4096,
14561456 container={
14571457 "skills": [
from line 1473
14731473
14741474 messages.append({"role": "assistant", "content": response.content})
14751475 response = client.messages.create(
1476 model="claude-opus-5",
1476 model="claude-opus-5-5",
14771477 max_tokens=4096,
14781478 container={
14791479 "id": response.container.id,
from line 1498
14981498 const maxRetries = 10;
14991499
15001500 let response = await client.messages.create({
1501 model: "claude-opus-5",
1501 model: "claude-opus-5-5",
15021502 max_tokens: 4096,
15031503 container: {
15041504 skills: [{ type: "custom", skill_id: "skill_01AbCdEfGhIjKlMnOpQrStUv", version: "latest" }]
from line 1518
15181518 content: response.content as Anthropic.ContentBlockParam[]
15191519 });
15201520 response = await client.messages.create({
1521 model: "claude-opus-5",
1521 model: "claude-opus-5-5",
15221522 max_tokens: 4096,
15231523 container: {
15241524 id: response.container!.id,
from line 1550
15501550 {
15511551 var parameters = new MessageCreateParams
15521552 {
1553 Model = "claude-opus-5",
1553 Model = "claude-opus-5-5",
15541554 MaxTokens = 4096,
15551555 Container = containerId is null
15561556 ? new ContainerParams
from line 1607
16071607 maxRetries := 10
16081608
16091609 response, err := client.Messages.New(context.TODO(), anthropic.MessageNewParams{
1610 Model: "claude-opus-5",
1610 Model: "claude-opus-5-5",
16111611 MaxTokens: 4096,
16121612 Container: anthropic.MessageCreateParamsContainerUnion{
16131613 OfContainers: &anthropic.ContainerParams{
from line 1637
16371637 messages = append(messages, response.ToParam())
16381638
16391639 response, err = client.Messages.New(context.TODO(), anthropic.MessageNewParams{
1640 Model: "claude-opus-5",
1640 Model: "claude-opus-5-5",
16411641 MaxTokens: 4096,
16421642 Container: anthropic.MessageCreateParamsContainerUnion{
16431643 OfContainers: &anthropic.ContainerParams{
from line 1684
16841684
16851685 Message response = client.messages().create(
16861686 MessageCreateParams.builder()
1687 .model(Model.CLAUDE_OPUS_5)
1687 .model(Model.CLAUDE_OPUS_5_5)
16881688 .maxTokens(4096L)
16891689 .container(ContainerParams.builder()
16901690 .addSkill(SkillParams.builder()
from line 1707
17071707
17081708 response = client.messages().create(
17091709 MessageCreateParams.builder()
1710 .model(Model.CLAUDE_OPUS_5)
1710 .model(Model.CLAUDE_OPUS_5_5)
17111711 .maxTokens(4096L)
17121712 .container(ContainerParams.builder()
17131713 .id(response.container().get().id())
from line 1735
17351735 $response = $client->messages->create(
17361736 maxTokens: 4096,
17371737 messages: $messages,
1738 model: 'claude-opus-5',
1738 model: 'claude-opus-5-5',
17391739 container: [
17401740 'skills' => [
17411741 [
from line 1758
17581758 $response = $client->messages->create(
17591759 maxTokens: 4096,
17601760 messages: $messages,
1761 model: 'claude-opus-5',
1761 model: 'claude-opus-5-5',
17621762 container: [
17631763 'id' => $response->container->id,
17641764 'skills' => [
from line 1783
17831783 max_retries = 10
17841784
17851785 response = client.messages.create(
1786 model: "claude-opus-5",
1786 model: "claude-opus-5-5",
17871787 max_tokens: 4096,
17881788 container: {
17891789 skills: [
from line 1804
18041804 messages << { role: "assistant", content: response.content }
18051805
18061806 response = client.messages.create(
1807 model: "claude-opus-5",
1807 model: "claude-opus-5-5",
18081808 max_tokens: 4096,
18091809 container: {
18101810 id: response.container.id,
from line 1838
18381838 -H "anthropic-version: 2023-06-01" \
18391839 -H "content-type: application/json" \
18401840 -d '{
1841 "model": "claude-opus-5",
1841 "model": "claude-opus-5-5",
18421842 "max_tokens": 4096,
18431843 "container": {
18441844 "skills": [
from line 1872
18721872
18731873 ```bash CLI
18741874 ant messages create <<'YAML'
1875 model: claude-opus-5
1875 model: claude-opus-5-5
18761876 max_tokens: 4096
18771877 container:
18781878 skills:
from line 1898
18981898 client = anthropic.Anthropic()
18991899
19001900 response = client.messages.create(
1901 model="claude-opus-5",
1901 model="claude-opus-5-5",
19021902 max_tokens=4096,
19031903 container={
19041904 "skills": [
from line 1922
19221922 const client = new Anthropic();
19231923
19241924 const response = await client.messages.create({
1925 model: "claude-opus-5",
1925 model: "claude-opus-5-5",
19261926 max_tokens: 4096,
19271927 container: {
19281928 skills: [
from line 1963
19631963
19641964 var parameters = new MessageCreateParams
19651965 {
1966 Model = "claude-opus-5",
1966 Model = "claude-opus-5-5",
19671967 MaxTokens = 4096,
19681968 Container = new ContainerParams
19691969 {
from line 2001
20012001 client := anthropic.NewClient()
20022002
20032003 response, err := client.Messages.New(context.TODO(), anthropic.MessageNewParams{
2004 Model: "claude-opus-5",
2004 Model: "claude-opus-5-5",
20052005 MaxTokens: 4096,
20062006 Container: anthropic.MessageCreateParamsContainerUnion{
20072007 OfContainers: &anthropic.ContainerParams{
from line 2046
20462046 AnthropicClient client = AnthropicOkHttpClient.fromEnv();
20472047
20482048 MessageCreateParams params = MessageCreateParams.builder()
2049 .model(Model.CLAUDE_OPUS_5)
2049 .model(Model.CLAUDE_OPUS_5_5)
20502050 .maxTokens(4096L)
20512051 .container(ContainerParams.builder()
20522052 .skills(List.of(
from line 2084
20842084 messages: [
20852085 ['role' => 'user', 'content' => 'Analyze sales data and create a presentation']
20862086 ],
2087 model: 'claude-opus-5',
2087 model: 'claude-opus-5-5',
20882088 container: [
20892089 'skills' => [
20902090 [
from line 2116
21162116 client = Anthropic::Client.new
21172117
21182118 message = client.messages.create(
2119 model: "claude-opus-5",
2119 model: "claude-opus-5-5",
21202120 max_tokens: 4096,
21212121 container: {
21222122 skills: [
from line 2811
28112811 -H "anthropic-version: 2023-06-01" \
28122812 -H "content-type: application/json" \
28132813 -d "{
2814 \"model\": \"claude-opus-5\",
2814 \"model\": \"claude-opus-5-5\",
28152815 \"max_tokens\": 4096,
28162816 \"container\": {
28172817 \"skills\": [{
from line 2830
28302830 -H "anthropic-version: 2023-06-01" \
28312831 -H "content-type: application/json" \
28322832 -d '{
2833 "model": "claude-opus-5",
2833 "model": "claude-opus-5-5",
28342834 "max_tokens": 4096,
28352835 "container": {
28362836 "skills": [{
from line 2854
28542854
28552855 # Use specific version
28562856 ant messages create <<YAML
2857 model: claude-opus-5
2857 model: claude-opus-5-5
28582858 max_tokens: 4096
28592859 container:
28602860 skills:
from line 2871
28712871
28722872 # Use latest version
28732873 ant messages create <<YAML
2874 model: claude-opus-5
2874 model: claude-opus-5-5
28752875 max_tokens: 4096
28762876 container:
28772877 skills:
from line 2901
29012901
29022902 # Use specific version
29032903 response = client.messages.create(
2904 model="claude-opus-5",
2904 model="claude-opus-5-5",
29052905 max_tokens=4096,
29062906 container={
29072907 "skills": [
from line 2918
29182918
29192919 # Use latest version
29202920 response = client.messages.create(
2921 model="claude-opus-5",
2921 model="claude-opus-5-5",
29222922 max_tokens=4096,
29232923 container={
29242924 "skills": [
from line 2946
29462946
29472947 // Use specific version
29482948 const specificVersionResponse = await client.messages.create({
2949 model: "claude-opus-5",
2949 model: "claude-opus-5-5",
29502950 max_tokens: 4096,
29512951 container: {
29522952 skills: [
from line 2963
29632963
29642964 // Use latest version
29652965 const latestVersionResponse = await client.messages.create({
2966 model: "claude-opus-5",
2966 model: "claude-opus-5-5",
29672967 max_tokens: 4096,
29682968 container: {
29692969 skills: [
from line 3008
30083008 // Use specific version
30093009 var specificVersionParams = new MessageCreateParams
30103010 {
3011 Model = "claude-opus-5",
3011 Model = "claude-opus-5-5",
30123012 MaxTokens = 4096,
30133013 Container = new ContainerParams
30143014 {
from line 3032
30323032 // Use latest version
30333033 var latestVersionParams = new MessageCreateParams
30343034 {
3035 Model = "claude-opus-5",
3035 Model = "claude-opus-5-5",
30363036 MaxTokens = 4096,
30373037 Container = new ContainerParams
30383038 {
from line 3085
30853085
30863086 // Use specific version
30873087 response, err := client.Messages.New(context.TODO(), anthropic.MessageNewParams{
3088 Model: "claude-opus-5",
3088 Model: "claude-opus-5-5",
30893089 MaxTokens: 4096,
30903090 Container: anthropic.MessageCreateParamsContainerUnion{
30913091 OfContainers: &anthropic.ContainerParams{
from line 3112
31123112
31133113 // Use latest version
31143114 latestResponse, err := client.Messages.New(context.TODO(), anthropic.MessageNewParams{
3115 Model: "claude-opus-5",
3115 Model: "claude-opus-5-5",
31163116 MaxTokens: 4096,
31173117 Container: anthropic.MessageCreateParamsContainerUnion{
31183118 OfContainers: &anthropic.ContainerParams{
from line 3168
31683168
31693169 // Use specific version
31703170 MessageCreateParams specificVersionParams = MessageCreateParams.builder()
3171 .model(Model.CLAUDE_OPUS_5)
3171 .model(Model.CLAUDE_OPUS_5_5)
31723172 .maxTokens(4096L)
31733173 .container(ContainerParams.builder()
31743174 .addSkill(SkillParams.builder()
from line 3186
31863186
31873187 // Use latest version
31883188 MessageCreateParams latestVersionParams = MessageCreateParams.builder()
3189 .model(Model.CLAUDE_OPUS_5)
3189 .model(Model.CLAUDE_OPUS_5_5)
31903190 .maxTokens(4096L)
31913191 .container(ContainerParams.builder()
31923192 .addSkill(SkillParams.builder()
from line 3230
32303230 $response = $client->messages->create(
32313231 maxTokens: 4096,
32323232 messages: [['role' => 'user', 'content' => 'Use updated Skill']],
3233 model: 'claude-opus-5',
3233 model: 'claude-opus-5-5',
32343234 container: [
32353235 'skills' => [[
32363236 'type' => 'custom',
from line 3246
32463246 $latestResponse = $client->messages->create(
32473247 maxTokens: 4096,
32483248 messages: [['role' => 'user', 'content' => 'Use latest Skill version']],
3249 model: 'claude-opus-5',
3249 model: 'claude-opus-5-5',
32503250 container: [
32513251 'skills' => [[
32523252 'type' => 'custom',
from line 3281
32813281
32823282 # Use specific version
32833283 response = client.messages.create(
3284 model: "claude-opus-5",
3284 model: "claude-opus-5-5",
32853285 max_tokens: 4096,
32863286 container: {
32873287 skills: [{
from line 3297
32973297
32983298 # Use latest version
32993299 latest_response = client.messages.create(
3300 model: "claude-opus-5",
3300 model: "claude-opus-5-5",
33013301 max_tokens: 4096,
33023302 container: {
33033303 skills: [{
from line 3475
34753475 -H "anthropic-version: 2023-06-01" \
34763476 -H "content-type: application/json" \
34773477 -d '{
3478 "model": "claude-opus-5",
3478 "model": "claude-opus-5-5",
34793479 "max_tokens": 4096,
34803480 "container": {
34813481 "skills": [
from line 3504
35043504
35053505 ```bash CLI
35063506 ant messages create <<'YAML'
3507 model: claude-opus-5
3507 model: claude-opus-5-5
35083508 max_tokens: 4096
35093509 container:
35103510 skills:
from line 3531
35313531
35323532 # Use with Excel to create financial model
35333533 response = client.messages.create(
3534 model="claude-opus-5",
3534 model="claude-opus-5-5",
35353535 max_tokens=4096,
35363536 container={
35373537 "skills": [
from line 3558
35583558
35593559 // Use with Excel to create financial model
35603560 const response = await client.messages.create({
3561 model: "claude-opus-5",
3561 model: "claude-opus-5-5",
35623562 max_tokens: 4096,
35633563 container: {
35643564 skills: [
from line 3586
35863586 // Use with Excel to create financial model
35873587 var parameters = new MessageCreateParams
35883588 {
3589 Model = "claude-opus-5",
3589 Model = "claude-opus-5-5",
35903590 MaxTokens = 4096,
35913591 Container = new ContainerParams
35923592 {
from line 3622
36223622
36233623 // Use with Excel to create financial model
36243624 response, err := client.Messages.New(context.TODO(), anthropic.MessageNewParams{
3625 Model: "claude-opus-5",
3625 Model: "claude-opus-5-5",
36263626 MaxTokens: 4096,
36273627 Container: anthropic.MessageCreateParamsContainerUnion{
36283628 OfContainers: &anthropic.ContainerParams{
from line 3666
36663666
36673667 // Use with Excel Skill to create financial model
36683668 MessageCreateParams params = MessageCreateParams.builder()
3669 .model(Model.CLAUDE_OPUS_5)
3669 .model(Model.CLAUDE_OPUS_5_5)
36703670 .maxTokens(4096L)
36713671 .container(ContainerParams.builder()
36723672 .skills(List.of(
from line 3703
37033703 messages: [
37043704 ['role' => 'user', 'content' => 'Build a DCF valuation model for a SaaS company']
37053705 ],
3706 model: 'claude-opus-5',
3706 model: 'claude-opus-5-5',
37073707 container: [
37083708 'skills' => [
37093709 ['type' => 'anthropic', 'skillID' => 'xlsx', 'version' => 'latest'],
from line 3725
37253725
37263726 # Use with Excel to create financial model
37273727 response = client.messages.create(
3728 model: "claude-opus-5",
3728 model: "claude-opus-5-5",
37293729 max_tokens: 4096,
37303730 container: {
37313731 skills: [
from line 3799
37993799 -H "anthropic-version: 2023-06-01" \
38003800 -H "content-type: application/json" \
38013801 -d '{
3802 "model": "claude-opus-5",
3802 "model": "claude-opus-5-5",
38033803 "max_tokens": 4096,
38043804 "container": {
38053805 "skills": [{
from line 3816
38163816 ```bash CLI
38173817 # Pin to specific versions for stability
38183818 ant messages create <<YAML
3819 model: claude-opus-5
3819 model: claude-opus-5-5
38203820 max_tokens: 4096
38213821 container:
38223822 skills:
from line 3940
39403940 -H "anthropic-version: 2023-06-01" \
39413941 -H "content-type: application/json" \
39423942 -d '{
3943 "model": "claude-opus-5",
3943 "model": "claude-opus-5-5",
39443944 "max_tokens": 4096,
39453945 "container": {
39463946 "skills": [{
from line 3957
39573957 ```bash CLI
39583958 # Use latest for active development
39593959 ant messages create <<YAML
3960 model: claude-opus-5
3960 model: claude-opus-5-5
39613961 max_tokens: 4096
39623962 container:
39633963 skills:
from line 4083
40834083 -H "anthropic-version: 2023-06-01" \
40844084 -H "content-type: application/json" \
40854085 -d '{
4086 "model": "claude-opus-5",
4086 "model": "claude-opus-5-5",
40874087 "max_tokens": 4096,
40884088 "container": {
40894089 "skills": [
from line 4100
41004100 -H "anthropic-version: 2023-06-01" \
41014101 -H "content-type: application/json" \
41024102 -d '{
4103 "model": "claude-opus-5",
4103 "model": "claude-opus-5-5",
41044104 "max_tokens": 4096,
41054105 "container": {
41064106 "skills": [
from line 4116
41164116 ```bash CLI
41174117 # Skills render into the system prompt in a fixed, cache-friendly order
41184118 ant messages create <<'YAML'
4119 model: claude-opus-5
4119 model: claude-opus-5-5
41204120 max_tokens: 4096
41214121 container:
41224122 skills:
from line 4133
41334133
41344134 # Changing the Skills list ([xlsx] vs [xlsx, pptx]) changes the prefix: a cache miss, while an identical list is a cache hit
41354135 ant messages create <<'YAML'
4136 model: claude-opus-5
4136 model: claude-opus-5-5
41374137 max_tokens: 4096
41384138 container:
41394139 skills:
from line 4157
41574157
41584158 # Skills render into the system prompt in a fixed, cache-friendly order
41594159 response1 = client.messages.create(
4160 model="claude-opus-5",
4160 model="claude-opus-5-5",
41614161 max_tokens=4096,
41624162 container={
41634163 "skills": [{"type": "anthropic", "skill_id": "xlsx", "version": "latest"}]
from line 4168
41684168
41694169 # Changing the Skills list ([xlsx] vs [xlsx, pptx]) changes the prefix: a cache miss, while an identical list is a cache hit
41704170 response2 = client.messages.create(
4171 model="claude-opus-5",
4171 model="claude-opus-5-5",
41724172 max_tokens=4096,
41734173 container={
41744174 "skills": [
from line 4190
41904190
41914191 // Skills render into the system prompt in a fixed, cache-friendly order
41924192 const response1 = await client.messages.create({
4193 model: "claude-opus-5",
4193 model: "claude-opus-5-5",
41944194 max_tokens: 4096,
41954195 container: {
41964196 skills: [{ type: "anthropic", skill_id: "xlsx", version: "latest" }]
from line 4201
42014201
42024202 // Changing the Skills list ([xlsx] vs [xlsx, pptx]) changes the prefix: a cache miss, while an identical list is a cache hit
42034203 const response2 = await client.messages.create({
4204 model: "claude-opus-5",
4204 model: "claude-opus-5-5",
42054205 max_tokens: 4096,
42064206 container: {
42074207 skills: [
from line 4220
42204220 // Skills render into the system prompt in a fixed, cache-friendly order
42214221 var parameters1 = new MessageCreateParams
42224222 {
4223 Model = "claude-opus-5",
4223 Model = "claude-opus-5-5",
42244224 MaxTokens = 4096,
42254225 Container = new ContainerParams
42264226 {
from line 4244
42444244 // Different Skill set ([xlsx] vs [xlsx, pptx]) = a different prefix: a cache miss (an identical set is a cache hit)
42454245 var parameters2 = new MessageCreateParams
42464246 {
4247 Model = "claude-opus-5",
4247 Model = "claude-opus-5-5",
42484248 MaxTokens = 4096,
42494249 Container = new ContainerParams
42504250 {
from line 4277
42774277
42784278 // Skills render into the system prompt in a fixed, cache-friendly order
42794279 response1, err := client.Messages.New(context.TODO(), anthropic.MessageNewParams{
4280 Model: "claude-opus-5",
4280 Model: "claude-opus-5-5",
42814281 MaxTokens: 4096,
42824282 Container: anthropic.MessageCreateParamsContainerUnion{
42834283 OfContainers: &anthropic.ContainerParams{
from line 4304
43044304
43054305 // Changing the Skills list ([xlsx] vs [xlsx, pptx]) changes the prefix: a cache miss, while an identical list is a cache hit
43064306 response2, err := client.Messages.New(context.TODO(), anthropic.MessageNewParams{
4307 Model: "claude-opus-5",
4307 Model: "claude-opus-5-5",
43084308 MaxTokens: 4096,
43094309 Container: anthropic.MessageCreateParamsContainerUnion{
43104310 OfContainers: &anthropic.ContainerParams{
from line 4345
43454345
43464346 // Skills render into the system prompt in a fixed, cache-friendly order
43474347 MessageCreateParams params1 = MessageCreateParams.builder()
4348 .model(Model.CLAUDE_OPUS_5)
4348 .model(Model.CLAUDE_OPUS_5_5)
43494349 .maxTokens(4096L)
43504350 .container(ContainerParams.builder()
43514351 .skills(List.of(
from line 4365
43654365
43664366 // Changing the Skills list ([xlsx] vs [xlsx, pptx]) changes the prefix: a cache miss, while an identical list is a cache hit
43674367 MessageCreateParams params2 = MessageCreateParams.builder()
4368 .model(Model.CLAUDE_OPUS_5)
4368 .model(Model.CLAUDE_OPUS_5_5)
43694369 .maxTokens(4096L)
43704370 .container(ContainerParams.builder()
43714371 .skills(List.of(
from line 4399
43994399 messages: [
44004400 ['role' => 'user', 'content' => 'Analyze sales data']
44014401 ],
4402 model: 'claude-opus-5',
4402 model: 'claude-opus-5-5',
44034403 container: [
44044404 'skills' => [
44054405 ['type' => 'anthropic', 'skillID' => 'xlsx', 'version' => 'latest']
from line 4417
44174417 messages: [
44184418 ['role' => 'user', 'content' => 'Create a presentation']
44194419 ],
4420 model: 'claude-opus-5',
4420 model: 'claude-opus-5-5',
44214421 container: [
44224422 'skills' => [
44234423 ['type' => 'anthropic', 'skillID' => 'xlsx', 'version' => 'latest'],
from line 4436
44364436
44374437 # Skills render into the system prompt in a fixed, cache-friendly order
44384438 response1 = client.messages.create(
4439 model: "claude-opus-5",
4439 model: "claude-opus-5-5",
44404440 max_tokens: 4096,
44414441 container: {
44424442 skills: [{ type: "anthropic", skill_id: "xlsx", version: "latest" }]
from line 4448
44484448
44494449 # Changing the Skills list ([xlsx] vs [xlsx, pptx]) changes the prefix: a cache miss, while an identical list is a cache hit
44504450 response2 = client.messages.create(
4451 model: "claude-opus-5",
4451 model: "claude-opus-5-5",
44524452 max_tokens: 4096,
44534453 container: {
44544454 skills: [
from line 4481
44814481 if ! RESULT=$(ant messages create \
44824482 --transform-error error.message \
44834483 --format-error yaml 2>&1 <<'YAML'
4484 model: claude-opus-5
4484 model: claude-opus-5-5
44854485 max_tokens: 4096
44864486 container:
44874487 skills:
from line 4514
45144514
45154515 try:
45164516 response = client.messages.create(
4517 model="claude-opus-5",
4517 model="claude-opus-5-5",
45184518 max_tokens=4096,
45194519 container={
45204520 "skills": [
from line 4541
45414541
45424542 try {
45434543 const response = await client.messages.create({
4544 model: "claude-opus-5",
4544 model: "claude-opus-5-5",
45454545 max_tokens: 4096,
45464546 container: {
45474547 skills: [
from line 4571
45714571 {
45724572 var parameters = new MessageCreateParams
45734573 {
4574 Model = "claude-opus-5",
4574 Model = "claude-opus-5-5",
45754575 MaxTokens = 4096,
45764576 Container = new ContainerParams
45774577 {
from line 4602
46024602 client := anthropic.NewClient()
46034603
46044604 response, err := client.Messages.New(context.TODO(), anthropic.MessageNewParams{
4605 Model: "claude-opus-5",
4605 Model: "claude-opus-5-5",
46064606 MaxTokens: 4096,
46074607 Container: anthropic.MessageCreateParamsContainerUnion{
46084608 OfContainers: &anthropic.ContainerParams{
from line 4647
46474647
46484648 try {
46494649 MessageCreateParams params = MessageCreateParams.builder()
4650 .model(Model.CLAUDE_OPUS_5)
4650 .model(Model.CLAUDE_OPUS_5_5)
46514651 .maxTokens(4096L)
46524652 .container(ContainerParams.builder()
46534653 .addSkill(SkillParams.builder()
from line 4683
46834683 messages: [
46844684 ['role' => 'user', 'content' => 'Process data']
46854685 ],
4686 model: 'claude-opus-5',
4686 model: 'claude-opus-5-5',
46874687 container: [
46884688 'skills' => [
46894689 [
from line 4712
47124712
47134713 begin
47144714 response = client.messages.create(
4715 model: "claude-opus-5",
4715 model: "claude-opus-5-5",
47164716 max_tokens: 4096,
47174717 container: {
47184718 skills: [
build-with-claude/streaming Changed · +46 / -46 lines
from line 13
1313<CodeGroup>
1414 ```bash CLI
1515 ant messages create --stream --format jsonl \
16 --model claude-opus-5 \
16 --model claude-opus-5-5 \
1717 --max-tokens 1024 \
1818 --message '{role: user, content: "Hello"}' \
1919 | jq -rj 'select(.delta.type? == "text_delta") | .delta.text'
from line 25
2525 with client.messages.stream(
2626 max_tokens=1024,
2727 messages=[{"role": "user", "content": "Hello"}],
28 model="claude-opus-5",
28 model="claude-opus-5-5",
2929 ) as stream:
3030 for text in stream.text_stream:
3131 print(text, end="", flush=True)
from line 37
3737 await client.messages
3838 .stream({
3939 messages: [{ role: "user", content: "Hello" }],
40 model: "claude-opus-5",
40 model: "claude-opus-5-5",
4141 max_tokens: 1024
4242 })
4343 .on("text", (text) => {
from line 50
5050
5151 var parameters = new MessageCreateParams
5252 {
53 Model = Model.ClaudeOpus5,
53 Model = Model.ClaudeOpus5_5,
5454 MaxTokens = 1024,
5555 Messages = [new() { Role = Role.User, Content = "Hello" }]
5656 };
from line 65
6565 client := anthropic.NewClient()
6666
6767 stream := client.Messages.NewStreaming(context.TODO(), anthropic.MessageNewParams{
68 Model: anthropic.ModelClaudeOpus5,
68 Model: anthropic.ModelClaudeOpus5_5,
6969 MaxTokens: 1024,
7070 Messages: []anthropic.MessageParam{
7171 anthropic.NewUserMessage(anthropic.NewTextBlock("Hello")),
from line 91
9191 AnthropicClient client = AnthropicOkHttpClient.fromEnv();
9292
9393 MessageCreateParams params = MessageCreateParams.builder()
94 .model(Model.CLAUDE_OPUS_5)
94 .model(Model.CLAUDE_OPUS_5_5)
9595 .maxTokens(1024L)
9696 .addUserMessage("Hello")
9797 .build();
from line 115
115115 messages: [
116116 ['role' => 'user', 'content' => 'Hello']
117117 ],
118 model: 'claude-opus-5',
118 model: 'claude-opus-5-5',
119119 );
120120
121121 foreach ($stream as $message) {
from line 127
127127 client = Anthropic::Client.new
128128
129129 stream = client.messages.stream(
130 model: "claude-opus-5",
130 model: "claude-opus-5-5",
131131 max_tokens: 1024,
132132 messages: [{ role: "user", content: "Hello" }]
133133 )
from line 146
146146 # accumulate into a final Message. For long generations, stream the
147147 # raw events:
148148 ant messages create --stream --format jsonl <<'YAML'
149 model: claude-opus-5
149 model: claude-opus-5-5
150150 max_tokens: 128000
151151 messages:
152152 - role: user
from line 160
160160 with client.messages.stream(
161161 max_tokens=128000,
162162 messages=[{"role": "user", "content": "Write a detailed analysis..."}],
163 model="claude-opus-5",
163 model="claude-opus-5-5",
164164 ) as stream:
165165 message = stream.get_final_message()
166166
from line 175
175175 const stream = client.messages.stream({
176176 max_tokens: 128000,
177177 messages: [{ role: "user", content: "Write a detailed analysis..." }],
178 model: "claude-opus-5"
178 model: "claude-opus-5-5"
179179 });
180180
181181 const message = await stream.finalMessage();
from line 190
190190
191191 var parameters = new MessageCreateParams
192192 {
193 Model = Model.ClaudeOpus5,
193 Model = Model.ClaudeOpus5_5,
194194 MaxTokens = 128000,
195195 Messages = [new() { Role = Role.User, Content = "Write a detailed analysis..." }]
196196 };
from line 208
208208 client := anthropic.NewClient()
209209
210210 stream := client.Messages.NewStreaming(context.TODO(), anthropic.MessageNewParams{
211 Model: anthropic.ModelClaudeOpus5,
211 Model: anthropic.ModelClaudeOpus5_5,
212212 MaxTokens: 128000,
213213 Messages: []anthropic.MessageParam{
214214 anthropic.NewUserMessage(anthropic.NewTextBlock("Write a detailed analysis...")),
from line 237
237237 AnthropicClient client = AnthropicOkHttpClient.fromEnv();
238238
239239 MessageCreateParams params = MessageCreateParams.builder()
240 .model(Model.CLAUDE_OPUS_5)
240 .model(Model.CLAUDE_OPUS_5_5)
241241 .maxTokens(128000L)
242242 .addUserMessage("Write a detailed analysis...")
243243 .build();
from line 261
261261 messages: [
262262 ['role' => 'user', 'content' => 'Write a detailed analysis...']
263263 ],
264 model: 'claude-opus-5',
264 model: 'claude-opus-5-5',
265265 );
266266
267267 $fullText = '';
from line 278
278278 client = Anthropic::Client.new
279279
280280 message = client.messages.stream(
281 model: "claude-opus-5",
281 model: "claude-opus-5-5",
282282 max_tokens: 128000,
283283 messages: [{ role: "user", content: "Write a detailed analysis..." }]
284284 ).accumulated_message
from line 402
402402 -H "content-type: application/json" \
403403 -H "x-api-key: $ANTHROPIC_API_KEY" \
404404 -d '{
405 "model": "claude-opus-5",
405 "model": "claude-opus-5-5",
406406 "messages": [{"role": "user", "content": "Hello"}],
407407 "max_tokens": 256,
408408 "stream": true
from line 411
411411
412412 ```bash CLI
413413 ant messages create --stream --format jsonl \
414 --model claude-opus-5 \
414 --model claude-opus-5-5 \
415415 --max-tokens 256 \
416416 --message '{role: user, content: Hello}'
417417 ```
from line 420
420420 client = anthropic.Anthropic()
421421
422422 with client.messages.stream(
423 model="claude-opus-5",
423 model="claude-opus-5-5",
424424 messages=[{"role": "user", "content": "Hello"}],
425425 max_tokens=256,
426426 ) as stream:
from line 432
432432 const client = new Anthropic();
433433
434434 const stream = client.messages.stream({
435 model: "claude-opus-5",
435 model: "claude-opus-5-5",
436436 messages: [{ role: "user", content: "Hello" }],
437437 max_tokens: 256
438438 });
from line 449
449449
450450 var parameters = new MessageCreateParams
451451 {
452 Model = Model.ClaudeOpus5,
452 Model = Model.ClaudeOpus5_5,
453453 MaxTokens = 256,
454454 Messages = [new() { Role = Role.User, Content = "Hello" }]
455455 };
from line 464
464464 client := anthropic.NewClient()
465465
466466 stream := client.Messages.NewStreaming(context.TODO(), anthropic.MessageNewParams{
467 Model: anthropic.ModelClaudeOpus5,
467 Model: anthropic.ModelClaudeOpus5_5,
468468 MaxTokens: 256,
469469 Messages: []anthropic.MessageParam{
470470 anthropic.NewUserMessage(anthropic.NewTextBlock("Hello")),
from line 490
490490 AnthropicClient client = AnthropicOkHttpClient.fromEnv();
491491
492492 MessageCreateParams params = MessageCreateParams.builder()
493 .model(Model.CLAUDE_OPUS_5)
493 .model(Model.CLAUDE_OPUS_5_5)
494494 .maxTokens(256L)
495495 .addUserMessage("Hello")
496496 .build();
from line 514
514514 messages: [
515515 ['role' => 'user', 'content' => 'Hello']
516516 ],
517 model: 'claude-opus-5',
517 model: 'claude-opus-5-5',
518518 );
519519
520520 foreach ($stream as $message) {
from line 526
526526 client = Anthropic::Client.new
527527
528528 stream = client.messages.stream(
529 model: "claude-opus-5",
529 model: "claude-opus-5-5",
530530 messages: [{ role: "user", content: "Hello" }],
531531 max_tokens: 256
532532 )
from line 537
537537
538538```sse Response
539539event: message_start
540data: {"type": "message_start", "message": {"id": "msg_1nZdL29xx5MUA1yADyHTEsnR8uuvGzszyY", "type": "message", "role": "assistant", "content": [], "model": "claude-opus-5", "stop_reason": null, "stop_sequence": null, "usage": {"input_tokens": 25, "output_tokens": 1}}}
540data: {"type": "message_start", "message": {"id": "msg_1nZdL29xx5MUA1yADyHTEsnR8uuvGzszyY", "type": "message", "role": "assistant", "content": [], "model": "claude-opus-5-5", "stop_reason": null, "stop_sequence": null, "usage": {"input_tokens": 25, "output_tokens": 1}}}
541541
542542event: content_block_start
543543data: {"type": "content_block_start", "index": 0, "content_block": {"type": "text", "text": ""}}
from line 973
973973 -H "anthropic-version: 2023-06-01" \
974974 -H "content-type: application/json" \
975975 -d '{
976 "model": "claude-opus-5",
976 "model": "claude-opus-5-5",
977977 "max_tokens": 20000,
978978 "stream": true,
979979 "thinking": {
from line 991
991991
992992 ```bash CLI
993993 ant messages create --stream --format jsonl \
994 --model claude-opus-5 \
994 --model claude-opus-5-5 \
995995 --max-tokens 20000 \
996996 --thinking '{type: adaptive, display: summarized}' \
997997 --message '{role: user, content: What is the greatest common divisor of 1071 and 462?}'
from line 1001
10011001 client = anthropic.Anthropic()
10021002
10031003 with client.messages.stream(
1004 model="claude-opus-5",
1004 model="claude-opus-5-5",
10051005 max_tokens=20000,
10061006 thinking={"type": "adaptive", "display": "summarized"},
10071007 messages=[
from line 1025
10251025 const client = new Anthropic();
10261026
10271027 const stream = client.messages.stream({
1028 model: "claude-opus-5",
1028 model: "claude-opus-5-5",
10291029 max_tokens: 20000,
10301030 thinking: { type: "adaptive", display: "summarized" },
10311031 messages: [
from line 1058
10581058
10591059 var parameters = new MessageCreateParams
10601060 {
1061 Model = Model.ClaudeOpus5,
1061 Model = Model.ClaudeOpus5_5,
10621062 MaxTokens = 20000,
10631063 Thinking = new ThinkingConfigAdaptive { Display = Display.Summarized },
10641064 Messages = [new() { Role = Role.User, Content = "What is the greatest common divisor of 1071 and 462?" }]
from line 1074
10741074 client := anthropic.NewClient()
10751075
10761076 stream := client.Messages.NewStreaming(context.TODO(), anthropic.MessageNewParams{
1077 Model: anthropic.ModelClaudeOpus5,
1077 Model: anthropic.ModelClaudeOpus5_5,
10781078 MaxTokens: 20000,
10791079 Thinking: anthropic.ThinkingConfigParamUnion{
10801080 OfAdaptive: &anthropic.ThinkingConfigAdaptiveParam{
from line 1107
11071107 AnthropicClient client = AnthropicOkHttpClient.fromEnv();
11081108
11091109 MessageCreateParams params = MessageCreateParams.builder()
1110 .model(Model.CLAUDE_OPUS_5)
1110 .model(Model.CLAUDE_OPUS_5_5)
11111111 .maxTokens(20000L)
11121112 .thinking(ThinkingConfigAdaptive.builder()
11131113 .display(ThinkingConfigAdaptive.Display.SUMMARIZED)
from line 1137
11371137 messages: [
11381138 ['role' => 'user', 'content' => 'What is the greatest common divisor of 1071 and 462?']
11391139 ],
1140 model: 'claude-opus-5',
1140 model: 'claude-opus-5-5',
11411141 thinking: ['type' => 'adaptive', 'display' => 'summarized'],
11421142 );
11431143
from line 1150
11501150 client = Anthropic::Client.new
11511151
11521152 stream = client.messages.stream(
1153 model: "claude-opus-5",
1153 model: "claude-opus-5-5",
11541154 max_tokens: 20000,
11551155 thinking: { type: "adaptive", display: "summarized" },
11561156 messages: [
from line 1174
11741174
11751175```sse Response
11761176event: message_start
1177data: {"type": "message_start", "message": {"id": "msg_01...", "type": "message", "role": "assistant", "content": [], "model": "claude-opus-5", "stop_reason": null, "stop_sequence": null}}
1177data: {"type": "message_start", "message": {"id": "msg_01...", "type": "message", "role": "assistant", "content": [], "model": "claude-opus-5-5", "stop_reason": null, "stop_sequence": null}}
11781178
11791179event: content_block_start
11801180data: {"type": "content_block_start", "index": 0, "content_block": {"type": "thinking", "thinking": "", "signature": ""}}
from line 1224
12241224 -H "anthropic-version: 2023-06-01" \
12251225 -H "content-type: application/json" \
12261226 -d '{
1227 "model": "claude-opus-5",
1227 "model": "claude-opus-5-5",
12281228 "max_tokens": 1024,
12291229 "stream": true,
12301230 "tools": [
from line 1245
12451245
12461246 ```bash CLI
12471247 ant messages create --stream --format jsonl \
1248 --model claude-opus-5 \
1248 --model claude-opus-5-5 \
12491249 --max-tokens 1024 \
12501250 --tool '{type: web_search_20250305, name: web_search, max_uses: 5}' \
12511251 --message '{role: user, content: What is the weather like in New York City today?}'
from line 1255
12551255 client = anthropic.Anthropic()
12561256
12571257 with client.messages.stream(
1258 model="claude-opus-5",
1258 model="claude-opus-5-5",
12591259 max_tokens=1024,
12601260 tools=[{"type": "web_search_20250305", "name": "web_search", "max_uses": 5}],
12611261 messages=[
from line 1270
12701270 const client = new Anthropic();
12711271
12721272 const stream = client.messages.stream({
1273 model: "claude-opus-5",
1273 model: "claude-opus-5-5",
12741274 max_tokens: 1024,
12751275 tools: [{ type: "web_search_20250305", name: "web_search", max_uses: 5 }],
12761276 messages: [{ role: "user", content: "What is the weather like in New York City today?" }]
from line 1291
12911291
12921292 var parameters = new MessageCreateParams
12931293 {
1294 Model = Model.ClaudeOpus5,
1294 Model = Model.ClaudeOpus5_5,
12951295 MaxTokens = 1024,
12961296 Tools = [new ToolUnion(new WebSearchTool20250305() { MaxUses = 5 })],
12971297 Messages = [new() { Role = Role.User, Content = "What is the weather like in New York City today?" }]
from line 1307
13071307 client := anthropic.NewClient()
13081308
13091309 stream := client.Messages.NewStreaming(context.TODO(), anthropic.MessageNewParams{
1310 Model: anthropic.ModelClaudeOpus5,
1310 Model: anthropic.ModelClaudeOpus5_5,
13111311 MaxTokens: 1024,
13121312 Tools: []anthropic.ToolUnionParam{
13131313 {
from line 1340
13401340 AnthropicClient client = AnthropicOkHttpClient.fromEnv();
13411341
13421342 MessageCreateParams params = MessageCreateParams.builder()
1343 .model(Model.CLAUDE_OPUS_5)
1343 .model(Model.CLAUDE_OPUS_5_5)
13441344 .maxTokens(1024L)
13451345 .addTool(WebSearchTool20250305.builder()
13461346 .maxUses(5L)
from line 1367
13671367 messages: [
13681368 ['role' => 'user', 'content' => 'What is the weather like in New York City today?']
13691369 ],
1370 model: 'claude-opus-5',
1370 model: 'claude-opus-5-5',
13711371 tools: [
13721372 ['type' => 'web_search_20250305', 'name' => 'web_search', 'max_uses' => 5]
13731373 ],
from line 1382
13821382 client = Anthropic::Client.new
13831383
13841384 stream = client.messages.stream(
1385 model: :"claude-opus-5",
1385 model: :"claude-opus-5-5",
13861386 max_tokens: 1024,
13871387 tools: [
13881388 {
from line 1405
14051405
14061406```sse Response
14071407event: message_start
1408data: {"type":"message_start","message":{"id":"msg_01G...","type":"message","role":"assistant","model":"claude-opus-5","content":[],"stop_reason":null,"stop_sequence":null,"usage":{"input_tokens":2679,"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"output_tokens":3}}}
1408data: {"type":"message_start","message":{"id":"msg_01G...","type":"message","role":"assistant","model":"claude-opus-5-5","content":[],"stop_reason":null,"stop_sequence":null,"usage":{"input_tokens":2679,"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"output_tokens":3}}}
14091409
14101410event: content_block_start
14111411data: {"type":"content_block_start","index":0,"content_block":{"type":"text","text":""}}
build-with-claude/structured-outputs Changed · +68 / -67 lines
from line 13
1313 - claude-fable-5
1414 - claude-mythos-5
1515 - claude-mythos-preview
16 - claude-opus-5-5
1617 - claude-opus-5
1718 - claude-opus-4-8
1819 - claude-opus-4-7
from line 77
7677 -H "x-api-key: $ANTHROPIC_API_KEY" \
7778 -H "anthropic-version: 2023-06-01" \
7879 -d '{
79 "model": "claude-opus-5",
80 "model": "claude-opus-5-5",
8081 "max_tokens": 1024,
8182 "messages": [
8283 {
from line 108
107108 ant messages create \
108109 --transform 'content.#(type=="text").text|@fromstr' \
109110 --format jsonl <<'YAML'
110 model: claude-opus-5
111 model: claude-opus-5-5
111112 max_tokens: 1024
112113 messages:
113114 - role: user
from line 135
134135 client = anthropic.Anthropic()
135136
136137 response = client.messages.create(
137 model="claude-opus-5",
138 model="claude-opus-5-5",
138139 max_tokens=1024,
139140 messages=[
140141 {
from line 167
166167 const client = new Anthropic();
167168
168169 const response = await client.messages.create({
169 model: "claude-opus-5",
170 model: "claude-opus-5-5",
170171 max_tokens: 1024,
171172 messages: [
172173 {
from line 210
209210
210211 var parameters = new MessageCreateParams
211212 {
212 Model = Model.ClaudeOpus5,
213 Model = Model.ClaudeOpus5_5,
213214 MaxTokens = 1024,
214215 Messages = [new() { Role = Role.User, Content = "Extract the key information from this email: John Smith ([email protected]) is interested in our Enterprise plan." }],
215216 OutputConfig = new OutputConfig
from line 243
242243
243244 response, _ := client.Messages.New(context.Background(),
244245 anthropic.MessageNewParams{
245 Model: anthropic.ModelClaudeOpus5,
246 Model: anthropic.ModelClaudeOpus5_5,
246247 MaxTokens: 1024,
247248 Messages: []anthropic.MessageParam{
248249 anthropic.NewUserMessage(
from line 287
286287 AnthropicClient client = AnthropicOkHttpClient.fromEnv();
287288
288289 StructuredMessageCreateParams<ContactInfo> params = MessageCreateParams.builder()
289 .model(Model.CLAUDE_OPUS_5)
290 .model(Model.CLAUDE_OPUS_5_5)
290291 .maxTokens(1024)
291292 .addUserMessage("Extract the key information from this email: John Smith ([email protected]) is interested in our Enterprise plan.")
292293 .outputConfig(ContactInfo.class)
from line 312
311312 'content' => 'Extract the key information from this email: John Smith ([email protected]) is interested in our Enterprise plan.'
312313 ]
313314 ],
314 model: 'claude-opus-5',
315 model: 'claude-opus-5-5',
315316 outputConfig: [
316317 'format' => [
317318 'type' => 'json_schema',
from line 339
338339 client = Anthropic::Client.new
339340
340341 response = client.messages.create(
341 model: "claude-opus-5",
342 model: "claude-opus-5-5",
342343 max_tokens: 1024,
343344 messages: [
344345 {
from line 422
421422 ant messages create \
422423 --transform 'content.#(type=="text").text|@fromstr|{name,email}' \
423424 --format yaml <<'YAML'
424 model: claude-opus-5
425 model: claude-opus-5-5
425426 max_tokens: 1024
426427 messages:
427428 - role: user
from line 460
459460 client = Anthropic()
460461
461462 response = client.messages.parse(
462 model="claude-opus-5",
463 model="claude-opus-5-5",
463464 max_tokens=1024,
464465 messages=[
465466 {
from line 488
487488 const client = new Anthropic();
488489
489490 const response = await client.messages.parse({
490 model: "claude-opus-5",
491 model: "claude-opus-5-5",
491492 max_tokens: 1024,
492493 messages: [
493494 {
from line 513
512513
513514 var response = await client.Messages.Create(new MessageCreateParams
514515 {
515 Model = Model.ClaudeOpus5,
516 Model = Model.ClaudeOpus5_5,
516517 MaxTokens = 1024,
517518 Messages = [new() {
518519 Role = Role.User,
from line 575
574575 schema := generateSchema(&ContactInfo{})
575576
576577 message, _ := client.Messages.New(context.TODO(), anthropic.MessageNewParams{
577 Model: anthropic.ModelClaudeOpus5,
578 Model: anthropic.ModelClaudeOpus5_5,
578579 MaxTokens: 1024,
579580 Messages: []anthropic.MessageParam{
580581 anthropic.NewUserMessage(anthropic.NewTextBlock(
from line 611
610611 AnthropicClient client = AnthropicOkHttpClient.fromEnv();
611612
612613 StructuredMessageCreateParams<ContactInfo> createParams = MessageCreateParams.builder()
613 .model(Model.CLAUDE_OPUS_5)
614 .model(Model.CLAUDE_OPUS_5_5)
614615 .maxTokens(1024)
615616 .outputConfig(ContactInfo.class)
616617 .addUserMessage("Extract the key information from this email: John Smith ([email protected]) is interested in our Enterprise plan and wants to schedule a demo for next Tuesday at 2pm.")
from line 646
645646 messages: [
646647 ['role' => 'user', 'content' => 'Extract the key information from this email: John Smith ([email protected]) is interested in our Enterprise plan and wants to schedule a demo for next Tuesday at 2pm.'],
647648 ],
648 model: 'claude-opus-5',
649 model: 'claude-opus-5-5',
649650 outputConfig: ['format' => ContactInfo::class],
650651 );
651652
from line 667
666667 end
667668
668669 message = client.messages.create(
669 model: "claude-opus-5",
670 model: "claude-opus-5-5",
670671 max_tokens: 1024,
671672 messages: [{
672673 role: "user",
from line 695
694695 ant messages create \
695696 --transform 'content.#(type=="text").text|@fromstr|{name,email}' \
696697 --format yaml <<'YAML'
697 model: claude-opus-5
698 model: claude-opus-5-5
698699 max_tokens: 1024
699700 messages:
700701 - role: user
from line 736
735736 plan_interest: str
736737 # ...
737738 response = client.messages.parse(
738 model="claude-opus-5",
739 model="claude-opus-5-5",
739740 max_tokens=1024,
740741 messages=[
741742 {
from line 768
767768 schema["properties"]["custom_field"] = {"type": "string"}
768769
769770 response = client.messages.create(
770 model="claude-opus-5",
771 model="claude-opus-5-5",
771772 max_tokens=1024,
772773 messages=[{"role": "user", "content": "..."}],
773774 output_config={
from line 796
795796 const client = new Anthropic();
796797
797798 const response = await client.messages.parse({
798 model: "claude-opus-5",
799 model: "claude-opus-5-5",
799800 max_tokens: 1024,
800801 messages: [
801802 {
from line 823
822823 const client = new Anthropic();
823824
824825 const response = await client.messages.parse({
825 model: "claude-opus-5",
826 model: "claude-opus-5-5",
826827 max_tokens: 1024,
827828 messages: [
828829 {
from line 868
867868
868869 var response = await client.Messages.Create(new MessageCreateParams
869870 {
870 Model = Model.ClaudeOpus5,
871 Model = Model.ClaudeOpus5_5,
871872 MaxTokens = 1024,
872873 Messages = [new() {
873874 Role = Role.User,
from line 934
933934 schema := generateSchema(&ContactInfo{})
934935
935936 message, _ := client.Messages.New(context.TODO(), anthropic.MessageNewParams{
936 Model: anthropic.ModelClaudeOpus5,
937 Model: anthropic.ModelClaudeOpus5_5,
937938 MaxTokens: 1024,
938939 Messages: []anthropic.MessageParam{
939940 anthropic.NewUserMessage(anthropic.NewTextBlock(
from line 981
980981 AnthropicClient client = AnthropicOkHttpClient.fromEnv();
981982
982983 StructuredMessageCreateParams<ContactInfo> createParams = MessageCreateParams.builder()
983 .model(Model.CLAUDE_OPUS_5)
984 .model(Model.CLAUDE_OPUS_5_5)
984985 .maxTokens(1024)
985986 .outputConfig(ContactInfo.class)
986987 .addUserMessage("Extract contact info: John Smith, [email protected], interested in the Pro plan")
from line 1021
10201021
10211022 void main() {
10221023 StructuredMessageCreateParams<BookList> createParams = MessageCreateParams.builder()
1023 .model(Model.CLAUDE_OPUS_5)
1024 .model(Model.CLAUDE_OPUS_5_5)
10241025 .maxTokens(2048)
10251026 .outputConfig(BookList.class, JsonSchemaLocalValidation.NO)
10261027 .addUserMessage("List some famous late twentieth century novels.")
from line 1204
12031204 .build();
12041205
12051206 MessageCreateParams createParams = MessageCreateParams.builder()
1206 .model(Model.CLAUDE_OPUS_5)
1207 .model(Model.CLAUDE_OPUS_5_5)
12071208 .maxTokens(1024)
12081209 .outputConfig(outputConfig)
12091210 .addUserMessage(
from line 1248
12471248 messages: [
12481249 ['role' => 'user', 'content' => 'Extract the key information from this email: John Smith ([email protected]) is interested in our Enterprise plan.'],
12491250 ],
1250 model: 'claude-opus-5',
1251 model: 'claude-opus-5-5',
12511252 outputConfig: ['format' => ContactInfo::class],
12521253 );
12531254
from line 1320
13191320 messages: [
13201321 ['role' => 'user', 'content' => 'Extract the key information from this email: John Smith ([email protected]) is interested in our Enterprise plan.'],
13211322 ],
1322 model: 'claude-opus-5',
1323 model: 'claude-opus-5-5',
13231324 outputConfig: OutputConfig::with(format: JSONOutputFormat::with(schema: [
13241325 'type' => 'object',
13251326 'properties' => [
from line 1355
13541355 client = Anthropic::Client.new
13551356
13561357 message = client.messages.create(
1357 model: "claude-opus-5",
1358 model: "claude-opus-5-5",
13581359 max_tokens: 1024,
13591360 messages: [
13601361 {
from line 1389
13881389 end
13891390
13901391 message = client.messages.create(
1391 model: "claude-opus-5",
1392 model: "claude-opus-5-5",
13921393 max_tokens: 1024,
13931394 messages: [{role: "user", content: "give me some famous numbers"}],
13941395 output_config: {format: Output}
from line 1429
14281429 -H "x-api-key: $ANTHROPIC_API_KEY" \
14291430 -H "anthropic-version: 2023-06-01" \
14301431 -d '{
1431 "model": "claude-opus-5",
1432 "model": "claude-opus-5-5",
14321433 "max_tokens": 4096,
14331434 "messages": [
14341435 {
from line 1464
14631464 ant messages create \
14641465 --transform 'content.#(type=="text").text|@fromstr' \
14651466 --format jsonl <<'YAML'
1466 model: claude-opus-5
1467 model: claude-opus-5-5
14671468 max_tokens: 4096
14681469 messages:
14691470 - role: user
from line 1503
15021503 invoice_text = "Invoice #12345, Date: 2024-01-15, Total: $500.00"
15031504
15041505 response = client.messages.parse(
1505 model="claude-opus-5",
1506 model="claude-opus-5-5",
15061507 max_tokens=4096,
15071508 output_format=Invoice,
15081509 messages=[
from line 1530
15291530
15301531 const invoiceText = "Invoice #12345, Date: 2024-01-15, Total: $500.00";
15311532 const response = await client.messages.parse({
1532 model: "claude-opus-5",
1533 model: "claude-opus-5-5",
15331534 max_tokens: 4096,
15341535 output_config: { format: zodOutputFormat(InvoiceSchema) },
15351536 messages: [{ role: "user", content: `Extract invoice data from: ${invoiceText}` }]
from line 1545
15441545
15451546 var parameters = new MessageCreateParams
15461547 {
1547 Model = Model.ClaudeOpus5,
1548 Model = Model.ClaudeOpus5_5,
15481549 MaxTokens = 4096,
15491550 OutputConfig = new OutputConfig
15501551 {
from line 1613
16121613 }
16131614
16141615 response, err := client.Messages.New(context.TODO(), anthropic.MessageNewParams{
1615 Model: anthropic.ModelClaudeOpus5,
1616 Model: anthropic.ModelClaudeOpus5_5,
16161617 MaxTokens: 4096,
16171618 OutputConfig: anthropic.OutputConfigParam{
16181619 Format: anthropic.JSONOutputFormatParam{
from line 1672
16711672 String invoiceText = "Invoice #12345, Date: 2024-01-15, Total: $500.00";
16721673
16731674 StructuredMessageCreateParams<Invoice> params = MessageCreateParams.builder()
1674 .model(Model.CLAUDE_OPUS_5)
1675 .model(Model.CLAUDE_OPUS_5_5)
16751676 .maxTokens(4096L)
16761677 .outputConfig(Invoice.class)
16771678 .addUserMessage("Extract invoice data from: " + invoiceText)
from line 1710
17091710 messages: [
17101711 ['role' => 'user', 'content' => "Extract invoice data from: $invoiceText"]
17111712 ],
1712 model: 'claude-opus-5',
1713 model: 'claude-opus-5-5',
17131714 outputConfig: ['format' => Invoice::class],
17141715 );
17151716
from line 1739
17381739 invoice_text = "Invoice #12345, Date: 2024-01-15, Total: $500.00"
17391740
17401741 message = client.messages.create(
1741 model: "claude-opus-5",
1742 model: "claude-opus-5-5",
17421743 max_tokens: 4096,
17431744 output_config: {format: Invoice},
17441745 messages: [
from line 1763
17621763 -H "x-api-key: $ANTHROPIC_API_KEY" \
17631764 -H "anthropic-version: 2023-06-01" \
17641765 -d '{
1765 "model": "claude-opus-5",
1766 "model": "claude-opus-5-5",
17661767 "max_tokens": 1024,
17671768 "messages": [
17681769 {
from line 1794
17931794 ant messages create \
17941795 --transform 'content.#(type=="text").text|@fromstr' \
17951796 --format jsonl <<'YAML'
1796 model: claude-opus-5
1797 model: claude-opus-5-5
17971798 max_tokens: 1024
17981799 messages:
17991800 - role: user
from line 1839
18381839
18391840 feedback_text = "Great product, but the delivery was slow."
18401841 response = client.messages.parse(
1841 model="claude-opus-5",
1842 model="claude-opus-5-5",
18421843 max_tokens=1024,
18431844 output_format=Classification,
18441845 messages=[{"role": "user", "content": f"Classify this feedback: {feedback_text}"}],
from line 1863
18621863
18631864 const feedbackText = "Great product, but the delivery was slow.";
18641865 const response = await client.messages.parse({
1865 model: "claude-opus-5",
1866 model: "claude-opus-5-5",
18661867 max_tokens: 1024,
18671868 output_config: { format: zodOutputFormat(ClassificationSchema) },
18681869 messages: [{ role: "user", content: `Classify this feedback: ${feedbackText}` }]
from line 1877
18761877
18771878 var parameters = new MessageCreateParams
18781879 {
1879 Model = Model.ClaudeOpus5,
1880 Model = Model.ClaudeOpus5_5,
18801881 MaxTokens = 1024,
18811882 Messages = [new() { Role = Role.User, Content = $"Classify this feedback: {feedbackText}" }],
18821883 OutputConfig = new OutputConfig
from line 1921
19201921 }
19211922
19221923 response, err := client.Messages.New(context.TODO(), anthropic.MessageNewParams{
1923 Model: anthropic.ModelClaudeOpus5,
1924 Model: anthropic.ModelClaudeOpus5_5,
19241925 MaxTokens: 1024,
19251926 OutputConfig: anthropic.OutputConfigParam{
19261927 Format: anthropic.JSONOutputFormatParam{
from line 1968
19671968 String feedbackText = "Great product, fast shipping!";
19681969
19691970 StructuredMessageCreateParams<Classification> params = MessageCreateParams.builder()
1970 .model(Model.CLAUDE_OPUS_5)
1971 .model(Model.CLAUDE_OPUS_5_5)
19711972 .maxTokens(1024L)
19721973 .outputConfig(Classification.class)
19731974 .addUserMessage("Classify this feedback: " + feedbackText)
from line 2005
20042005 messages: [
20052006 ['role' => 'user', 'content' => "Classify this feedback: {$feedbackText}"]
20062007 ],
2007 model: 'claude-opus-5',
2008 model: 'claude-opus-5-5',
20082009 outputConfig: ['format' => Classification::class],
20092010 );
20102011
from line 2028
20272028 feedback_text = "Great product, fast shipping!"
20282029
20292030 message = client.messages.create(
2030 model: "claude-opus-5",
2031 model: "claude-opus-5-5",
20312032 max_tokens: 1024,
20322033 output_config: {format: Classification},
20332034 messages: [
from line 2050
20492050 -H "x-api-key: $ANTHROPIC_API_KEY" \
20502051 -H "anthropic-version: 2023-06-01" \
20512052 -d '{
2052 "model": "claude-opus-5",
2053 "model": "claude-opus-5-5",
20532054 "max_tokens": 1024,
20542055 "messages": [
20552056 {
from line 2084
20832084 ant messages create \
20842085 --transform 'content.#(type=="text").text' \
20852086 --raw-output <<'YAML'
2086 model: claude-opus-5
2087 model: claude-opus-5-5
20872088 max_tokens: 1024
20882089 output_config:
20892090 format:
from line 2130
21292130
21302131
21312132 response = client.messages.parse(
2132 model="claude-opus-5",
2133 model="claude-opus-5-5",
21332134 max_tokens=1024,
21342135 output_format=APIResponse,
21352136 messages=[{"role": "user", "content": "Process this request: ..."}],
from line 2153
21522153 });
21532154
21542155 const response = await client.messages.parse({
2155 model: "claude-opus-5",
2156 model: "claude-opus-5-5",
21562157 max_tokens: 1024,
21572158 output_config: { format: zodOutputFormat(APIResponseSchema) },
21582159 messages: [{ role: "user", content: "Process this request..." }]
from line 2165
21642165 ```csharp C#
21652166 var parameters = new MessageCreateParams
21662167 {
2167 Model = Model.ClaudeOpus5,
2168 Model = Model.ClaudeOpus5_5,
21682169 MaxTokens = 1024,
21692170 Messages = [new() { Role = Role.User, Content = "Process this request: ..." }],
21702171 OutputConfig = new OutputConfig
from line 2201
22002201 client := anthropic.NewClient()
22012202
22022203 response, err := client.Messages.New(context.TODO(), anthropic.MessageNewParams{
2203 Model: anthropic.ModelClaudeOpus5,
2204 Model: anthropic.ModelClaudeOpus5_5,
22042205 MaxTokens: 1024,
22052206 OutputConfig: anthropic.OutputConfigParam{
22062207 Format: anthropic.JSONOutputFormatParam{
from line 2292
22912292 AnthropicClient client = AnthropicOkHttpClient.fromEnv();
22922293
22932294 StructuredMessageCreateParams<APIResponse> params = MessageCreateParams.builder()
2294 .model(Model.CLAUDE_OPUS_5)
2295 .model(Model.CLAUDE_OPUS_5_5)
22952296 .maxTokens(1024L)
22962297 .outputConfig(APIResponse.class)
22972298 .addUserMessage("Process this request: ...")
from line 2335
23342335 messages: [
23352336 ['role' => 'user', 'content' => 'Process this request: ...']
23362337 ],
2337 model: 'claude-opus-5',
2338 model: 'claude-opus-5-5',
23382339 outputConfig: ['format' => APIResponse::class],
23392340 );
23402341
from line 2369
23682369 end
23692370
23702371 message = client.messages.create(
2371 model: "claude-opus-5",
2372 model: "claude-opus-5-5",
23722373 max_tokens: 1024,
23732374 output_config: {format: APIResponse},
23742375 messages: [
from line 2402
24012402 -H "x-api-key: $ANTHROPIC_API_KEY" \
24022403 -H "anthropic-version: 2023-06-01" \
24032404 -d '{
2404 "model": "claude-opus-5",
2405 "model": "claude-opus-5-5",
24052406 "max_tokens": 1024,
24062407 "messages": [
24072408 {
from line 2444
24432444
24442445 ```bash CLI
24452446 ant messages create <<'YAML'
2446 model: claude-opus-5
2447 model: claude-opus-5-5
24472448 max_tokens: 1024
24482449 messages:
24492450 - role: user
from line 2483
24822483
24832484 ```python Python
24842485 response = client.messages.create(
2485 model="claude-opus-5",
2486 model="claude-opus-5-5",
24862487 max_tokens=1024,
24872488 messages=[
24882489 {
from line 2529
25282529
25292530 ```typescript TypeScript
25302531 const response = await client.messages.create({
2531 model: "claude-opus-5",
2532 model: "claude-opus-5-5",
25322533 max_tokens: 1024,
25332534 messages: [{ role: "user", content: "Help me plan a trip to Paris departing May 15, 2026" }],
25342535 // JSON outputs: structured response format
from line 2583
25822583 ```csharp C#
25832584 var parameters = new MessageCreateParams
25842585 {
2585 Model = Model.ClaudeOpus5,
2586 Model = Model.ClaudeOpus5_5,
25862587 MaxTokens = 1024,
25872588 Messages = [new() { Role = Role.User, Content = "Help me plan a trip to Paris departing May 15, 2026" }],
25882589 // JSON outputs: structured response format
from line 2633
26322633 client := anthropic.NewClient()
26332634
26342635 response, err := client.Messages.New(context.TODO(), anthropic.MessageNewParams{
2635 Model: anthropic.ModelClaudeOpus5,
2636 Model: anthropic.ModelClaudeOpus5_5,
26362637 MaxTokens: 1024,
26372638 Messages: []anthropic.MessageParam{
26382639 anthropic.NewUserMessage(anthropic.NewTextBlock("Help me plan a trip to Paris departing May 15, 2026")),
from line 2700
26992700 .build();
27002701
27012702 MessageCreateParams params = MessageCreateParams.builder()
2702 .model(Model.CLAUDE_OPUS_5)
2703 .model(Model.CLAUDE_OPUS_5_5)
27032704 .maxTokens(1024L)
27042705 .addUserMessage("Help me plan a trip to Paris departing May 15, 2026")
27052706 .outputConfig(OutputConfig.builder()
from line 2738
27372738 messages: [
27382739 ['role' => 'user', 'content' => 'Help me plan a trip to Paris departing May 15, 2026']
27392740 ],
2740 model: 'claude-opus-5',
2741 model: 'claude-opus-5-5',
27412742 // JSON outputs: structured response format
27422743 outputConfig: ['format' => TripPlan::class],
27432744 // Strict tool use: guaranteed tool parameters
from line 2772
27712772 client = Anthropic::Client.new
27722773
27732774 message = client.messages.create(
2774 model: "claude-opus-5",
2775 model: "claude-opus-5-5",
27752776 max_tokens: 1024,
27762777 messages: [
27772778 {role: "user", content: "Help me plan a trip to Paris departing May 15, 2026"}
build-with-claude/task-budgets Changed · +19 / -17 lines
from line 10
1010 - claude-mythos-5-1
1111 - claude-fable-5
1212 - claude-mythos-5
13 - claude-opus-5-5
1314 - claude-opus-5
1415 - claude-opus-4-8
1516 - claude-opus-4-7
from line 41
4041 -H "anthropic-beta: task-budgets-2026-03-13" \
4142 -H "content-type: application/json" \
4243 -d '{
43 "model": "claude-opus-5",
44 "model": "claude-opus-5-5",
4445 "max_tokens": 128000,
4546 "stream": true,
4647 "messages": [{
from line 58
5758 ```bash CLI
5859 ant beta:messages create --beta task-budgets-2026-03-13 \
5960 --stream --format jsonl <<'YAML' | jq 'select(.type == "message_delta").usage'
60 model: claude-opus-5
61 model: claude-opus-5-5
6162 max_tokens: 128000
6263 messages:
6364 - role: user
from line 75
7475 client = anthropic.Anthropic()
7576
7677 with client.beta.messages.stream(
77 model="claude-opus-5",
78 model="claude-opus-5-5",
7879 max_tokens=128000,
7980 output_config={
8081 "effort": "high",
from line 95
9495 const client = new Anthropic();
9596
9697 const stream = client.beta.messages.stream({
97 model: "claude-opus-5",
98 model: "claude-opus-5-5",
9899 max_tokens: 128000,
99100 output_config: {
100101 effort: "high",
from line 115
114115
115116 var responseUpdates = client.Beta.Messages.CreateStreaming(new MessageCreateParams
116117 {
117 Model = Messages::Model.ClaudeOpus5,
118 Model = Messages::Model.ClaudeOpus5_5,
118119 MaxTokens = 128000,
119120 Messages = [new() { Role = Role.User, Content = "Review the codebase and propose a refactor plan." }],
120121 OutputConfig = new BetaOutputConfig
from line 134
133134 client := anthropic.NewClient()
134135
135136 stream := client.Beta.Messages.NewStreaming(context.TODO(), anthropic.BetaMessageNewParams{
136 Model: anthropic.ModelClaudeOpus5,
137 Model: anthropic.ModelClaudeOpus5_5,
137138 MaxTokens: 128000,
138139 Betas: []anthropic.AnthropicBeta{"task-budgets-2026-03-13"},
139140 Messages: []anthropic.BetaMessageParam{{
from line 169
168169 AnthropicClient client = AnthropicOkHttpClient.fromEnv();
169170
170171 MessageCreateParams params = MessageCreateParams.builder()
171 .model(Model.CLAUDE_OPUS_5)
172 .model(Model.CLAUDE_OPUS_5_5)
172173 .maxTokens(128000L)
173174 .addUserMessage("Review the codebase and propose a refactor plan.")
174175 .outputConfig(BetaOutputConfig.builder()
from line 195
194195 $client = new Client();
195196
196197 $stream = $client->beta->messages->createStream(
197 model: 'claude-opus-5',
198 model: 'claude-opus-5-5',
198199 maxTokens: 128000,
199200 messages: [
200201 ['role' => 'user', 'content' => 'Review the codebase and propose a refactor plan.'],
from line 222
221222 client = Anthropic::Client.new
222223
223224 stream = client.beta.messages.stream(
224 model: "claude-opus-5",
225 model: "claude-opus-5-5",
225226 max_tokens: 128_000,
226227 messages: [
227228 { role: "user", content: "Review the codebase and propose a refactor plan." }
from line 515
514515<CodeGroup>
515516 ```bash CLI
516517 ant messages create --transform 'usage.output_tokens' <<'YAML'
517 model: claude-opus-5
518 model: claude-opus-5-5
518519 max_tokens: 4096
519520 messages:
520521 - role: user
from line 527
526527 client = anthropic.Anthropic()
527528
528529 response = client.messages.create(
529 model="claude-opus-5",
530 model="claude-opus-5-5",
530531 max_tokens=4096,
531532 messages=[
532533 {"role": "user", "content": "Review the codebase and propose a refactor plan."}
from line 542
541542 const client = new Anthropic();
542543
543544 const response = await client.messages.create({
544 model: "claude-opus-5",
545 model: "claude-opus-5-5",
545546 max_tokens: 4096,
546547 messages: [{ role: "user", content: "Review the codebase and propose a refactor plan." }]
547548 });
from line 557
556557
557558 var response = await client.Messages.Create(new MessageCreateParams
558559 {
559 Model = Model.ClaudeOpus5,
560 Model = Model.ClaudeOpus5_5,
560561 MaxTokens = 4096,
561562 Messages = [new() { Role = Role.User, Content = "Review the codebase and propose a refactor plan." }],
562563 });
from line 570
569570 client := anthropic.NewClient()
570571
571572 response, err := client.Messages.New(context.TODO(), anthropic.MessageNewParams{
572 Model: anthropic.ModelClaudeOpus5,
573 Model: anthropic.ModelClaudeOpus5_5,
573574 MaxTokens: 4096,
574575 Messages: []anthropic.MessageParam{
575576 anthropic.NewUserMessage(anthropic.NewTextBlock("Review the codebase and propose a refactor plan.")),
from line 588
587588 AnthropicClient client = AnthropicOkHttpClient.fromEnv();
588589
589590 MessageCreateParams params = MessageCreateParams.builder()
590 .model(Model.CLAUDE_OPUS_5)
591 .model(Model.CLAUDE_OPUS_5_5)
591592 .maxTokens(4096L)
592593 .addUserMessage("Review the codebase and propose a refactor plan.")
593594 .build();
from line 602
601602 $client = new Client();
602603
603604 $response = $client->messages->create(
604 model: 'claude-opus-5',
605 model: 'claude-opus-5-5',
605606 maxTokens: 4096,
606607 messages: [
607608 ['role' => 'user', 'content' => 'Review the codebase and propose a refactor plan.'],
from line 617
616617 client = Anthropic::Client.new
617618
618619 response = client.messages.create(
619 model: "claude-opus-5",
620 model: "claude-opus-5-5",
620621 max_tokens: 4096,
621622 messages: [
622623 { role: "user", content: "Review the codebase and propose a refactor plan." }
from line 646
645646| ----------------- | ------------------------------------------- |
646647| Claude Fable 5.1 | Beta (set `task-budgets-2026-03-13` header) |
647648| Claude Mythos 5.1 | Beta (set `task-budgets-2026-03-13` header) |
649| Claude Opus 5.5 | Beta (set `task-budgets-2026-03-13` header) |
648650| Claude Opus 5 | Beta (set `task-budgets-2026-03-13` header) |
649651| Claude Fable 5 | Beta (set `task-budgets-2026-03-13` header) |
650652| Claude Mythos 5 | Beta (set `task-budgets-2026-03-13` header) |
build-with-claude/thinking Changed · +16 / -15 lines
from line 46
4646
4747On most models, thinking is on by default or one parameter away. Which configuration each model accepts, and what it defaults to, is listed in the [per-model configuration table](https://platform.claude.com/docs/en/build-with-claude/thinking-troubleshooting#supported-models) on the Troubleshooting page.
4848
49On Claude Opus 5, Claude Sonnet 5, Claude Fable 5.1, Claude Mythos 5.1, Claude Fable 5, Claude Mythos 5, and Claude Mythos Preview, thinking is already on and needs no configuration. `display` defaults to `"omitted"` on these models, so the thinking text is hidden until you opt in. Opt in with `thinking: {"type": "adaptive", "display": "summarized"}`, which is exactly the following request with the [model string](https://platform.claude.com/docs/en/models/overview) swapped.
49On Claude Opus 5.5, Claude Opus 5, Claude Sonnet 5, Claude Fable 5.1, Claude Mythos 5.1, Claude Fable 5, Claude Mythos 5, and Claude Mythos Preview, thinking is already on and needs no configuration. `display` defaults to `"omitted"` on these models, so the thinking text is hidden until you opt in. Opt in with `thinking: {"type": "adaptive", "display": "summarized"}`, which is exactly the following request with the [model string](https://platform.claude.com/docs/en/models/overview) swapped.
5050
5151On Claude Opus 4.8, Claude Opus 4.7, Claude Opus 4.6, and Claude Sonnet 4.6, thinking is off until you set `thinking: {type: "adaptive"}`, which lets Claude decide when and how deeply to think based on the request. The following examples do that, set `display: "summarized"` so the thinking text is visible, and use a roomy `max_tokens`:
5252
from line 438
438438 ```
439439</CodeGroup>
440440
441Claude Opus 5 also has thinking on by default and accepts `thinking: {type: "disabled"}` at [effort](https://platform.claude.com/docs/en/build-with-claude/effort) `high` or below. At `xhigh` or `max` effort, thinking cannot be turned off: requests that combine `thinking: {type: "disabled"}` with those effort levels return a 400 error. This restriction applies to Claude Opus 5 and later models and is enforced on each request. With thinking disabled, Claude Opus 5 can occasionally emit tool calls as plain text or include internal XML tags in its visible output. See [Running with thinking disabled](https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/prompting-claude-opus-5#running-with-thinking-disabled) for prompting mitigations.
441Claude Opus 5 also has thinking on by default and accepts `thinking: {type: "disabled"}` at [effort](https://platform.claude.com/docs/en/build-with-claude/effort) `high` or below. At `xhigh` or `max` effort, thinking cannot be turned off: requests that combine `thinking: {type: "disabled"}` with those effort levels return a 400 error. This restriction is enforced on each request. With thinking disabled, Claude Opus 5 can occasionally emit tool calls as plain text or include internal XML tags in its visible output. See [Running with thinking disabled](https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/prompting-claude-opus-5#running-with-thinking-disabled) for prompting mitigations.
442442
443Claude Fable 5.1, Claude Mythos 5.1, Claude Fable 5, Claude Mythos 5, and Claude Mythos Preview reject `thinking: {type: "disabled"}`. Thinking can't be turned off on these models.
443Claude Fable 5.1, Claude Mythos 5.1, Claude Fable 5, Claude Mythos 5, Claude Opus 5.5, and Claude Mythos Preview reject `thinking: {type: "disabled"}`. Thinking can't be turned off on these models.
444444
445445If your model supports only extended thinking (see the [per-model configuration table](https://platform.claude.com/docs/en/build-with-claude/thinking-troubleshooting#supported-models)), configure it with `type: "enabled"` and a `budget_tokens` value instead. The [Extended thinking](https://platform.claude.com/docs/en/build-with-claude/extended-thinking) page covers that configuration. And if any thinking configuration comes back with a 400 error, [Troubleshooting thinking](https://platform.claude.com/docs/en/build-with-claude/thinking-troubleshooting) matches each error message to its fix.
446446
from line 451
451451The `display` field on the thinking configuration controls how thinking content is returned in API responses. `display` works in both modes: set it alongside `type: "adaptive"` or `type: "enabled"`. It accepts these values:
452452
453453* `"summarized"`: thinking blocks contain [summarized thinking](https://platform.claude.com/docs/en/build-with-claude/thinking#summarized-thinking) text, a readable summary of Claude's reasoning. This is the default on Claude Opus 4.6, Claude Sonnet 4.6, and earlier models.
454* `"omitted"`: thinking blocks are returned with an empty `thinking` field. The `signature` field still carries the encrypted full thinking for multi-turn continuity (see [Thinking encryption](https://platform.claude.com/docs/en/build-with-claude/thinking#thinking-encryption)). This is the default on Claude Fable 5.1, Claude Mythos 5.1, Claude Fable 5, Claude Mythos 5, Claude Opus 5, Claude Sonnet 5, Claude Opus 4.8, Claude Opus 4.7, and [Claude Mythos Preview](https://anthropic.com/glasswing).
454* `"omitted"`: thinking blocks are returned with an empty `thinking` field. The `signature` field still carries the encrypted full thinking for multi-turn continuity (see [Thinking encryption](https://platform.claude.com/docs/en/build-with-claude/thinking#thinking-encryption)). This is the default on Claude Fable 5.1, Claude Mythos 5.1, Claude Fable 5, Claude Mythos 5, Claude Opus 5.5, Claude Opus 5, Claude Sonnet 5, Claude Opus 4.8, Claude Opus 4.7, and [Claude Mythos Preview](https://anthropic.com/glasswing).
455455* `"updates"` (beta): reasoning blocks are returned with an empty `thinking` field, as with `"omitted"`, and the short [progress updates](https://platform.claude.com/docs/en/build-with-claude/thinking#progress-updates) some models write between tool calls come back as readable text. Requires the beta header `thinking-display-updates-2026-08-18`.
456456
457457Set `display: "omitted"` when your application doesn't surface thinking content to users. The primary benefit is faster time-to-first-text-token when streaming: the server skips streaming thinking tokens entirely and delivers only the signature, so the final text response begins streaming sooner.
from line 504
504504 In rare cases where you need access to full thinking output, [contact Anthropic sales](mailto:[email protected]).
505505</Note>
506506
507To see the model's reasoning, read the `thinking` blocks rather than prompting for reasoning in the response text. On Claude Fable 5.1 and Claude Fable 5, a request that attempts to elicit the model's internal reasoning as part of the response text can be refused with `stop_details.category: "reasoning_extraction"`. See [Refusal categories](https://platform.claude.com/docs/en/build-with-claude/refusals-and-fallback#refusal-response) for the field reference and handling guidance.
507To see the model's reasoning, read the `thinking` blocks rather than prompting for reasoning in the response text. On Claude Fable 5.1, Claude Opus 5.5, and Claude Fable 5, a request that attempts to elicit the model's internal reasoning as part of the response text can be refused with `stop_details.category: "reasoning_extraction"`. See [Refusal categories](https://platform.claude.com/docs/en/build-with-claude/refusals-and-fallback#refusal-response) for the field reference and handling guidance.
508508
509509### Streaming thinking
510510
from line 877
877877
878878Thinking works alongside [tool use](https://platform.claude.com/docs/en/agents-and-tools/tool-use/overview), letting Claude reason through tool selection and process tool results. Two constraints apply:
879879
8801. **Tool choice limitation (manual mode):** tool use with manual extended thinking (`thinking: {type: "enabled"}`) only supports `tool_choice: {"type": "auto"}` (the default) or `tool_choice: {"type": "none"}`. Using `tool_choice: {"type": "any"}` or `tool_choice: {"type": "tool", "name": "..."}` results in an error because these options force tool use, which is incompatible with manual extended thinking. Adaptive thinking, including on models where thinking is on by default, supports forced tool use, except on Claude Fable 5.1 and Claude Mythos 5.1 (see [Response prefill and forced tool use](https://platform.claude.com/docs/en/build-with-claude/thinking#limits-and-feature-compatibility)).
8801. **Tool choice limitation (manual mode):** tool use with manual extended thinking (`thinking: {type: "enabled"}`) only supports `tool_choice: {"type": "auto"}` (the default) or `tool_choice: {"type": "none"}`. Using `tool_choice: {"type": "any"}` or `tool_choice: {"type": "tool", "name": "..."}` results in an error because these options force tool use, which is incompatible with manual extended thinking. Adaptive thinking, including on models where thinking is on by default, supports forced tool use, except on Claude Opus 5.5, Claude Fable 5.1, and Claude Mythos 5.1 (see [Response prefill and forced tool use](https://platform.claude.com/docs/en/build-with-claude/thinking#limits-and-feature-compatibility)).
8818812. **Preserving thinking blocks:** when you return tool results, you must pass the thinking blocks from the assistant message back to the API, complete and unmodified. See [Preserving thinking blocks](https://platform.claude.com/docs/en/build-with-claude/thinking#preserving-thinking-blocks).
882882
883883**A tool-use loop is one assistant turn.** From the model's perspective, an assistant turn doesn't complete until Claude finishes its full response, which may include multiple tool calls and results. This whole sequence is a single assistant turn:
from line 941
941941 Consecutive tool calls do not require interleaved thinking. Claude can chain tool calls with or without interleaved thinking. Interleaving changes where thinking blocks appear between tool calls, not whether tool calls can chain.
942942</Note>
943943
944With adaptive thinking, interleaved thinking is automatic on every model that supports adaptive thinking. No beta header is needed. On Claude Fable 5.1, Claude Mythos 5.1, Claude Fable 5, Claude Mythos 5, Claude Mythos Preview, Claude Opus 5, Claude Opus 4.8, and Claude Opus 4.7, reasoning between tool calls always appears in thinking blocks. Claude Haiku 4.5 does not support interleaved thinking. On models using manual extended thinking, interleaving requires a beta header and changes how the thinking budget is counted. [Interleaved thinking in manual mode](https://platform.claude.com/docs/en/build-with-claude/extended-thinking#interleaved-thinking) covers the per-model rules and platform-specific header behavior.
944With adaptive thinking, interleaved thinking is automatic on every model that supports adaptive thinking. No beta header is needed. On Claude Fable 5.1, Claude Mythos 5.1, Claude Fable 5, Claude Mythos 5, Claude Mythos Preview, Claude Opus 5.5, Claude Opus 5, Claude Opus 4.8, and Claude Opus 4.7, reasoning between tool calls always appears in thinking blocks. Claude Haiku 4.5 does not support interleaved thinking. On models using manual extended thinking, interleaving requires a beta header and changes how the thinking budget is counted. [Interleaved thinking in manual mode](https://platform.claude.com/docs/en/build-with-claude/extended-thinking#interleaved-thinking) covers the per-model rules and platform-specific header behavior.
945945
946946With interleaved thinking, the thinking allocation can span the entire assistant turn rather than a single response. Interleaved thinking is only supported for [tools used through the Messages API](https://platform.claude.com/docs/en/agents-and-tools/tool-use/overview).
947947
from line 949
949949
950950### Progress updates between tool calls
951951
952On Claude Fable 5.1, Claude Mythos 5.1, and Claude Fable 5, the model can write a progress update between tool calls. A progress update is a sentence or two on what the model just found and what it's about to do next, written for the person watching the agent rather than as reasoning. Each one comes back as its own `thinking` block with its own `signature`, separate from any reasoning block at the same point. It sits immediately before the `tool_use` or `server_tool_use` block it introduces. At most one progress update precedes each tool call, and the model can skip any of them. Progress updates aren't [interleaved thinking](https://platform.claude.com/docs/en/build-with-claude/thinking#interleaved-thinking): they appear whether or not reasoning blocks appear between tool calls, and a response can contain both.
952On Claude Fable 5.1, Claude Mythos 5.1, Claude Opus 5.5, and Claude Fable 5, the model can write a progress update between tool calls. A progress update is a sentence or two on what the model just found and what it's about to do next, written for the person watching the agent rather than as reasoning. Each one comes back as its own `thinking` block with its own `signature`, separate from any reasoning block at the same point. It sits immediately before the `tool_use` or `server_tool_use` block it introduces. At most one progress update precedes each tool call, and the model can skip any of them. Progress updates aren't [interleaved thinking](https://platform.claude.com/docs/en/build-with-claude/thinking#interleaved-thinking): they appear whether or not reasoning blocks appear between tool calls, and a response can contain both.
953953
954954What a progress-update block contains depends on [`display`](https://platform.claude.com/docs/en/build-with-claude/thinking#controlling-thinking-display):
955955
from line 1021
10211021* A progress-update block can come back with an empty `thinking` field under any `display` value. Render nothing for an empty block. Under `"updates"` it looks the same as an empty reasoning block and needs no separate handling.
10221022* When a response stops on `max_tokens`, `model_context_window_exceeded`, or `stop_sequence` soon after a tool call or tool result, its last block can be a progress-update block standing in for the work the model hadn't finished. Under `"updates"` and `"summarized"` its text is exactly `This part of the response was interrupted before it finished.` and you can show it like any other update. Under `"omitted"` it's empty. To continue, pass the assistant turn back unchanged and append a new `user` message (with a `tool_result` for each `tool_use` block in that turn).
10231023* When [streaming](https://platform.claude.com/docs/en/build-with-claude/thinking#streaming-thinking), expect a pause of several seconds before a progress-update block opens. See the `"updates"` trace in [Streaming thinking](https://platform.claude.com/docs/en/build-with-claude/thinking#streaming-thinking).
1024* These models write fewer progress updates at higher [effort](https://platform.claude.com/docs/en/build-with-claude/effort) and in long tool chains. If your interface depends on them, see [Ask for user-facing progress updates](https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/prompting-claude-fable-5-1#ask-for-user-facing-progress-updates).
1024* These models write fewer progress updates at higher [effort](https://platform.claude.com/docs/en/build-with-claude/effort) and in long tool chains. If your interface depends on them, see [Ask for user-facing progress updates](https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/prompting-claude-fable-5-1#ask-for-user-facing-progress-updates) or, for Claude Opus 5.5, [User-facing progress updates](https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/prompting-claude-opus-5-5#user-facing-progress-updates).
10251025
10261026### Thinking block preservation by model
10271027
from line 1037
10371037
10381038The tradeoff is context usage: long conversations consume more context space on keep-all models, because retained thinking blocks count as input like any other conversation history (see [Thinking and the context window](https://platform.claude.com/docs/en/build-with-claude/thinking#thinking-and-the-context-window)). The behavior is automatic in both regimes. No code changes or beta headers are required, and you should keep passing complete, unmodified thinking blocks back as described in [Preserving thinking blocks](https://platform.claude.com/docs/en/build-with-claude/thinking#preserving-thinking-blocks). To override the default in either direction, use [thinking block clearing](https://platform.claude.com/docs/en/build-with-claude/context-editing#thinking-block-clearing).
10391039
1040**Switching models mid-conversation.** Keep passing thinking blocks back unchanged when you switch models, for example after a [classifier refusal fallback](https://platform.claude.com/docs/en/build-with-claude/refusals-and-fallback). A thinking block is readable only by the model that produced it or a newer one, and the API ignores or drops the blocks the target model can't read. On Claude Fable 5.1 and Claude Mythos 5.1 the direction matters: they read every earlier model's thinking blocks and no earlier model reads theirs, so switching up to them keeps the conversation's reasoning and switching down drops it (see [how dropped blocks are billed and reported](https://platform.claude.com/docs/en/build-with-claude/preserved-thinking#switching-models)). Strip prior `thinking` and `redacted_thinking` blocks yourself only to save input tokens on models that ignore rather than drop them, and never when redeeming a [fallback credit](https://platform.claude.com/docs/en/build-with-claude/fallback-credit), which requires the body unchanged.
1040**Switching models mid-conversation.** Keep passing thinking blocks back unchanged when you switch models, for example after a [classifier refusal fallback](https://platform.claude.com/docs/en/build-with-claude/refusals-and-fallback). A thinking block is readable only by the model that produced it and certain other models, and the API ignores or drops the blocks the target model can't read. On Claude Fable 5.1 and Claude Mythos 5.1 the direction matters: they read every earlier model's thinking blocks and no earlier model reads theirs, so switching up to them keeps the conversation's reasoning and switching down drops it (see [how dropped blocks are billed and reported](https://platform.claude.com/docs/en/build-with-claude/preserved-thinking#switching-models)). Claude Opus 5.5 reads Claude Opus 5's thinking blocks and those of earlier Opus, Sonnet, and Haiku models, but not those of the Claude Fable and Claude Mythos models; on the Claude API, Claude Fable 5.1 and Claude Mythos 5.1 read Claude Opus 5.5's blocks. A switch from Claude Opus 5.5 up to Claude Fable 5.1 on the Claude API keeps the earlier turns' reasoning; a switch from Claude Fable 5.1 to Claude Opus 5.5 drops it. Strip prior `thinking` and `redacted_thinking` blocks yourself only to save input tokens on models that ignore rather than drop them, and never when redeeming a [fallback credit](https://platform.claude.com/docs/en/build-with-claude/fallback-credit), which requires the body unchanged.
10411041
10421042## Preserved thinking
10431043
10441044[Preserved thinking](https://platform.claude.com/docs/en/build-with-claude/preserved-thinking) decides whether the model can use a thinking block that you send back from an earlier turn. Starting with Claude Fable 5.1, the API checks the `signature` of every `thinking` or `redacted_thinking` block in a request for two things:
10451045
1046* **The model that produced it.** A model reads its own thinking blocks and those of earlier models, never those of a newer model. Claude Fable 5.1 reads blocks from Claude Opus 5, but Claude Opus 5 can't read blocks from Claude Fable 5.1. The API drops a block the current model can't read, without an error and without billing it. See [Switching models mid-conversation](https://platform.claude.com/docs/en/build-with-claude/preserved-thinking#switching-models).
1046* **The model that produced it.** Each model reads its own thinking blocks and those of a fixed set of other models. Claude Fable 5.1 reads blocks from Claude Opus 5 and, on the Claude API, from Claude Opus 5.5; neither Claude Opus 5 nor Claude Opus 5.5 reads blocks from Claude Fable 5.1. The API drops a block the current model can't read, without an error and without billing it. See [Switching models mid-conversation](https://platform.claude.com/docs/en/build-with-claude/preserved-thinking#switching-models).
10471047* **Everything sent before it.** A block stays valid only while the top-level `system` prompt, the `tools`, and the messages before it are unchanged. If any of them changes, that block and every later thinking block are invalid, and the API rejects the request with a 400 error or drops the invalid blocks, whichever you choose. See [Keeping the prefix unchanged](https://platform.claude.com/docs/en/build-with-claude/preserved-thinking#prefix-check).
10481048
1049The model check applies to every account. The API enforces the prefix check by default for accounts created on or after August 31, 2026, 00:00 UTC. On older accounts it enforces the check only on requests that set `thinking.block_binding.prefix_mismatch_behavior`. Later models will enforce it for all accounts, so make your integration append-only now.
1049The model check applies to every account. The API enforces the prefix check by default for accounts created on or after August 31, 2026, 00:00 UTC. On older accounts it enforces the check only on requests that set `thinking.block_binding.prefix_mismatch_behavior`. Make your integration append-only regardless of your account's age, so the same code works on every account, including newer accounts enforced by default.
10501050
10511051To keep thinking valid, send every assistant turn back exactly as you received it and add new messages only at the end of `messages`. If your code builds the `messages` array itself, the Preserved thinking page covers:
10521052
from line 1153
11531153
11541154### Sampling parameters
11551155
1156On Claude Fable 5.1, Claude Mythos 5.1, Claude Fable 5, Claude Mythos 5, Claude Mythos Preview, Claude Opus 5, Claude Opus 4.8, Claude Opus 4.7, and Claude Sonnet 5, non-default `temperature`, `top_p`, or `top_k` values return a 400 error on every request, regardless of whether thinking is used. On older models, the restriction applies only while thinking is on: `temperature` and `top_k` are incompatible with thinking, and `top_p` is allowed at values between 0.95 and 1.
1156On Claude Fable 5.1, Claude Mythos 5.1, Claude Fable 5, Claude Mythos 5, Claude Mythos Preview, Claude Opus 5.5, Claude Opus 5, Claude Opus 4.8, Claude Opus 4.7, and Claude Sonnet 5, non-default `temperature`, `top_p`, or `top_k` values return a 400 error on every request, regardless of whether thinking is used. On older models, the restriction applies only while thinking is on: `temperature` and `top_k` are incompatible with thinking, and `top_p` is allowed at values between 0.95 and 1.
11571157
11581158### Response prefill and forced tool use
11591159
1160You can't prefill the assistant response while thinking is on. Forced tool use (`tool_choice: {"type": "any"}` or `{"type": "tool", ...}`) is incompatible with manual extended thinking but works with adaptive thinking. The exceptions are Claude Fable 5.1 and Claude Mythos 5.1, which reject forced tool use on every request with a 400 error. On those models, use `tool_choice: {"type": "auto"}` with [strict tool use](https://platform.claude.com/docs/en/agents-and-tools/tool-use/strict-tool-use) or [structured outputs](https://platform.claude.com/docs/en/build-with-claude/structured-outputs) instead. See [Thinking with tool use](https://platform.claude.com/docs/en/build-with-claude/thinking#thinking-with-tool-use).
1160You can't prefill the assistant response while thinking is on. Forced tool use (`tool_choice: {"type": "any"}` or `{"type": "tool", ...}`) is incompatible with manual extended thinking but works with adaptive thinking. The exceptions are Claude Opus 5.5, Claude Fable 5.1, and Claude Mythos 5.1, which reject forced tool use on every request with a 400 error. On those models, use `tool_choice: {"type": "auto"}` with [strict tool use](https://platform.claude.com/docs/en/agents-and-tools/tool-use/strict-tool-use) or [structured outputs](https://platform.claude.com/docs/en/build-with-claude/structured-outputs) instead. See [Thinking with tool use](https://platform.claude.com/docs/en/build-with-claude/thinking#thinking-with-tool-use).
11611161
11621162### Output limits
11631163
from line 1170
11701170| Claude Fable 5 | 128K | — |
11711171| Claude Mythos 5 | 128K | — |
11721172| Claude Mythos Preview | 128K | Not available |
1173| Claude Opus 5.5 | 128K | 300K |
11731174| Claude Opus 5 | 128K | 300K |
11741175| Claude Opus 4.8 | 128K | 300K |
11751176| Claude Opus 4.7 | 128K | 300K |
build-with-claude/thinking-steering-and-cost Changed · +22 / -22 lines
from line 59
5959
6060```json
6161{
62 "model": "claude-opus-5",
62 "model": "claude-opus-5-5",
6363 "max_tokens": 4096,
6464 "output_config": { "effort": "medium" },
6565 "messages": [{ "role": "user", "content": "..." }]
from line 175
175175 # First request - establish cache
176176 print("First request - establishing cache")
177177 response1 = client.messages.create(
178 model="claude-opus-5",
178 model="claude-opus-5-5",
179179 max_tokens=16000,
180180 thinking={"type": "adaptive"},
181181 messages=MESSAGES,
from line 189
189189 # Second request - same configuration (cache hit expected)
190190 print("\nSecond request - same configuration (cache hit expected)")
191191 response2 = client.messages.create(
192 model="claude-opus-5",
192 model="claude-opus-5-5",
193193 max_tokens=16000,
194194 thinking={"type": "adaptive"},
195195 messages=MESSAGES,
from line 203
203203 # Third request - different effort level (cache miss expected)
204204 print("\nThird request - different effort level (cache miss expected)")
205205 response3 = client.messages.create(
206 model="claude-opus-5",
206 model="claude-opus-5-5",
207207 max_tokens=16000,
208208 thinking={"type": "adaptive"},
209209 output_config={"effort": "medium"},
from line 251
251251 // First request - establish cache
252252 console.log("First request - establishing cache");
253253 const response1 = await client.messages.create({
254 model: "claude-opus-5",
254 model: "claude-opus-5-5",
255255 max_tokens: 16000,
256256 thinking: { type: "adaptive" },
257257 messages
from line 267
267267 // Second request - same configuration (cache hit expected)
268268 console.log("\nSecond request - same configuration (cache hit expected)");
269269 const response2 = await client.messages.create({
270 model: "claude-opus-5",
270 model: "claude-opus-5-5",
271271 max_tokens: 16000,
272272 thinking: { type: "adaptive" },
273273 messages
from line 283
283283 // Third request - different effort level (cache miss expected)
284284 console.log("\nThird request - different effort level (cache miss expected)");
285285 const response3 = await client.messages.create({
286 model: "claude-opus-5",
286 model: "claude-opus-5-5",
287287 max_tokens: 16000,
288288 thinking: { type: "adaptive" },
289289 output_config: { effort: "medium" },
from line 305
305305 Console.WriteLine("First request - establishing cache");
306306 var parameters1 = new MessageCreateParams
307307 {
308 Model = Model.ClaudeOpus5,
308 Model = Model.ClaudeOpus5_5,
309309 MaxTokens = 16000,
310310 Thinking = new ThinkingConfigAdaptive(),
311311 Messages =
from line 335
335335 Console.WriteLine("\nSecond request - same configuration (cache hit expected)");
336336 var parameters2 = new MessageCreateParams
337337 {
338 Model = Model.ClaudeOpus5,
338 Model = Model.ClaudeOpus5_5,
339339 MaxTokens = 16000,
340340 Thinking = new ThinkingConfigAdaptive(),
341341 Messages =
from line 375
375375 Console.WriteLine("\nThird request - different effort level (cache miss expected)");
376376 var parameters3 = new MessageCreateParams
377377 {
378 Model = Model.ClaudeOpus5,
378 Model = Model.ClaudeOpus5_5,
379379 MaxTokens = 16000,
380380 Thinking = new ThinkingConfigAdaptive(),
381381 OutputConfig = new OutputConfig
from line 464
464464 // First request - establish cache
465465 fmt.Println("First request - establishing cache")
466466 response1, err := client.Messages.New(context.TODO(), anthropic.MessageNewParams{
467 Model: anthropic.ModelClaudeOpus5,
467 Model: anthropic.ModelClaudeOpus5_5,
468468 MaxTokens: 16000,
469469 Thinking: anthropic.ThinkingConfigParamUnion{
470470 OfAdaptive: &anthropic.ThinkingConfigAdaptiveParam{},
from line 482
482482 // Second request - same configuration (cache hit expected)
483483 fmt.Println("\nSecond request - same configuration (cache hit expected)")
484484 response2, err := client.Messages.New(context.TODO(), anthropic.MessageNewParams{
485 Model: anthropic.ModelClaudeOpus5,
485 Model: anthropic.ModelClaudeOpus5_5,
486486 MaxTokens: 16000,
487487 Thinking: anthropic.ThinkingConfigParamUnion{
488488 OfAdaptive: &anthropic.ThinkingConfigAdaptiveParam{},
from line 500
500500 // Third request - different effort level (cache miss expected)
501501 fmt.Println("\nThird request - different effort level (cache miss expected)")
502502 response3, err := client.Messages.New(context.TODO(), anthropic.MessageNewParams{
503 Model: anthropic.ModelClaudeOpus5,
503 Model: anthropic.ModelClaudeOpus5_5,
504504 MaxTokens: 16000,
505505 Thinking: anthropic.ThinkingConfigParamUnion{
506506 OfAdaptive: &anthropic.ThinkingConfigAdaptiveParam{},
from line 531
531531 // First request - establishing cache
532532 IO.println("First request - establishing cache");
533533 MessageCreateParams params1 = MessageCreateParams.builder()
534 .model(Model.CLAUDE_OPUS_5)
534 .model(Model.CLAUDE_OPUS_5_5)
535535 .maxTokens(16000L)
536536 .thinking(ThinkingConfigAdaptive.builder().build())
537537 .addUserMessageOfBlockParams(List.of(
from line 551
551551 // Second request - same configuration (cache hit expected)
552552 IO.println("\nSecond request - same configuration (cache hit expected)");
553553 MessageCreateParams params2 = MessageCreateParams.builder()
554 .model(Model.CLAUDE_OPUS_5)
554 .model(Model.CLAUDE_OPUS_5_5)
555555 .maxTokens(16000L)
556556 .thinking(ThinkingConfigAdaptive.builder().build())
557557 .addUserMessageOfBlockParams(List.of(
from line 575
575575 // Third request - different effort level (cache miss expected)
576576 IO.println("\nThird request - different effort level (cache miss expected)");
577577 MessageCreateParams params3 = MessageCreateParams.builder()
578 .model(Model.CLAUDE_OPUS_5)
578 .model(Model.CLAUDE_OPUS_5_5)
579579 .maxTokens(16000L)
580580 .thinking(ThinkingConfigAdaptive.builder().build())
581581 .outputConfig(OutputConfig.builder()
from line 647
647647 ]
648648 ]
649649 ]],
650 model: 'claude-opus-5',
650 model: 'claude-opus-5-5',
651651 thinking: ['type' => 'adaptive'],
652652 );
653653
from line 680
680680 'content' => 'Analyze the characters in this passage.'
681681 ]
682682 ],
683 model: 'claude-opus-5',
683 model: 'claude-opus-5-5',
684684 thinking: ['type' => 'adaptive'],
685685 );
686686
from line 721
721721 'content' => 'Analyze the setting in this passage.'
722722 ]
723723 ],
724 model: 'claude-opus-5',
724 model: 'claude-opus-5-5',
725725 thinking: ['type' => 'adaptive'],
726726 outputConfig: ['effort' => 'medium'],
727727 );
from line 752
752752
753753 puts "First request - establishing cache"
754754 response1 = client.messages.create(
755 model: "claude-opus-5",
755 model: "claude-opus-5-5",
756756 max_tokens: 16000,
757757 thinking: {
758758 type: "adaptive"
from line 777
777777
778778 puts "\nSecond request - same configuration (cache hit expected)"
779779 response2 = client.messages.create(
780 model: "claude-opus-5",
780 model: "claude-opus-5-5",
781781 max_tokens: 16000,
782782 thinking: {
783783 type: "adaptive"
from line 812
812812
813813 puts "\nThird request - different effort level (cache miss expected)"
814814 response3 = client.messages.create(
815 model: "claude-opus-5",
815 model: "claude-opus-5-5",
816816 max_tokens: 16000,
817817 thinking: {
818818 type: "adaptive"
build-with-claude/thinking-troubleshooting Changed · +5 / -4 lines
from line 25
2525| Claude Fable 5 | Adaptive only | Always on | `"enabled"`, `"disabled"` |
2626| Claude Mythos 5 | Adaptive only | Always on | `"enabled"`, `"disabled"` |
2727| Claude Mythos Preview | Adaptive, extended | Always on | `"disabled"` |
28| Claude Opus 5.5 | Adaptive only | Always on | `"enabled"`, `"disabled"` |
2829| Claude Opus 5 | Adaptive only | On | `"enabled"`, `"disabled"`2 |
2930| Claude Opus 4.8 | Adaptive only | Off | `"enabled"` |
3031| Claude Opus 4.7 | Adaptive only | Off | `"enabled"` |
from line 37
3637| Claude Sonnet 4.5 | Extended only | Off | `"adaptive"` |
3738
3839*1 `enabled` and `budget_tokens` still work on these models but are deprecated; use adaptive thinking instead.*\
39*2 Claude Opus 5 accepts `"disabled"` at [effort](https://platform.claude.com/docs/en/build-with-claude/effort) `high` or below; combining it with effort `xhigh` or `max` returns a 400 error. This restriction applies to Claude Opus 5 and later models and is enforced on each request.*
40*2 Claude Opus 5 accepts `"disabled"` at [effort](https://platform.claude.com/docs/en/build-with-claude/effort) `high` or below; combining it with effort `xhigh` or `max` returns a 400 error. This restriction is enforced on each request.*
4041
4142Models marked `Always on` cannot turn thinking off. Models marked `On` default to thinking but accept `thinking: {type: "disabled"}`.
4243
from line 57
5657
5758## A 400 error says `"thinking.type.disabled"` is not supported
5859
59The request fails with a 400 error. On Claude Fable 5.1, Claude Mythos 5.1, Claude Fable 5, and Claude Mythos 5, the message reads:
60The request fails with a 400 error. On Claude Fable 5.1, Claude Mythos 5.1, Claude Fable 5, Claude Opus 5.5, and Claude Mythos 5, the message reads:
6061
6162```text wrap
6263"thinking.type.disabled" is not supported for this model. Use "thinking.type.adaptive" and "output_config.effort" to control thinking behavior.
from line 101
100101
101102## A 400 error says a thinking block signature is invalid
102103
103A request to Claude Fable 5.1 that replays earlier thinking blocks fails with a 400 `invalid_request_error` whose message reads:
104A request to Claude Fable 5.1 or Claude Opus 5.5 that replays earlier thinking blocks fails with a 400 `invalid_request_error` whose message reads:
104105
105106```text wrap
106107messages.{i}.content.{j}: Invalid `signature` in `thinking` block. The block is bound to a different conversation. Remove the block, or set `thinking.block_binding.prefix_mismatch_behavior` to "drop_block".
from line 113
112113
113114If the message stops after ``Invalid `signature` in `thinking` block``, the signature itself didn't verify: it was truncated, altered, or sent back empty, and `prefix_mismatch_behavior` doesn't apply. Edited thinking text returns a different error. See [A 400 error says thinking blocks cannot be modified](https://platform.claude.com/docs/en/build-with-claude/thinking-troubleshooting#error-thinking-blocks-modified).
114115
115On Claude Fable 5.1, the API accepts a replayed thinking block only while the `system` prompt, `tools`, and messages that preceded it are unchanged. See [Keeping the prefix unchanged](https://platform.claude.com/docs/en/build-with-claude/preserved-thinking#prefix-check). The error means something earlier in the conversation changed between requests: an edited, reordered, or removed turn, a per-turn reminder that was injected and later removed, a rebuilt `system` prompt or `tools` array, or client-side compaction that kept recent turns and their thinking verbatim. The check is enforced for new accounts created on or after August 31, 2026, and for any request that sets `thinking.block_binding.prefix_mismatch_behavior`. Server-side [compaction](https://platform.claude.com/docs/en/build-with-claude/compaction) and [context editing](https://platform.claude.com/docs/en/build-with-claude/context-editing) never trigger it.
116On Claude Fable 5.1 and Claude Opus 5.5, the API accepts a replayed thinking block only while the `system` prompt, `tools`, and messages that preceded it are unchanged. See [Keeping the prefix unchanged](https://platform.claude.com/docs/en/build-with-claude/preserved-thinking#prefix-check). The error means something earlier in the conversation changed between requests: an edited, reordered, or removed turn, a per-turn reminder that was injected and later removed, a rebuilt `system` prompt or `tools` array, or client-side compaction that kept recent turns and their thinking verbatim. The check is enforced for new accounts created on or after August 31, 2026, and for any request that sets `thinking.block_binding.prefix_mismatch_behavior`. Server-side [compaction](https://platform.claude.com/docs/en/build-with-claude/compaction) and [context editing](https://platform.claude.com/docs/en/build-with-claude/context-editing) never trigger it.
116117
117118To fix it, keep the history append-only: pass earlier turns back exactly as sent and received, add instructions with a [mid-conversation system message](https://platform.claude.com/docs/en/build-with-claude/mid-conversation-system-messages) instead of editing `system` or `tools`, and let server-side [context editing](https://platform.claude.com/docs/en/build-with-claude/context-editing) or [compaction](https://platform.claude.com/docs/en/build-with-claude/compaction) do any trimming. Retrying the same request body doesn't clear the error. To continue this request without the invalidated reasoning, send the `thinking-binding-controls-2026-08-01` beta header and set `thinking.block_binding.prefix_mismatch_behavior` to `"drop_block"`. Alternatively, strip every `thinking` and `redacted_thinking` block from the history (at minimum the named block and every one after it, in that turn and all later turns), leave each turn's other blocks in place, and retry once.
118119
build-with-claude/token-counting Changed · +45 / -45 lines
from line 52
5252 -H "content-type: application/json" \
5353 -H "anthropic-version: 2023-06-01" \
5454 -d '{
55 "model": "claude-opus-5",
55 "model": "claude-opus-5-5",
5656 "system": "You are a scientist",
5757 "messages": [{
5858 "role": "user",
from line 63
6363
6464 ```bash CLI
6565 ant messages count-tokens \
66 --model claude-opus-5 \
66 --model claude-opus-5-5 \
6767 --system "You are a scientist" \
6868 --message '{role: user, content: "Hello, Claude"}'
6969 ```
from line 72
7272 client = anthropic.Anthropic()
7373
7474 response = client.messages.count_tokens(
75 model="claude-opus-5",
75 model="claude-opus-5-5",
7676 system="You are a scientist",
7777 messages=[{"role": "user", "content": "Hello, Claude"}],
7878 )
from line 84
8484 const client = new Anthropic();
8585
8686 const response = await client.messages.countTokens({
87 model: "claude-opus-5",
87 model: "claude-opus-5-5",
8888 system: "You are a scientist",
8989 messages: [
9090 {
from line 107
107107
108108 var parameters = new MessageCountTokensParams
109109 {
110 Model = Model.ClaudeOpus5,
110 Model = Model.ClaudeOpus5_5,
111111 System = "You are a scientist",
112112 Messages = [new() { Role = Role.User, Content = "Hello, Claude" }]
113113 };
from line 120
120120 client := anthropic.NewClient()
121121
122122 response, err := client.Messages.CountTokens(context.TODO(), anthropic.MessageCountTokensParams{
123 Model: anthropic.ModelClaudeOpus5,
123 Model: anthropic.ModelClaudeOpus5_5,
124124 System: anthropic.MessageCountTokensParamsSystemUnion{
125125 OfString: anthropic.String("You are a scientist"),
126126 },
from line 146
146146 AnthropicClient client = AnthropicOkHttpClient.fromEnv();
147147
148148 MessageCountTokensParams params = MessageCountTokensParams.builder()
149 .model(Model.CLAUDE_OPUS_5)
149 .model(Model.CLAUDE_OPUS_5_5)
150150 .system("You are a scientist")
151151 .addUserMessage("Hello, Claude")
152152 .build();
from line 164
164164 messages: [
165165 ['role' => 'user', 'content' => 'Hello, Claude']
166166 ],
167 model: 'claude-opus-5',
167 model: 'claude-opus-5-5',
168168 system: 'You are a scientist',
169169 );
170170
from line 175
175175 client = Anthropic::Client.new
176176
177177 response = client.messages.count_tokens(
178 model: "claude-opus-5",
178 model: "claude-opus-5-5",
179179 system: "You are a scientist",
180180 messages: [
181181 { role: "user", content: "Hello, Claude" }
from line 203
203203 -H "content-type: application/json" \
204204 -H "anthropic-version: 2023-06-01" \
205205 -d '{
206 "model": "claude-opus-5",
206 "model": "claude-opus-5-5",
207207 "tools": [
208208 {
209209 "name": "get_weather",
from line 231
231231
232232 ```bash CLI
233233 ant messages count-tokens <<'YAML'
234 model: claude-opus-5
234 model: claude-opus-5-5
235235 tools:
236236 - name: get_weather
237237 description: Get the current weather in a given location
from line 253
253253 client = anthropic.Anthropic()
254254
255255 response = client.messages.count_tokens(
256 model="claude-opus-5",
256 model="claude-opus-5-5",
257257 tools=[
258258 {
259259 "name": "get_weather",
from line 280
280280 const client = new Anthropic();
281281
282282 const response = await client.messages.countTokens({
283 model: "claude-opus-5",
283 model: "claude-opus-5-5",
284284 tools: [
285285 {
286286 name: "get_weather",
from line 315
315315
316316 var parameters = new MessageCountTokensParams
317317 {
318 Model = Model.ClaudeOpus5,
318 Model = Model.ClaudeOpus5_5,
319319 Tools =
320320 [
321321 new MessageCountTokensTool(new Tool()
from line 343
343343 client := anthropic.NewClient()
344344
345345 response, err := client.Messages.CountTokens(context.TODO(), anthropic.MessageCountTokensParams{
346 Model: anthropic.ModelClaudeOpus5,
346 Model: anthropic.ModelClaudeOpus5_5,
347347 Tools: []anthropic.MessageCountTokensToolUnionParam{
348348 {OfTool: &anthropic.ToolParam{
349349 Name: "get_weather",
from line 395
395395 .build();
396396
397397 MessageCountTokensParams params = MessageCountTokensParams.builder()
398 .model(Model.CLAUDE_OPUS_5)
398 .model(Model.CLAUDE_OPUS_5_5)
399399 .addTool(
400400 Tool.builder()
401401 .name("get_weather")
from line 417
417417 messages: [
418418 ['role' => 'user', 'content' => "What's the weather like in San Francisco?"]
419419 ],
420 model: 'claude-opus-5',
420 model: 'claude-opus-5-5',
421421 tools: [
422422 [
423423 'name' => 'get_weather',
from line 443
443443 client = Anthropic::Client.new
444444
445445 response = client.messages.count_tokens(
446 model: "claude-opus-5",
446 model: "claude-opus-5-5",
447447 tools: [
448448 {
449449 name: "get_weather",
from line 489
489489 -H "content-type: application/json" \
490490 -d @- <<EOF
491491 {
492 "model": "claude-opus-5",
492 "model": "claude-opus-5-5",
493493 "messages": [
494494 {"role": "user", "content": [
495495 {"type": "image", "source": {
from line 509
509509 curl -s "$IMAGE_URL" -o ./vision-example.jpg
510510
511511 ant messages count-tokens <<'YAML'
512 model: claude-opus-5
512 model: claude-opus-5-5
513513 messages:
514514 - role: user
515515 content:
from line 534
534534 client = anthropic.Anthropic()
535535
536536 response = client.messages.count_tokens(
537 model="claude-opus-5",
537 model="claude-opus-5-5",
538538 messages=[
539539 {
540540 "role": "user",
from line 564
564564 const imageData = Buffer.from(imageArrayBuffer).toString("base64");
565565
566566 const response = await anthropic.messages.countTokens({
567 model: "claude-opus-5",
567 model: "claude-opus-5-5",
568568 messages: [
569569 {
570570 role: "user",
from line 606
606606
607607 var parameters = new MessageCountTokensParams
608608 {
609 Model = Model.ClaudeOpus5,
609 Model = Model.ClaudeOpus5_5,
610610 Messages =
611611 [
612612 new()
from line 655
655655 client := anthropic.NewClient()
656656
657657 response, err := client.Messages.CountTokens(context.TODO(), anthropic.MessageCountTokensParams{
658 Model: anthropic.ModelClaudeOpus5,
658 Model: anthropic.ModelClaudeOpus5_5,
659659 Messages: []anthropic.MessageParam{
660660 anthropic.NewUserMessage(
661661 anthropic.NewImageBlockBase64("image/jpeg", imageData),
from line 705
705705 );
706706
707707 MessageCountTokensParams params = MessageCountTokensParams.builder()
708 .model(Model.CLAUDE_OPUS_5)
708 .model(Model.CLAUDE_OPUS_5_5)
709709 .addUserMessageOfBlockParams(List.of(imageBlock, textBlock))
710710 .build();
711711
from line 737
737737 ]
738738 ]
739739 ],
740 model: 'claude-opus-5',
740 model: 'claude-opus-5-5',
741741 );
742742 print_r($response);
743743 ```
from line 755
755755 client = Anthropic::Client.new
756756
757757 response = client.messages.count_tokens(
758 model: "claude-opus-5",
758 model: "claude-opus-5-5",
759759 messages: [
760760 {
761761 role: "user",
from line 799
799799 -H "content-type: application/json" \
800800 -H "anthropic-version: 2023-06-01" \
801801 -d '{
802 "model": "claude-opus-5",
802 "model": "claude-opus-5-5",
803803 "thinking": {
804804 "type": "adaptive"
805805 },
from line 832
832832
833833 ```bash CLI
834834 ant messages count-tokens <<'YAML'
835 model: claude-opus-5
835 model: claude-opus-5-5
836836 thinking:
837837 type: adaptive
838838 messages:
from line 856
856856 client = anthropic.Anthropic()
857857
858858 response = client.messages.count_tokens(
859 model="claude-opus-5",
859 model="claude-opus-5-5",
860860 thinking={"type": "adaptive"},
861861 messages=[
862862 {
from line 888
888888 const client = new Anthropic();
889889
890890 const response = await client.messages.countTokens({
891 model: "claude-opus-5",
891 model: "claude-opus-5-5",
892892 thinking: { type: "adaptive" },
893893 messages: [
894894 {
from line 932
932932
933933 var parameters = new MessageCountTokensParams
934934 {
935 Model = Model.ClaudeOpus5,
935 Model = Model.ClaudeOpus5_5,
936936 Thinking = new ThinkingConfigAdaptive(),
937937 Messages =
938938 [
from line 979
979979 )
980980
981981 response, err := client.Messages.CountTokens(context.TODO(), anthropic.MessageCountTokensParams{
982 Model: anthropic.ModelClaudeOpus5,
982 Model: anthropic.ModelClaudeOpus5_5,
983983 Thinking: anthropic.ThinkingConfigParamUnion{
984984 OfAdaptive: &anthropic.ThinkingConfigAdaptiveParam{},
985985 },
from line 1024
10241024 );
10251025
10261026 MessageCountTokensParams params = MessageCountTokensParams.builder()
1027 .model(Model.CLAUDE_OPUS_5)
1027 .model(Model.CLAUDE_OPUS_5_5)
10281028 .thinking(ThinkingConfigAdaptive.builder().build())
10291029 .addUserMessage("Are there an infinite number of prime numbers such that n mod 4 == 3?")
10301030 .addAssistantMessageOfBlockParams(assistantBlocks)
from line 1063
10631063 'content' => 'Can you write a formal proof?'
10641064 ]
10651065 ],
1066 model: 'claude-opus-5',
1066 model: 'claude-opus-5-5',
10671067 thinking: ['type' => 'adaptive'],
10681068 );
10691069
from line 1074
10741074 client = Anthropic::Client.new
10751075
10761076 response = client.messages.count_tokens(
1077 model: "claude-opus-5",
1077 model: "claude-opus-5-5",
10781078 thinking: {
10791079 type: "adaptive"
10801080 },
from line 1126
11261126 -H "anthropic-version: 2023-06-01" \
11271127 -d @- <<EOF
11281128 {
1129 "model": "claude-opus-5",
1129 "model": "claude-opus-5-5",
11301130 "messages": [{
11311131 "role": "user",
11321132 "content": [
from line 1150
11501150
11511151 ```bash CLI
11521152 ant messages count-tokens <<'YAML'
1153 model: claude-opus-5
1153 model: claude-opus-5-5
11541154 messages:
11551155 - role: user
11561156 content:
from line 1174
11741174 pdf_base64 = base64.standard_b64encode(pdf_file.read()).decode("utf-8")
11751175
11761176 response = client.messages.count_tokens(
1177 model="claude-opus-5",
1177 model="claude-opus-5-5",
11781178 messages=[
11791179 {
11801180 "role": "user",
from line 1204
12041204 const pdfBase64 = await readFile("/path/to/document.pdf", { encoding: "base64" });
12051205
12061206 const response = await client.messages.countTokens({
1207 model: "claude-opus-5",
1207 model: "claude-opus-5-5",
12081208 messages: [
12091209 {
12101210 role: "user",
from line 1244
12441244
12451245 var parameters = new MessageCountTokensParams
12461246 {
1247 Model = Model.ClaudeOpus5,
1247 Model = Model.ClaudeOpus5_5,
12481248 Messages =
12491249 [
12501250 new()
from line 1278
12781278 pdfBase64 := base64.StdEncoding.EncodeToString(pdfBytes)
12791279
12801280 response, err := client.Messages.CountTokens(context.TODO(), anthropic.MessageCountTokensParams{
1281 Model: anthropic.ModelClaudeOpus5,
1281 Model: anthropic.ModelClaudeOpus5_5,
12821282 Messages: []anthropic.MessageParam{
12831283 anthropic.NewUserMessage(
12841284 anthropic.NewDocumentBlock(anthropic.Base64PDFSourceParam{
from line 1318
13181318 );
13191319
13201320 MessageCountTokensParams params = MessageCountTokensParams.builder()
1321 .model(Model.CLAUDE_OPUS_5)
1321 .model(Model.CLAUDE_OPUS_5_5)
13221322 .addUserMessageOfBlockParams(List.of(documentBlock, textBlock))
13231323 .build();
13241324
from line 1351
13511351 ]
13521352 ]
13531353 ],
1354 model: 'claude-opus-5',
1354 model: 'claude-opus-5-5',
13551355 );
13561356
13571357 echo json_encode($response);
from line 1365
13651365 pdf_base64 = Base64.strict_encode64(File.binread("/path/to/document.pdf"))
13661366
13671367 response = client.messages.count_tokens(
1368 model: "claude-opus-5",
1368 model: "claude-opus-5-5",
13691369 messages: [
13701370 {
13711371 role: "user",
build-with-claude/vision Changed · +36 / -36 lines
from line 40
4040 -H "content-type: application/json" \
4141 -d @- <<EOF
4242 {
43 "model": "claude-opus-5",
43 "model": "claude-opus-5-5",
4444 "max_tokens": 1024,
4545 "messages": [
4646 {
from line 70
7070 https://platform.claude.com/docs/images/vision-example.jpg
7171
7272 ant messages create <<'YAML'
73 model: claude-opus-5
73 model: claude-opus-5-5
7474 max_tokens: 1024
7575 messages:
7676 - role: user
from line 91
9191
9292 client = anthropic.Anthropic()
9393 message = client.messages.create(
94 model="claude-opus-5",
94 model="claude-opus-5-5",
9595 max_tokens=1024,
9696 messages=[
9797 {
from line 117
117117 const anthropic = new Anthropic();
118118
119119 const message = await anthropic.messages.create({
120 model: "claude-opus-5",
120 model: "claude-opus-5-5",
121121 max_tokens: 1024,
122122 messages: [
123123 {
from line 154
154154
155155 var message = await client.Messages.Create(new MessageCreateParams
156156 {
157 Model = Model.ClaudeOpus5,
157 Model = Model.ClaudeOpus5_5,
158158 MaxTokens = 1024,
159159 Messages =
160160 [
from line 185
185185 imageData := "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR4nGP4z8AAAAMBAQDJ/pLvAAAAAElFTkSuQmCC"
186186
187187 message, err := client.Messages.New(context.TODO(), anthropic.MessageNewParams{
188 Model: anthropic.ModelClaudeOpus5,
188 Model: anthropic.ModelClaudeOpus5_5,
189189 MaxTokens: 1024,
190190 Messages: []anthropic.MessageParam{
191191 anthropic.NewUserMessage(
from line 223
223223 .messages()
224224 .create(
225225 MessageCreateParams.builder()
226 .model(Model.CLAUDE_OPUS_5)
226 .model(Model.CLAUDE_OPUS_5_5)
227227 .maxTokens(1024)
228228 .addUserMessageOfBlockParams(contentBlockParams)
229229 .build()
from line 255
255255 ],
256256 ],
257257 ],
258 model: 'claude-opus-5',
258 model: 'claude-opus-5-5',
259259 );
260260
261261 echo json_encode($message, JSON_PRETTY_PRINT), PHP_EOL;
from line 267
267267 image_data = "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR4nGP4z8AAAAMBAQDJ/pLvAAAAAElFTkSuQmCC"
268268
269269 message = client.messages.create(
270 model: "claude-opus-5",
270 model: "claude-opus-5-5",
271271 max_tokens: 1024,
272272 messages: [
273273 {
from line 300
300300 -H "anthropic-version: 2023-06-01" \
301301 -H "content-type: application/json" \
302302 -d '{
303 "model": "claude-opus-5",
303 "model": "claude-opus-5-5",
304304 "max_tokens": 1024,
305305 "messages": [
306306 {
from line 325
325325
326326 ```bash CLI
327327 ant messages create <<'YAML'
328 model: claude-opus-5
328 model: claude-opus-5-5
329329 max_tokens: 1024
330330 messages:
331331 - role: user
from line 342
342342 ```python Python
343343 client = anthropic.Anthropic()
344344 message = client.messages.create(
345 model="claude-opus-5",
345 model="claude-opus-5-5",
346346 max_tokens=1024,
347347 messages=[
348348 {
from line 367
367367 const anthropic = new Anthropic();
368368
369369 const message = await anthropic.messages.create({
370 model: "claude-opus-5",
370 model: "claude-opus-5-5",
371371 max_tokens: 1024,
372372 messages: [
373373 {
from line 401
401401
402402 var message = await client.Messages.Create(new MessageCreateParams
403403 {
404 Model = Model.ClaudeOpus5,
404 Model = Model.ClaudeOpus5_5,
405405 MaxTokens = 1024,
406406 Messages =
407407 [
from line 429
429429 client := anthropic.NewClient()
430430
431431 message, err := client.Messages.New(context.TODO(), anthropic.MessageNewParams{
432 Model: anthropic.ModelClaudeOpus5,
432 Model: anthropic.ModelClaudeOpus5_5,
433433 MaxTokens: 1024,
434434 Messages: []anthropic.MessageParam{
435435 anthropic.NewUserMessage(
from line 466
466466 .messages()
467467 .create(
468468 MessageCreateParams.builder()
469 .model(Model.CLAUDE_OPUS_5)
469 .model(Model.CLAUDE_OPUS_5_5)
470470 .maxTokens(1024)
471471 .addUserMessageOfBlockParams(contentBlockParams)
472472 .build()
from line 494
494494 ],
495495 ],
496496 ],
497 model: 'claude-opus-5',
497 model: 'claude-opus-5-5',
498498 );
499499
500500 echo json_encode($message, JSON_PRETTY_PRINT), PHP_EOL;
from line 504
504504 client = Anthropic::Client.new
505505
506506 message = client.messages.create(
507 model: "claude-opus-5",
507 model: "claude-opus-5-5",
508508 max_tokens: 1024,
509509 messages: [
510510 {
from line 550
550550 -H "content-type: application/json" \
551551 -d @- <<EOF
552552 {
553 "model": "claude-opus-5",
553 "model": "claude-opus-5-5",
554554 "max_tokens": 1024,
555555 "messages": [
556556 {
from line 586
586586 # Then use the returned file_id in your message
587587 ant messages create \
588588 --transform content --format yaml <<YAML
589 model: claude-opus-5
589 model: claude-opus-5-5
590590 max_tokens: 1024
591591 messages:
592592 - role: user
from line 609
609609
610610 # Use the uploaded file in a message
611611 message = client.messages.create(
612 model="claude-opus-5",
612 model="claude-opus-5-5",
613613 max_tokens=1024,
614614 messages=[
615615 {
from line 643
643643
644644 // Use the uploaded file in a message
645645 const response = await anthropic.messages.create({
646 model: "claude-opus-5",
646 model: "claude-opus-5-5",
647647 max_tokens: 1024,
648648 messages: [
649649 {
from line 691
691691 // Use the uploaded file in a message
692692 var response = await client.Messages.Create(new MessageCreateParams
693693 {
694 Model = Model.ClaudeOpus5,
694 Model = Model.ClaudeOpus5_5,
695695 MaxTokens = 1024,
696696 Messages =
697697 [
from line 733
733733 // Use the uploaded file in a message
734734 message, err := client.Messages.New(context.Background(),
735735 anthropic.MessageNewParams{
736 Model: anthropic.ModelClaudeOpus5,
736 Model: anthropic.ModelClaudeOpus5_5,
737737 MaxTokens: 1024,
738738 Messages: []anthropic.MessageParam{
739739 anthropic.NewUserMessage(
from line 775
775775 ImageBlockParam imageParam = ImageBlockParam.builder().fileSource(file.id()).build();
776776
777777 MessageCreateParams params = MessageCreateParams.builder()
778 .model(Model.CLAUDE_OPUS_5)
778 .model(Model.CLAUDE_OPUS_5_5)
779779 .maxTokens(1024)
780780 .addUserMessageOfBlockParams(
781781 List.of(
from line 816
816816 ],
817817 ],
818818 ],
819 model: 'claude-opus-5',
819 model: 'claude-opus-5-5',
820820 );
821821
822822 echo json_encode($message, JSON_PRETTY_PRINT), PHP_EOL;
from line 835
835835
836836 # Use the uploaded file in a message
837837 message = client.messages.create(
838 model: "claude-opus-5",
838 model: "claude-opus-5-5",
839839 max_tokens: 1024,
840840 messages: [
841841 {
from line 868
868868 -H "anthropic-version: 2023-06-01" \
869869 -H "content-type: application/json" \
870870 -d '{
871 "model": "claude-opus-5",
871 "model": "claude-opus-5-5",
872872 "max_tokens": 1024,
873873 "messages": [
874874 {
from line 910
910910
911911 ```bash CLI
912912 ant messages create <<'YAML'
913 model: claude-opus-5
913 model: claude-opus-5-5
914914 max_tokens: 1024
915915 messages:
916916 - role: user
from line 940
940940
941941 client = anthropic.Anthropic()
942942 message = client.messages.create(
943 model="claude-opus-5",
943 model="claude-opus-5-5",
944944 max_tokens=1024,
945945 messages=[
946946 {
from line 981
981981 "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR4nGNgYPgPAAEDAQAIicLsAAAAAElFTkSuQmCC";
982982
983983 const message = await anthropic.messages.create({
984 model: "claude-opus-5",
984 model: "claude-opus-5-5",
985985 max_tokens: 1024,
986986 messages: [
987987 {
from line 1031
10311031
10321032 var message = await client.Messages.Create(new MessageCreateParams
10331033 {
1034 Model = Model.ClaudeOpus5,
1034 Model = Model.ClaudeOpus5_5,
10351035 MaxTokens = 1024,
10361036 Messages =
10371037 [
from line 1072
10721072 image2Data := "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR4nGNgYPgPAAEDAQAIicLsAAAAAElFTkSuQmCC"
10731073
10741074 message, err := client.Messages.New(context.TODO(), anthropic.MessageNewParams{
1075 Model: anthropic.ModelClaudeOpus5,
1075 Model: anthropic.ModelClaudeOpus5_5,
10761076 MaxTokens: 1024,
10771077 Messages: []anthropic.MessageParam{
10781078 anthropic.NewUserMessage(
from line 1129
11291129 .messages()
11301130 .create(
11311131 MessageCreateParams.builder()
1132 .model(Model.CLAUDE_OPUS_5)
1132 .model(Model.CLAUDE_OPUS_5_5)
11331133 .maxTokens(1024)
11341134 .addUserMessageOfBlockParams(contentBlockParams)
11351135 .build()
from line 1172
11721172 ],
11731173 ],
11741174 ],
1175 model: 'claude-opus-5',
1175 model: 'claude-opus-5-5',
11761176 );
11771177
11781178 echo $message;
from line 1185
11851185 image2_data = "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR4nGNgYPgPAAEDAQAIicLsAAAAAElFTkSuQmCC"
11861186
11871187 message = client.messages.create(
1188 model: "claude-opus-5",
1188 model: "claude-opus-5-5",
11891189 max_tokens: 1024,
11901190 messages: [
11911191 {
build-with-claude/working-with-messages Changed · +40 / -40 lines
from line 31
3131 -H "anthropic-version: 2023-06-01" \
3232 -H "content-type: application/json" \
3333 -d '{
34 "model": "claude-opus-5",
34 "model": "claude-opus-5-5",
3535 "max_tokens": 1024,
3636 "messages": [
3737 {"role": "user", "content": "Hello, Claude"}
from line 41
4141
4242 ```bash CLI
4343 ant messages create \
44 --model claude-opus-5 \
44 --model claude-opus-5-5 \
4545 --max-tokens 1024 \
4646 --message '{role: user, content: "Hello, Claude"}'
4747 ```
from line 48
4848
4949 ```python Python
5050 message = anthropic.Anthropic().messages.create(
51 model="claude-opus-5",
51 model="claude-opus-5-5",
5252 max_tokens=1024,
5353 messages=[{"role": "user", "content": "Hello, Claude"}],
5454 )
from line 59
5959 const anthropic = new Anthropic();
6060
6161 const message = await anthropic.messages.create({
62 model: "claude-opus-5",
62 model: "claude-opus-5-5",
6363 max_tokens: 1024,
6464 messages: [{ role: "user", content: "Hello, Claude" }]
6565 });
from line 71
7171
7272 var parameters = new MessageCreateParams
7373 {
74 Model = Model.ClaudeOpus5,
74 Model = Model.ClaudeOpus5_5,
7575 MaxTokens = 1024,
7676 Messages = [new() { Role = Role.User, Content = "Hello, Claude" }]
7777 };
from line 83
8383 client := anthropic.NewClient()
8484
8585 response, err := client.Messages.New(context.TODO(), anthropic.MessageNewParams{
86 Model: anthropic.ModelClaudeOpus5,
86 Model: anthropic.ModelClaudeOpus5_5,
8787 MaxTokens: 1024,
8888 Messages: []anthropic.MessageParam{
8989 anthropic.NewUserMessage(anthropic.NewTextBlock("Hello, Claude")),
from line 99
9999 AnthropicClient client = AnthropicOkHttpClient.fromEnv();
100100
101101 MessageCreateParams params = MessageCreateParams.builder()
102 .model(Model.CLAUDE_OPUS_5)
102 .model(Model.CLAUDE_OPUS_5_5)
103103 .maxTokens(1024L)
104104 .addUserMessage("Hello, Claude")
105105 .build();
from line 114
114114 $message = $client->messages->create(
115115 maxTokens: 1024,
116116 messages: [['role' => 'user', 'content' => 'Hello, Claude']],
117 model: 'claude-opus-5',
117 model: 'claude-opus-5-5',
118118 );
119119 echo json_encode($message, JSON_PRETTY_PRINT), PHP_EOL;
120120 ```
from line 123
123123 client = Anthropic::Client.new
124124
125125 message = client.messages.create(
126 model: "claude-opus-5",
126 model: "claude-opus-5-5",
127127 max_tokens: 1024,
128128 messages: [
129129 { role: "user", content: "Hello, Claude" }
from line 144
144144 "text": "Hello!"
145145 }
146146 ],
147 "model": "claude-opus-5",
147 "model": "claude-opus-5-5",
148148 "stop_reason": "end_turn",
149149 "stop_sequence": null,
150150 "usage": {
from line 168
168168 -H "anthropic-version: 2023-06-01" \
169169 -H "content-type: application/json" \
170170 -d '{
171 "model": "claude-opus-5",
171 "model": "claude-opus-5-5",
172172 "max_tokens": 1024,
173173 "messages": [
174174 {"role": "user", "content": "Hello, Claude"},
from line 181
181181
182182 ```bash CLI
183183 ant messages create \
184 --model claude-opus-5 \
184 --model claude-opus-5-5 \
185185 --max-tokens 1024 \
186186 --message '{role: user, content: "Hello, Claude"}' \
187187 --message '{role: assistant, content: "Hello!"}' \
from line 190
190190
191191 ```python Python
192192 message = anthropic.Anthropic().messages.create(
193 model="claude-opus-5",
193 model="claude-opus-5-5",
194194 max_tokens=1024,
195195 messages=[
196196 {"role": "user", "content": "Hello, Claude"},
from line 205
205205 const anthropic = new Anthropic();
206206
207207 const message = await anthropic.messages.create({
208 model: "claude-opus-5",
208 model: "claude-opus-5-5",
209209 max_tokens: 1024,
210210 messages: [
211211 { role: "user", content: "Hello, Claude" },
from line 221
221221
222222 var parameters = new MessageCreateParams
223223 {
224 Model = Model.ClaudeOpus5,
224 Model = Model.ClaudeOpus5_5,
225225 MaxTokens = 1024,
226226 Messages =
227227 [
from line 239
239239 client := anthropic.NewClient()
240240
241241 response, err := client.Messages.New(context.TODO(), anthropic.MessageNewParams{
242 Model: anthropic.ModelClaudeOpus5,
242 Model: anthropic.ModelClaudeOpus5_5,
243243 MaxTokens: 1024,
244244 Messages: []anthropic.MessageParam{
245245 anthropic.NewUserMessage(anthropic.NewTextBlock("Hello, Claude")),
from line 257
257257 AnthropicClient client = AnthropicOkHttpClient.fromEnv();
258258
259259 MessageCreateParams params = MessageCreateParams.builder()
260 .model(Model.CLAUDE_OPUS_5)
260 .model(Model.CLAUDE_OPUS_5_5)
261261 .maxTokens(1024L)
262262 .addUserMessage("Hello, Claude")
263263 .addAssistantMessage("Hello!")
from line 278
278278 ['role' => 'assistant', 'content' => 'Hello!'],
279279 ['role' => 'user', 'content' => 'Can you describe LLMs to me?'],
280280 ],
281 model: 'claude-opus-5',
281 model: 'claude-opus-5-5',
282282 );
283283
284284 echo json_encode($message, JSON_PRETTY_PRINT), PHP_EOL;
from line 288
288288 client = Anthropic::Client.new
289289
290290 message = client.messages.create(
291 model: "claude-opus-5",
291 model: "claude-opus-5-5",
292292 max_tokens: 1024,
293293 messages: [
294294 { role: "user", content: "Hello, Claude" },
from line 311
311311 "text": "Sure, I'd be happy to provide..."
312312 }
313313 ],
314 "model": "claude-opus-5",
314 "model": "claude-opus-5-5",
315315 "stop_reason": "end_turn",
316316 "stop_sequence": null,
317317 "usage": {
from line 323
323323
324324### System role in messages
325325
326On Claude Fable 5.1, [Claude Mythos 5.1](https://anthropic.com/glasswing), Claude Fable 5, [Claude Mythos 5](https://anthropic.com/glasswing), Claude Opus 4.8, and Claude Opus 5, you can include messages with `"role": "system"` after a user turn (subject to [placement rules](https://platform.claude.com/docs/en/build-with-claude/mid-conversation-system-messages#limitations)) to add a new system instruction partway through a conversation. A `system` message cannot be the first entry in `messages`. Use the top-level `system` field for instructions that apply from the start.
326On Claude Fable 5.1, [Claude Mythos 5.1](https://anthropic.com/glasswing), Claude Fable 5, [Claude Mythos 5](https://anthropic.com/glasswing), Claude Opus 5.5, Claude Opus 4.8, and Claude Opus 5, you can include messages with `"role": "system"` after a user turn (subject to [placement rules](https://platform.claude.com/docs/en/build-with-claude/mid-conversation-system-messages#limitations)) to add a new system instruction partway through a conversation. A `system` message cannot be the first entry in `messages`. Use the top-level `system` field for instructions that apply from the start.
327327
328328A mid-conversation system message has the same authority as the top-level `system` field, but because it is appended to the end of the message history, it does not invalidate any cached prefix that came before it. Use the top-level `system` field for instructions that should apply from the very first turn, and a mid-conversation system message for instructions that only become relevant later.
329329
from line 518
518518 -H "content-type: application/json" \
519519 -d @- <<EOF
520520 {
521 "model": "claude-opus-5",
521 "model": "claude-opus-5-5",
522522 "max_tokens": 1024,
523523 "messages": [
524524 {"role": "user", "content": [
from line 539
539539 -H "anthropic-version: 2023-06-01" \
540540 -H "content-type: application/json" \
541541 -d '{
542 "model": "claude-opus-5",
542 "model": "claude-opus-5-5",
543543 "max_tokens": 1024,
544544 "messages": [
545545 {"role": "user", "content": [
from line 560
560560 curl -s "$IMAGE_URL" -o ./vision-example.jpg
561561
562562 ant messages create <<'YAML'
563 model: claude-opus-5
563 model: claude-opus-5-5
564564 max_tokens: 1024
565565 messages:
566566 - role: user
from line 576
576576
577577 # Option 2: URL-referenced image
578578 ant messages create <<YAML
579 model: claude-opus-5
579 model: claude-opus-5-5
580580 max_tokens: 1024
581581 messages:
582582 - role: user
from line 600
600600 image_data = base64.standard_b64encode(httpx2.get(image_url).content).decode("utf-8")
601601
602602 message = anthropic.Anthropic().messages.create(
603 model="claude-opus-5",
603 model="claude-opus-5-5",
604604 max_tokens=1024,
605605 messages=[
606606 {
from line 623
623623
624624 # Option 2: URL-referenced image
625625 message_from_url = anthropic.Anthropic().messages.create(
626 model="claude-opus-5",
626 model="claude-opus-5-5",
627627 max_tokens=1024,
628628 messages=[
629629 {
from line 654
654654 const imageData = Buffer.from(imageArrayBuffer).toString("base64");
655655
656656 const message = await anthropic.messages.create({
657 model: "claude-opus-5",
657 model: "claude-opus-5-5",
658658 max_tokens: 1024,
659659 messages: [
660660 {
from line 680
680680
681681 // Option 2: URL-referenced image
682682 const messageFromUrl = await anthropic.messages.create({
683 model: "claude-opus-5",
683 model: "claude-opus-5-5",
684684 max_tokens: 1024,
685685 messages: [
686686 {
from line 721
721721
722722 var parameters = new MessageCreateParams
723723 {
724 Model = Model.ClaudeOpus5,
724 Model = Model.ClaudeOpus5_5,
725725 MaxTokens = 1024,
726726 Messages =
727727 [
from line 749
749749 // Option 2: URL-referenced image
750750 var parametersFromUrl = new MessageCreateParams
751751 {
752 Model = Model.ClaudeOpus5,
752 Model = Model.ClaudeOpus5_5,
753753 MaxTokens = 1024,
754754 Messages =
755755 [
from line 799
799799 imageData := base64.StdEncoding.EncodeToString(imageBytes)
800800
801801 message, err := client.Messages.New(context.TODO(), anthropic.MessageNewParams{
802 Model: anthropic.ModelClaudeOpus5,
802 Model: anthropic.ModelClaudeOpus5_5,
803803 MaxTokens: 1024,
804804 Messages: []anthropic.MessageParam{
805805 anthropic.NewUserMessage(
from line 815
815815
816816 // Option 2: URL-referenced image
817817 messageFromURL, err := client.Messages.New(context.TODO(), anthropic.MessageNewParams{
818 Model: anthropic.ModelClaudeOpus5,
818 Model: anthropic.ModelClaudeOpus5_5,
819819 MaxTokens: 1024,
820820 Messages: []anthropic.MessageParam{
821821 anthropic.NewUserMessage(
from line 859
859859
860860 Message message = client.messages().create(
861861 MessageCreateParams.builder()
862 .model(Model.CLAUDE_OPUS_5)
862 .model(Model.CLAUDE_OPUS_5_5)
863863 .maxTokens(1024L)
864864 .addUserMessageOfBlockParams(base64Content)
865865 .build());
from line 881
881881
882882 Message messageFromUrl = client.messages().create(
883883 MessageCreateParams.builder()
884 .model(Model.CLAUDE_OPUS_5)
884 .model(Model.CLAUDE_OPUS_5_5)
885885 .maxTokens(1024L)
886886 .addUserMessageOfBlockParams(urlContent)
887887 .build());
from line 917
917917 ],
918918 ],
919919 ],
920 model: 'claude-opus-5',
920 model: 'claude-opus-5-5',
921921 );
922922 echo $message;
923923
from line 942
942942 ],
943943 ],
944944 ],
945 model: 'claude-opus-5',
945 model: 'claude-opus-5-5',
946946 );
947947 echo $message_from_url;
948948 ```
from line 959
959959 image_data = Base64.strict_encode64(Net::HTTP.get(URI(image_url)))
960960
961961 message = client.messages.create(
962 model: "claude-opus-5",
962 model: "claude-opus-5-5",
963963 max_tokens: 1024,
964964 messages: [
965965 {
from line 985
985985
986986 # Option 2: URL-referenced image
987987 message_from_url = client.messages.create(
988 model: "claude-opus-5",
988 model: "claude-opus-5-5",
989989 max_tokens: 1024,
990990 messages: [
991991 {
from line 1021
10211021 "text": "This image is a beautiful minimalist/flat-design illustration of a sunset landscape. Here's what it contains:\n\n**Sky & Sun:**\n- A warm gradient sky transitioning from golden-yellow at the top to deep orange toward the horizon\n- A large pale yellow sun positioned in the upper-right area\n\n**Birds:**\n- Three small silhouetted birds flying in the upper-left portion of the sky, depicted as simple \"M\" or \"v\" shapes\n\n**Mountains:**\n- Multiple layered mountain peaks in purple and maroon tones\n- The mountains overlap to create depth, with varying shades of dusty purple and deep burgundy\n\n**Water:**\n- A dark purple body of water at the bottom of the image\n- A reflection of the sun shown as horizontal cream/peach colored lines in the center-bottom area\n\nThe overall style is clean, geometric, and uses a warm sunset color palette (oranges, yellows, purples, and maroons), giving it a peaceful, serene aesthetic typical of modern vector/flat design artwork."
10221022 }
10231023 ],
1024 "model": "claude-opus-5",
1024 "model": "claude-opus-5-5",
10251025 "stop_reason": "end_turn",
10261026 "stop_sequence": null,
10271027 "usage": {
claude_api_primer Changed · +22 / -22 lines
from line 11
1111## Models
1212
1313```text wrap
14Recommended default for most work, including complex agentic coding: Claude Opus 5: claude-opus-5
15Step up for the hardest long-running agentic and research tasks, at 2x Claude Opus 5 pricing: Claude Fable 5.1: claude-fable-5-1
16Previous Opus model: Claude Opus 4.8: claude-opus-4-8
14Recommended default for most work, including complex agentic coding: Claude Opus 5.5: claude-opus-5-5
15Step up for the hardest long-running agentic and research tasks, at 2.5x Claude Opus 5.5 pricing: Claude Fable 5.1: claude-fable-5-1
16Previous Opus model: Claude Opus 5: claude-opus-5
1717Smart model: Claude Sonnet 5: claude-sonnet-5
1818For fast, cost-effective tasks: Claude Haiku 4.5: claude-haiku-4-5-20251001
1919```
from line 25
2525<CodeGroup exclude="shell:cURL, typescript, csharp, go, java, php, ruby">
2626 ```bash CLI
2727 ant messages create \
28 --model claude-opus-5 \
28 --model claude-opus-5-5 \
2929 --max-tokens 1024 \
3030 --message '{"role": "user", "content": "Hello, Claude"}'
3131 ```
from line 34
3434 import anthropic
3535
3636 message = anthropic.Anthropic().messages.create(
37 model="claude-opus-5",
37 model="claude-opus-5-5",
3838 max_tokens=1024,
3939 messages=[{"role": "user", "content": "Hello, Claude"}],
4040 )
from line 53
5353 "text": "Hello!"
5454 }
5555 ],
56 "model": "claude-opus-5",
56 "model": "claude-opus-5-5",
5757 "stop_reason": "end_turn",
5858 "stop_sequence": null,
5959 "usage": {
from line 70
7070<CodeGroup exclude="shell:cURL, typescript, csharp, go, java, php, ruby">
7171 ```bash CLI
7272 ant messages create <<'YAML'
73 model: claude-opus-5
73 model: claude-opus-5-5
7474 max_tokens: 1024
7575 messages:
7676 - role: user
from line 86
8686 import anthropic
8787
8888 message = anthropic.Anthropic().messages.create(
89 model="claude-opus-5",
89 model="claude-opus-5-5",
9090 max_tokens=1024,
9191 messages=[
9292 {"role": "user", "content": "Hello, Claude"},
from line 149
149149 curl -sSo vision-example.jpg "$IMAGE_URL"
150150
151151 ant messages create <<'YAML'
152 model: claude-opus-5
152 model: claude-opus-5-5
153153 max_tokens: 1024
154154 messages:
155155 - role: user
from line 165
165165
166166 # Option 2: URL-referenced image
167167 ant messages create <<YAML
168 model: claude-opus-5
168 model: claude-opus-5-5
169169 max_tokens: 1024
170170 messages:
171171 - role: user
from line 190
190190 image_data = base64.standard_b64encode(httpx2.get(image_url).content).decode("utf-8")
191191
192192 message = anthropic.Anthropic().messages.create(
193 model="claude-opus-5",
193 model="claude-opus-5-5",
194194 max_tokens=1024,
195195 messages=[
196196 {
from line 213
213213
214214 # Option 2: URL-referenced image
215215 message_from_url = anthropic.Anthropic().messages.create(
216 model="claude-opus-5",
216 model="claude-opus-5-5",
217217 max_tokens=1024,
218218 messages=[
219219 {
from line 264
264264<CodeGroup exclude="shell:cURL, typescript, csharp, go, java, php, ruby">
265265 ```bash CLI
266266 ant messages create --transform content --format yaml <<'YAML'
267 model: claude-opus-5
267 model: claude-opus-5-5
268268 max_tokens: 16000
269269 thinking:
270270 type: adaptive
from line 281
281281 client = anthropic.Anthropic()
282282
283283 response = client.messages.create(
284 model="claude-opus-5",
284 model="claude-opus-5-5",
285285 max_tokens=16000,
286286 thinking={"type": "adaptive", "display": "summarized"},
287287 messages=[
from line 321
321321 # blocks, signatures intact) as compact JSON.
322322 ASSISTANT_CONTENT=$(ant messages create \
323323 --transform content --format jsonl <<'YAML'
324 model: claude-opus-5
324 model: claude-opus-5-5
325325 max_tokens: 16000
326326 thinking:
327327 type: adaptive
from line 348
348348 # Second request: pass the captured blocks back unchanged as the assistant
349349 # message. The thinking block must accompany the tool_use block.
350350 ant messages create <<YAML
351 model: claude-opus-5
351 model: claude-opus-5-5
352352 max_tokens: 16000
353353 thinking:
354354 type: adaptive
from line 395
395395
396396 # First request - Claude responds with thinking and tool request
397397 response = client.messages.create(
398 model="claude-opus-5",
398 model="claude-opus-5-5",
399399 max_tokens=16000,
400400 thinking={"type": "adaptive", "display": "summarized"},
401401 tools=[weather_tool],
from line 412
412412
413413 # Second request - Include thinking block and tool result
414414 continuation = client.messages.create(
415 model="claude-opus-5",
415 model="claude-opus-5-5",
416416 max_tokens=16000,
417417 thinking={"type": "adaptive", "display": "summarized"},
418418 tools=[weather_tool],
from line 624
624624* `tool` forces Claude to always use a particular tool.
625625* `none` prevents Claude from using any tools.
626626
627On Claude Fable 5.1 and Claude Mythos 5.1, `any` and `tool` return a 400 error. Leave `tool_choice` at `auto` and set `"strict": true` on the tool definition to guarantee that any call Claude makes matches the tool's `input_schema`. See [Strict tool use](https://platform.claude.com/docs/en/agents-and-tools/tool-use/strict-tool-use).
627On Claude Opus 5.5, Claude Fable 5.1, and Claude Mythos 5.1, `any` and `tool` return a 400 error. Leave `tool_choice` at `auto` and set `"strict": true` on the tool definition to guarantee that any call Claude makes matches the tool's `input_schema`. See [Strict tool use](https://platform.claude.com/docs/en/agents-and-tools/tool-use/strict-tool-use).
628628
629629### JSON output
630630
from line 726
726726<CodeGroup exclude="shell:cURL, typescript, csharp, go, java, php, ruby">
727727 ```bash CLI
728728 ant messages create --stream --format jsonl \
729 --model claude-opus-5 \
729 --model claude-opus-5-5 \
730730 --max-tokens 1024 \
731731 --message '{role: user, content: "Hello"}' \
732732 | jq -rj 'select(.delta.type? == "text_delta") | .delta.text'
from line 740
740740 with client.messages.stream(
741741 max_tokens=1024,
742742 messages=[{"role": "user", "content": "Hello"}],
743 model="claude-opus-5",
743 model="claude-opus-5-5",
744744 ) as stream:
745745 for text in stream.text_stream:
746746 print(text, end="", flush=True)
from line 797
797797
798798```sse
799799event: message_start
800data: {"type": "message_start", "message": {"id": "msg_1nZdL29xx5MUA1yADyHTEsnR8uuvGzszyY", "type": "message", "role": "assistant", "content": [], "model": "claude-opus-5", "stop_reason": null, "stop_sequence": null, "usage": {"input_tokens": 25, "output_tokens": 1}}}
800data: {"type": "message_start", "message": {"id": "msg_1nZdL29xx5MUA1yADyHTEsnR8uuvGzszyY", "type": "message", "role": "assistant", "content": [], "model": "claude-opus-5-5", "stop_reason": null, "stop_sequence": null, "usage": {"input_tokens": 25, "output_tokens": 1}}}
801801
802802event: content_block_start
803803data: {"type": "content_block_start", "index": 0, "content_block": {"type": "text", "text": ""}}
cli-sdks-libraries/cli/apply Changed · +5 / -3 lines
from line 21
2121 ```markdown
2222 ---
2323 name: Summarizer
24 model: claude-opus-5
24 model: claude-opus-5-5
2525 tools:
2626 - type: agent_toolset_20260401
2727 ---
from line 111
111111 ```markdown
112112 ---
113113 name: Code reviewer
114 model: claude-opus-5
114 model: claude-opus-5-5
115115 tools:
116116 - type: agent_toolset_20260401
117117 skills:
from line 126
126126 ```markdown
127127 ---
128128 name: Engineering lead
129 model: claude-opus-5
129 model: claude-opus-5-5
130130 multiagent:
131131 type: coordinator
132132 agents:
from line 152
152152
153153 <File filename="environments/cloud.yaml">
154154 ```yaml
155 # yaml-language-server: $schema=https://platform.claude.com/schemas/ant/beta/environment.json
155156 name: review-env
156157 description: Cloud container with unrestricted networking for review sessions.
157158 config:
from line 164
163164
164165 <File filename="memory_stores/review-notes.yaml">
165166 ```yaml
167 # yaml-language-server: $schema=https://platform.claude.com/schemas/ant/beta/memory_store.json
166168 name: Review notes
167169 description: Recurring issues and house-style decisions the reviewer has recorded between runs.
168170 ```
cli-sdks-libraries/cli/quickstart Changed · +3 / -3 lines
from line 29
2929 For Linux environments, download the release binary directly.
3030
3131 ```bash
32 VERSION=1.33.0
32 VERSION=1.35.0
3333 OS=$(uname -s | tr '[:upper:]' '[:lower:]')
3434 case $(uname -m) in
3535 x86_64) ARCH=amd64 ;;
from line 81
8181
8282```bash
8383ant messages create \
84 --model claude-opus-5 \
84 --model claude-opus-5-5 \
8585 --max-tokens 1024 \
8686 --message '{role: user, content: "Hello, Claude"}'
8787```
from line 88
8888
8989```text Output wrap
9090{
91 "model": "claude-opus-5",
91 "model": "claude-opus-5-5",
9292 "id": "msg_01YMmR5XodC5nTqMxLZMKaq6",
9393 "type": "message",
9494 "role": "assistant",
cli-sdks-libraries/cli/using Changed · +13 / -13 lines
from line 20
2020
2121```bash
2222ant models list
23ant messages create --model claude-opus-5 --max-tokens 1024 ...
23ant messages create --model claude-opus-5-5 --max-tokens 1024 ...
2424ant beta:agents retrieve --agent-id agent_01...
2525ant beta:sessions:events list --session-id session_01...
2626```
from line 43
4343`auto` pretty-prints JSON and is the default for commands that create or modify resources. List and retrieve commands default to the [interactive explorer](https://platform.claude.com/docs/en/cli-sdks-libraries/cli/using#interactive-explorer) when writing to a terminal, and to pretty-printed JSON when piped. Override either default with `--format`:
4444
4545```bash
46ant models retrieve --model-id claude-opus-5 --format yaml
46ant models retrieve --model-id claude-opus-5-5 --format yaml
4747```
4848
4949```yaml Output
5050type: model
51id: claude-opus-5
52display_name: Claude Opus 5
53created_at: "2026-07-24T00:00:00Z"
51id: claude-opus-5-5
52display_name: Claude Opus 5.5
53created_at: "2026-09-22T00:00:00Z"
5454...
5555```
5656
from line 75
7575```
7676
7777```jsonl Output
78{"id": "agent_011CYm1BLqPX...", "name": "Docs CLI Test Agent", "model": "claude-opus-5"}
79{"id": "agent_011CYkVwfaEt...", "name": "Coffee Making Assistant", "model": "claude-opus-5"}
80{"id": "agent_011CYixHhtUP...", "name": "Coding Assistant", "model": "claude-opus-5"}
78{"id": "agent_011CYm1BLqPX...", "name": "Docs CLI Test Agent", "model": "claude-opus-5-5"}
79{"id": "agent_011CYkVwfaEt...", "name": "Coffee Making Assistant", "model": "claude-opus-5-5"}
80{"id": "agent_011CYixHhtUP...", "name": "Coding Assistant", "model": "claude-opus-5-5"}
8181```
8282
8383### Extract a scalar
from line 87
8787```bash
8888AGENT_ID=$(ant beta:agents create \
8989 --name "My Agent" \
90 --model '{id: claude-opus-5}' \
90 --model '{id: claude-opus-5-5}' \
9191 --transform id --raw-output)
9292
9393printf '%s\n' "$AGENT_ID"
from line 121
121121```bash
122122ant beta:agents create \
123123 --name "Research Agent" \
124 --model '{id: claude-opus-5}' \
124 --model '{id: claude-opus-5-5}' \
125125 --tool '{type: agent_toolset_20260401}' \
126126 --tool '{type: custom, name: search_docs, input_schema: {type: object, properties: {query: {type: string}}}}'
127127```
from line 140
140140```bash
141141ant beta:agents create <<'YAML'
142142name: Research Agent
143model: claude-opus-5
143model: claude-opus-5-5
144144system: |
145145 You are a research assistant. Cite sources for every claim.
146146tools:
from line 160
160160
161161```bash
162162ant beta:agents create \
163 --name "Researcher" --model '{id: claude-opus-5}' \
163 --name "Researcher" --model '{id: claude-opus-5-5}' \
164164 --system @./prompts/researcher.txt
165165```
166166
from line 168
168168
169169```bash
170170ant messages create \
171 --model claude-opus-5 \
171 --model claude-opus-5-5 \
172172 --max-tokens 1024 \
173173 --message '{role: user, content: [
174174 {type: document, source: {type: base64, media_type: application/pdf, data: "@./scan.pdf"}},
cli-sdks-libraries/libraries/openai-sdk Changed · +6 / -6 lines
from line 45
4545 )
4646
4747 response = client.chat.completions.create(
48 model="claude-opus-5", # Claude model name
48 model="claude-opus-5-5", # Claude model name
4949 messages=[
5050 {"role": "system", "content": "You are a helpful assistant."},
5151 {"role": "user", "content": "Who are you?"},
from line 68
6868 { role: "system", content: "You are a helpful assistant." },
6969 { role: "user", content: "Who are you?" }
7070 ],
71 model: "claude-opus-5" // Claude model name
71 model: "claude-opus-5-5" // Claude model name
7272 });
7373
7474 console.log(response.choices[0].message.content);
from line 80
8080 using OpenAI.Chat;
8181
8282 ChatClient chatClient = new(
83 model: "claude-opus-5", // Claude model name
83 model: "claude-opus-5-5", // Claude model name
8484 credential: new ApiKeyCredential(
8585 Environment.GetEnvironmentVariable("ANTHROPIC_API_KEY")), // Your Claude API key
8686 options: new OpenAIClientOptions()
from line 114
114114 )
115115
116116 response, err := client.Chat.Completions.New(context.Background(), openai.ChatCompletionNewParams{
117 Model: "claude-opus-5", // Claude model name
117 Model: "claude-opus-5-5", // Claude model name
118118 Messages: []openai.ChatCompletionMessageParamUnion{
119119 openai.SystemMessage("You are a helpful assistant."),
120120 openai.UserMessage("Who are you?"),
from line 142
142142 .build();
143143
144144 ChatCompletionCreateParams params = ChatCompletionCreateParams.builder()
145 .model("claude-opus-5") // Claude model name
145 .model("claude-opus-5-5") // Claude model name
146146 .addSystemMessage("You are a helpful assistant.")
147147 .addUserMessage("Who are you?")
148148 .build();
from line 169
169169 )
170170
171171 response = openai.chat.completions.create(
172 model: "claude-opus-5", # Claude model name
172 model: "claude-opus-5-5", # Claude model name
173173 messages: [
174174 {role: "system", content: "You are a helpful assistant."},
175175 {role: "user", content: "Who are you?"}
cli-sdks-libraries/sdks/csharp Changed · +3 / -3 lines
from line 46
4646 Content = "Hello, Claude",
4747 },
4848 ],
49 Model = Model.ClaudeOpus5,
49 Model = Model.ClaudeOpus5_5,
5050};
5151
5252var message = await client.Messages.Create(parameters);
from line 138
138138 Content = "Hello, Claude",
139139 },
140140 ],
141 Model = Model.ClaudeOpus5,
141 Model = Model.ClaudeOpus5_5,
142142};
143143
144144await foreach (var message in client.Messages.CreateStreaming(parameters))
from line 320
320320// Configured using the ANTHROPIC_API_KEY, ANTHROPIC_AUTH_TOKEN and ANTHROPIC_BASE_URL environment variables
321321AnthropicClient client = new();
322322
323IChatClient chatClient = client.AsIChatClient("claude-opus-5")
323IChatClient chatClient = client.AsIChatClient("claude-opus-5-5")
324324 .AsBuilder()
325325 .UseFunctionInvocation()
326326 .Build();
cli-sdks-libraries/sdks/go Changed · +10 / -10 lines
from line 50
5050 Messages: []anthropic.MessageParam{
5151 anthropic.NewUserMessage(anthropic.NewTextBlock("What is a quaternion?")),
5252 },
53 Model: anthropic.ModelClaudeOpus5,
53 Model: anthropic.ModelClaudeOpus5_5,
5454 })
5555 if err != nil {
5656 panic(err.Error())
from line 73
7373 }
7474
7575 message, err := client.Messages.New(context.TODO(), anthropic.MessageNewParams{
76 Model: anthropic.ModelClaudeOpus5,
76 Model: anthropic.ModelClaudeOpus5_5,
7777 Messages: messages,
7878 MaxTokens: 1024,
7979 })
from line 89
8989 ))
9090
9191 message, err = client.Messages.New(context.TODO(), anthropic.MessageNewParams{
92 Model: anthropic.ModelClaudeOpus5,
92 Model: anthropic.ModelClaudeOpus5_5,
9393 Messages: messages,
9494 MaxTokens: 1024,
9595 })
from line 104
104104 <Accordion title="System prompts">
105105 ```go
106106 message, err := client.Messages.New(context.TODO(), anthropic.MessageNewParams{
107 Model: anthropic.ModelClaudeOpus5,
107 Model: anthropic.ModelClaudeOpus5_5,
108108 MaxTokens: 1024,
109109 System: []anthropic.TextBlockParam{
110110 {Text: "Be very serious at all times."},
from line 123
123123 content := "What is a quaternion?"
124124
125125 stream := client.Messages.NewStreaming(context.TODO(), anthropic.MessageNewParams{
126 Model: anthropic.ModelClaudeOpus5,
126 Model: anthropic.ModelClaudeOpus5_5,
127127 MaxTokens: 1024,
128128 Messages: []anthropic.MessageParam{
129129 anthropic.NewUserMessage(anthropic.NewTextBlock(content)),
from line 174
174174
175175 for {
176176 message, err := client.Messages.New(context.TODO(), anthropic.MessageNewParams{
177 Model: anthropic.ModelClaudeOpus5,
177 Model: anthropic.ModelClaudeOpus5_5,
178178 MaxTokens: 1024,
179179 Messages: messages,
180180 Tools: tools,
from line 466
466466 }},
467467 Role: anthropic.MessageParamRoleUser,
468468 }},
469 Model: anthropic.ModelClaudeOpus5,
469 Model: anthropic.ModelClaudeOpus5_5,
470470})
471471if err != nil {
472472 var apierr *anthropic.Error
from line 507
507507 }},
508508 Role: anthropic.MessageParamRoleUser,
509509 }},
510 Model: anthropic.ModelClaudeOpus5,
510 Model: anthropic.ModelClaudeOpus5_5,
511511 },
512512 option.WithMaxRetries(5),
513513 )
from line 536
536536 }},
537537 Role: anthropic.MessageParamRoleUser,
538538 }},
539 Model: anthropic.ModelClaudeOpus5,
539 Model: anthropic.ModelClaudeOpus5_5,
540540 },
541541 // This sets the per-retry timeout
542542 option.WithRequestTimeout(20*time.Second),
from line 676
676676 }},
677677 Role: anthropic.MessageParamRoleUser,
678678 }},
679 Model: anthropic.ModelClaudeOpus5,
679 Model: anthropic.ModelClaudeOpus5_5,
680680 },
681681 option.WithResponseInto(&response),
682682)
cli-sdks-libraries/sdks/java Changed · +12 / -12 lines
from line 15
1515<Tabs>
1616 <Tab title="Gradle">
1717 ```kotlin
18 implementation("com.anthropic:anthropic-java:2.63.0")
18 implementation("com.anthropic:anthropic-java:2.65.0")
1919 ```
2020 </Tab>
2121
from line 24
2424 <dependency>
2525 <groupId>com.anthropic</groupId>
2626 <artifactId>anthropic-java</artifactId>
27 <version>2.63.0</version>
27 <version>2.65.0</version>
2828 </dependency>
2929 ```
3030 </Tab>
from line 54
5454MessageCreateParams params = MessageCreateParams.builder()
5555 .maxTokens(1024L)
5656 .addUserMessage("Hello, Claude")
57 .model(Model.CLAUDE_OPUS_5)
57 .model(Model.CLAUDE_OPUS_5_5)
5858 .build();
5959
6060Message message = client.messages().create(params);
from line 146
146146MessageCreateParams params = MessageCreateParams.builder()
147147 .maxTokens(1024L)
148148 .addUserMessage("Hello, Claude")
149 .model(Model.CLAUDE_OPUS_5)
149 .model(Model.CLAUDE_OPUS_5_5)
150150 .build();
151151
152152CompletableFuture<Message> message = client.async().messages().create(params);
from line 166
166166MessageCreateParams params = MessageCreateParams.builder()
167167 .maxTokens(1024L)
168168 .addUserMessage("Hello, Claude")
169 .model(Model.CLAUDE_OPUS_5)
169 .model(Model.CLAUDE_OPUS_5_5)
170170 .build();
171171
172172CompletableFuture<Message> message = client.messages().create(params);
from line 394
394394AnthropicClient client = AnthropicOkHttpClient.fromEnv();
395395
396396MessageCreateParams.Builder createParamsBuilder = MessageCreateParams.builder()
397 .model(Model.CLAUDE_OPUS_5)
397 .model(Model.CLAUDE_OPUS_5_5)
398398 .maxTokens(2048)
399399 .addTool(GetWeather.class)
400400 .addUserMessage("What's the temperature in New York?");
from line 440
440440
441441```java
442442MessageCreateParams.Builder createParamsBuilder = MessageCreateParams.builder()
443 .model(Model.CLAUDE_OPUS_5)
443 .model(Model.CLAUDE_OPUS_5_5)
444444 .maxTokens(2048)
445445 .addTool(GetWeather.class, JsonSchemaLocalValidation.NO)
446446 .addUserMessage("What's the temperature in New York?");
from line 799
799799MessageCreateParams params = MessageCreateParams.builder()
800800 .maxTokens(1024L)
801801 .addUserMessage("Hello, Claude")
802 .model(Model.CLAUDE_OPUS_5)
802 .model(Model.CLAUDE_OPUS_5_5)
803803 .build();
804804
805805// Create a modified copy using toBuilder()
from line 861
861861MessageCreateParams params = MessageCreateParams.builder()
862862 .maxTokens(JsonValue.from(3.14))
863863 .addUserMessage("Hello, Claude")
864 .model(Model.CLAUDE_OPUS_5)
864 .model(Model.CLAUDE_OPUS_5_5)
865865 .build();
866866```
867867
from line 903
903903
904904MessageCreateParams params = MessageCreateParams.builder()
905905 .addUserMessage("Hello, world")
906 .model(Model.CLAUDE_OPUS_5)
906 .model(Model.CLAUDE_OPUS_5_5)
907907 .maxTokens(JsonMissing.of())
908908 .build();
909909```
from line 1102
11021102MessageCreateParams params = MessageCreateParams.builder()
11031103 .maxTokens(1024L)
11041104 .addUserMessage("Hello, Claude")
1105 .model(Model.CLAUDE_OPUS_5)
1105 .model(Model.CLAUDE_OPUS_5_5)
11061106 .build();
11071107
11081108HttpResponseFor<Message> message = client.messages().withRawResponse().create(params);
from line 1212
12121212
12131213 BetaMessage message = client.beta().messages().create(
12141214 MessageCreateParams.builder()
1215 .model(Model.CLAUDE_OPUS_5)
1215 .model(Model.CLAUDE_OPUS_5_5)
12161216 .maxTokens(1024L)
12171217 .addBeta(AnthropicBeta.CONTEXT_MANAGEMENT_2025_06_27)
12181218 .addUserMessage("Hello, Claude")
cli-sdks-libraries/sdks/php Changed · +5 / -5 lines
from line 36
3636$message = $client->messages->create(
3737 maxTokens: 1024,
3838 messages: [['role' => 'user', 'content' => 'Hello, Claude']],
39 model: 'claude-opus-5',
39 model: 'claude-opus-5-5',
4040);
4141
4242$textBlock = array_find($message->content, static fn ($block): bool => $block->type === 'text');
from line 61
6161$stream = $client->messages->createStream(
6262 maxTokens: 1024,
6363 messages: [['role' => 'user', 'content' => 'Hello, Claude']],
64 model: 'claude-opus-5',
64 model: 'claude-opus-5-5',
6565);
6666
6767foreach ($stream as $event) {
from line 92
9292 $message = $client->messages->create(
9393 maxTokens: 1024,
9494 messages: [['role' => 'user', 'content' => 'Hello, Claude']],
95 model: 'claude-opus-5',
95 model: 'claude-opus-5-5',
9696 );
9797} catch (APIConnectionException $e) {
9898 echo "The server could not be reached", PHP_EOL;
from line 139
139139$result = $client->messages->create(
140140 maxTokens: 1024,
141141 messages: [['role' => 'user', 'content' => 'Hello, Claude']],
142 model: 'claude-opus-5',
142 model: 'claude-opus-5-5',
143143 requestOptions: RequestOptions::with(maxRetries: 5),
144144);
145145```
from line 183
183183$message = $client->messages->create(
184184 maxTokens: 1024,
185185 messages: [['role' => 'user', 'content' => 'Hello, Claude']],
186 model: 'claude-opus-5',
186 model: 'claude-opus-5-5',
187187 requestOptions: RequestOptions::with(
188188 extraQueryParams: ['my_query_parameter' => 'value'],
189189 extraBodyParams: ['my_body_parameter' => 'value'],
cli-sdks-libraries/sdks/python Changed · +19 / -19 lines
from line 57
5757 "content": "Hello, Claude",
5858 }
5959 ],
60 model="claude-opus-5",
60 model="claude-opus-5-5",
6161)
6262
6363for block in message.content:
from line 92
9292 "content": "Hello, Claude",
9393 }
9494 ],
95 model="claude-opus-5",
95 model="claude-opus-5-5",
9696 )
9797 print(message.content)
9898
from line 123
123123 "content": "Hello, Claude",
124124 }
125125 ],
126 model="claude-opus-5",
126 model="claude-opus-5-5",
127127 )
128128 print(message.content)
129129
from line 146
146146 "content": "Hello, Claude",
147147 }
148148 ],
149 model="claude-opus-5",
149 model="claude-opus-5-5",
150150 stream=True,
151151)
152152for event in stream:
from line 166
166166 "content": "Hello, Claude",
167167 }
168168 ],
169 model="claude-opus-5",
169 model="claude-opus-5-5",
170170 stream=True,
171171)
172172async for event in stream:
from line 187
187187 "content": "Say hello there!",
188188 }
189189 ],
190 model="claude-opus-5",
190 model="claude-opus-5-5",
191191 ) as stream:
192192 async for text in stream.text_stream:
193193 print(text, end="", flush=True)
from line 218
218218
219219```python
220220count = client.messages.count_tokens(
221 model="claude-opus-5", messages=[{"role": "user", "content": "Hello, world"}]
221 model="claude-opus-5-5", messages=[{"role": "user", "content": "Hello, world"}]
222222)
223223print(count.input_tokens) # 10
224224```
from line 259
259259# Use the tool_runner to automatically handle tool calls
260260runner = client.beta.messages.tool_runner(
261261 max_tokens=1024,
262 model="claude-opus-5",
262 model="claude-opus-5-5",
263263 tools=[get_weather],
264264 messages=[
265265 {"role": "user", "content": "What is the weather in SF?"},
from line 285
285285 {
286286 "custom_id": "my-first-request",
287287 "params": {
288 "model": "claude-opus-5",
288 "model": "claude-opus-5-5",
289289 "max_tokens": 1024,
290290 "messages": [{"role": "user", "content": "Hello, world"}],
291291 },
from line 293
293293 {
294294 "custom_id": "my-second-request",
295295 "params": {
296 "model": "claude-opus-5",
296 "model": "claude-opus-5-5",
297297 "max_tokens": 1024,
298298 "messages": [{"role": "user", "content": "Hi again, friend"}],
299299 },
from line 358
358358 "content": "Hello, Claude",
359359 }
360360 ],
361 model="claude-opus-5",
361 model="claude-opus-5-5",
362362 )
363363except anthropic.APIConnectionError as e:
364364 print("The server could not be reached")
from line 395
395395message = client.messages.create(
396396 max_tokens=1024,
397397 messages=[{"role": "user", "content": "Hello, Claude"}],
398 model="claude-opus-5",
398 model="claude-opus-5-5",
399399)
400400print(message._request_id) # e.g., req_018EeWyXxfu5pfWkrYcMdjWG
401401```
from line 420
420420client.with_options(max_retries=5).messages.create(
421421 max_tokens=1024,
422422 messages=[{"role": "user", "content": "Hello, Claude"}],
423 model="claude-opus-5",
423 model="claude-opus-5-5",
424424)
425425```
426426
from line 446
446446client.with_options(timeout=5.0).messages.create(
447447 max_tokens=1024,
448448 messages=[{"role": "user", "content": "Hello, Claude"}],
449 model="claude-opus-5",
449 model="claude-opus-5-5",
450450)
451451```
452452
from line 540
540540client.messages.with_raw_response.create(
541541 max_tokens=1024,
542542 messages=[{"role": "user", "content": "Hello, Claude"}],
543 model="claude-opus-5",
543 model="claude-opus-5-5",
544544 extra_headers={"anthropic-version": "My-Custom-Value"},
545545)
546546```
from line 573
573573
574574```python
575575response = client.messages.create(
576 model="claude-opus-5",
576 model="claude-opus-5-5",
577577 max_tokens=1024,
578578 messages=[{"role": "user", "content": "Hello"}],
579579)
from line 596
596596response = client.messages.with_raw_response.create(
597597 max_tokens=1024,
598598 messages=[{"role": "user", "content": "Hello, Claude"}],
599 model="claude-opus-5",
599 model="claude-opus-5-5",
600600)
601601
602602print(response.headers.get("request-id"))
from line 616
616616with client.messages.with_streaming_response.create(
617617 max_tokens=1024,
618618 messages=[{"role": "user", "content": "Hello, Claude"}],
619 model="claude-opus-5",
619 model="claude-opus-5-5",
620620) as response:
621621 print(response.headers.get("request-id"))
622622
from line 721
721721client = Anthropic()
722722
723723response = client.beta.messages.create(
724 model="claude-opus-5",
724 model="claude-opus-5-5",
725725 max_tokens=1024,
726726 messages=[{"role": "user", "content": "Hello, Claude"}],
727727 betas=["context-management-2025-06-27"],
cli-sdks-libraries/sdks/ruby Changed · +11 / -11 lines
from line 32
3232message = anthropic.messages.create(
3333 max_tokens: 1024,
3434 messages: [{role: "user", content: "Hello, Claude"}],
35 model: :"claude-opus-5"
35 model: :"claude-opus-5-5"
3636)
3737
3838message.content.each do |block|
from line 51
5151stream = anthropic.messages.stream(
5252 max_tokens: 1024,
5353 messages: [{role: "user", content: "Hello, Claude"}],
54 model: :"claude-opus-5"
54 model: :"claude-opus-5-5"
5555)
5656
5757stream.each do |message|
from line 68
6868stream = anthropic.messages.stream(
6969 max_tokens: 1024,
7070 messages: [{role: :user, content: "Say hello there!"}],
71 model: :"claude-opus-5"
71 model: :"claude-opus-5-5"
7272)
7373
7474stream.text.each do |text|
from line 100
100100
101101# Automatically handles tool execution loop
102102anthropic.beta.messages.tool_runner(
103 model: "claude-opus-5",
103 model: "claude-opus-5-5",
104104 max_tokens: 1024,
105105 messages: [{role: "user", content: "What's 15 * 7?"}],
106106 tools: [Calculator.new]
from line 121
121121 message = anthropic.messages.create(
122122 max_tokens: 1024,
123123 messages: [{role: "user", content: "Hello, Claude"}],
124 model: :"claude-opus-5"
124 model: :"claude-opus-5-5"
125125 )
126126rescue Anthropic::Errors::APIConnectionError => e
127127 puts("The server could not be reached")
from line 168
168168anthropic.messages.create(
169169 max_tokens: 1024,
170170 messages: [{role: "user", content: "Hello, Claude"}],
171 model: :"claude-opus-5",
171 model: :"claude-opus-5-5",
172172 request_options: {max_retries: 5}
173173)
174174```
from line 187
187187anthropic.messages.create(
188188 max_tokens: 1024,
189189 messages: [{role: "user", content: "Hello, Claude"}],
190 model: :"claude-opus-5",
190 model: :"claude-opus-5-5",
191191 request_options: {timeout: 5}
192192)
193193```
from line 262
262262anthropic.messages.create(
263263 max_tokens: 1024,
264264 messages: [Anthropic::MessageParam.new(role: "user", content: "Hello, Claude")],
265 model: :"claude-opus-5"
265 model: :"claude-opus-5-5"
266266)
267267```
268268
from line 274
274274anthropic.messages.create(
275275 max_tokens: 1024,
276276 messages: [{role: "user", content: "Hello, Claude"}],
277 model: :"claude-opus-5"
277 model: :"claude-opus-5-5"
278278)
279279
280280# You can also splat a full Params class:
from line 281
281281params = Anthropic::MessageCreateParams.new(
282282 max_tokens: 1024,
283283 messages: [Anthropic::MessageParam.new(role: "user", content: "Hello, Claude")],
284 model: :"claude-opus-5"
284 model: :"claude-opus-5-5"
285285)
286286anthropic.messages.create(**params)
287287```
from line 353
353353 anthropic.messages.create(
354354 max_tokens: 1024,
355355 messages: [{role: "user", content: "Hello, Claude"}],
356 model: :"claude-opus-5",
356 model: :"claude-opus-5-5",
357357 request_options: {
358358 extra_query: {my_query_parameter: value},
359359 extra_body: {my_body_parameter: value},
cli-sdks-libraries/sdks/typescript Changed · +18 / -18 lines
from line 45
4545const message = await client.messages.create({
4646 max_tokens: 1024,
4747 messages: [{ role: "user", content: "Hello, Claude" }],
48 model: "claude-opus-5"
48 model: "claude-opus-5-5"
4949});
5050
5151for (const block of message.content) {
from line 69
6969const params: Anthropic.MessageCreateParams = {
7070 max_tokens: 1024,
7171 messages: [{ role: "user", content: "Hello, Claude" }],
72 model: "claude-opus-5"
72 model: "claude-opus-5-5"
7373};
7474const message: Anthropic.Message = await client.messages.create(params);
7575```
from line 96
9696const stream = await client.messages.create({
9797 max_tokens: 1024,
9898 messages: [{ role: "user", content: "Hello, Claude" }],
99 model: "claude-opus-5",
99 model: "claude-opus-5-5",
100100 stream: true
101101});
102102for await (const messageStreamEvent of stream) {
from line 115
115115
116116const stream = anthropic.messages
117117 .stream({
118 model: "claude-opus-5",
118 model: "claude-opus-5-5",
119119 max_tokens: 1024,
120120 messages: [
121121 {
from line 160
160160});
161161
162162const finalMessage = await anthropic.beta.messages.toolRunner({
163 model: "claude-opus-5",
163 model: "claude-opus-5-5",
164164 max_tokens: 1000,
165165 messages: [{ role: "user", content: "What is the weather in San Francisco?" }],
166166 tools: [weatherTool]
from line 236
236236// Use MCP prompts
237237const { messages } = await mcpClient.getPrompt({ name: "my-prompt" });
238238const response = await anthropic.beta.messages.create({
239 model: "claude-opus-5",
239 model: "claude-opus-5-5",
240240 max_tokens: 1024,
241241 messages: mcpMessages(messages)
242242});
from line 245
245245// Use MCP tools with toolRunner
246246const { tools } = await mcpClient.listTools();
247247const finalMessage = await anthropic.beta.messages.toolRunner({
248 model: "claude-opus-5",
248 model: "claude-opus-5-5",
249249 max_tokens: 1024,
250250 messages: [{ role: "user", content: "Use the available tools" }],
251251 tools: mcpTools(tools, mcpClient)
from line 255
255255// Use MCP resources as content
256256const resource = await mcpClient.readResource({ uri: "file:///path/to/doc.txt" });
257257await anthropic.beta.messages.create({
258 model: "claude-opus-5",
258 model: "claude-opus-5-5",
259259 max_tokens: 1024,
260260 messages: [
261261 {
from line 291
291291 {
292292 custom_id: "my-first-request",
293293 params: {
294 model: "claude-opus-5",
294 model: "claude-opus-5-5",
295295 max_tokens: 1024,
296296 messages: [{ role: "user", content: "Hello, world" }]
297297 }
from line 299
299299 {
300300 custom_id: "my-second-request",
301301 params: {
302 model: "claude-opus-5",
302 model: "claude-opus-5-5",
303303 max_tokens: 1024,
304304 messages: [{ role: "user", content: "Hi again, friend" }]
305305 }
from line 372
372372 .create({
373373 max_tokens: 1024,
374374 messages: [{ role: "user", content: "Hello, Claude" }],
375 model: "claude-opus-5"
375 model: "claude-opus-5-5"
376376 })
377377 .catch(async (err) => {
378378 if (err instanceof Anthropic.APIError) {
from line 409
409409const message = await client.messages.create({
410410 max_tokens: 1024,
411411 messages: [{ role: "user", content: "Hello, Claude" }],
412 model: "claude-opus-5"
412 model: "claude-opus-5-5"
413413});
414414console.log(message._request_id); // req_018EeWyXxfu5pfWkrYcMdjWG
415415```
from line 431
431431 {
432432 max_tokens: 1024,
433433 messages: [{ role: "user", content: "Hello, Claude" }],
434 model: "claude-opus-5"
434 model: "claude-opus-5-5"
435435 },
436436 { maxRetries: 5 }
437437);
from line 462
462462 {
463463 max_tokens: 1024,
464464 messages: [{ role: "user", content: "Hello, Claude" }],
465 model: "claude-opus-5"
465 model: "claude-opus-5-5"
466466 },
467467 { timeout: 5 * 1000 }
468468);
from line 531
531531 {
532532 max_tokens: 1024,
533533 messages: [{ role: "user", content: "Hello, Claude" }],
534 model: "claude-opus-5"
534 model: "claude-opus-5-5"
535535 },
536536 { headers: { "anthropic-version": "My-Custom-Value" } }
537537);
from line 552
552552 .create({
553553 max_tokens: 1024,
554554 messages: [{ role: "user", content: "Hello, Claude" }],
555 model: "claude-opus-5"
555 model: "claude-opus-5-5"
556556 })
557557 .asResponse();
558558console.log(response.headers.get("X-My-Header"));
from line 562
562562 .create({
563563 max_tokens: 1024,
564564 messages: [{ role: "user", content: "Hello, Claude" }],
565 model: "claude-opus-5"
565 model: "claude-opus-5-5"
566566 })
567567 .withResponse();
568568console.log(raw.headers.get("X-My-Header"));
from line 735
735735```typescript
736736const client = new Anthropic();
737737const response = await client.beta.messages.create({
738 model: "claude-opus-5",
738 model: "claude-opus-5-5",
739739 max_tokens: 1024,
740740 messages: [{ role: "user", content: "Hello, Claude" }],
741741 betas: ["context-management-2025-06-27"]
get-started Changed · +13 / -13 lines
from line 31
3131 -H "x-api-key: $ANTHROPIC_API_KEY" \
3232 -H "anthropic-version: 2023-06-01" \
3333 -d '{
34 "model": "claude-opus-5",
34 "model": "claude-opus-5-5",
3535 "max_tokens": 1000,
3636 "messages": [
3737 {
from line 46
4646
4747 ```json Output
4848 {
49 "model": "claude-opus-5",
49 "model": "claude-opus-5-5",
5050 "id": "msg_013mHbppMPd2PrVJzGMZPt2D",
5151 "type": "message",
5252 "role": "assistant",
from line 102
102102
103103 ```bash CLI
104104 ant messages create \
105 --model claude-opus-5 \
105 --model claude-opus-5-5 \
106106 --max-tokens 1000 \
107107 --message '{
108108 role: user,
from line 114
114114
115115 ```json Output
116116 {
117 "model": "claude-opus-5",
117 "model": "claude-opus-5-5",
118118 "id": "msg_01N1ycuCkM5Mzd7WhTU4fwST",
119119 "type": "message",
120120 "role": "assistant",
from line 161
161161 client = anthropic.Anthropic()
162162
163163 message = client.messages.create(
164 model="claude-opus-5",
164 model="claude-opus-5-5",
165165 max_tokens=1000,
166166 messages=[
167167 {
from line 221
221221 const client = new Anthropic();
222222
223223 const message = await client.messages.create({
224 model: "claude-opus-5",
224 model: "claude-opus-5-5",
225225 max_tokens: 1000,
226226 messages: [
227227 {
from line 286
286286
287287 var message = await client.Messages.Create(new MessageCreateParams
288288 {
289 Model = Model.ClaudeOpus5,
289 Model = Model.ClaudeOpus5_5,
290290 MaxTokens = 1000,
291291 Messages =
292292 [
from line 362
362362 client := anthropic.NewClient()
363363
364364 message, err := client.Messages.New(context.Background(), anthropic.MessageNewParams{
365 Model: anthropic.ModelClaudeOpus5,
365 Model: anthropic.ModelClaudeOpus5_5,
366366 MaxTokens: 1000,
367367 Messages: []anthropic.MessageParam{
368368 anthropic.NewUserMessage(anthropic.NewTextBlock("What should I search for to find the latest developments in renewable energy?")),
from line 436
436436 }
437437
438438 dependencies {
439 implementation("com.anthropic:anthropic-java:2.63.0")
439 implementation("com.anthropic:anthropic-java:2.65.0")
440440 }
441441
442442 application {
from line 462
462462 <dependency>
463463 <groupId>com.anthropic</groupId>
464464 <artifactId>anthropic-java</artifactId>
465 <version>2.63.0</version>
465 <version>2.65.0</version>
466466 </dependency>
467467 </dependencies>
468468 </project>
from line 484
484484 var client = AnthropicOkHttpClient.fromEnv();
485485
486486 var params = MessageCreateParams.builder()
487 .model(Model.CLAUDE_OPUS_5)
487 .model(Model.CLAUDE_OPUS_5_5)
488488 .maxTokens(1000)
489489 .addUserMessage(
490490 "What should I search for to find the latest developments in renewable energy?"
from line 556
556556 $client = new Client();
557557
558558 $message = $client->messages->create(
559 model: Model::CLAUDE_OPUS_5,
559 model: Model::CLAUDE_OPUS_5_5,
560560 maxTokens: 1000,
561561 messages: [
562562 [
from line 617
617617 client = Anthropic::Client.new
618618
619619 message = client.messages.create(
620 model: Anthropic::Model::CLAUDE_OPUS_5,
620 model: Anthropic::Model::CLAUDE_OPUS_5_5,
621621 max_tokens: 1000,
622622 messages: [
623623 {