Anthropic 缓存读:cache_read 对上缓存列
官方 Anthropic SDK:cache_read_input_tokens 进缓存列。Fable 5.1 贴纸 $10/$50、缓存读 $0.25 只写在 Fable 行的注释里,不是 MiniMax / Gemma 的价。
本页不发起请求;不收 Key;中转 curl 不在本站。
← 计费示例 · Token 主表 · 官方 usage 文档
输入usage.input_tokensusage.cache_creation_input_tokens
输出usage.output_tokens
缓存usage.cache_read_input_tokens
import os
from anthropic import Anthropic
# Official Anthropic SDK only. Key from env. Never paste a key.
# claude-fable-5-1 sticker is $10 / $50; cache read $0.25/M — Fable row only.
# Do not copy those numbers onto MiniMax or Gemma.
client = Anthropic(api_key=os.environ["ANTHROPIC_API_KEY"])
message = client.messages.create(
model="claude-fable-5-1",
max_tokens=16,
system=[
{
"type": "text",
"text": ("You are a billing ledger. Keep answers short. ") * 80,
"cache_control": {"type": "ephemeral"},
}
],
messages=[{"role": "user", "content": "Reply with one word: ok"}],
)
usage = message.usage
inp = usage.input_tokens or 0 # 输入(未命中段)
out = usage.output_tokens or 0 # 输出
cache_read = usage.cache_read_input_tokens or 0 # 缓存列
cache_write = usage.cache_creation_input_tokens or 0 # 写入,不进缓存列
print("输入", inp)
print("输出", out)
print("缓存", cache_read)
print("cache_write", cache_write)
| 字段 | 对上列 | 说明 |
|---|---|---|
usage.input_tokens | 输入 | 未命中段。有缓存时这是断点之后的 tokens,不是整段 prompt。Fable 5.1 贴纸输入 $10/M。 |
usage.output_tokens | 输出 | 对账乘 Fable 5.1 输出 $50/M。不要抄到 MiniMax / Gemma 行。 |
usage.cache_read_input_tokens | 缓存 | 唯一按缓存读单价的字段。Fable 5.1 已核缓存读 $0.25/M。没有字段就当 0。 |
usage.cache_creation_input_tokens | 输入 | 写入不是折扣。接近输入价。不要记进缓存列。 |