studioglobal
热门发现
答案已发布9 来源

Claude Opus 4.7 API 收费指南:$5/$25、Prompt Caching 和 Token 怎么算

Anthropic API 中 Claude Opus 4.7 的基础价格为 input tokens $5/百万、output tokens $25/百万;但 prompt caching 需要按 cache write 和 cache read 另算。[19] 最可靠的成本流程是:请求前用 /v1/messages/count tokens 统计实际 payload,请求后用 response usage 记录真实用量,并用 Usage & Cost Admin API 做团队对账。[16][18] 不要把所有 token 混成一个总数乘单价;input、output、cache write、cache read 单价不同...

18K0
Claude Opus 4.7 API 收費表、token 計算與 prompt caching 成本公式的編輯插圖
Claude Opus 4.7 API 收費指南:$5/$25、Token 計法同成本公式AI-generated editorial illustration for Claude Opus 4.7 API pricing and token accounting.
AI 提示

Create a landscape editorial hero image for this Studio Global article: Claude Opus 4.7 API 收費指南:$5/$25、Token 計法同成本公式. Article summary: Claude Opus 4.7 API 基礎價係每百萬 input tokens $5、每百萬 output tokens $25;但 prompt caching 要另計,而且新 tokenizer 可能令同一段文字用大約 1x 至 1.35x token。[19][20]. Topic tags: ai, anthropic, claude, api pricing, llm. Reference image context from search candidates: Reference image 1: visual subject "# Claude Opus 4.7 上线完全指南(2026 最新):核心升级与国内 API 接入方案. **Claude Opus 4.7 于 2026 年 4 月 16 日正式发布,API model ID 为 `claude-opus-4-7`,定价维持与 Opus 4.6 相同的 $5/M 输入 token、$25/M 输出 token 不变,1M t" source context "Claude Opus 4.7 上线完全指南(2026 最新):核心升级与 ..." Reference image 2: visual subject "# Claude Opus 4.7 上线完全指南(2026 最新):核心升级与国内 API 接入方案. **Claude Opus 4.7 于 2026 年 4 月 16 日正式发布,API model ID 为 `claude-opus-4-7`,定价维持与 Opus 4.6 相同的 $5/M 输入 token、$25/M 输出 token 不变,1M t" source context "Claude Opus 4.

openai.com

Claude Opus 4.7 的 API 价格表面上很直观:input $5/百万 token,output $25/百万 token。但如果你的应用有长上下文、工具定义、图片/PDF 输入,或者启用了 prompt caching,只看一个“总 token 数”很容易把账算偏。

Anthropic 表示,开发者可以通过 Claude API 使用模型 ID claude-opus-4-7;第三方价格索引也列出 Claude Opus 4.7 从 $5/百万 input tokens、$25/百万 output tokens 起步。[7][9][21] 不过,实际账单仍应以你调用的渠道为准:如果不是直接走 Anthropic API,而是通过云厂商或聚合平台接入,要查看该平台最终计费规则。[19]

先看价格:不止 $5 和 $25

下文用 MTok 表示 1,000,000 tokens。Anthropic 的 pricing 文档把 Base Input Tokens、Cache Writes、Cache Hits 和 Output Tokens 分开列出,因此实际入账也应分项计算。[19]

计费项目单价怎么理解
Base input tokens$5 / MTok普通输入 token,未按 cache write/read 计费的部分。[19]
Output tokens$25 / MTokClaude 生成回复时产生的输出 token。[19]
Prompt cache write,5 分钟 TTL$6.25 / MTok第一次写入可复用的 prompt cache,TTL 为 5 分钟时适用。[19]
Prompt cache write,1 小时 TTL$10 / MTok写入 1 小时 TTL 的 prompt cache 时适用。[19]
Cache read / hit$0.50 / MTok命中并读取已缓存内容时适用。[19]

关键点是:不要用“全部 token × 一个平均价”来估算。Claude Opus 4.7 的 input、output、cache write、cache read 单价不同;只要你的产品使用 prompt caching,成本模型就必须拆开算。[19]

成本公式:先判断有没有 prompt caching

不使用 prompt caching

最基础的公式是:

