Your Router Is Fighting Your Prompt Cache

Provider prompt caches are per model, so the moment a router moves a session from Sonnet to Haiku it re-writes the entire cached prefix at a 1.25x premium. A cache read costs a tenth of fresh input on Anthropic, and the router also forfeits the 90% discount it was already earning. On a 50,000-token prefix, the cheap model loses: staying on warm Sonnet costs $0.0285 for the next turn, switching to cold Haiku costs $0.0670, 2.4x more for the model with the smaller price tag. Whether the switch ever pays back depends on one variable almost no router looks at: how many turns the session has left. Here is the break-even math, and how to make a routing decision that prices the cache instead of ignoring it.

Published 2026-07-16 by Dor Amir on the Nadir blog.

Filed under Caching.

The discount that belongs to one model

Prompt caching is the closest thing to free money in the hosted LLM stack, and this blog has made that case before: mark a stable prefix, pay to write it once, and every request that repeats it within the TTL bills that prefix at a fraction of list price. On Anthropic a cache read costs 10% of fresh input. On OpenAI it is about 50%, automatic, with no write fee. On Gemini, about 25%. Source: Anthropic, "Prompt caching"; Source: OpenAI, "Prompt caching".

The part that gets skipped: that discount is keyed to a model. The cache Anthropic keeps for your 50,000-token agent scaffold lives under claude-sonnet-4-6 specifically. Route the next turn of that same session to claude-haiku-4-5 and, as far as the cache is concerned, you are a stranger. The prefix processes from scratch at Haiku's rates, plus a 1.25x cache-write premium if you keep caching, which you should. And the 90% read discount Sonnet had already earned is simply forfeited.

A model router makes exactly that move on purpose, on every request. Per-request routing, this blog's whole thesis, asks "which is the cheapest adequate model for this prompt?" and sends the easy turn to the cheap model. Prompt caching quietly makes that question wrong for multi-turn sessions. The cheapest model for this request and the cheapest path for this session stop being the same thing once a large prefix is warm somewhere, because cost is no longer a property of the request. It is a property of the session's cache state.

The arithmetic of a switch

Put real prices on it. Claude Sonnet bills $3 per million input tokens and $15 per million output. Haiku bills $1 and $5, three times cheaper on paper. Cache reads are 10% of input price, cache writes 1.25x for the default 5-minute TTL. Source: Anthropic, "Pricing".

Now take a coding-agent session with a 50,000-token cached prefix, system prompt, tool schemas, and accumulated context, warm on Sonnet. The next turn adds 2,000 fresh input tokens and produces about 500 output tokens.

Stay on warm Sonnet. The prefix bills at the read rate, the new tokens at list:

50,000 x $0.30/M + 2,000 x $3/M + 500 x $15/M = $0.0285

Switch to cold Haiku. The prefix re-bills at Haiku's write rate, then Haiku's cheaper rates apply to the turn:

50,000 x $1.25/M + 2,000 x $1/M + 500 x $5/M = $0.0670

The switch costs 2.4x more than staying, for a model that costs a third as much per token. Per prefix token, the comparison is a $0.30/M cache read against a $1.25/M cache write, a 4.2x spread before Haiku's cheaper fresh tokens claw anything back. At one thousand such sessions a day, cache-blind downrouting on that single turn is the difference between $28.50 and $67.00, roughly $14,000 a year, spent by the cost-optimization layer.

The cache-write tax post covered writes as a standalone line item. A switching router pays that tax repeatedly, and pays it precisely when it believes it is saving money.

The variable that decides it: turns remaining

Switching is not always wrong. It pays a one-time cost, the prefix re-write, and earns a recurring per-turn saving, the cheaper model's rates on everything after the prefix. Whether it nets out depends on how long the session keeps going. Over N remaining turns, with prefix P and a per-turn load of T_new fresh input and T_out output tokens:

stay   = N x (P x read_warm + T_new x in_warm + T_out x out_warm)
switch = P x write_new + (N - 1) x P x read_new
         + N x (T_new x in_new + T_out x out_new)

Run the 50,000-token example across horizons:

Turns remainingStay on warm SonnetSwitch to HaikuWinner
1$0.0285$0.0670Stay, by 2.4x
3$0.0855$0.0860Dead even
10$0.2850$0.1525Switch, saves 46%
30$0.8550$0.3425Switch, saves 60%

The break-even in this example sits near three turns. A support bot wrapping up a conversation should stay warm. An agent loop settling in for forty tool calls should eat the re-write immediately, because Haiku warms its own cache on turn one and every turn after that bills the prefix at Haiku's own 10% read rate.

The intuition compresses to one line: the bigger the cached prefix is relative to each turn's fresh work, the longer you should stay on the model that holds it. Agent scaffolds are exactly the workloads with huge stable prefixes and small per-turn deltas, which is why this bites agent traffic hardest, the same traffic where structural overhead already dominates the token budget.

Quality still rules, cost only breaks ties

One guardrail before any of this ships: cache math must never route a request below the quality it needs. If the session is warm on Haiku and the next turn is genuinely Opus-tier work, the router should escalate and eat the cache loss. The stay-or-switch comparison is legitimate only between candidates already admitted by policy. Nadir's older 60% / 98% RouterBench figure is a reference-assisted research ceiling, not evidence that the deployed cache-aware path universally clears that constraint.

