Repository navigation
Description
The problem, in your words
The question this series exists to answer (#1449): I pay fixed fees for Claude Max and ChatGPT and dip into metered API usage on top — Bedrock, OpenRouter. How much metered spend did I incur this month, through which door, in which tool? No surface can say.
Every surface CodeBurn has slices spend by the coding harness — the tool that produced the session: --provider claude|codex|hermes… on the CLI, the agent tab strip in the macOS menubar (AgentTabStrip.swift) and Windows dock (AgentTabStrip.tsx), providers / providerDetails in the menubar payload, the provider picker in the desktop and web dashboards. None of them can slice by who billed the call.
Those are different axes and a user's invoices follow the second one. One Claude Code session on this machine is billed by Anthropic, the next by AWS (Bedrock), a Hermes session by AWS or by OpenAI's ChatGPT subscription (openai-codex), an OpenCode session by OpenRouter — and the only place any of that shows today is a (Bedrock) suffix on a model-row label (#1448), with nothing to click on and nothing to filter by. "How much did I put on the AWS account this month?" has no answer in the UI.
What you tried
--provider bedrock— rejected by design;--provideris the harness.- Reading the
(Bedrock)suffix offcodeburn modelsand adding rows by hand. - Grepping
codeburn exportfor the label — string-matching a display name, and blind to routes that are only in a provider column (Add OpenRouter as a billing route and carry metered/subscription on each call: read the endpoint from the provider's own column, not the model id (with a list of routes to follow) #1450).
Proposed change
Treat the billing route as a first-class dimension next to the harness, on every surface, without replacing the harness view.
Headline: metered vs subscription. Before any per-route detail, one split on the overview and the menubar: This month · metered $X (Bedrock $a · OpenRouter $b · Anthropic API $c) · subscription-covered usage $Y API-equivalent (Claude Max, ChatGPT). The metered figure is the one that varies with behaviour and is the number the series is for; the subscription figure keeps the existing "what this would have cost" semantics and feeds codeburn plan's overage line unchanged.
CLI
--billing metered|subscriptionalongside--route <id>ontoday/models/sessions/export/audit/compare, applied at the call level so a session that mixed routes contributes only its matching calls;--route directfor the complement;codeburn routes(ormodels --by-route) listing spend per route with the harnesses that fed it.- The interactive dashboard's By Model rows become drill-through targets for their route, the same way a project or task row drills today.
Menubar payload (src/menubar-json.ts, contract test tests/menubar-json.test.ts)
current.billing: { metered: number, subscription: number },current.routes: Record<string, number>androuteDetails: Array<{ id, label, billing, hasUsage, cost, calls, inputTokens, outputTokens, sessions }>mirroringproviders/providerDetails;route?: stringontopModelsentries so clients group without parsing the suffix back out. Add-only and optional so older menubar builds keep working.
macOS menubar / Windows dock / desktop / web dash
- A second grouping on the tab strip — "By tool" (today's) / "By billing" — with a Metered / Subscription pair at the top and one tab per active route beneath: AWS Bedrock, OpenRouter, Anthropic API, OpenAI API · Claude Max, ChatGPT, … Each tab reuses the existing period tiles, model list and quota card where the route has one (Bedrock has none; Anthropic and Codex already do via the Capacity Dock adapters).
- Telemetry snapshot (
src/telemetry-snapshot.ts) gains the route split alongside the model × task cross so the anonymous aggregate can show how much usage runs through cloud marketplaces vs first-party.
Order: CLI filter and payload fields first (they are what the desktop surfaces consume), then the tab strip.
Related:
- Epic: quota intelligence (live remaining, burn-rate forecast, pre-flight awareness, invoice reconciliation) #725 Part 5 (invoice reconciliation against the Anthropic cost API / OpenRouter key endpoint) needs spend split per billing account before any per-account reconciliation is possible; this is its prerequisite.
- Overview all-provider model table is capped at 20 rows since it reads topModels #1318: Overview's all-provider model table reads
topModels, capped at 20. Splitting rows by route consumes slots; aroutefield on entries lets a consumer collapse or expand rather than the cap deciding. - Cost modes: reconcile displayed cost with the source's own reported cost (auto/calculate/display) #890's provenance principle (a computed number and a reported one are different things and both must be visible) applies to routes: a "By billing" tile should say whether the route came from the id shape or the provider's own column.
Depends on #1450 (route carried on the call) which depends on #1448.
Activity
[-]Slice spend by billing route on every surface, not only by coding harness (CLI --route, payload, tab strip)[/-][+]Show metered vs subscription spend, and slice by billing route, on every surface (CLI --billing/--route, payload, tab strip)[/+]ulises-c commentedon Sep 18, 2026
Plan before code — proposed first reviewable slice for #1451:
subscriptiononly when Hermes records the resolved cost basis asincluded;meteredwhen Hermes records anactualamount, or when the effective registered route is Bedrock;--route <bedrock|direct>and--billing <metered|subscription>onmodels,sessions,export, andaudit. The filters compose with provider/project/task filters using AND and rebuild all nested totals from only matching calls.--route directis the requested complement of recognized routes. Because the current source data cannot distinguish every direct call from an unknown door, help/output will describe this limitation rather than claim confirmed first-party billing.Tests will cover both Bedrock evidence paths (model-ID shape and Hermes provider field), Hermes
included/actual/estimated/unknown cost bases, cache round trips and invalid values, mixed-route sessions with rebuilt totals, combined filters, invalid CLI values, and end-to-end JSON/CSV outputs. I will run the full root suite and lock suite on both main and the branch, plus typecheck and build.Deferred from this PR:
today/report/status,compare, menubar payload fields, daily-cache v34, and native/web UI. Those require structured durable route/billing aggregates; filtering only surviving session detail would make historical headline totals incorrect. The payload/cache contract would be the next slice after this one.Does this scope and fail-closed classification match the intended first step for #1451?
ulises-c commentedon Sep 18, 2026
Update: I now have usage-bearing OpenRouter data, so the first slice can include that route without relying only on a synthetic fixture.
Two fresh Hermes sessions were run through OpenRouter today:
openrouter/free: 4 API calls, 107,456 input / 668 output tokens,billing_provider=openrouter,billing_base_url=https://openrouter.ai/api/v1, recorded cost $0.cohere/north-mini-code:free: 1 API call, 15,001 input / 69 output tokens, the same provider/base URL, recorded cost $0.The first session used tools to read
src/models.tsand returned the registered route, so this is real coding-harness traffic rather than a hand-written fixture. The explicit:freemodel verifies the provider with no paid-model spend. On current main,codeburn models --provider hermes --period today --format json --min-cost 0reports both rows withroute: null, confirming that Hermes selectsbilling_providerbut CodeBurn currently dropsopenrouteratrouteFromProviderField.Scope adjustment: register exactly the observed provider field
openrouteras route idopenrouter, labelOpenRouter, billing defaultmetered; add no model-id detector and no speculative aliases (openrouter/.../openrouter:...provider-field spellings remain out). The free calls currently contribute $0 but still prove the route and call-level filter path. Bedrock remains the only id-shape route.