
## 2026 OpenAI Prompt Caching 官方价格怎么算:输入/输出/缓存字段全解析
OpenAI Prompt Caching 是官方 API 的自动提示缓存功能,能让重复的系统提示、前缀内容按 10% 的缓存输入价计费,大幅降低延迟并节省高达 90% 的输入成本。适合 ChatGPT Plus 用户、开发者、企业账单对账者,尤其是重度使用 API 的团队——通过查看 usage 字段即可决策是否开启缓存,快速判断是否值得节省成本。
缓存价格字段说明:输入 tokens、输出 tokens、缓存 tokens 分别对应什么
OpenAI Prompt Caching 自动生效,无需额外配置。所有支持缓存的模型(GPT-4o 及更新的 GPT-5 系列)在提示词长度 >= 1024 tokens 时生效。官方报告字段可直接从 API 响应中提取,用于对账。
- 输入 tokens (prompt_tokens):总输入 token 数(包括未命中 + 缓存命中)。
- 缓存 tokens (cached_tokens):命中缓存的部分,按 缓存输入价 计费(通常是标准输入价的 10%)。
- 输出 tokens (completion_tokens):生成内容 token 数,按标准输出价计费(不受缓存影响)。
- Cache writes (cache_write_tokens):仅 GPT-5.6 及以上模型在写入缓存时额外收取费用,按标准输入价的 1.25 倍计费;此前模型免费写入。
实际对账时:缓存命中部分只算 cached_tokens 费,total input = regular input + cached input。所有字段均包含在官方 API 响应中。
Prompt Caching vs 标准 API 计费:节省公式与示例
公式(每百万 tokens):
总费用 = (prompt_tokens - cached_tokens) × 标准输入价 + cached_tokens × 缓存输入价 + completion_tokens × 输出价
节省率 = (标准输入价 - 缓存输入价) × 缓存命中率
2026 年官方价格对比表(标准上下文,单位:$/M tokens):
| 模型 | 标准输入价 | 缓存输入价 | 输出价 | 缓存写入费(GPT-5.6+) | 节省潜力 |
|---|---|---|---|---|---|
| gpt-5.6-sol | $5.00 | $0.50 | $30.00 | $6.25 | 90% |
| gpt-5.6-terra | $2.00 | $0.20 | $12.00 | $2.50 | 90% |
| gpt-5.6-luna | $0.20 | $0.02 | $1.20 | $0.25 | 90% |
| gpt-5.5 | $5.00 | $0.50 | $30.00 | - | 90% |
| gpt-5.4 | $2.50 | $0.25 | $15.00 | - | 90% |
示例(gpt-5.6-sol,单次请求 5000 tokens 输入 + 500 tokens 输出):
- 无缓存:总计 = 5000 × $5 + 500 × $30 = $25 + $15 = $40
- 80% 命中缓存(4000 tokens 命中):总计 = (1000 × $5) + (4000 × $0.50) + (500 × $30) = $5 + $2 + $15 = $22
- 节省 45%,延迟降至原先的 20%。
2026 年命中率门槛与实际省钱门槛
命中率门槛:
- 最低触发:提示词前缀 >= 1024 tokens。
- GPT-5.6+ 需设置
prompt_cache_key并使用prompt_cache_breakpoint(否则命中率可能低于 30%)。 - 实际门槛:连续复用同一前缀 >= 5-10 次 即可快速回本(写入免费或低成本后,后续每次命中 90% 节省)。
实际省钱门槛:
- 缓存命中率 > 50% 时,单次调用即可节省 >30%。
- 高频场景(系统提示 + 历史上下文):命中率 70-90% 是常态,月节省可达 60-80%。
- 最低省钱案例:提示词 1024 tokens,2 次请求后命中,单请求节省约 $4.50(gpt-5.6-sol)。
企业账单对账:如何从发票中提取缓存消耗数据
1. 官方发票/账单字段:OpenAI 企业账单会单独显示 cached_tokens 或 cache_write_tokens 消耗(部分企业账单已集成)。
2. API 日志提取:在 Responses/Chat Completions API 响应中查看 usage.prompt_tokens_details.cached_tokens 与 usage.prompt_tokens。
3. 计算公式:
缓存消耗金额 = cached_tokens / 1,000,000 × 缓存输入价
4. 推荐工具:对接 OpenAI Dashboard 或第三方账单 reconcile 工具,自动对比标准 vs 缓存费用。
长上下文示例(>270K tokens):输入价为标准值的 2 倍,但缓存输入价同样按短上下文折扣(例如 gpt-5.6-sol 长上下文缓存输入 $1.00)。
缓存使用场景推荐:何时开启缓存最划算
- 最划算场景(推荐优先开启):
- 企业知识库问答、RAG 系统(系统提示 + 文档前缀完全相同)。
- 代码审查/多轮调试(同一代码库上下文)。
- 多用户客服/代理系统(重复指令模板)。
- 次优场景:
- 聊天历史长对话(历史固定部分)。
- 图像/工具调用场景(图像 ID 或文件 ID 作为前缀)。
- 不推荐:完全动态用户输入(命中率 <10%),或单次请求场景(无复用)。
开启建议:在系统提示词开头放置静态内容,使用 prompt_cache_key 提高命中率,目标命中率 >60% 即可大幅降本。
常见问题解答:缓存未命中或费用异常怎么办
未命中原因:
- 提示前缀 <1024 tokens。
- 前缀不完全匹配(需检查大小写、换行)。
- 跨机器路由(高流量时可能溢出)。
费用异常处理:
- 检查
usage字段是否缺失。 - 确认模型是否支持(GPT-5 系列及以上)。
- 联系 OpenAI 支持,提供 request ID 查看日志。
- GPT-5.6+ 写入费异常:检查是否设置了正确
prompt_cache_options。
提示缓存与 o 系列模型的结合使用
o 系列(o1/o3 等推理模型)默认开启缓存,但输出为思考过程时,缓存命中主要影响输入部分。结合使用:
- 系统提示 + 工具调用历史共享。
- 避免缓存用户查询(动态部分放在提示尾部)。
- 实际效果:推理模型输入节省 90%,但输出 token 不变。适合复杂任务时仍能降低整体成本。
缓存价格调整历史:2026 年最新调整记录
- 2026 年初:默认保留期从几分钟调整为 24 小时(企业账单默认)。
- 2026 年 3 月:GPT-5.6 系列引入 cache writes 1.25× 费率(此前免费)。
- 2026 年 7 月:Extended retention 扩展至更多模型,长上下文价格统一按 2× 标准计费但缓存折扣不变。
- 2026 年 8 月:Luna 系列推出,缓存输入价进一步降低至 $0.02。
风险与边界
此指南基于 OpenAI 官方 2026 年定价和文档,仅供参考。实际账单以 OpenAI 官方发票为准,API 价格可能随时间调整,具体以 official-prices 或官方定价页为准。OpenAICN 仅为官方 API 计费对照站,不提供任何投资、法律或技术建议。
---
English summary
This guide details how OpenAI Prompt Caching pricing works in 2026. OpenAI automatically caches repeated prompt prefixes (minimum 1024 tokens), charging only 10% of the standard input rate for hits while leaving output tokens unchanged. Key fields include prompt_tokens, cached_tokens, and (for GPT-5.6+) cache_write_tokens. Savings formula: total cost = (regular input × rate) + (cached input × discounted rate) + output. For most models, cache input is $0.50/M vs $5.00/M standard (90% discount), with 24-hour retention now default. On GPT-5.6+ models, writes cost 1.25× but remain free for earlier families. Enterprise billing extracts data via usage fields or invoices; hit rate >50% typically pays off quickly. Use cases include RAG, multi-turn coding, and shared system prompts. For exact model rates and latest updates, check official pricing. Always verify against your specific API key and context length.