There is a second, quieter half of this contract: whatever optimizes your context must not invalidate the prefix either. Compression that rewrites an earlier message re-bills the whole cached prefix at write rates, which can cost more than the tokens it removed. Nadir's /v1/optimize holds a prefix-stability contract for exactly this reason: re-optimizing a conversation that has grown by a turn reproduces the previously optimized messages byte-identically, so the cache keyed on the optimized prefix keeps hitting.

Making the router cache-aware

The fix is to hand the router the one fact it is missing, what is warm and how big it is. Nadir's decision endpoint takes it as an optional field:

curl https://api.getnadir.com/v1/recommend \
  -H "X-API-Key: $NADIR_API_KEY" \
  -d '{
    "prompt": "Apply the fix we discussed to the parser.",
    "cache_state": {
      "model": "claude-sonnet-4-6",
      "cached_tokens": 50000,
      "ttl": "5m",
      "expected_remaining_turns": 2
    }
  }'

The response carries the fresh pick, the cache-adjusted decision, and both projected costs, so the override is auditable rather than magical:

{
  "recommended_model": "claude-sonnet-4-6",
  "selection_method": "cache_aware_stay",
  "cache_advice": {
    "decision": "stay_warm",
    "router_model": "claude-haiku-4-5",
    "stay_cost_usd": 0.057,
    "switch_cost_usd": 0.0765,
    "switch_penalty_usd": 0.0195,
    "horizon_turns": 2
  }
}

If the cache has expired, the quality bar rules the warm model out, or the horizon is long enough that switching pays, the fresh pick stands and cache_advice says why. The same economics surface in the dashboard: the Analytics cost view now tracks cache reads against cache writes per model, with the one warning worth automating, writes exceeding reads, which means you are paying the 1.25x premium for prefixes that expire before anything reads them back.

If you run your own router

The checklist is the same whether or not Nadir is in the loop:

Routing and caching are the two biggest levers on an LLM bill, and most stacks operate them as if they were independent. They are not: every routing decision is also a cache decision. Price them together and the router stops fighting the cache and starts using it, which is the difference between a router that optimizes requests and one that optimizes your bill. For the rest of that playbook, start with the complete guide to cutting LLM API costs.

More on caching

What Nadir is

Nadir is an LLM router. Nadir sends each prompt to the cheapest model that can handle it. A small decision model reads each prompt against your model menu and picks the lowest-cost model it expects to handle it. When the decision model is uncertain or unavailable, the request goes to the strongest model on the menu. The routing step makes no call to your model provider.

Nadir runs two ways. The decision API returns a model, reasoning-effort, cache, context, and policy recommendation without calling a model provider, beside the gateway you already run. That is how a shadow-mode evaluation works, and its projected savings stay advisory. The OpenAI compatible managed proxy executes the route, and migration is a two-line change: point the base URL at api.getnadir.com and set model to auto. On that path an optional verifier can score a complete non-streaming answer and escalate to a stronger model when it misses the configured bar. Streaming bypasses post-generation verification. BYOK is supported on every tier.

For coding agents, Nadir Auto is a terminal launcher for Claude Code or Codex that asks Nadir for the main-session model before each turn, with your configured model as the fallback and cost ceiling. Delegation integrations for Claude Code, Codex, or Cursor instead recommend a model tier for subagent work, and the agent decides; the Claude plugin can also move a main-thread turn to Haiku when Nadir's cache check prices it cheaper, unless its switch_main_model option is off. Either way inference runs on your own provider account, so Nadir holds no provider keys on that path.

What the numbers are, and what they are not

Nadir publishes each evaluation with its scope. On checkable code, run-check-escalate solved 392 of 395 common HumanEval and MBPP problems (99.2%), graded by running the canonical tests; that applies only to tasks with runnable deterministic tests. Nadir-Tumbler posts an arena_score of 72.3 on RouterArena's public scorer, 5th of 23 routers, which measures the routing decision on RouterArena's own model pool. A reference-assisted RouterBench evaluation over 11,420 held-out triples produced a 60% lower projected cost than always-Opus with about 98% retained quality and a 1.7% catastrophic-route rate. That experiment gave the verifier the expensive-model reference answer, which production does not have, so it is a research ceiling and not the deployed path.

None of these is a production guarantee, a universal savings rate, or a forecast for any particular workload. Customer savings are reported from measured execution against a declared baseline, and customer quality only from outcome-labelled traffic. Projected savings and realized savings are separate artifacts and are never blended.

Design-partner program

Three rungs, picked by risk appetite. Rung 0 Shadow runs advisory decision calls alongside live traffic and returns a projected receipt, with nothing in the request path changed. Rung 1 Hosted is the two-line swap on a production slice and returns a realized receipt. Rung 2 On-prem is a supervised six-week proof of concept inside the partner's VPC, where no prompt, response, or usage reaches Nadir. The commitments are the same at every rung. Apply for a rung directly: Rung 0 Shadow, Rung 1 Hosted, or Rung 2 On-prem. Not sure which fits? Start at getnadir.com/contact/?reason=design-partner.

Licensing

NadirClaw is the self-hosted core, source-available under the PolyForm Noncommercial License. Source-available is the correct label; NadirClaw is not open source. Nadir Route's hosted plan has no base fee and charges a variable fee only on measured savings from requests Nadir executed.

Pages on this site

Machine-readable summaries of this site: llms.txt and llms-full.txt.