---
title: See what a run cost
description: 'How Studio prices a run''s token usage at read time from a pricing table: the cost fields on every run row, own versus delegated cost, what unpriced, unknown and scripted mean, and how to supply your own table with studio.Pricing, WEFT_PRICING or weft studio --pricing.'
url: https://weftgo.dev/docs/observe/studio/cost/
type: how-to
sources:
  - weft/studio/experiments.go:396 (an experiment counts runs); weft/studio/pricing.go:528-532 (cost_partial on any figure not known with priced parts)
  - weft/studio/pricing.go:450-539 (cost_partial {usd, priced, of}), 884-894 (child runs in the reasons), 974-980 (the panel-token and tag-token reasons)
  - 'weft/CHANGELOG.md:42 (0.20.0: cost_partial on both surfaces), 62 (the panel header follows it), 76 (child runs), 78 (turns'' cost not known, without yet)'
  - 'weft/studio/pricing.go:29-132 (cost at read time; the table; matching; the formula; the wire fields; the scripted rule; running and never-ended runs; own and delegated; session cost), 137-163 (PricingTable, ModelPrice), 169-177 (Pricing), 198-210 (DefaultPricing), 219-233 (LoadPricing), 260-336 (parsePricing: the errors), 341-362 (resolvePricing: Pricing, else WEFT_PRICING, else the default), 402-407 (scripted, scriptedReason), 415 (gcp.gemini prices as google), 521-529 (five models, then (+n)), 556-565 (cacheOf, cacheNote), 569-600 (price), 839-883 (compute: own = usage minus the Subagent children''s), 897-966 (tally: one line counting the runs), 999-1007 (subagents: <parent>/<step>/<call> only), 1015-1032 (usagePending, derivedUsageUnknown), 1099-1301 (sessionCost, setCost), 1315-1358 (api/meta pricing, GET /api/settings/pricing, capability pricing)'
  - weft/studio/pricing.json (dated 2026-10-10, 47 rows, the note)
  - weft/studio/internal/pricingdata (the table's source; go generate ./studio/...)
  - weft/studio/routes.go:221-224 (the pricing group is always registered)
  - weft/core/model.go:51-62 (ModelInfo through the optional Info method)
  - weft/studio/web/src/routes/runs.index.tsx:223-234 (search pages by offset), 312-348 (a live frame patches its row in place)
  - 'weft/studio/README.md:393-396 (cost sort: in-place live rows, load more re-prices, offset paging)'
  - weft/studio/search.go:35, 56-80 (min_cost, sort=cost, the first 2,000 runs, cost_sort_cap)
  - weft/cmd/weft/pricing.go:15-38 (--pricing, else WEFT_PRICING; a start error naming the path and the field; the banner line)
  - 'weft/studio/README.md:269-365 (Cost), 2397-2420 (Settings: the pricing table edited per browser, download pricing.json, no PUT)'
  - 'weft/studio/web/src/lib/cost.ts:1-16 (the rules), 603-611 (formatUSD), 77-78 (CACHE_HINT), 95 (SCRIPTED_TEXT), 198-205 (costSortNote), 398-453 (atLeastCost: ≥ $x · k of n runs priced), 138-177 (unpricedLine)'
  - 'weft/studio/web/src/components/studio/cost.tsx:1-4 (no cost cell without capability pricing), 53-103 (the unpriced chip), 106-144 (UnpricedNote: price this model…), 165-224 (cache not reported; own · delegated)'
  - weft/studio/web/src/panel/badges.ts:429-445 (the panel's + $y delegated); weft/studio/web/src/panel/element.ts:5470-5496 (the result pane's run cost, N replays of this turn); weft/studio/web/src/panel/cost.test.ts:149
  - weft/core/wefttest/replay.go:300, 364-370 (a Replay model reports the recorded model)
  - weft/obsdb/tree.go:133 (ChildRunsCap 10,000)
  - 'weft/studio/pricing.go:1076-1077, 1106-1107 (sessionCost: 20 pages of 500, the session reason), 862-872 (a panel token''s hidden children: own still subtracts them, the delegated figure cut), 968-988 (scopeCutDelegated: the reason, counted, a visible reason after "; ")'
  - 'weft/studio/experiments.go:280-282, 353-370 (experimentRunPages: 20 pages of 500; experimentSummary: past the cap run_count from the total, the experiment reason)'
  - 'weft/studio/README.md:206-209 (a panel token: own takes the hidden children''s usage out, delegated_cost_known false)'
  - 'weft/studio/web/src/lib/settings.ts:101-108 (editsKey: source, path, dated)'
  - weft/studio/web/src/routes/settings.tsx:83-91 (?price=), 588-634 (the Pricing section, source words), 662-854 (the editable table, add row, reset to the server's table, download pricing.json)
  - weft/studio/web/src/lib/settings.ts:498-511 (SETTINGS_SECTIONS)
  - weft/studio/web/src/components/studio/step-diff.tsx:186-210 (the compare's cost column, the first 50 steps)
  - 'weft/AGENTS.md:227-233 (Pricing, PricingTable, ModelPrice, ModelGlob, DefaultPricing, WEFT_PRICING, LoadPricing), 263 (min_cost, sort=cost, cost_sort_cap), 273-282 (cost on every run row: cost_usd, cost_badge, cost_reason, cost_known, cache, delegated, unpriced_models, the scripted rule, /settings?price=, settings/pricing, capability pricing), 448 (--pricing, studio.Pricing(studio.LoadPricing(path)))'
  - 'weft/CHANGELOG.md:347 (no live PUT /api/settings/pricing), 349 (one unpriced reason per page; scripted; the any-provider row; unpriced_models; price this model…; the unpriced chip; ≥ $x · k of n runs priced), 475 (the panel''s cost), 573, 576 (a derived run without usage reads unknown), 1127 (plan A5.1), 1170 (plan A5.2: the Cost column, own · delegated, the compare and playground), 1199 (deleting a child moves its usage into the parent''s own cost)'
  - 'docs-site/examples/studio/cost.go (pricing-table, pricing-file); cost_test.go: TestScriptedRunCostsZero, TestPricingTablePricesRun, TestUnpricedModelCost, TestLoadPricing'
  - 'observed: weft studio v0.17.0 over a scratch database of three support-bot runs and a lead run with one research subagent, with the shipped table and with --pricing pricing.json (outputs below)'
  - 'weft v0.20.2: studio/api.go:285-296 (own_usage, delegated_usage on a run row, U30.2: omitted with no Subagent child, running, a failed read, a hidden child), 440-470 (the run document''s summarizer); weft/AGENTS.md:258 (own_usage / delegated_usage), 318 (a session''s delegated_usage: the whole delegated tree''s); weft/CHANGELOG.md:225 (0.18.0: the summarizer''s cost: weft.chat.role summarizer, never in the run''s usage, summarizer_usage, priced at read time, an estimate drawn ≈, + summarizer $x)'
---

# See what a run cost

Studio prices a run's token usage when it reads the run, from a pricing table in USD per 1M tokens. Nothing is stored, sent anywhere or fetched. Every run row carries `cost_usd`, the cost of the run's own model calls, and `delegated_cost_usd`, the cost of its [subagents](https://weftgo.dev/docs/reference/glossary/#subagent). A model the table has no row for reads unpriced: its figure is null, never $0. A `wefttest` scripted model is an exact $0. To price your own models, replace the table with [`studio.Pricing`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2/studio#Pricing), `WEFT_PRICING` or `weft studio --pricing`.

A table built in Go, from `docs-site/examples/studio/cost.go`:

```go title="studio/cost.go"
table := studio.PricingTable{
	Dated: "2026-10-18", // the day the rates were read, YYYY-MM-DD
	Note:  "acme list prices, USD per 1M tokens",
	Models: []studio.ModelPrice{ // first match wins: the specific row first
		{Provider: "acme", ModelGlob: "acme-large", Input: 2, Output: 8, CachedInput: ptr(0.2)},
		{Provider: "acme", ModelGlob: "acme-*", Input: 0.5, Output: 2},
	},
}
h := studio.Handler(studio.DB(db), studio.Pricing(table))
```

[studio/cost.go on GitHub](https://github.com/weftgo/weftgo.dev/blob/main/docs-site/examples/studio/cost.go)

The table replaces the shipped one whole. A run on `acme/acme-large` now prices with the first row, a run on any other `acme-` model with the second, and every other model reads unpriced.

![The runs list with costs: "6 runs unpriced: no row for globex/globex-mini, …" above the rows, a lead at $0 · scripted with "+ $0.0006 delegated" under it, a support-bot run at $0.0022, and another support-bot run's cost unpriced](https://weftgo.dev/docs/_astro/studio-cost.light.DNL_mD1r.webp)

*The runs list under this table: a scripted lead with &quot;+ $0.0006 delegated&quot; under its $0, a support-bot run at $0.0022, another unpriced, and the unpriced line above the rows naming globex/globex-mini.*

## Where Studio shows cost

Cost is drawn only under the `pricing` capability, which every v0.20.2 Studio lists. A Studio without it (an older one) gets no cost cell at all, not a "—".

| Surface | Shows |
|---|---|
| Runs list | A cost column: the run's own figure, its subagents' under it (`+ $0.0018 delegated`). Sortable ([Sort and filter by cost](#sort-and-filter-by-cost)) |
| Run header | `own` and `delegated` as two numbers, never added together; a run without subagents shows one `cost` figure |
| Step card | The step's own model call, once the step is read |
| [Compare page](https://weftgo.dev/docs/observe/studio/compare/) | A cost column per run, informational: it never marks a step changed |
| Sessions list | One figure per session: its turns' own plus delegated cost |
| Playground | Each result card's cost and a per-variant total ([Run experiments with the option lab](https://weftgo.dev/docs/observe/playground/experiments/)) |
| Devtools panel | Each turn's figure beside its tokens, its subagents' as a second figure (`$0.0029 + $0.0011 delegated`); the header's sum over the turns; the result pane's run cost and "N replays of this turn" ([Read a run in the panel](https://weftgo.dev/docs/observe/devtools/reading-runs/)) |

A figure reads one of these ways:

- **`$0.0022`**: a known figure. Under a cent it has four decimals; under $0.0001 it reads `<$0.0001`. Hover it for the exact six-decimal value.
- **`$0 · scripted`**: a scripted model's exact $0.
- **`—`**: not known. The hover gives the reason. An unpriced figure adds a small `unpriced` chip.
- **`≥ $x · k of n runs priced`**: a sum where some parts are not known. It reads `—` when the known part is $0.

A page with unpriced rows says so once, above them, with a link: "2 runs unpriced: no row for acme/acme-large" and **price this model…**. The link opens [Settings](https://weftgo.dev/docs/observe/studio/navigation/#settings) at `/settings?price=acme/acme-large`, where the pricing table leads with a row for that model, its rates left for you to fill. A run figure priced without a cache split carries a small "cache not reported" hint: every input token was priced at the input rate, which may overstate a cached prompt.

## Read the cost fields

Every priced object in the API (run rows in lists, documents, children, search hits and live `run` frames; steps; sessions; experiment runs; the export's run block) carries the same fields:

| Field | Meaning |
|---|---|
| `cost_usd` | The figure in USD, rounded to 6 decimals. `null` when not known, never `0` for an unpriced model |
| `cost_known` | Whether `cost_usd` is a figure |
| `cache` | `exact`, or `not_reported` when the adapter reported no cache split (below) |
| `cost_badge` | `unpriced` (no row matches the model), `unknown` (the figure cannot be computed yet, or at all), or `scripted` (a known exact $0). Absent on a priced figure |
| `cost_reason` | Why, in one short line: `acme/acme-large has no price` |
| `unpriced_models` | The `provider/model` pairs without a price behind the figure, deduped |
| `delegated_cost_usd`, `delegated_cost_known`, `delegated_cost_reason`, `delegated_unpriced_models` | The same for the run's subagents (run rows and a step's children only) |

The model lists stop at five; a sixth and more read as one last element, `"(+n)"`. The runs from the examples, against `weft studio` with the shipped table and its dev token in `$TOKEN`:

```sh
curl -s -H "Authorization: Bearer $TOKEN" http://127.0.0.1:7331/api/runs \
  | jq -c '.runs[] | {agent, model: "\(.model.provider)/\(.model.name)", cost_usd, cost_badge, cost_reason, delegated_cost_usd, delegated_cost_reason}'
```

```text
{"agent":"lead","model":"wefttest/script","cost_usd":0,"cost_badge":"scripted","cost_reason":"a scripted model: nothing bills it, an exact $0","delegated_cost_usd":null,"delegated_cost_reason":"1 of 1 child runs unpriced: no price for acme/acme-large"}
{"agent":"support-bot","model":"acme/acme-large","cost_usd":null,"cost_badge":"unpriced","cost_reason":"acme/acme-large has no price","delegated_cost_usd":0,"delegated_cost_reason":null}
{"agent":"support-bot","model":"wefttest/script","cost_usd":0,"cost_badge":"scripted","cost_reason":"a scripted model: nothing bills it, an exact $0","delegated_cost_usd":0,"delegated_cost_reason":null}
{"agent":"support-bot","model":"wefttest/script","cost_usd":0,"cost_badge":"scripted","cost_reason":"a scripted model: nothing bills it, an exact $0","delegated_cost_usd":0,"delegated_cost_reason":null}
```

A run with no subagents has a delegated cost of exactly `0`, known. [Studio HTTP API](https://weftgo.dev/docs/reference/studio-api/) lists every route that carries these fields, and [Badges and holes](https://weftgo.dev/docs/reference/badges/) every badge.

### Unpriced, unknown and scripted

- **`unpriced`**: no row of the table matches the run's `provider/model`. Reason: `acme/acme-large has no price`; `the run reported no model to price`.
- **`unknown`**: the run is still running: the core reports a run's usage once, at its end. Reason: `running: usage arrives at run end`.
- **`unknown`**: the run's end never arrived: no `run_finish` record and no `invoke_agent` span. Reason: `the run's end (run_finish or its invoke_agent span) never arrived: its usage is not recorded`.
- **`unknown`**: a [derived run](https://weftgo.dev/docs/reference/glossary/#derived-run) whose stock spans report no usage, or only zeros. Reason: `the stock spans report no (or zero) usage …`.
- **`unknown`**: the run's subagent children could not be read, or number more than the 10,000 child runs one read takes. Reason: `the run's subagent children could not be read, …`.
- **`unknown`**: a session or an experiment that holds more than 10,000 runs, the 20 pages of 500 one read walks. Reason: `the session holds more than 10000 runs: too many to price at read time`, or `the experiment holds more than 10000 runs: too many to price at read time`. The experiment's `run_count` is still given.
- **`unknown`** (delegated only), under a [panel token](https://weftgo.dev/docs/observe/devtools/security/): some of the run's subagent children carry another public id, or none. The run's own figure still takes their usage out, since the core rolled it in, but the token reads no part of their bill, so `delegated_cost_known` is false and the hidden runs are counted, never named. Reason: `N of M child runs carry another public id, or none: a panel token does not read their cost`, then `; ` and any reason the visible children had. A tag-scoped token reads `N of M child runs are without your token's tags (or of another public id): your token's access does not reach their cost`.
- **`scripted`**: a scripted model that no row matches. Reason: `a scripted model: nothing bills it, an exact $0`.

The scripted rule covers every model of the `wefttest` provider ([`wefttest.Script`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2/wefttest#Script)) and the playground's scripted engine (`weft/runtime/scripted`), nothing else. It is Go code in Studio, not a row, so an override file cannot lose it. A row that matches a scripted model still wins, as any first match does. A wrapper that wraps other models ships its own row. A [`wefttest.Replay`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2/wefttest#Replay) model is not scripted in this sense: it reports the recorded model, so its runs are priced at that model's row.

A figure that sums several runs (a delegated figure, a session, an experiment) says why it is not known in one line that counts the runs, never one clause per run. For example: `2 of 3 child runs unpriced: no price for openai/x, acme/y`, or `1 of 3 child runs' cost not known yet (…)` when a child is still running (before 0.20.0 these said "subagent runs"). When any part is not known yet, the whole reads `unknown`, whatever unpriced part it also counts. A session's unknown reason drops "yet", `N of M turns' cost not known (…)`, when every unknown part is a derived run whose spans report no usage. An experiment's reason counts runs, not turns: `N of M runs' cost not known (…)`.

An unknown or unpriced session or experiment figure still carries its known part, `cost_partial` `{usd, priced, of}`. It is the sum and count of the parts whose whole bill, own plus delegated, is known; a part whose delegated figure is unknown adds nothing. It is absent when no part is priced. Studio's sessions list, session page and experiments list, and the devtools panel's header, draw it by one rule:

- "≥ $x · k of n turns priced" (an experiment's "k of n runs priced");
- "≥ $0 · k of n turns priced" when the priced parts are $0;
- "—" when no part is priced.

## Own and delegated cost

The core rolls a [child run](https://weftgo.dev/docs/reference/glossary/#child-run)'s usage into its parent's ([AGENTS rule 13](https://weftgo.dev/docs/explanation/design-principles/)). Studio splits the bill back into two numbers and never folds them:

- `cost_usd` is the run's own model calls: its usage minus its direct `weft.Subagent` children's, priced at the run's own model.
- `delegated_cost_usd` is the sum of its subagent descendants' own costs. It is `null` when any of them is unpriced or running.

The lead run above used 820 input tokens: 20 of its own and 800 through its research child. Its own figure is the scripted $0; its delegated figure is the child's. With `weft studio --pricing pricing.json` and an acme row, the same rows read:

```text
{"id":"93155b4ade161db6f7e80ee9b2ce01cb","agent":"lead","cost_usd":0,"cost_badge":"scripted","cache":"exact","delegated_cost_usd":0.00184}
{"id":"8f5d685f366f3f15056d6f99da944732","agent":"support-bot","cost_usd":0.0022,"cost_badge":null,"cache":"exact","delegated_cost_usd":0}
```

Only core `Subagent` children are subtracted: the runs whose id is `<parent>/<step>/<call>`. A [`thread/pool`](https://weftgo.dev/docs/sessions/pools/) child session's run, or another agent's `Generate` inside a tool handler, is linked to the parent but was never rolled up, so it keeps its own figure on its own row and is neither subtracted nor delegated. Deleting or sweeping a subagent child moves its usage into the parent's own cost, since own is the parent's usage minus its remaining children's.

Since 0.20.0 each run row also carries the usage behind the two figures: `own_usage`, the run's usage less its `Subagent` children's, and `delegated_usage`, theirs. Both are omitted on a run with no `Subagent` child, while it runs, when the children could not be read, or when a panel token cannot see one of the children. A session document's `delegated_usage` is its whole delegated tree's, beside the session's own.

Other figures:

- **A session row** is its turns' own plus delegated cost, where a turn is every run of the session that is not a subagent child of another of its runs. A pool child's cost is on its own session, not the parent session's. Since 0.18.0 that child session is listed in `/api/sessions` with its lineage (`parent_session`), and the parent's `/api/sessions/{id}` reports the delegated sessions' cost beside its own, never folded in (`delegated_sessions_cost_usd`).
- **The summarizer.** Since 0.18.0 every summary model call of a `thread` compaction or a `SummarizeLeft` branch is a `chat` span with `weft.chat.role` `summarizer`, its model and its usage, filed under the turn in flight or the last run. It is never in that run's usage, model or cost: obsdb stores it and sums it apart (a session row's `summarizer_usage`, split by model). Studio prices it at read time per model, on a session's timeline and on each turn's run document (`summarizer`); a call with no recorded model is an estimate at its turn's model, drawn `≈`. The run header, the session and the panel's open turn draw it as `+ summarizer $x` beside the turn's own cost.
- **A step** (`GET /api/runs/{id}/steps/{n}`) prices its own model call at the model that answered it, else the model it asked for. The run's own figure prices every step at the run's model, so a step that `mw.Fallback` or `weft.UseModel` answered with another model is priced at the primary's rate there.

## Pricing

The table is a plain JSON file of rates in USD per 1M tokens. The shipped one, `studio/pricing.json` ([`studio.DefaultPricing`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2/studio#DefaultPricing)), is dated 2026-10-10 and holds 47 rows of Anthropic, OpenAI and Gemini list prices. It is generated by `go generate ./studio/...` from `studio/internal/pricingdata`. Nothing is fetched: a newer price arrives with a newer weft, or with your own table. Its shape:

```json
{"dated": "2026-10-10", "note": "…", "models": [
  {"provider": "anthropic", "model_glob": "claude-opus-5-5",
   "input": 4, "output": 20, "cached_input": 0.2, "cache_write": 5}]}
```

`LoadPricing` enforces the required fields; `studio.Pricing` does not check a table built in Go. In Go it is a [`studio.PricingTable`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2/studio#PricingTable) of [`studio.ModelPrice`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2/studio#ModelPrice) rows:

| JSON (Go field) | Required in a file | Meaning |
|---|---|---|
| `dated` ([`Dated`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2/studio#PricingTable.Dated)) | yes | The day the rates were read, `YYYY-MM-DD` |
| `note` ([`Note`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2/studio#PricingTable.Note)) | no | The file's comment: what the rates are and where from |
| `models` ([`Models`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2/studio#PricingTable.Models)) | yes | The rows, first match wins; `[]` prices nothing |
| `provider` ([`Provider`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2/studio#ModelPrice.Provider)) | no | The run's provider, `anthropic`. Empty or `*` matches any provider |
| `model_glob` ([`ModelGlob`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2/studio#ModelPrice.ModelGlob)) | yes | A `path.Match` pattern for the model |
| `input` ([`Input`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2/studio#ModelPrice.Input)) | yes | Uncached input tokens |
| `output` ([`Output`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2/studio#ModelPrice.Output)) | yes | Output tokens other than reasoning |
| `cached_input` ([`CachedInput`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2/studio#ModelPrice.CachedInput)) | no | Cache reads; missing prices them at `input` |
| `cache_write` ([`CacheWrite`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2/studio#ModelPrice.CacheWrite)) | no | Cache writes; missing prices them at `input` |
| `reasoning` ([`Reasoning`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2/studio#ModelPrice.Reasoning)) | no | Reasoning tokens; missing prices them at `output` |

### How a run's model is matched

Studio looks the run's model up as `provider/model` against each row's `provider/model_glob`, with `path.Match` rules: either half may hold a glob, and `*` matches any run of characters except `/`. The first match wins, so put the most specific row first. A row with no provider, or `"provider": "*"`, matches on its `model_glob` alone, whatever the transport: `{"model_glob": "kimi-k2.7-code", …}` prices that model reached through the openai adapter at an OpenAI-compatible base URL. The provider is the table's spelling: a run whose provider arrived as the span's `gcp.gemini` is priced as `google`.

### The formula

[`weft.Usage`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2#Usage)'s splits are subsets of its totals (cached and cache-write tokens of the input, reasoning tokens of the output), so:

```text
cost = input        × (InputTokens − CachedInputTokens − CacheWriteTokens)
     + cached_input × CachedInputTokens
     + cache_write  × CacheWriteTokens
     + output       × (OutputTokens − ReasoningTokens)
     + reasoning    × ReasoningTokens                    (all ÷ 1,000,000)
```

The acme run used 2,500 input tokens, 2,000 of them cached, and 100 output tokens. Under the `acme-large` row that is 2 × 500 + 0.2 × 2,000 + 8 × 100 = 2,200, or $0.0022.

The figure is exact where the adapter reports the splits. When it reports no cache split (cached and cache-write tokens both zero), every input token is priced at the input rate and `cache` reads `not_reported`, with the reason `no cache split reported; a cached prompt may be overstated`. An uncached prompt reads the same, and its figure is exact.

The shipped table has limits its note states. `cache_write` is the 5-minute rate (1.25× input), so a 1-hour cache write (2×) is understated. The Gemini rows have no `cached_input`, so a cached Gemini prompt is priced at the input rate. Premium speed tiers (Claude Opus 5.5 fast mode) and long-context tiers are not modelled. Models with a long-context tier are left out, so they read unpriced rather than a guess.

### Supply your own table

Studio takes the first of:

1. [`studio.Pricing(table)`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2/studio#Pricing) in Go, as at the top of this page (source `option`);
2. `weft studio --pricing <path>` or `weft dev --pricing <path>`; the flag wins over the variable (source `file`);
3. `WEFT_PRICING=<path>`, read by `studio.New` and by the binary (source `file`);
4. the shipped table (source `default`).

Each replaces the shipped table whole: there is no merging. Start from `studio/pricing.json`, which is also the template. To read a file in Go, pass [`studio.LoadPricing`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2/studio#LoadPricing)'s table to `Pricing`:

```go title="studio/cost.go"
table, err := studio.LoadPricing(path) // the error names the path and the field
if err != nil {
	return nil, err
}
h := studio.Handler(studio.DB(db), studio.Pricing(table))
```

[studio/cost.go on GitHub](https://github.com/weftgo/weftgo.dev/blob/main/docs-site/examples/studio/cost.go)

A row loaded without a provider gets `*`. A file that does not parse, names an unknown field, misses `dated`, `models`, `model_glob`, `input` or `output`, carries a negative rate, a bad glob, or a `dated` that is not `YYYY-MM-DD` is an error that names the path and the field. It never falls back to the default. `weft studio` exits 1 with it (the file holds a row with no `output`; the message names the file by its absolute path, shortened here):

```sh
weft studio --db sqlite://runs.db --pricing bad-pricing.json
```

```text
weft: --pricing: pricing …/bad-pricing.json: models[0].output: missing (USD per 1M tokens)
```

Under `studio.New`, a bad `WEFT_PRICING` file panics, naming the same. A good file is named in the start banner:

```text
studio: pricing pricing.json (--pricing), dated 2026-10-18, 2 models
```

### Edit the table in Settings

The **Pricing** section of [Settings](https://weftgo.dev/docs/observe/studio/navigation/#settings) shows the effective table (its source, path, dated and note) as an editable grid with **add row** and a remove button per row. Studio never writes a file, so your edits stay in this browser's localStorage (keyed by the served table's source, path and dated) and are never sent; **reset to the server's table** drops them. **download pricing.json** saves them as an override file, refused while a field `LoadPricing` would reject is wrong. To apply it, restart Studio with `--pricing <file>` or `WEFT_PRICING`: there is no live `PUT`.

![The Pricing section of Studio's Settings: the table's source (file, --pricing), path, dated 2026-10-18 and note, and its two acme rows as an editable grid with add row, reset and download pricing.json](https://weftgo.dev/docs/_astro/studio-settings.light.BTG685Oe.webp)

*The Pricing section with a table loaded by --pricing: its source, path, dated and note, and the two acme rows as an editable grid.*

### Read the effective table

`GET /api/settings/pricing` returns the table in the file's shape plus its `source` and, for the dev token or setup A's loopback, its `path`. Every identity may read it, since prices are not secrets. The file it returns loads back with `LoadPricing`. `/api/meta` carries a summary:

```sh
curl -s -H "Authorization: Bearer $TOKEN" http://127.0.0.1:7331/api/meta | jq -c .pricing
```

```text
{"source":"default","dated":"2026-10-10","models":47}
```

## Sort and filter by cost

`GET /api/search` takes `min_cost=` (USD, own plus delegated; an unpriced run never matches) and `sort=cost` (most first, runs with no known cost last). Since cost is computed at read time, Studio prices the first 2,000 runs of the match in the order asked; a larger match is cut there, and the response carries `cost_sort_cap`. On the runs list, the cost column header sorts, and under `?sort=cost` a line says how many rows have no known cost and that they are listed last, newest first, not sorted. [Find runs](https://weftgo.dev/docs/observe/studio/runs/#search) covers the filters.

## Complete example

`docs-site/examples/studio/cost.go` adds the acme model, a priced Studio and a file-priced Studio beside the setup-A program on [Run Studio](https://weftgo.dev/docs/observe/studio/setup/):

```go title="studio/cost.go"
package main

import (
	"context"
	"net/http"

	"github.com/weftgo/weft"
	"github.com/weftgo/weft/obsdb"
	"github.com/weftgo/weft/studio"
	"github.com/weftgo/weft/wefttest"
)

// acmeModel is a scripted model under another provider's name: what an
// adapter for a model the shipped pricing table does not list reports
// (core.ModelInfo through the optional Info method).
type acmeModel struct{ *wefttest.Model }

func (acmeModel) Info() weft.ModelInfo {
	return weft.ModelInfo{Provider: "acme", Name: "acme-large"}
}

// acmeAgent is the support agent on the acme model. Each step reports
// its usage, a cached prompt included, as a real adapter would.
func acmeAgent() *weft.Agent {
	lookup := weft.Tool("lookup_order", "Look up an order by ID.",
		func(ctx context.Context, in LookupInput) (string, error) {
			return "order " + in.OrderID + ": shipped", nil
		})
	model := acmeModel{wefttest.Script(
		wefttest.ToolCalls(wefttest.Call{ID: "c1", Name: "lookup_order", Args: `{"order_id":"1234"}`}).
			WithUsage(weft.Usage{InputTokens: 1200, CachedInputTokens: 1000, OutputTokens: 40}),
		wefttest.Say("Order 1234 has shipped.").
			WithUsage(weft.Usage{InputTokens: 1300, CachedInputTokens: 1000, OutputTokens: 60}),
	)}
	return weft.New(model, weft.Name("support-bot"), lookup)
}

func ptr(v float64) *float64 { return &v }

// pricedStudio prices runs with a table built in Go. The table replaces
// the shipped one whole: a model no row matches reads unpriced.
func pricedStudio(db obsdb.DB) http.Handler {
	table := studio.PricingTable{
		Dated: "2026-10-18", // the day the rates were read, YYYY-MM-DD
		Note:  "acme list prices, USD per 1M tokens",
		Models: []studio.ModelPrice{ // first match wins: the specific row first
			{Provider: "acme", ModelGlob: "acme-large", Input: 2, Output: 8, CachedInput: ptr(0.2)},
			{Provider: "acme", ModelGlob: "acme-*", Input: 0.5, Output: 2},
		},
	}
	h := studio.Handler(studio.DB(db), studio.Pricing(table))
	return h
}

// fileStudio prices runs with a table read from a pricing.json-shaped
// file, the same file WEFT_PRICING and weft studio --pricing load.
func fileStudio(db obsdb.DB, path string) (http.Handler, error) {
	table, err := studio.LoadPricing(path) // the error names the path and the field
	if err != nil {
		return nil, err
	}
	h := studio.Handler(studio.DB(db), studio.Pricing(table))
	return h, nil
}
```

[studio/cost.go on GitHub](https://github.com/weftgo/weftgo.dev/blob/main/docs-site/examples/studio/cost.go)

[View on GitHub](https://github.com/weftgo/weftgo.dev/tree/main/docs-site/examples/studio) · run the cost tests from `docs-site/examples`:

```sh
go test -v -run 'Cost|Pric' ./studio
```

```text
--- PASS: TestScriptedRunCostsZero (0.02s)
--- PASS: TestPricingTablePricesRun (0.02s)
--- PASS: TestUnpricedModelCost (0.02s)
--- PASS: TestLoadPricing (0.02s)
PASS
ok  	weftgo.dev/docs/examples/studio	0.078s
```

They record each agent into a temporary database and read `/api/runs`. The scripted run is an exact `0` badged `scripted`, and the Go table prices the acme run at `0.0022`. The shipped table leaves it `null`, badged `unpriced`, with `acme/acme-large has no price`; and a file without an `output` rate fails with `models[0].output: missing (USD per 1M tokens)`.

## Best practices & gotchas

- **Report your model.** Studio prices `provider/model` from the run's `ModelInfo`; a model with no `Info` method reports no model, and its runs read `the run reported no model to price`. (Source: `core/model.go:51-62`; `studio/pricing.go:571-573`)
- **Put specific rows first.** The first matching row wins, so a broad `acme-*` row above `acme-large` prices both at the broad rate. (Source: `studio/pricing.go:29-60`)
- **Copy the shipped table before you add a row.** An override replaces the table whole: a file with one row leaves every other model unpriced. (Source: `studio/pricing.go:56-58`)
- **Read `null` as unknown, not free.** A summing client must treat a `null` `cost_usd` or `delegated_cost_usd` as unknown; Studio's own sums read `≥ $x · k of n runs priced`. (Source: `studio/web/src/lib/cost.ts:1-16`; CHANGELOG.md:349)
- **Refetch a cost-sorted list before you trust its order.** Under `?sort=cost` a live frame replaces its run's row in place without re-sorting until the next refetch. Each **load more** has Studio price up to 2,000 runs of the match again. Offset paging over a set that changes between pages can repeat or skip a row. (Source: `studio/web/src/routes/runs.index.tsx:223-234, 312-348`; `studio/search.go:56-80`; `studio/README.md:393-396`)
- **Budgets do not read Studio's figures.** Cost is computed when Studio reads a run and is never stored; to stop a run on spend, set `weft.UsageLimit` in tokens. (Source: `studio/pricing.go:29-31`; AGENTS rule 13)

## See also

- [Find runs: the runs list, search and filters](https://weftgo.dev/docs/observe/studio/runs/)
- [Compare runs step by step](https://weftgo.dev/docs/observe/studio/compare/)
- [Get around Studio: keyboard, panes and settings](https://weftgo.dev/docs/observe/studio/navigation/)
- [Run Studio: embedded, local binary or hosted](https://weftgo.dev/docs/observe/studio/setup/)
- [Studio HTTP API](https://weftgo.dev/docs/reference/studio-api/)

Symbols used: [`studio.Pricing`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2/studio#Pricing) · [`studio.PricingTable`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2/studio#PricingTable) · [`studio.ModelPrice`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2/studio#ModelPrice) · [`studio.DefaultPricing`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2/studio#DefaultPricing) · [`studio.LoadPricing`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2/studio#LoadPricing) · [`studio.Handler`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2/studio#Handler) · [`weft.Usage`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2#Usage) · [`weft.ModelInfo`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2#ModelInfo) · [`wefttest.Script`](https://pkg.go.dev/github.com/weftgo/weft@v0.20.2/wefttest#Script)