成本 = input_tokens ÷ 1,000,000 × 5 + output_tokens ÷ 1,000,000 × 25

例如一次请求包含 200,000 input tokens 和 20,000 output tokens,不考虑缓存时,费用就是

$1.00 + $0.50 = $1.50
。这只是按 Anthropic API 的 input/output 单价做的计算,不包含其他平台可能叠加的费用或差异。[19]

使用 prompt caching

启用 prompt caching 后,应按不同 token 类型逐项相加:

成本 = base_input_tokens ÷ 1,000,000 × 5 + output_tokens ÷ 1,000,000 × 25 + cache_write_5m_tokens ÷ 1,000,000 × 6.25 + cache_write_1h_tokens ÷ 1,000,000 × 10 + cache_read_input_tokens ÷ 1,000,000 × 0.50

如果只使用一种缓存 TTL,就只保留对应的 cache write 项。Anthropic 的 streaming 文档示例显示,usage 中可能包含 input_tokensoutput_tokenscache_creation_input_tokenscache_read_input_tokens 等字段;pricing 文档也将 cache write 和 cache hit 分开计费。[15][19]

Token 怎么算最准确:请求前用 count_tokens

不要用中文字数、英文字数或字符数去粗略估 API 成本。Anthropic 的 /v1/messages/count_tokens endpoint 用于在真正发送 message 之前计算 token;文档说明,它接受与创建 message 类似的结构化输入,包括 system prompts、tools、images 和 PDFs,并返回 total input tokens;所有 active models 都支持 token counting。[18]

比较稳妥的流程是:把实际会发给 Messages API 的 payload 原样拿去跑 count_tokens,包括 system prompt、messages、tools、图片或 PDF。这样可以在正式调用模型前估算 input token 成本,也方便在产品内设置预算上限、预警或拒绝超额请求。[18]

请求完成后:用 response usage 做真实入账

请求完成后,应记录 API response 里的 usage,不要再用输出文本长度反推。Anthropic 的 Messages API 示例显示,response usage 可包含 input_tokensoutput_tokens 等字段;streaming 文档也展示了 cache_creation_input_tokenscache_read_input_tokens 等与缓存相关的字段。[15][17]

如果使用 streaming,还要特别注意:Anthropic streaming 文档指出,message_delta 中的 usage token counts 是累计值,不是每个 event 的新增量。也就是说,如果把每个 delta 的 usage 直接相加,就会重复计费同一批 token。[15]

团队月结和对账:看 Usage & Cost Admin API

单次 response log 适合做实时监控,但团队月结、workspace 分账、长期趋势分析,应该再使用 Anthropic 的 Usage & Cost Admin API。官方文档称,该 API 提供 programmatic、granular access to historical API usage and cost data,并可按 model、workspace、service tier 等维度拆分 usage report。[16]

实践上可以这样分工:应用端记录每次请求的 usage,用于产品内限额、告警和即时成本估算;正式财务或团队对账,则以 Usage & Cost Admin API 的历史 usage/cost 数据为准。[16]

从旧版升级到 Opus 4.7:要重新跑 token budget

Claude Opus 4.7 引入了新的 tokenizer。Anthropic 文档说明,新 tokenizer 处理文本时,可能使用约为 previous models 的 1x 至 1.35x tokens,最高约多 35%,实际幅度因内容而异;同一段 input 用 /v1/messages/count_tokens 在 Opus 4.7 和 Opus 4.6 上会返回不同 token number。[20]

因此,“input $5/MTok、output $25/MTok”不代表升级后账单一定不变。如果你从 Opus 4.6 或更早模型迁移到 Opus 4.7,建议抽取高流量 prompt、长上下文 prompt、包含 tool definitions 的 payload,以及成本最高的 workflow,重新跑一遍 /v1/messages/count_tokens,再更新 alert、rate limit 和成本上限。[18][20]

实务核对清单

  • 确认 API model ID 使用 claude-opus-4-7[9]
  • 重要版本发布前,用 /v1/messages/count_tokens 对代表性 payload 做成本预估。[18]
  • input_tokensoutput_tokens、cache write、cache read 分开入账,不要只存一个 total token 数。[15][19]
  • 使用 streaming 时,记住 message_delta.usage 是累计值,不能逐个 event 直接相加。[15]
  • 团队月结、workspace 分账或历史趋势分析,使用 Usage & Cost Admin API。[16]
  • 从旧版 Claude model 升级到 Opus 4.7 前,重新测试 tokenizer 对实际 prompt 的影响。[20]

