# Cost calculation

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. For each call Brizz uses the best signal available:

1. A cost the provider returned in its response (most accurate), or
2. A cost computed from the token counts and the LiteLLM rate for that model.

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.

**What Brizz does not detect yet:** premiums charged through signals that aren't visible in the model ID — 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.

## See also

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