Claude 官方文件:Prompt caching 快取讀取只要 0.1 倍(新模型 0.05 倍)
Claude Developer Platform docs: Prompt caching
摘要分析
Prompt caching 是 Claude API 最直接的省錢機制:快取 tools→system→messages 前綴,命中時跳過重算。官方文件列出倍率:5 分鐘寫入 1.25 倍、1 小時寫入 2 倍、讀取多數模型 0.1 倍,Opus 5.5/Sonnet 5.5 降到 0.05 倍(2026-10-07 調整)。2026 年新增自動快取:請求最上層加 cache_control ephemeral 即可,也可手動放最多 4 個斷點。注意最短 512 token、斷點別放在每次都變的內容,並以 usage 的 cache_read_input_tokens 驗證。
- 倍率:5 分鐘寫入 1.25x、1 小時寫入 2x、讀取 0.1x(Opus/Sonnet 5.5 為 0.05x)
- 自動快取:client.messages.create(..., cache_control={"type":"ephemeral"}) 放在最上層
- 手動最多 4 個斷點,放在「每次請求都相同」的最後一塊
- 新模型最短 512 token 才會快取;看 usage.cache_read_input_tokens 確認命中
- max_tokens:0 可預熱快取;預設 TTL 5 分鐘、每次讀取免費續期
Prompt caching is the most direct cost lever on the Claude API: the tools→system→messages prefix up to a cache_control breakpoint is reused, skipping reprocessing on a hit. The official docs list the multipliers: 5-minute cache writes cost 1.25x base input, 1-hour writes 2x, and reads 0.1x for most models, dropping to 0.05x on Opus 5.5 and Sonnet 5.5 (updated 2026-10-07) and 0.025x on Fable 5.1. A 2026 addition is automatic caching: add a top-level cache_control={'type':'ephemeral'} and the system places the breakpoint on the last cacheable block and moves it forward as the conversation grows; up to four explicit breakpoints may be combined. Mind the minimum cacheable length (512 tokens on newer models), never put a breakpoint on content that changes every request, verify hits via cache_read_input_tokens in usage, and pre-warm with max_tokens: 0.
- Multipliers: 1.25x 5-min write, 2x 1-hour write, 0.1x read (0.05x on 5.5 models)
- Automatic caching via top-level cache_control ephemeral
- Up to 4 explicit breakpoints on stable content
- 512-token minimum on newer models; check cache_read_input_tokens
- Pre-warm with max_tokens: 0; 5-minute TTL refreshed on read
關鍵字:prompt cachingClaude APItoken 節費cache_controlTTL
來源原文:https://platform.claude.com/docs/en/build-with-claude/prompt-caching
本頁為報導內容的摘要與分析,版權屬原媒體所有;請以原文為準。