总结一句话:Claude Opus 4.7 的基础单价很好记,input $5/MTok、output $25/MTok;但要把成本算准,必须在请求前用 count_tokens,请求后记录 usage,并把 prompt caching 和新 tokenizer 的影响纳入模型。[18][19][20]

Studio Global AI

Search, cite, and publish your own answer

Use this topic as a starting point for a fresh source-backed answer, then compare citations before you share it.

使用 Studio Global AI 搜索并核查事实

要点

  • Anthropic API 中 Claude Opus 4.7 的基础价格为 input tokens $5/百万、output tokens $25/百万;但 prompt caching 需要按 cache write 和 cache read 另算。[19]
  • 最可靠的成本流程是:请求前用 /v1/messages/count tokens 统计实际 payload,请求后用 response usage 记录真实用量,并用 Usage & Cost Admin API 做团队对账。[16][18]
  • 不要把所有 token 混成一个总数乘单价;input、output、cache write、cache read 单价不同,且 Opus 4.7 新 tokenizer 可能让同一文本使用约 1x 至 1.35x token。[19][20]

人们还问

“Claude Opus 4.7 API 收费指南:$5/$25、Prompt Caching 和 Token 怎么算”的简短答案是什么?

Anthropic API 中 Claude Opus 4.7 的基础价格为 input tokens $5/百万、output tokens $25/百万;但 prompt caching 需要按 cache write 和 cache read 另算。[19]

首先要验证的关键点是什么?

Anthropic API 中 Claude Opus 4.7 的基础价格为 input tokens $5/百万、output tokens $25/百万;但 prompt caching 需要按 cache write 和 cache read 另算。[19] 最可靠的成本流程是:请求前用 /v1/messages/count tokens 统计实际 payload,请求后用 response usage 记录真实用量,并用 Usage & Cost Admin API 做团队对账。[16][18]

接下来在实践中我应该做什么?

不要把所有 token 混成一个总数乘单价;input、output、cache write、cache read 单价不同,且 Opus 4.7 新 tokenizer 可能让同一文本使用约 1x 至 1.35x token。[19][20]

接下来我应该探索哪个相关主题?

继续“Claude Security 公测版详解:Anthropic 的 AI 代码漏洞扫描工具”以获得另一个角度和额外的引用。

打开相关页面

我应该将其与什么进行比较?

对照“Grok 4.3 API 解读:1M 上下文、低 token 价与语音平台野心”交叉检查此答案。

打开相关页面

继续你的研究

研究对话

研究问题

搜尋及事實查核:Claude Opus 4.7 幾錢?token 點計先最清楚?

Studio Global AI29 来源

引用的答案

如果你講嘅係 Anthropic API,Claude Opus 4.7 官方價目前係每百萬 input tokens 收 $5、每百萬 output tokens 收 $25;如果用 prompt caching,5 分鐘 cache write 係 $6.25/MTok、1 小時 cache write 係 $10/MTok、cache hit/refresh 係 $0.50/MTok。[3] 而且 Opus 4.7 用咗新 tokenizer,官方話同一段固定文字相比舊模型可能會多用最多約 35% tokens,所以「標價冇變」唔代表實際成本一定同舊版一樣。[3][8]

  • 官方 models 頁面列明 Claude Opus 4.7 已經係 generally available,API model ID 係 claude-opus-4-7,定價同上面一致。[2]

  • 最清楚嘅 token 計法,唔好自己估字數,直接用官方 /v1/messages/count_tokens;Anthropic 話呢個 token counting endpoint 接受同 Messages API 一樣嘅結構化輸入,可以喺送出前先計好 input tokens。[9]

  • 送出 request 之後,再睇 API 回傳嘅 usage 欄位;官方文件示例顯示會有 input_tokensoutput_tokens,以及快取相關欄位如 cache_creation_input_tokenscache_read_input_tokens[5]

  • 如果你用 streaming,message_delta 入面見到嘅 usage token counts 係累積值,不是每個 event 單獨新增值。[5]

  • 如果你想對帳最準,官方建議用 Usage & Cost Admin API,因為佢提供歷史 usage 同 cost 資料,並強調可以攞到較精確嘅 token counts,而唔係只靠單次 response 去估。[6]

  • 實際計錢公式,最易記係:

    • 無 cache:
      成本 = (input_tokens / 1,000,000 × $5) + (output_tokens / 1,000,000 × $25)
      [3]
    • 有 cache:再加上 cache_creation_input_tokens 對應 write 價,並把 cache_read_input_tokens 按 $0.50/MTok 去計。[3][5]
  • 例子:如果一次 request 用咗 200,000 input tokens 同 20,000 output tokens,未計 cache 時大約係 $1.00 + $0.50 = $1.50。[3]

  • 要留意,Opus 4.7 新 tokenizer 可能令同一段 prompt 比舊 model 食多 token,所以你如果由 Opus 4.6 轉過去,最好先跑一次 count_tokens 再改 budget。[8][9]

