# How a saving is calculated

> Each lever's formula and the baseline it is measured against.

Each lever below has the same parts: the **baseline** it is measured against, the **formula**, the **conservative choices** that keep it from overstating, and its **coverage** (how much of your estate reported what the lever needs). The same arithmetic is used by the Overview, the Savings page, the API and the MCP tool. The caching and routing definitions are shared with the value report your deployment produces, and both are tested against one set of vectors so they cannot drift apart.

All prices are your deployment’s price card: the newest complete snapshot of the models it may call, in US dollars per million tokens. In the formulas, `M` is 1,000,000.

## Retrieval against context stuffing

**Baseline.** Context stuffing: every request sends everything the caller may search, instead of the passages retrieval chose.

**Formula**, per search:

```text
stuffed   = min(corpus_tokens_in_scope, window)
avoided   = max(stuffed − context_tokens_sent, 0) × (1 / sample_rate)
saving    = Σ avoided × rate / M

window    = the smallest context window among the priced models the pack called
            (200,000 where the price card names none)
rate      = the input price, weighted by each model's share of the pack's uncached input;
            or the cache-read price, if the deployment used the prompt cache in the period
```

**How the corpus is counted.** `corpus_tokens_in_scope` is measured in your account from the documents’ own characters, not by summing chunks. Chunks overlap (60 words of every 400), so summing them would count each boundary twice and overstate the baseline by up to 17%. Each chunk after a document’s first gives back its overlap, at eight characters a word, which subtracts slightly more than the overlap holds: the corpus, and with it the saving, errs low.

**Conservative choices.**

- Capped at the context window: stuffing could never send more than fits. A search whose corpus did not fit is counted, and for it the figure is a floor.
- The cache-read price wherever you cache, because a stuffed prefix would have been cached too.
- A search that did not report its scope counts nothing, rather than being given an assumed corpus.

**Coverage.** Searches that reported `corpus_tokens_in_scope`, over all searches.

**Tokens.** `Σ avoided` is the headline’s token figure: tokens kept out of a model’s context.

## Model routing against the top model

**Baseline.** Every call run on the most capable model you could have run. Not the dearest model anywhere: a saving against a model you cannot buy is not a saving.

The figure comes from one of two sources, and `detail.source` says which.

### Where the router decided: `source: decisions`

Each routing decision records what the chosen model was estimated to cost for that call and what the top model would have cost, both on your price card. See [the model router](/router/).

```text
saving    = Σ saving_usd over decisions in mode route or pinned  −  Σ escalation_usd

saving_usd = top_usd − chosen_usd, for that call
```

- **Net of escalations.** When a cheaper model’s answer failed its check and the call was escalated, the escalation’s cost comes off the saving that choice bought.
- **A decision recorded while the router was off is reported and never counted** (`off_saving_usd`): it changed nothing. Today the gateway records decisions only while the router is on, so this figure is zero; see [where the router runs](/router/#where-it-runs).
- `detail.decisions` carries the counts (`decisions`, `routed`, `off`, `fallback`, `escalated`, `changed`), the saving, the escalation cost, the quality and bar, and a breakdown by task class.

### Where it decided nothing: `source: counterfactual`

For a period with no routing decisions, the lever falls back to reconstructing what each call would have cost on the reference model:

```text
saving    = Σ over calls not on the reference
              [ cost(tokens, reference) − cost(tokens, model it ran on) ]

cost(t, m) = ( t.input × m.input + t.output × m.output
             + t.cache_read × m.cache_read + t.cache_write × m.cache_write ) / M
```

The **reference** is the model your administrator chose (**Insights → Savings**, settings), or else the most capable model available in your library: by the provider’s own tiers, then version, then price.

This is a fair comparison but a reconstruction, because nothing routed. `detail.counterfactual_usd` keeps it beside the decisions figure whenever both exist, so you can compare them.

**Conservative choices.** Calls already on the reference are left out (and counted, so coverage is honest). Cache tokens are priced at the reference’s own cache rates, so caching is not counted twice. Refused calls, and calls on a model missing from the card, count nothing.

**Coverage.** Calls priced, over calls not on the reference.

Routing saves dollars, not tokens: it adds nothing to the headline’s token figure.

## Prompt caching against no cache

**Baseline.** No prompt cache: every cached token billed at the full input price.

**Formula**, per deployment and model:

```text
saving    = cache_read × (input − cache_read_rate) / M
          − cache_write × max(cache_write_rate − input, 0) / M
```

The reads’ discount, less the writes’ premium. Five-minute and one-hour writes are both priced at the card’s one write rate, as the gateway settles them.

**Two companion figures** on **Spend → Caching**:

```text
read_ratio         = cache_read / (input_uncached + cache_read + cache_write)
write_amortisation = reads' discount / writes' premium
```

The read ratio is the share of all your input that was read from the cache. Write amortisation is how many times the cache paid back the cost of writing it.

**Conservative choices.** Net of the write premium. A model with no cache-read price on the card saves nothing here, rather than being assumed a provider’s usual discount. Cached tokens were still sent, so they are not counted as tokens saved.

## Your infrastructure against a hosted agent platform

**Baseline.** What a hosted agent runtime would have billed for the same agent time, at its published rates.

**Formula**, over the days your account reported a cloud cost for the stack:

```text
hosted    = Σ runs  hours × (vcpu × cpu_active_share × vcpu_hour + gb × gb_hour)
          + tool calls × tool_calls_per_1000 / 1000
saving    = hosted − your cloud cost for the stack on those days
```

A run’s hours are its longest recorded duration. Your cloud cost comes from the cost job in your own account, which reads your cloud’s billing by the stack’s cost-allocation tag.

**Conservative choices.** Runtime only: the hosted platform’s memory, observability, storage and transfer charges are left out, so the comparison is a floor. The lower of its published rates. CPU priced for only part of each run, since a hosted runtime bills none while the agent waits on a model.

**When it counts.** Against Atlantic’s reference card, the lever shows a partial comparison: a figure, but not added to the headline. It counts in the headline only once you set a comparison card of your own. Without a cost feed from your account it shows why, and no number.

## Ephemeral infrastructure against always-on

**Baseline.** The same services run always on: the gateway, relay and reader your deployment reported, its network gateway and service endpoints, and its database, at list prices for its cloud and region.

**Formula**, per day a deployment on the ephemeral profile has a cost figure:

```text
saving    = max(always_on_estimate − actual cost that day, 0)
```

List prices come from Atlantic’s versioned cost model, each with its source and the date it was read (cloud price lists, before credits and discounts).

**Conservative choices.** Lines common to both profiles (load balancer, logs, keys) are left out of the baseline but stay in the actual cost, so the saving is understated. Never below zero: the baseline is partial, so a negative figure would be an artefact, not a loss.

**Not counted twice.** This saving is already inside your actual bill, which the infrastructure lever compares. While that lever has a figure, this one shows as `included` and is not added to the headline again. See [Deployment profiles](/concepts/deployment-profiles/).

## The headline

```text
headline.usd     = Σ levers with status "ok"   (signed: a lever that cost more lowers it)
headline.tokens  = retrieval's tokens avoided
```

A lever without data says why (`no_data`, `no_price_card`, `no_comparison`, `no_cost_feed`) and contributes nothing. Every figure carries `estimated: true`, `basis: "price-card"` and `counted: false`: none of it is ever on an invoice.

Source: https://docs.atlanticagenticlabs.com/cost/savings/
