# How cost is computed

How Brizz computes and displays the cost of each session.

## How Brizz computes cost

Brizz computes cost per LLM call. For each call it multiplies the token count for each billing class by that class's per-token rate, then sums across every call in the session:

```
session cost = Σ (tokens_class × rate_class)   for each LLM call in the session
```

The billing classes are:

| Class | What it counts |
|---|---|
| **Input** | Fresh (non-cached) prompt tokens |
| **Cache read** | Prompt tokens served from the provider's prompt cache |
| **Cache write** | Prompt tokens written into the provider's prompt cache |
| **Output** | Completion tokens generated by the model |
| **Tools** | Flat per-call surcharge for tool/function calling, when billed separately |

## Where rates come from

Rates come from [LiteLLM's model price list](https://github.com/BerriAI/litellm), refreshed periodically. Brizz normally computes each call from its token counts and the matching rate. If an SDK supplies a dedicated final cost, Brizz uses it directly. A cost embedded in provider metadata is less authoritative: Brizz uses it to identify the matching rate when possible, and uses it as the total only when it cannot compute one.

Some models bill the whole call at a higher rate once the prompt passes a size line (for example, twice the rate past 272K input tokens). The line counts every input token, cached or not, and the **Cost breakdown** shows the rate the call was billed at. A model with no published cache-write rate bills tokens written to cache at its input rate.

Costs are **estimates** and may differ slightly from the invoice your provider issues.

## Provider and region premiums

The same model can be billed at different rates depending on how it's reached. The clearest example is Amazon Bedrock: its region-pinned profiles (`eu.`, `us.`, `apac.`, …) are priced above the `global.` profile and the base provider rate for the *identical* model.

When a model is reached through a routing or locality prefix and that profile's rate differs from the model's base-family rate, Brizz surfaces the difference as a **premium** (`+X%`) — or, if billed below base, a **discount** (`−X%`). It's computed server-side at billing time against the same pricing snapshot used to bill the call, so it always reconciles with the displayed cost. A model-version price change is *not* treated as a premium — only a routing/locality difference is.

**What Brizz detects today:** Amazon Bedrock region-pinned profiles. For example, `eu.anthropic.claude-sonnet-4-6` shows **+10%**, while the same model via the `global.` profile or the base provider API shows no premium. Brizz also detects regional routing for calls made through Vercel AI Gateway when the gateway reports the call's cost: it selects a rate only when one row for that model reproduces the reported total within 1% and no differently priced row also fits.

**What Brizz does not detect yet:** premiums charged through signals that aren't visible in the model ID or a trustworthy per-call cost — for example Azure data-zone vs. regional deployments, Vertex regional endpoints, or OpenAI/Anthropic service tiers (batch, priority). Those calls are still billed at Brizz's rate for the model, but the *reason* for the difference isn't named.

A premium is computed only for sessions ingested after this feature shipped; older sessions show no premium line.

## Reading the breakdown panel

Open the panel from any cost figure — it's titled **Cost breakdown**. Each row reads left-to-right as **tokens × rate = cost**, where the rate is the per-million-token rate actually billed for that class, ending in a **Total**.

- **"—"** in a Tokens or Rate cell means there's no token-level data for that class (e.g. a flat tool surcharge has no per-token rate).
- **"Breakdown not available"** means the cost came straight from the provider response without a per-class split. The total is still accurate.
- **Single vs. multiple models:** a single-model session shows one breakdown. A multi-model session shows one card per model — model, provider, any premium, and a **Subtotal** — with a bold **Session total** at the bottom.

## Caveats

- Costs shown are **estimates** derived from token counts and rate tables; they may differ from your provider's invoice (rounding, promotional rates, committed-use discounts).
- Cache read and cache write are distinct billing classes at different rates. If your provider doesn't report cache token counts, those rows won't appear.
- A failed LLM call your provider refused (a rate limit, an unknown model, an overloaded or failing provider, a request it rejected) carries no tokens and no cost, since providers don't bill those. A failed call the provider was already answering, such as one your app cancelled or timed out on mid-response, still carries an estimated cost.

## See also

- [Cost](/docs/platform/dashboards/cost.md) — the dashboard that reports the spend computed here.
- [Custom charts](/docs/platform/dashboards/custom-charts.md) — chart cost over time, by model, or per user with the cost metric described here.
- [Custom dashboards](/docs/platform/dashboards/custom-dashboards.md) — collect cost charts into a board your team reviews.
- [Performance](/docs/platform/dashboards/performance.md) — cost tracked alongside session volumes and error rates.

---

[All Brizz documentation](https://docs.brizz.ai/llms.txt) · [Full documentation (single file)](https://docs.brizz.ai/llms-full.txt)
