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. 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, WEFT_PRICING or weft studio --pricing.
A table built in Go, from docs-site/examples/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))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.


Where Studio shows cost
Section titled “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) |
| 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 | 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) |
| 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) |
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 smallunpricedchip.≥ $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 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
Section titled “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:
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}'{"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 lists every route that carries these fields, and Badges and holes every badge.
Unpriced, unknown and scripted
Section titled “Unpriced, unknown and scripted”unpriced: no row of the table matches the run’sprovider/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: norun_finishrecord and noinvoke_agentspan. Reason:the run's end (run_finish or its invoke_agent span) never arrived: its usage is not recorded.unknown: a 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, orthe experiment holds more than 10000 runs: too many to price at read time. The experiment’srun_countis still given.unknown(delegated only), under a panel token: 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, sodelegated_cost_knownis 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 readsN 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) 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 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
Section titled “Own and delegated cost”The core rolls a child run’s usage into its parent’s (AGENTS rule 13). Studio splits the bill back into two numbers and never folds them:
cost_usdis the run’s own model calls: its usage minus its directweft.Subagentchildren’s, priced at the run’s own model.delegated_cost_usdis the sum of its subagent descendants’ own costs. It isnullwhen 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:
{"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 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/sessionswith 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
threadcompaction or aSummarizeLeftbranch is achatspan withweft.chat.rolesummarizer, 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’ssummarizer_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 $xbeside 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 thatmw.Fallbackorweft.UseModelanswered with another model is priced at the primary’s rate there.
Pricing
Section titled “Pricing”The table is a plain JSON file of rates in USD per 1M tokens. The shipped one, studio/pricing.json (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:
{"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 of studio.ModelPrice rows:
| JSON (Go field) | Required in a file | Meaning |
|---|---|---|
dated (Dated) | yes | The day the rates were read, YYYY-MM-DD |
note (Note) | no | The file’s comment: what the rates are and where from |
models (Models) | yes | The rows, first match wins; [] prices nothing |
provider (Provider) | no | The run’s provider, anthropic. Empty or * matches any provider |
model_glob (ModelGlob) | yes | A path.Match pattern for the model |
input (Input) | yes | Uncached input tokens |
output (Output) | yes | Output tokens other than reasoning |
cached_input (CachedInput) | no | Cache reads; missing prices them at input |
cache_write (CacheWrite) | no | Cache writes; missing prices them at input |
reasoning (Reasoning) | no | Reasoning tokens; missing prices them at output |
How a run’s model is matched
Section titled “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
Section titled “The formula”weft.Usage’s splits are subsets of its totals (cached and cache-write tokens of the input, reasoning tokens of the output), so:
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
Section titled “Supply your own table”Studio takes the first of:
studio.Pricing(table)in Go, as at the top of this page (sourceoption);weft studio --pricing <path>orweft dev --pricing <path>; the flag wins over the variable (sourcefile);WEFT_PRICING=<path>, read bystudio.Newand by the binary (sourcefile);- 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’s table to Pricing:
table, err := studio.LoadPricing(path) // the error names the path and the fieldif err != nil { return nil, err}h := studio.Handler(studio.DB(db), studio.Pricing(table))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):
weft studio --db sqlite://runs.db --pricing bad-pricing.jsonweft: --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:
studio: pricing pricing.json (--pricing), dated 2026-10-18, 2 modelsEdit the table in Settings
Section titled “Edit the table in Settings”The Pricing section of 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.


Read the effective table
Section titled “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:
curl -s -H "Authorization: Bearer $TOKEN" http://127.0.0.1:7331/api/meta | jq -c .pricing{"source":"default","dated":"2026-10-10","models":47}Sort and filter by cost
Section titled “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 covers the filters.
Complete example
Section titled “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:
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}View on GitHub · run the cost tests from docs-site/examples:
go test -v -run 'Cost|Pric' ./studio--- PASS: TestScriptedRunCostsZero (0.02s)--- PASS: TestPricingTablePricesRun (0.02s)--- PASS: TestUnpricedModelCost (0.02s)--- PASS: TestLoadPricing (0.02s)PASSok weftgo.dev/docs/examples/studio 0.078sThey 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
Section titled “Best practices & gotchas”- Report your model. Studio prices
provider/modelfrom the run’sModelInfo; a model with noInfomethod reports no model, and its runs readthe 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 aboveacme-largeprices 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
nullas unknown, not free. A summing client must treat anullcost_usdordelegated_cost_usdas 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=costa 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.UsageLimitin tokens. (Source:studio/pricing.go:29-31; AGENTS rule 13)
See also
Section titled “See also”- Find runs: the runs list, search and filters
- Compare runs step by step
- Get around Studio: keyboard, panes and settings
- Run Studio: embedded, local binary or hosted
- Studio HTTP API
Symbols used: studio.Pricing · studio.PricingTable · studio.ModelPrice · studio.DefaultPricing · studio.LoadPricing · studio.Handler · weft.Usage · weft.ModelInfo · wefttest.Script