Sweep 22 Sep 2026 · 17:19Z Build v2.1.280 501 read Stable v2.1.267 Latest v2.1.280 Next v2.1.280 Feeds RSS JSON llms.txt Unofficial
One change · api

Request 2 caches its request content (not the response) changed

build-with-claude/prompt-caching

Nearest release: v2.1.280, published under an hour before this site recorded the change. Shown because the two are within 24 hours of each other. Nothing here says the release caused the edit.

Recorded here
Lines+95added
Lines−88removed
From line 24 where the diff opens
First seen 14 Aug 2026 this site's first read of the page
Recorded edits9to this page, all time

The whole hunk

from line 24, old and new numbered
/
lines
from line 24
2424 -H "x-api-key: $ANTHROPIC_API_KEY" \
2525 -H "anthropic-version: 2023-06-01" \
2626 -d '{
27 "model": "claude-opus-5",
27 "model": "claude-opus-5-5",
2828 "max_tokens": 1024,
2929 "cache_control": {"type": "ephemeral"},
3030 "system": "You are an AI assistant tasked with analyzing literary works. Your goal is to provide insightful commentary on themes, characters, and writing style.",
from line 39
3939 
4040 ```bash CLI
4141 ant messages create --transform usage <<'YAML'
42 model: claude-opus-5
42 model: claude-opus-5-5
4343 max_tokens: 1024
4444 cache_control:
4545 type: ephemeral
from line 56
5656 client = anthropic.Anthropic()
5757 
5858 response = client.messages.create(
59 model="claude-opus-5",
59 model="claude-opus-5-5",
6060 max_tokens=1024,
6161 cache_control={"type": "ephemeral"},
6262 system="You are an AI assistant tasked with analyzing literary works. Your goal is to provide insightful commentary on themes, characters, and writing style.",
from line 74
7474 const client = new Anthropic();
7575 
7676 const response = await client.messages.create({
77 model: "claude-opus-5",
77 model: "claude-opus-5-5",
7878 max_tokens: 1024,
7979 cache_control: { type: "ephemeral" },
8080 system:
from line 94
9494 
9595 var parameters = new MessageCreateParams
9696 {
97 Model = Model.ClaudeOpus5,
97 Model = Model.ClaudeOpus5_5,
9898 MaxTokens = 1024,
9999 CacheControl = new CacheControlEphemeral(),
100100 System = "You are an AI assistant tasked with analyzing literary works. Your goal is to provide insightful commentary on themes, characters, and writing style.",
from line 116
116116 client := anthropic.NewClient()
117117 
118118 response, err := client.Messages.New(context.TODO(), anthropic.MessageNewParams{
119 Model: anthropic.ModelClaudeOpus5,
119 Model: anthropic.ModelClaudeOpus5_5,
120120 MaxTokens: 1024,
121121 CacheControl: anthropic.NewCacheControlEphemeralParam(),
122122 System: []anthropic.TextBlockParam{
from line 141
141141 AnthropicClient client = AnthropicOkHttpClient.fromEnv();
142142 
143143 MessageCreateParams params = MessageCreateParams.builder()
144 .model(Model.CLAUDE_OPUS_5)
144 .model(Model.CLAUDE_OPUS_5_5)
145145 .maxTokens(1024)
146146 .cacheControl(CacheControlEphemeral.builder().build())
147147 .system("You are an AI assistant tasked with analyzing literary works. Your goal is to provide insightful commentary on themes, characters, and writing style.")
from line 164
164164 messages: [
165165 ['role' => 'user', 'content' => "Analyze the major themes in 'Pride and Prejudice'."]
166166 ],
167 model: 'claude-opus-5',
167 model: 'claude-opus-5-5',
168168 cacheControl: CacheControlEphemeral::with(),
169169 system: "You are an AI assistant tasked with analyzing literary works. Your goal is to provide insightful commentary on themes, characters, and writing style.",
170170 );
from line 175
175175 client = Anthropic::Client.new
176176 
177177 response = client.messages.create(
178 model: "claude-opus-5",
178 model: "claude-opus-5-5",
179179 max_tokens: 1024,
180180 cache_control: {type: "ephemeral"},
181181 system: "You are an AI assistant tasked with analyzing literary works. Your goal is to provide insightful commentary on themes, characters, and writing style.",
from line 222
222222<Tip>
223223 **Prompt caching caches the full prefix**
224224 
225 Prompt caching references the entire prompt - `tools`, `system`, and `messages` (in that order) up to and including the block designated with `cache_control`.
225 Prompt caching references the entire prompt: `tools`, `system`, and `messages` (in that order), up to and including the block designated with `cache_control`.
226226</Tip>
227227 
228228***
from line 237
237237| Claude Mythos 5.1 ([limited availability](https://anthropic.com/glasswing)) | $10 / MTok | $12.50 / MTok | $20 / MTok | $0.25 / MTok<sup>1</sup> | $50 / MTok |
238238| Claude Fable 5 | $10 / MTok | $12.50 / MTok | $20 / MTok | $1 / MTok | $50 / MTok |
239239| Claude Mythos 5 ([limited availability](https://anthropic.com/glasswing)) | $10 / MTok | $12.50 / MTok | $20 / MTok | $1 / MTok | $50 / MTok |
240| Claude Opus 5.5 | $4 / MTok | $5 / MTok | $8 / MTok | $0.20 / MTok<sup>2</sup> | $20 / MTok |
240241| Claude Opus 5 | $5 / MTok | $6.25 / MTok | $10 / MTok | $0.50 / MTok | $25 / MTok |
241242| Claude Opus 4.8 | $5 / MTok | $6.25 / MTok | $10 / MTok | $0.50 / MTok | $25 / MTok |
242243| Claude Opus 4.7 | $5 / MTok | $6.25 / MTok | $10 / MTok | $0.50 / MTok | $25 / MTok |
from line 252
251252| Claude Haiku 4.5 | $1 / MTok | $1.25 / MTok | $2 / MTok | $0.10 / MTok | $5 / MTok |
252253| Claude Haiku 3.5 ([retired, except on Bedrock and Google Cloud](https://platform.claude.com/docs/en/about-claude/model-deprecations)) | $0.80 / MTok | $1 / MTok | $1.60 / MTok | $0.08 / MTok | $4 / MTok |
253254 
254*<sup>1 Cache hits and refreshes on Claude Fable 5.1 and Claude Mythos 5.1 are priced at 0.025x the base input price. All other models use the standard 0.1x multiplier.</sup>*
255*<sup>1 Cache hits and refreshes on Claude Fable 5.1 and Claude Mythos 5.1 are priced at 0.025x the base input price.</sup>*
255256 
257*<sup>2 Cache hits and refreshes on Claude Opus 5.5 are priced at 0.05x the base input price.</sup>*
258 
259*<sup>All other models use the standard 0.1x multiplier.</sup>*
260 
256261<Note>
257262 The previous table reflects the following pricing multipliers for prompt caching:
258263 
from line 287
282287 -H "x-api-key: $ANTHROPIC_API_KEY" \
283288 -H "anthropic-version: 2023-06-01" \
284289 -d '{
285 "model": "claude-opus-5",
290 "model": "claude-opus-5-5",
286291 "max_tokens": 1024,
287292 "cache_control": {"type": "ephemeral"},
288293 "system": "You are a helpful assistant that remembers our conversation.",
from line 301
296301 
297302 ```bash CLI
298303 ant messages create --transform usage <<'YAML'
299 model: claude-opus-5
304 model: claude-opus-5-5
300305 max_tokens: 1024
301306 cache_control:
302307 type: ephemeral
from line 320
315320 client = anthropic.Anthropic()
316321 
317322 response = client.messages.create(
318 model="claude-opus-5",
323 model="claude-opus-5-5",
319324 max_tokens=1024,
320325 cache_control={"type": "ephemeral"},
321326 system="You are a helpful assistant that remembers our conversation.",
from line 340
335340 const client = new Anthropic();
336341 
337342 const response = await client.messages.create({
338 model: "claude-opus-5",
343 model: "claude-opus-5-5",
339344 max_tokens: 1024,
340345 cache_control: { type: "ephemeral" },
341346 system: "You are a helpful assistant that remembers our conversation.",
from line 361
356361 
357362 var parameters = new MessageCreateParams
358363 {
359 Model = Model.ClaudeOpus5,
364 Model = Model.ClaudeOpus5_5,
360365 MaxTokens = 1024,
361366 CacheControl = new CacheControlEphemeral(),
362367 System = "You are a helpful assistant that remembers our conversation.",
from line 393
388393 client := anthropic.NewClient()
389394 
390395 response, err := client.Messages.New(context.TODO(), anthropic.MessageNewParams{
391 Model: anthropic.ModelClaudeOpus5,
396 Model: anthropic.ModelClaudeOpus5_5,
392397 MaxTokens: 1024,
393398 CacheControl: anthropic.NewCacheControlEphemeralParam(),
394399 System: []anthropic.TextBlockParam{
from line 420
415420 AnthropicClient client = AnthropicOkHttpClient.fromEnv();
416421 
417422 MessageCreateParams params = MessageCreateParams.builder()
418 .model(Model.CLAUDE_OPUS_5)
423 .model(Model.CLAUDE_OPUS_5_5)
419424 .maxTokens(1024)
420425 .cacheControl(CacheControlEphemeral.builder().build())
421426 .system("You are a helpful assistant that remembers our conversation.")
from line 447
442447 ['role' => 'assistant', 'content' => 'Nice to meet you, Alex! How can I help with your ML work today?'],
443448 ['role' => 'user', 'content' => 'What did I say I work on?'],
444449 ],
445 model: 'claude-opus-5',
450 model: 'claude-opus-5-5',
446451 cacheControl: CacheControlEphemeral::with(),
447452 system: 'You are a helpful assistant that remembers our conversation.',
448453 );
from line 458
453458 client = Anthropic::Client.new
454459 
455460 response = client.messages.create(
456 model: "claude-opus-5",
461 model: "claude-opus-5-5",
457462 max_tokens: 1024,
458463 cache_control: {type: "ephemeral"},
459464 system: "You are a helpful assistant that remembers our conversation.",
from line 500
495500 
496501```json
497502{
498 "model": "claude-opus-5",
503 "model": "claude-opus-5-5",
499504 "max_tokens": 1024,
500505 "cache_control": { "type": "ephemeral" },
501506 "system": [
from line 523
518523* If the last block already has an explicit `cache_control` with the same TTL, automatic caching is a no-op.
519524* If the last block has an explicit `cache_control` with a different TTL, the API returns a 400 error.
520525* If 4 explicit block-level breakpoints already exist, the API returns a 400 error (no slots left for automatic caching).
521* If the last block is not eligible as an automatic cache breakpoint target, the system silently walks backwards to find the nearest eligible block. If none is found, caching is skipped.
526* If the last block is not eligible as an automatic cache breakpoint target, the system silently walks backward to find the nearest eligible block. If none is found, caching is skipped.
522527 
523528<Note>
524529 Automatic caching is available on every platform except the legacy [Amazon Bedrock (Opus 4.6 and earlier)](https://platform.claude.com/docs/en/build-with-claude/claude-on-amazon-bedrock-legacy) integration. On that integration, the API returns a 400 error for a top-level `cache_control` field, so use [explicit cache breakpoints](https://platform.claude.com/docs/en/build-with-claude/prompt-caching#explicit-cache-breakpoints) instead.
from line 589
584589**Cache breakpoints themselves don't add any cost.** You are only charged for:
585590 
586591* **Cache writes:** When new content is written to the cache (25% more than base input tokens for 5-minute TTL)
587* **Cache reads:** When cached content is used (10% of base input token price, or 2.5% on Claude Fable 5.1 and Claude Mythos 5.1)
592* **Cache reads:** When cached content is used (10% of base input token price, or 2.5% on Claude Fable 5.1 and Claude Mythos 5.1, and 5% on Claude Opus 5.5)
588593* **Regular input tokens:** For any uncached content
589594 
590Adding more `cache_control` breakpoints doesn't increase your costs - you still pay the same amount based on what content is actually cached and read. The breakpoints give you control over what sections can be cached independently.
595Adding more `cache_control` breakpoints doesn't increase your costs; you still pay the same amount based on what content is actually cached and read. The breakpoints give you control over what sections can be cached independently.
591596 
592597***
593598 
from line 602
597602 
598603On the Claude API, [Claude Platform on AWS](https://platform.claude.com/docs/en/build-with-claude/claude-platform-on-aws), [Google Cloud](https://platform.claude.com/docs/en/build-with-claude/claude-on-vertex-ai), and [Microsoft Foundry](https://platform.claude.com/docs/en/build-with-claude/claude-in-microsoft-foundry), the minimum cacheable prompt length is:
599604 
600* 512 tokens for Claude Fable 5.1, Claude Mythos 5.1, Claude Opus 5, Claude Fable 5, and [Claude Mythos 5](https://anthropic.com/glasswing)
605* 512 tokens for Claude Fable 5.1, Claude Mythos 5.1, Claude Opus 5.5, Claude Opus 5, Claude Fable 5, and [Claude Mythos 5](https://anthropic.com/glasswing)
601606* 2,048 tokens for [Claude Mythos Preview](https://anthropic.com/glasswing) and Claude Opus 4.7
602607* 4,096 tokens for Claude Opus 4.6 and Claude Opus 4.5
603608* 1,024 tokens for Claude Opus 4.8, Claude Sonnet 5, Claude Sonnet 4.6, Claude Sonnet 4.5, Claude Opus 4.1 ([retired, except on Bedrock and Google Cloud](https://platform.claude.com/docs/en/about-claude/model-deprecations)), Claude Opus 4 ([retired, except on Google Cloud](https://platform.claude.com/docs/en/about-claude/model-deprecations)), and Claude Sonnet 4 ([retired, except on Bedrock and Google Cloud](https://platform.claude.com/docs/en/about-claude/model-deprecations))
from line 668
663668| **Non-tool results passed to extended thinking requests** | ✓ | ✓ | Model-specific | On Opus 4.5+ and Sonnet 4.6+, thinking blocks are preserved by default, so the cache remains valid (✓). On earlier Opus/Sonnet models and all Haiku models, all previously-cached thinking blocks are stripped from context, and any messages that follow those thinking blocks are removed from the cache (✘). For more details, see [Caching with thinking blocks](https://platform.claude.com/docs/en/build-with-claude/prompt-caching#caching-with-thinking-blocks). |
664669| **Dropped thinking blocks** | ✓ | ✓ | ✘ | When the API drops a Claude Fable 5.1 or Claude Mythos 5.1 thinking block that isn't [preserved](https://platform.claude.com/docs/en/build-with-claude/thinking#preserved-thinking) on that request (for example, one you replay to an earlier model), the cached prefix changes from that block's position onward on that request. Blocks the receiving model can read, passed back unchanged, keep the cache intact. |
665670 
671On models that support [mid-conversation tool changes](https://platform.claude.com/docs/en/build-with-claude/mid-conversation-system-messages#mid-conversation-tool-changes), the `inline-tools-2026-09-15` beta header lets you add a tool, or change a tool's definition, partway through a conversation without editing `tools`. Send the definition in a `tool_addition` block in a mid-conversation system message and leave `tools` exactly as you first sent it. The cached prefix still matches, so only the appended message is processed as new input. The one exception is a `tools` array with no non-deferred tool, where the first tool defined this way costs one full cache miss on that request. See [Define tools in a message](https://platform.claude.com/docs/en/build-with-claude/mid-conversation-system-messages#define-tools-in-a-message-beta).
672 
666673<Note>
667 On Claude Fable 5.1, Claude Mythos 5.1, Claude Fable 5, [Claude Mythos 5](https://anthropic.com/glasswing), Claude Opus 4.8, and Claude Opus 5, you can add a new system instruction partway through a conversation without invalidating the system or message caches. Append a `{"role": "system"}` message to `messages` instead of editing the top-level `system` field, so the cached prefix stays unchanged. This feature is not available on Claude Sonnet 5. Use the top-level `system` field instead. See [Mid-conversation system messages](https://platform.claude.com/docs/en/build-with-claude/mid-conversation-system-messages).
674 On Claude Fable 5.1, Claude Mythos 5.1, Claude Fable 5, [Claude Mythos 5](https://anthropic.com/glasswing), Claude Opus 5.5, Claude Opus 4.8, and Claude Opus 5, you can add a new system instruction partway through a conversation without invalidating the system or message caches. Append a `{"role": "system"}` message to `messages` instead of editing the top-level `system` field, so the cached prefix stays unchanged. This feature is not available on Claude Sonnet 5. Use the top-level `system` field instead. See [Mid-conversation system messages](https://platform.claude.com/docs/en/build-with-claude/mid-conversation-system-messages).
668675</Note>
669676 
670677### Tracking cache performance
from line 685
678685<Note>
679686 **Understanding the token breakdown**
680687 
681 The `input_tokens` field represents only the tokens that come **after the last cache breakpoint** in your request - not all the input tokens you sent.
688 The `input_tokens` field represents only the tokens that come **after the last cache breakpoint** in your request, not all the input tokens you sent.
682689 
683690 To calculate total input tokens:
684691 
from line 782
775782Tailor your prompt caching strategy to your scenario:
776783 
777784* Conversational agents: Reduce cost and latency for extended conversations, especially those with long instructions or uploaded documents.
778* Coding assistants: Improve autocomplete and codebase Q\&A by keeping relevant sections or a summarized version of the codebase in the prompt.
785* Coding assistants: Improve autocomplete and code base Q\&A by keeping relevant sections or a summarized version of the code base in the prompt.
779786* Large document processing: Incorporate complete long-form material including images in your prompt without increasing response latency.
780787* Detailed instruction sets: Share extensive lists of instructions, procedures, and examples to fine-tune Claude's responses. Developers often include an example or two in the prompt, but with prompt caching you can get even better performance by including 20+ diverse examples of high quality answers.
781788* Agentic tool use: Enhance performance for scenarios involving multiple tool calls and iterative code changes, where each step typically requires a new API call.
from line 856
849856The 1-hour cache is best used in the following scenarios:
850857 
851858* When you have prompts that are likely used less frequently than 5 minutes, but more frequently than every hour. For example, when an agentic side-agent will take longer than 5 minutes, or when storing a long chat conversation with a user and you generally expect that user may not respond in the next 5 minutes.
852* When latency is important and your follow up prompts may be sent beyond 5 minutes.
859* When latency is important and your follow-up prompts may be sent beyond 5 minutes.
853860* When you want to improve your rate limit utilization, because cache hits are not deducted against your rate limit.
854861 
855862<Note>
from line 908
901908 -H "x-api-key: $ANTHROPIC_API_KEY" \
902909 -H "anthropic-version: 2023-06-01" \
903910 -d '{
904 "model": "claude-opus-5",
911 "model": "claude-opus-5-5",
905912 "max_tokens": 0,
906913 "system": [
907914 {
from line 924
917924 ```bash CLI
918925 ant messages create \
919926 --transform '{stop_reason,content,usage}' --format yaml <<'YAML'
920 model: claude-opus-5
927 model: claude-opus-5-5
921928 max_tokens: 0
922929 system:
923930 - type: text
from line 944
937944 
938945 # Fire this before users arrive to warm the shared system-prompt cache.
939946 prewarm = client.messages.create(
940 model="claude-opus-5",
947 model="claude-opus-5-5",
941948 max_tokens=0,
942949 system=[
943950 {
from line 965
958965 
959966 // Fire this before users arrive to warm the shared system-prompt cache.
960967 const prewarm = await client.messages.create({
961 model: "claude-opus-5",
968 model: "claude-opus-5-5",
962969 max_tokens: 0,
963970 system: [
964971 {
from line 987
980987 var prewarm = await client.Messages.Create(
981988 new()
982989 {
983 Model = Model.ClaudeOpus5,
990 Model = Model.ClaudeOpus5_5,
984991 MaxTokens = 0,
985992 System = new(
986993 [
from line 1011
10041011 client := anthropic.NewClient()
10051012 
10061013 prewarm, err := client.Messages.New(context.TODO(), anthropic.MessageNewParams{
1007 Model: anthropic.ModelClaudeOpus5,
1014 Model: anthropic.ModelClaudeOpus5_5,
10081015 MaxTokens: 0,
10091016 System: []anthropic.TextBlockParam{
10101017 {
from line 1036
10291036 AnthropicClient client = AnthropicOkHttpClient.fromEnv();
10301037 
10311038 Message prewarm = client.messages().create(MessageCreateParams.builder()
1032 .model(Model.CLAUDE_OPUS_5)
1039 .model(Model.CLAUDE_OPUS_5_5)
10331040 .maxTokens(0)
10341041 .systemOfTextBlockParams(List.of(TextBlockParam.builder()
10351042 .text("You are an expert software engineer with deep knowledge of distributed systems...")
from line 1054
10471054 $client = new Client();
10481055 
10491056 $prewarm = $client->messages->create(
1050 model: Model::CLAUDE_OPUS_5,
1057 model: Model::CLAUDE_OPUS_5_5,
10511058 maxTokens: 0,
10521059 system: [
10531060 [
from line 1075
10681075 client = Anthropic::Client.new
10691076 
10701077 prewarm = client.messages.create(
1071 model: Anthropic::Model::CLAUDE_OPUS_5,
1078 model: Anthropic::Model::CLAUDE_OPUS_5_5,
10721079 max_tokens: 0,
10731080 system_: [
10741081 {
from line 1101
10941101 "type": "message",
10951102 "role": "assistant",
10961103 "content": [],
1097 "model": "claude-opus-5",
1104 "model": "claude-opus-5-5",
10981105 "stop_reason": "max_tokens",
10991106 "stop_sequence": null,
11001107 "usage": {
from line 1144
11371144 -H "x-api-key: $ANTHROPIC_API_KEY" \
11381145 -H "anthropic-version: 2023-06-01" \
11391146 -d '{
1140 "model": "claude-opus-5",
1147 "model": "claude-opus-5-5",
11411148 "max_tokens": 0,
11421149 "system": [
11431150 {
from line 1162
11551162 -H "x-api-key: $ANTHROPIC_API_KEY" \
11561163 -H "anthropic-version: 2023-06-01" \
11571164 -d '{
1158 "model": "claude-opus-5",
1165 "model": "claude-opus-5-5",
11591166 "max_tokens": 1024,
11601167 "system": [
11611168 {
from line 1178
11711178 ```bash CLI
11721179 # Warm the cache at application startup or on a scheduled interval.
11731180 ant messages create --transform usage <<'YAML'
1174 model: claude-opus-5
1181 model: claude-opus-5-5
11751182 max_tokens: 0
11761183 system:
11771184 - type: text
from line 1194
11871194 
11881195 # Later, when the user submits a message, the system-prompt prefix is already cached.
11891196 ant messages create --transform 'content.#(type=="text").text' --raw-output <<'YAML'
1190 model: claude-opus-5
1197 model: claude-opus-5-5
11911198 max_tokens: 1024
11921199 system:
11931200 - type: text
from line 1224
12171224 def prewarm_cache() -> None:
12181225 """Call this at application startup or on a scheduled interval."""
12191226 client.messages.create(
1220 model="claude-opus-5",
1227 model="claude-opus-5-5",
12211228 max_tokens=0,
12221229 system=SYSTEM_PROMPT,
12231230 messages=[{"role": "user", "content": "warmup"}],
from line 1234
12271234 def respond(user_message: str) -> anthropic.types.Message:
12281235 """The real user request; benefits from a warm cache."""
12291236 return client.messages.create(
1230 model="claude-opus-5",
1237 model="claude-opus-5-5",
12311238 max_tokens=1024,
12321239 system=SYSTEM_PROMPT,
12331240 messages=[{"role": "user", "content": user_message}],
from line 1265
12581265 // Call this at application startup or on a scheduled interval.
12591266 async function prewarmCache(): Promise<void> {
12601267 await client.messages.create({
1261 model: "claude-opus-5",
1268 model: "claude-opus-5-5",
12621269 max_tokens: 0,
12631270 system: SYSTEM_PROMPT,
12641271 messages: [{ role: "user", content: "warmup" }]
from line 1275
12681275 // The real user request; benefits from a warm cache.
12691276 async function respond(userMessage: string): Promise<Anthropic.Message> {
12701277 return client.messages.create({
1271 model: "claude-opus-5",
1278 model: "claude-opus-5-5",
12721279 max_tokens: 1024,
12731280 system: SYSTEM_PROMPT,
12741281 messages: [{ role: "user", content: userMessage }]
from line 1310
13031310 await client.Messages.Create(
13041311 new()
13051312 {
1306 Model = Model.ClaudeOpus5,
1313 Model = Model.ClaudeOpus5_5,
13071314 MaxTokens = 0,
13081315 System = new(systemPrompt),
13091316 Messages = [new() { Role = Role.User, Content = "warmup" }],
from line 1322
13151322 await client.Messages.Create(
13161323 new()
13171324 {
1318 Model = Model.ClaudeOpus5,
1325 Model = Model.ClaudeOpus5_5,
13191326 MaxTokens = 1024,
13201327 System = new(systemPrompt),
13211328 Messages = [new() { Role = Role.User, Content = userMessage }],
from line 1356
13491356 // Call this at application startup or on a scheduled interval.
13501357 func prewarmCache() error {
13511358 _, err := client.Messages.New(context.TODO(), anthropic.MessageNewParams{
1352 Model: anthropic.ModelClaudeOpus5,
1359 Model: anthropic.ModelClaudeOpus5_5,
13531360 MaxTokens: 0,
13541361 System: systemPrompt,
13551362 Messages: []anthropic.MessageParam{
from line 1369
13621369 // The real user request; benefits from a warm cache.
13631370 func respond(userMessage string) (*anthropic.Message, error) {
13641371 return client.Messages.New(context.TODO(), anthropic.MessageNewParams{
1365 Model: anthropic.ModelClaudeOpus5,
1372 Model: anthropic.ModelClaudeOpus5_5,
13661373 MaxTokens: 1024,
13671374 System: systemPrompt,
13681375 Messages: []anthropic.MessageParam{
from line 1408
14011408 // Call this at application startup or on a scheduled interval.
14021409 void prewarmCache() {
14031410 client.messages().create(MessageCreateParams.builder()
1404 .model(Model.CLAUDE_OPUS_5)
1411 .model(Model.CLAUDE_OPUS_5_5)
14051412 .maxTokens(0)
14061413 .systemOfTextBlockParams(systemPrompt)
14071414 .addUserMessage("warmup")
from line 1418
14111418 // The real user request; benefits from a warm cache.
14121419 Message respond(String userMessage) {
14131420 return client.messages().create(MessageCreateParams.builder()
1414 .model(Model.CLAUDE_OPUS_5)
1421 .model(Model.CLAUDE_OPUS_5_5)
14151422 .maxTokens(1024)
14161423 .systemOfTextBlockParams(systemPrompt)
14171424 .addUserMessage(userMessage)
from line 1450
14431450 
14441451 // Call this at application startup or on a scheduled interval.
14451452 $prewarmCache = fn () => $client->messages->create(
1446 model: Model::CLAUDE_OPUS_5,
1453 model: Model::CLAUDE_OPUS_5_5,
14471454 maxTokens: 0,
14481455 system: $systemPrompt,
14491456 messages: [['role' => 'user', 'content' => 'warmup']],
from line 1458
14511458 
14521459 // The real user request; benefits from a warm cache.
14531460 $respond = fn (string $userMessage) => $client->messages->create(
1454 model: Model::CLAUDE_OPUS_5,
1461 model: Model::CLAUDE_OPUS_5_5,
14551462 maxTokens: 1024,
14561463 system: $systemPrompt,
14571464 messages: [['role' => 'user', 'content' => $userMessage]],
from line 1490
14831490 # Call this at application startup or on a scheduled interval.
14841491 def prewarm_cache(client)
14851492 client.messages.create(
1486 model: Anthropic::Model::CLAUDE_OPUS_5,
1493 model: Anthropic::Model::CLAUDE_OPUS_5_5,
14871494 max_tokens: 0,
14881495 system_: SYSTEM_PROMPT,
14891496 messages: [{role: "user", content: "warmup"}]
from line 1500
14931500 # The real user request; benefits from a warm cache.
14941501 def respond(client, user_message)
14951502 client.messages.create(
1496 model: Anthropic::Model::CLAUDE_OPUS_5,
1503 model: Anthropic::Model::CLAUDE_OPUS_5_5,
14971504 max_tokens: 1024,
14981505 system_: SYSTEM_PROMPT,
14991506 messages: [{role: "user", content: user_message}]
from line 1552
15451552 -H "anthropic-version: 2023-06-01" \
15461553 -H "content-type: application/json" \
15471554 -d '{
1548 "model": "claude-opus-5",
1555 "model": "claude-opus-5-5",
15491556 "max_tokens": 1024,
15501557 "system": [
15511558 {
from line 1576
15691576 
15701577 ```bash CLI
15711578 ant messages create --transform usage <<'YAML'
1572 model: claude-opus-5
1579 model: claude-opus-5-5
15731580 max_tokens: 1024
15741581 system:
15751582 - type: text
from line 1597
15901597 client = anthropic.Anthropic()
15911598 
15921599 response = client.messages.create(
1593 model="claude-opus-5",
1600 model="claude-opus-5-5",
15941601 max_tokens=1024,
15951602 system=[
15961603 {
from line 1624
16171624 const client = new Anthropic();
16181625 
16191626 const response = await client.messages.create({
1620 model: "claude-opus-5",
1627 model: "claude-opus-5-5",
16211628 max_tokens: 1024,
16221629 system: [
16231630 {
from line 1655
16481655 
16491656 var parameters = new MessageCreateParams
16501657 {
1651 Model = Model.ClaudeOpus5,
1658 Model = Model.ClaudeOpus5_5,
16521659 MaxTokens = 1024,
16531660 System = new MessageCreateParamsSystem(new List<TextBlockParam>
16541661 {
from line 1687
16801687 client := anthropic.NewClient()
16811688 
16821689 response, err := client.Messages.New(context.TODO(), anthropic.MessageNewParams{
1683 Model: anthropic.ModelClaudeOpus5,
1690 Model: anthropic.ModelClaudeOpus5_5,
16841691 MaxTokens: 1024,
16851692 System: []anthropic.TextBlockParam{
16861693 {
from line 1717
17101717 AnthropicClient client = AnthropicOkHttpClient.fromEnv();
17111718 
17121719 MessageCreateParams params = MessageCreateParams.builder()
1713 .model(Model.CLAUDE_OPUS_5)
1720 .model(Model.CLAUDE_OPUS_5_5)
17141721 .maxTokens(1024)
17151722 .systemOfTextBlockParams(
17161723 List.of(
from line 1752
17451752 'content' => 'What are the key terms and conditions in this agreement?'
17461753 ]
17471754 ],
1748 model: 'claude-opus-5',
1755 model: 'claude-opus-5-5',
17491756 system: [
17501757 [
17511758 'type' => 'text',
from line 1773
17661773 client = Anthropic::Client.new
17671774 
17681775 message = client.messages.create(
1769 model: "claude-opus-5",
1776 model: "claude-opus-5-5",
17701777 max_tokens: 1024,
17711778 system: [
17721779 {
from line 1817
18101817 
18111818 ```json
18121819 {
1813 "model": "claude-opus-5",
1820 "model": "claude-opus-5-5",
18141821 "max_tokens": 1024,
18151822 "tools": [
18161823 {
from line 1857
18501857 -H "anthropic-version: 2023-06-01" \
18511858 -H "content-type: application/json" \
18521859 -d '{
1853 "model": "claude-opus-5",
1860 "model": "claude-opus-5-5",
18541861 "max_tokens": 1024,
18551862 "system": [
18561863 {
from line 1900
18931900 
18941901 ```bash CLI
18951902 ant messages create --transform usage <<'YAML'
1896 model: claude-opus-5
1903 model: claude-opus-5-5
18971904 max_tokens: 1024
18981905 system:
18991906 - type: text
from line 1936
19291936 client = anthropic.Anthropic()
19301937 
19311938 response = client.messages.create(
1932 model="claude-opus-5",
1939 model="claude-opus-5-5",
19331940 max_tokens=1024,
19341941 system=[
19351942 {
from line 1980
19731980 const client = new Anthropic();
19741981 
19751982 const response = await client.messages.create({
1976 model: "claude-opus-5",
1983 model: "claude-opus-5-5",
19771984 max_tokens: 1024,
19781985 system: [
19791986 {
from line 2029
20222029 
20232030 var parameters = new MessageCreateParams
20242031 {
2025 Model = Model.ClaudeOpus5,
2032 Model = Model.ClaudeOpus5_5,
20262033 MaxTokens = 1024,
20272034 System = new MessageCreateParamsSystem(new List<TextBlockParam>
20282035 {
from line 2078
20712078 client := anthropic.NewClient()
20722079 
20732080 response, err := client.Messages.New(context.TODO(), anthropic.MessageNewParams{
2074 Model: anthropic.ModelClaudeOpus5,
2081 Model: anthropic.ModelClaudeOpus5_5,
20752082 MaxTokens: 1024,
20762083 System: []anthropic.TextBlockParam{
20772084 {
from line 2123
21162123 
21172124 // Create message params
21182125 MessageCreateParams params = MessageCreateParams.builder()
2119 .model(Model.CLAUDE_OPUS_5)
2126 .model(Model.CLAUDE_OPUS_5_5)
21202127 .maxTokens(1024)
21212128 .systemOfTextBlockParams(List.of(systemPrompt))
21222129 // First user message (without cache control)
from line 2183
21762183 ]
21772184 ]
21782185 ],
2179 model: 'claude-opus-5',
2186 model: 'claude-opus-5-5',
21802187 system: [
21812188 [
21822189 'type' => 'text',
from line 2200
21932200 client = Anthropic::Client.new
21942201 
21952202 message = client.messages.create(
2196 model: "claude-opus-5",
2203 model: "claude-opus-5-5",
21972204 max_tokens: 1024,
21982205 system: [
21992206 {
from line 2263
22562263 -H "anthropic-version: 2023-06-01" \
22572264 -H "content-type: application/json" \
22582265 -d '{
2259 "model": "claude-opus-5",
2266 "model": "claude-opus-5-5",
22602267 "max_tokens": 1024,
22612268 "tools": [
22622269 {
from line 2359
23522359 
23532360 ```bash CLI
23542361 ant messages create --transform usage <<'YAML'
2355 model: claude-opus-5
2362 model: claude-opus-5-5
23562363 max_tokens: 1024
23572364 tools:
23582365 - name: search_documents
from line 2449
24422449 client = anthropic.Anthropic()
24432450 
24442451 response = client.messages.create(
2445 model="claude-opus-5",
2452 model="claude-opus-5-5",
24462453 max_tokens=1024,
24472454 tools=[
24482455 {
from line 2542
25352542 const client = new Anthropic();
25362543 
25372544 const response = await client.messages.create({
2538 model: "claude-opus-5",
2545 model: "claude-opus-5-5",
25392546 max_tokens: 1024,
25402547 tools: [
25412548 {
from line 2646
26392646 
26402647 var parameters = new MessageCreateParams
26412648 {
2642 Model = Model.ClaudeOpus5,
2649 Model = Model.ClaudeOpus5_5,
26432650 MaxTokens = 1024,
26442651 Tools =
26452652 [
from line 2750
27432750 client := anthropic.NewClient()
27442751 
27452752 response, err := client.Messages.New(context.TODO(), anthropic.MessageNewParams{
2746 Model: anthropic.ModelClaudeOpus5,
2753 Model: anthropic.ModelClaudeOpus5_5,
27472754 MaxTokens: 1024,
27482755 Tools: []anthropic.ToolUnionParam{
27492756 {OfTool: &anthropic.ToolParam{
from line 2850
28432850 .build();
28442851 
28452852 MessageCreateParams params = MessageCreateParams.builder()
2846 .model(Model.CLAUDE_OPUS_5)
2853 .model(Model.CLAUDE_OPUS_5_5)
28472854 .maxTokens(1024)
28482855 // Tools with cache control on the last one
28492856 .addTool(
from line 2990
29832990 ]
29842991 ]
29852992 ],
2986 model: 'claude-opus-5',
2993 model: 'claude-opus-5-5',
29872994 system: [
29882995 [
29892996 'type' => 'text',
from line 3043
30363043 client = Anthropic::Client.new
30373044 
30383045 message = client.messages.create(
3039 model: "claude-opus-5",
3046 model: "claude-opus-5-5",
30403047 max_tokens: 1024,
30413048 tools: [
30423049 {
from line 3209
32023209 * Reading from cache (a fraction of the base input token price, see [Pricing](https://platform.claude.com/docs/en/build-with-claude/prompt-caching#pricing))
32033210 * Regular input tokens for uncached content
32043211 
3205 The number of breakpoints doesn't affect pricing - only the amount of content cached and read matters.
3212 The number of breakpoints doesn't affect pricing; only the amount of content cached and read matters.
32063213 </Accordion>
32073214 
32083215 <Accordion title="How do I calculate total input tokens from the usage fields?">
from line 3223
32163223 * `cache_creation_input_tokens`: New tokens being written to cache (at cache breakpoints)
32173224 * `input_tokens`: Tokens **after the last cache breakpoint** that aren't cached
32183225 
3219 **Important:** `input_tokens` does NOT represent all input tokens - only the portion after your last cache breakpoint. If you have cached content, `input_tokens` will typically be much smaller than your total input.
3226 **Important:** `input_tokens` does NOT represent all input tokens, only the portion after your last cache breakpoint. If you have cached content, `input_tokens` will typically be much smaller than your total input.
32203227 
32213228 **Example:** With a 200k token document cached and a 50 token user question:
32223229 
from line 3340
33333340 client.beta.promptCaching.messages.create(/* ... */);
33343341 ```
33353342 
3336 Simply use:
3343 Use:
33373344 
33383345 ```typescript
33393346 client.messages.create(/* ... */);