This post follows one turn of a coding agent through Nadir, from the moment the agent sends it to the moment the provider bills it. There are four stages. The agent asks. Nadir picks a model and an effort. Nadir checks whether switching models is worth giving up a warm prompt cache. Then the agent makes the call itself, on its own keys.
Every number in this post is illustrative: a made-up turn, list prices for a made-up three-rung ladder, and the arithmetic that follows from them. None of it was measured on customer traffic, and none of it is a savings forecast.
1. Ask: the agent sends a turn, as usual
You are in Claude Code, Codex or Cursor, and you type: "Add pagination to the users endpoint." The agent does what it always does. It reads the two files that matter, the route handler and the query layer underneath it, and builds a request out of the system prompt and tool definitions it carries on every call, the session so far, your ask, and the two files.
Two numbers about that request decide the rest of this post:
- About 8,000 new tokens this turn: your ask plus the two file reads.
- 12,000 tokens of earlier context (the system prompt, the tool definitions, the earlier turns) that the provider already holds in its prompt cache. The session has been running on the top model, so that is where the cache is warm.
Nothing about the agent's workflow changes. Before the call goes out, a hook in the agent asks Nadir one question: which model should take this turn, and at what effort? It sends the prompt along with the session's cache state, meaning which model is warm and how big the cached prefix is.
2. Pick: the cheapest rung that can do the turn
A ladder is an ordered list of models, cheapest to most capable, set per API key. This example uses three rungs at list price, and prices this turn's 8,000 tokens in and 1,200 out on each:
| Rung and effort | Per 1M tokens, in / out | This turn |
|---|---|---|
| Top model, xhigh | $5 / $25 | $0.070 |
| Mid model, medium | $2 / $10 | $0.028 |
| Small model, none | $1 / $5 | $0.014 |
Nadir's classifier reads the turn and scores how much model it needs. Price does not enter that score. Price only orders the ladder, and Nadir takes the cheapest rung that clears the score. For this turn that is the mid model. Pagination touches the endpoint's contract and the query under it, a two-file change with a real design choice in it (cursor or offset, what the default page size is). That is more than a rename and less than a cross-service refactor.
The small model would be cheapest, at $0.014, and for "rename this variable" or "fix this lint error" it is the right pick. Here it is a false economy. A weaker first attempt is a turn you pay for twice, once for the miss and once for the retry. The classifier is trained to treat sending a hard turn too low as the costlier of the two mistakes, so when it is unsure it leans up the ladder, not down.
Effort comes with the rung. Effort is how much the model reasons before it answers, and reasoning is billed as output tokens. Turns that land on the top rung are the ones that need deep reasoning, so it runs at xhigh. A mid-sized turn at medium effort does not spend reasoning tokens it has no use for. Some small models take no effort parameter at all, so that rung sends none.
The table holds output at 1,200 tokens on every rung to keep the arithmetic readable. In practice a model at xhigh effort writes more reasoning tokens than one at medium, so the flat figure flatters the top rung, not the mid one.
3. Check: switch only when it beats rebuilding the cache
The pick says mid. But the session is warm on the top model, and a prompt cache belongs to one model. The 12,000 cached tokens bill at a cache-read rate on the top model. The mid model has never seen them, so its first turn has to write them into its own cache at a cache-write rate, and the read discount the top model had already earned is gone. Your Router Is Fighting Your Prompt Cache works through that penalty in depth.
So before it answers, Nadir prices both paths over the turns the session is expected to have left:
- Stay on the top model. Every turn reads the 12,000-token prefix from cache and pays top-model prices for its new tokens.
- Switch to the mid model. The first turn writes the prefix into the mid model's cache, later turns read it from there, and every turn pays mid-model prices for its new tokens.
It recommends the switch only when the switch path is cheaper. When it is not, the turn stays on the warm top model, which is at least as capable as the model the classifier picked and cheaper for the session as a whole.
With illustrative cache pricing, a read at 10% of the input price and a write at 125% of it (a common provider pattern), this turn looks like this:
| First turn | Stay on top model | Switch to mid model |
|---|---|---|
| 12,000-token cached prefix | read: $0.006 | write: $0.030 |
| This turn's own tokens | $0.070 | $0.028 |
| Total | $0.076 | $0.058 |
Rebuilding the cache costs $0.024 more than reading it, and the turn itself is $0.042 cheaper on the mid model. The switch pays for itself on the first turn. Decision: switch to mid.
That is the easy case. The check earns its keep when the warm prefix is large, and in a long coding session the carried context grows with every file read and tool result (The Prefix Tax covers why). Same turn, same prices, bigger prefix:
| Warm prefix | First turn, stay vs switch | Switch pays from |
|---|---|---|
| 12,000 tokens | $0.076 vs $0.058 | turn 1 |
| 30,000 tokens | $0.085 vs $0.103 | turn 2 |
| 60,000 tokens | $0.100 vs $0.178 | turn 3 |
| 120,000 tokens | $0.130 vs $0.328 | turn 4 |
At 60,000 tokens the first turn on the mid model costs $0.178 against $0.100 for staying, and the switch only comes out ahead from the third turn. At 120,000 it takes four. If the session is about to end, say the agent is writing its last commit, the cheaper model never earns back its own cache, and the right answer is to stay. A router that only asks "what is the cheapest model for this prompt" gets that case wrong every time.
Nadir cannot know how many turns are left, so it prices over a short, conservative default horizon unless the agent's harness sends its own estimate.
4. Call: your agent makes the call
Nadir's answer is a model and an effort. The agent makes the provider call itself, on its own sign-in or API keys, straight to the provider it already uses. With the Claude Code, Codex and Cursor installs the agent keeps its own sign-in and provider, and Nadir only answers which model.
| Receipt | |
|---|---|
| This turn, on the mid model | $0.028 |
| Same turn, on the top model | $0.070 |
| Provider call | your agent, your keys |
The receipt prices the turn's own tokens at list price: 8,000 in, 1,200 out. The cache line is in stage 3. Because Nadir did not make the call, the receipt is a projection. The real number is on your provider's bill. The decision comes back with its reasons attached, the model, the effort, the cache verdict and the projected cost of both paths, so you can audit why each turn went where it went.
What this walkthrough leaves out
- The classifier can be wrong. The pick is a prediction. A turn that needed the top model and got the mid one costs a retry, which is why the classifier leans up the ladder when it is unsure.
- Cache pricing differs by provider. Some bill a cache read at a quarter or half of the input price and charge nothing extra to write. There the switch penalty is smaller and the break-even comes sooner. The check uses each model's own prices, not the 10% and 125% used here.
- Context grows. Real sessions accumulate tool output, so later turns re-read more than earlier ones, on both paths. This example holds every turn at the same size.
- Effort changes output. The 1,200-token output is held flat across rungs. Higher effort usually writes more, which widens the gap in favour of the lower rung.
Nadir publishes no universal savings or quality percentage until one is measured on outcome-labelled customer traffic. The useful number is the one from your own turns.
If your team's coding-agent bill is the number you are trying to move, book a call and we will walk your own sessions through the same four stages, or see pricing.