OpenRouter measures how to cut AI agent token costs
OpenRouter replayed one 40-step synthetic coding session through its API under six context configurations, measuring token use, cache hits, cost and accuracy. A timestamp at the start of the system prompt broke prompt caching and raised the session cost from $0.084 to $0.658, while capping tool results once produced the cheapest setup at $0.054. OpenRouter recommends keeping the prompt prefix unchanged, using a constant session_id and compacting long sessions without summarizing earlier summaries.
The measurements show that preserving an identical cached prefix can matter more than reducing raw token volume, but the findings come from one synthetic session on one model with one provider's caching setup.
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.