# How to prove LLM cost savings before you ship: trace replay and cost simulation

*Published November 11, 2026 by Setta AI. Canonical: https://setta-ai.com/guides/prove-llm-savings-before-you-ship*

You prove an LLM cost saving before shipping by replaying your recorded production traces under the change and pricing the replay the way your provider bills it: cache writes, cache reads, fresh input and output priced separately, with the prompt cache modeled call by call. Before trusting any projection, replay the unchanged traces and check that the result reproduces what you actually paid. Then report the saving on runs held out from the analysis, as a lower bound rather than a point estimate, and reject any change that alters what the agent decides to do. Counting the tokens a change removes is not proof: with prompt caching, fewer tokens can mean a bigger bill.

## Why token estimates mislead

Most cost tools estimate savings by counting the tokens a change removes and multiplying by a price. That ignores how inference is billed now:

- **Cached input is cheap; writing the cache is not.** On most major APIs a cache read costs a fraction of fresh input, and on several providers a cache write costs more than fresh input. A trim that changes the cached prefix turns cheap reads into expensive writes.
- **Output costs more than input.** A compressed input that makes the model write longer answers can cost more overall.
- **One field can break the cache for everyone.** Moving a timestamp or tenant ID near the top of a prompt rewrites the cache on every call.

This is measurable. Across 2,848 Claude Code sessions, cutting tool-output tokens 38.4% raised the bill 6.8%, and one compression tool raised it 48.4% ([PointFive, Aug 2026](https://www.pointfive.co/press/pointfive-research-token-reduction-not-cost-reduction)). An analysis of model routing found that cache recompute after switching models ate about two thirds of the theoretical routing saving ([Towards Data Science](https://towardsdatascience.com/the-hidden-cost-of-llm-routing-why-switching-models-costs-more/)).

## The ways to estimate a saving, compared

| Method | What it tells you | What it misses |
|---|---|---|
| Token re-count | How many tokens a change removes | Cache writes and reads, output changes, behavior changes |
| Re-pricing under another model or price | What the same traffic costs at different rates | The new model behaving differently; cache warm-up after a switch |
| Offline eval set | Whether quality holds on chosen examples | Your real traffic mix, and cost |
| Live A/B test | The real effect on cost and quality | Spends real tokens and exposes customers before you know it's safe |
| Cache-aware counterfactual replay | What your recorded traffic would have cost under the change, priced as billed | Anything the replay can't know about new model output (see limits below) |

Replay doesn't replace the A/B test. It decides which changes are worth one, and stops the ones that would have cost money or changed behavior.

## How a cache-aware replay works

### 1. Collect traces with full content

You need every LLM call with its full request (system prompt, messages, tools), the response, the usage fields including cache reads and writes, timestamps, and a run ID. Summaries and token counts alone are not enough, because the cache depends on the exact content and order of the prompt. Exports from LangSmith, Langfuse, OpenTelemetry or provider logs usually have this.

### 2. Check the replay against the real bill first

Replay the traces with no change and price them. The result should reproduce what each call actually cost, cache hits and misses included. Measure the gap call by call. If the baseline replay doesn't match the bill, nothing projected from it can be trusted: the data is incomplete, the cache model is wrong, or prices are off.

### 3. Apply the change step by step

Run each trace forward as a sequence of steps and apply the real change at every step: the edited prompt, the filtered tool list, the moved cache breakpoint, the deduplicated tool output. Where the change is deterministic, the replay is exact. Where it could change what the model says or does next, the model's decision has to be simulated, and that is where honest limits apply.

### 4. Model the cache per provider

Track what each provider would have cached: where the breakpoints are, how long entries live, what invalidates them (on most APIs, any change earlier in the prompt, including the tool list), and when they are evicted. Price writes, reads, fresh input and output at that provider's rates. For self-hosted models, model the server's prefix cache instead: per-replica capacity, eviction, and how requests are routed across replicas, since a prefix cached on one replica doesn't help a request sent to another.

### 5. Report a lower bound on held-out runs

Fit and choose changes on part of the traffic, then measure the saving on runs the analysis didn't see. Report a bootstrap lower bound, not just the average, and recommend a change only when the lower bound is above zero.

### 6. Reject changes that alter behavior

Compare what the agent decides in the replay (which tools it calls, with what arguments) to what it decided in production. A change that saves money by making the agent skip a tool call it needed is not a saving. List rejected changes in the report along with accepted ones.

### 7. Ship behind an A/B test and compare

Roll out what survives behind an A/B test against unchanged traffic, with a way to roll back, and compare the realized saving to the projection.

## Limits to be honest about

- A replay can't know exactly what a different model would have written. Changes that swap models or alter the model's inputs heavily need the behavior check in step 6 and a live A/B test before anyone counts the saving.
- The replay is only as good as the traces. Missing calls, truncated prompts or absent cache fields show up as a gap in step 2, which is why that check comes first.
- Prices and cache rules change. A projection is tied to the rates and cache behavior of the day it was made, so it needs re-running when they change.

## The same method for model and price changes

The same replay answers "should we switch to the new model?" or "what does the new price structure do to our bill?" Re-run your recorded traffic under the new model's prices and cache rules, check how behavior changes, and you know what the switch does to the bill before you make it.

## How Setta does this

Setta's simulator does the steps above on your production traces: it replays them step by step with the real fixes applied and only the model's decisions simulated, models caching per provider (and vLLM-style prefix caching for self-hosted models), checks the baseline against your actual bill before projecting anything, prices savings on held-out runs with a bootstrap lower bound, and lists the fixes it rejected. No tokens are spent and production is untouched. You send a trace export; there is nothing to install. The [free audit](/#cta) runs it on your traffic. To find what's worth testing in the first place, see [where agents waste tokens](/guides/where-agents-waste-tokens).
