Prompts2026年4月8日·1 分钟阅读

Anthropic Prompt Caching — Cut AI API Costs 90%

Use Anthropic's prompt caching to reduce Claude API costs by up to 90%. Cache system prompts, tool definitions, and long documents across requests for massive savings.

PR
Prompt Lab · Community
快速使用

先拿来用,再决定要不要深挖

这里应该同时让用户和 Agent 知道第一步该复制什么、安装什么、落到哪里。

在 system prompt 中添加 cache_control 字段,后续请求省 90% 成本。

什么是 Prompt Caching?

Anthropic 的提示缓存,将重复使用的内容(系统提示、工具定义、长文档)缓存在请求间复用,缓存读取仅需 1/10 成本。

一句话总结:Anthropic 提示缓存,缓存系统提示/工具/文档,读取成本仅 1/10,5 分钟 TTL 自动续期,生产级 Claude 应用必用,最高省 90%。

可缓存内容

  1. 系统提示 — 最常见场景
  2. 工具定义 — 大量工具时效果显著
  3. RAG 文档 — 同一文档多轮问答
  4. 多轮对话前缀 — 早期上下文缓存

最佳实践

  • 最长最稳定的内容先缓存
  • 缓存内容必须是前缀
  • 监控 cache_read_input_tokens 确认命中
  • 最小 1024 tokens

常见问题

Q: 影响质量? A: 不影响,模型看到的输入完全一致。

Q: Claude Code 用了吗? A: 用了,自动缓存 CLAUDE.md 和工具定义。

来源与致谢

Anthropic Prompt Caching

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产