LLM cost optimization: how we cut the bill on agents already in production
Model routing, prompt caching, streaming and per request telemetry. What we review, how we decide which model does which step, when routing is not worth it, and how we deliver it.
by Zechim
An agent that works in a demo can still be expensive in production. The bill grows with volume, and most teams only look at the total at the end of the month.
LLM cost optimization is the work of finding where the money goes, step by step, and spending it where it buys quality. This post describes how we do it as a service.
What we review
1. Which model does which step
A typical agent conversation about data has 3 to 5 model calls: pick a tool, write the query, read the result, write the final answer. Most of those steps are mechanical and a smaller, faster model handles them well. The step that reaches a person is where a larger model earns its price.
Our rule of thumb:
Use the smaller model when:
- The task is classification or structured extraction
- The output is code or data that another system will run or parse
- The context is short
Use the larger model when:
- The output goes straight to a human reader
- The task needs multi-step reasoning in the same turn
- The context is long and has cross references
2. Prompt caching
A system prompt with the schema, rules and examples is paid in full on every call unless it is cached. Cached tokens are billed at a fraction of the normal price, and in multi-turn conversations the same prompt is read many times. We check whether caching is enabled, whether the cache is actually hit, and whether something in the prompt breaks it on every request.
3. Streaming and limits
Users wait less when the answer streams, and waiting less changes how people use the product. We also look at output length limits, retries that repeat expensive calls, and loops that run longer than the task needs.
4. Telemetry per request
You cannot reduce what you cannot see. We add cost and token counts per request, per step and per model, so the next decision uses numbers.
What it looked like on our own agent
On our public demo (one agent, about 400 conversations in the month we measured, 3.2 model calls per conversation on average), routing the loop to the smaller model and caching the system prompt moved the cost per conversation from about $0.012 to about $0.005, around 60 percent less, with the same perceived quality on the cases we tested.
That is one agent with one traffic pattern. Your numbers will differ, and we will not promise a percentage before looking at your breakdown.
When routing is not worth it
- Low volume. At around 100 conversations a month the savings are small. Use one model and save the engineering time.
- Tight latency. Every model switch is one more call. For very short response budgets, stay on one model.
- Answers that must be right every time. Financial, medical or legal products usually keep the larger model everywhere.
Most medium volume business cases fall in the range where routing pays.
What we do not do
- We do not promise a percentage. The first step is reading your cost breakdown.
- We do not lower quality to lower cost. Every change is checked against a set of real cases before it ships.
- We do not lock you into a vendor. The routing logic is yours and works with any provider.
How we deliver it
- 2 week Discovery. We read your usage and cost data, trace a sample of conversations step by step, and return a ranked list of changes with expected savings and risk.
- 4 to 8 week Pilot. We apply the changes with the best return, with an evaluation set that guards quality, and report cost per request before and after.
- Optional ongoing mode. A Fractional AI Lead keeps the cost review running as models and prices change.
The code, the evaluation set and the documentation are yours.
What you need to start
- Read access to your usage and billing data from the model provider.
- A way to replay or sample real conversations.
- Someone who can say which answers must never get worse.
If you run agents in production and have never looked at the cost breakdown per model and per step, worth 30 minutes to look at it together.