如果你想,我可以下一步直接幫你整一個「Claude Opus 4.7 成本速算表」:輸入 prompt token、output token、cache 有冇開,我即刻幫你計到每次 request 幾錢。

来源

  • [7] Claude Opus 4.7 pricing & specs — Anthropic | CloudPricecloudprice.net

    Claude Opus 4.7. Claude Opus 4.7isAnthropic logoAnthropic's language model with a 1.0M context window and up to 128K output tokens, available from 7 providers, starting at $5.00 / 1M input and $25.00 / 1M output. Canonical ID anthropic-claude-4-7-opus . Ama...

  • [9] Introducing Claude Opus 4.7 - Anthropicanthropic.com

    Skip to main contentSkip to footer. Developers can use claude-opus-4-7 via the Claude API. . . ![Image 5: logo](

  • [15] Streaming Messages - Claude API Docsplatform.claude.com

    event: message startevent: message startdata: {"type":"message start","message":{"id":"msg 01G...","type":"message","role":"assistant","model":"claude-opus-4-6","content":[],"stop reason":null,"stop sequence":null,"usage":{"input tokens":2679,"cache creatio...

  • [16] Usage and Cost API - Claude API Docsplatform.claude.com

    Usage and Cost API. The Usage & Cost Admin API provides programmatic and granular access to historical API usage and cost data for your organization. Leading observability platforms offer ready-to-use integrations for monitoring your Claude API usage and co...

  • [17] Using the Messages API - Claude API Docsplatform.claude.com

    !/bin/sh !/bin/shcurl \ curl \ --header "x-api-key: $ANTHROPIC API KEY" \ --header "x-api-key: $ANTHROPIC API KEY " \ --header "anthropic-version: 2023-06-01" \ --header "anthropic-version: 2023-06-01" \ --header "content-type: application/json" \ --header...

  • [18] Token counting - Claude API Docsplatform.claude.com

    Token counting. Token counting enables you to determine the number of tokens in a message before sending it to Claude, helping you make informed decisions about your prompts and usage. With token counting, you can. How to count message tokens. The token cou...

  • [19] Pricing - Claude API Docsplatform.claude.com

    The "Base Input Tokens" column shows standard input pricing, "Cache Writes" and "Cache Hits" are specific to prompt caching, and "Output Tokens" shows output pricing. Prompt caching multipliers apply on top of fast mode pricing. Fast mode is not available w...

  • [20] What's new in Claude Opus 4.7platform.claude.com

    Claude Opus 4.7 introduces task budgets. This new tokenizer may use roughly 1x to 1.35x as many tokens when processing text compared to previous models (up to 35% more, varying by content), and /v1/messages/count tokens will return a different number of tok...

  • [21] Claude Opus 4.7 API Pricing 2026 - Costs, Performance & Providerspricepertoken.com

    Join the conversation on AI models, pricing, and tools. Price Per TokenPrice Per Token. Claude Opus 4.7 API Pricing 2026. Compare pricing, benchmarks, and providers for Claude Opus 4.7. Pricing starts at $5.00 per million input tokens and $25.00 per million...