OpenRouter实测降低智能体令牌成本
OpenRouter通过API以六种上下文配置重放了一个40步的合成编程会话,并测量令牌用量、缓存命中、成本和准确率。在系统提示开头加入时间戳会破坏提示缓存,使同一会话成本从0.084美元升至0.658美元;而仅在工具结果进入历史时截断一次,则以0.054美元成为最便宜的方案。OpenRouter建议保持提示前缀不变、全程使用相同的session_id,并避免反复总结先前的总结。
测试表明,保持相同的缓存前缀有时比单纯减少令牌数量更重要,但结论仅基于一个合成会话、一个模型和单一提供商的缓存设置。
How to Reduce Token Usage in AI Agents (Measured)
OpenRouter ·12/1/2026


An AI agent resends its whole conversation to the model on every step, so a long session’s token count and its bill grow with every call. This guide shows you how to bring both down, using measurements instead of guesswork.
We replayed one 40-step coding session through the OpenRouter API under six context setups, including one failed first attempt at compaction, and measured the tokens, cache hits, cost and accuracy of each. The most expensive run sent exactly the same tokens as a much cheaper one, and the difference came down to one line in the system prompt.