刷新

OpenAI Prompt Caching 有效 $/M 怎么算:命中率与对账单核对

内容刷新 / GEO:补 English summary 与最新核对清单 — oa-openai-prompt-cache-effective-price

返回指南列表

封面:OpenAI Prompt Caching 有效 $/M 怎么算:命中率与对账单核对

## OpenAI Prompt Caching 有效 $/M 怎么算:命中率与对账单核对

OpenAI Prompt Caching 通过复用相同前缀提示(prompt prefix)来节省算力,直接将输入 Token 的官方计费降低到标准价格的 10% 甚至更低(最高可达 95% 折扣)。这对需要重复发送系统提示、工具定义或长上下文的应用特别适用,能显著降低 API 账单,同时降低延迟。

如果你在处理多轮对话、Agent 工作流或频繁调用同一系统提示,掌握命中率(cache hit rate)与实际有效单价 $/M 计算,就能准确判断是否值得优化,避免低命中率导致“白费功夫”。以下内容直接对应你的对账单数据,帮你决策是否继续使用 Prompt Caching。

现状与数据更新

2026 年底,OpenAI 已将 Prompt Caching 功能扩展到 Responses API 与 Agents API,支持 30 分钟和 12 小时缓存时长。默认启用,但命中率高度依赖你的提示结构稳定性——前缀完全一致才能命中。

官方定价页面(以 2026 年 11 月 6 日最新数据为准)显示,不同模型的缓存输入单价差异巨大:

  • gpt-6-luna(短上下文):标准输入 $0.10 /M,缓存输入 $0.01 /M(折扣 90%)。
  • gpt-5.6-luna:标准 $0.20 /M,缓存 $0.02 /M(折扣 90%)。
  • gpt-5.4-mini:标准 $0.75 /M,缓存 $0.075 /M(折扣 90%)。

缓存写入(cache write)价格高于普通输入,但不计额外费用(使用普通输入或缓存输入单价)。长上下文模型折扣比例相同,但写入成本通常更高(30 分钟写入 1.25 倍普通输入,12 小时写入 2.5 倍)。

命中率每下降 10%,有效 $/M 就会相应上升。长期运行的 Agent 或 RAG 系统若前缀稳定,命中率 80% 以上即可实现 70-90% 成本降低。

核对清单:计算你的有效 $/M 并核对账单

1. 确认缓存是否启用:在 OpenAI API Dashboard(https://platform.openai.com/usage)查看 Prompt Caching 部分,检查是否有缓存命中记录。

2. 收集指标:每次请求返回 prompt_tokens_details.cached_tokens + total_prompt_tokens,计算命中率 = cached_tokens / total_prompt_tokens。

3. 查看账单:账单按总 Token 计费,但缓存部分按缓存单价扣款。打开对账单对比“缓存输入”与“标准输入”字段。

4. 模拟计算:假设每月 1000 万 Token,命中率 70%:

- 总计价 Token = 1000 万

- 有效成本 = (总 Token - cached Tokens) × 标准 $/M + cached Tokens × 缓存 $/M

5. 跨模型测试:切换模型查看不同有效单价,优先选择缓存折扣高的型号。

以下是核心核对表格(数据参考官方定价页,可在你的账单中对应字段验证):

模型 标准输入 $/M 缓存输入 $/M 折扣比例 典型应用场景 有效 $/M(假设 70% 命中)
gpt-6-luna 0.10 0.01 90% 短上下文系统提示 0.05
gpt-5.6-luna 0.20 0.02 90% 中长上下文 Agent 0.10
gpt-5.4-mini 0.75 0.075 90% 轻量级对话 0.375
gpt-4o 2.50 1.25 50% 传统多模态 1.50

说明:表格仅供参考,实际以 OpenAI 官方定价页为准(https://platform.openai.com/docs/pricing)。如果你使用自定义模型或子帐户,单价可能有差异。

风险边界

Prompt Caching 并非“无限省钱”的工具。命中率过低时,等效于支付更高单价,实际成本更高;缓存写入频繁或前缀不稳定还会增加延迟。极端情况下,修改提示结构可能导致缓存失效,引发“缓存命中为 0”的对账单异常。

如果你遇到账单大幅高于预期,或 Dashboard 显示命中率持续 <20%,建议立即暂停缓存优化,转而评估模型升级或上下文压缩(context_management)。

非法律意见声明:以上信息基于公开官方文档和 2026 年 11 月数据,仅供参考。请以 OpenAI 官方定价页面、API Dashboard 或支持团队数据为准。OpenAI 定价可能随时间更新,本指南不构成任何形式的投资、购买或法律建议。

站内路径

想更深入了解?推荐阅读:

English summary

OpenAI Prompt Caching reuses the same prompt prefix across requests, delivering up to 90% discount on cached input tokens and reducing latency by up to 80%. Effective price per million tokens ($/M) is calculated by multiplying total tokens by the standard rate plus cached tokens by the discounted rate, with hit rate determining actual savings.

This optimization suits repetitive system prompts, tool definitions, or long-context Agent workflows. Track hit rate via cached_tokens / total tokens in API responses, and cross-check your billing dashboard for “cached input” vs standard charges.

As of November 2026, flagship models like gpt-6-luna offer the deepest discounts (90%), while older ones like gpt-4o provide only 50%. Low hit rates can turn caching into a costlier option—always measure before optimizing.

See our guide for decision-making on when to enable caching, common pitfalls, and integration with other cost controls. Data is based on the latest official pricing and recommendations—always verify directly with OpenAI’s platform for your specific models and accounts.