Skip to content

Show metered vs subscription spend, and slice by billing route, on every surface (CLI --billing/--route, payload, tab strip) #1451

Closed

Description

@ulises-c

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

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|subscription alongside --route <id> on today / models / sessions / export / audit / compare, applied at the call level so a session that mixed routes contributes only its matching calls; --route direct for the complement; codeburn routes (or models --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> and routeDetails: Array<{ id, label, billing, hasUsage, cost, calls, inputTokens, outputTokens, sessions }> mirroring providers / providerDetails; route?: string on topModels entries 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:

Depends on #1450 (route carried on the call) which depends on #1448.

Activity

  1. changed the title [-]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)[/+] on Sep 15, 2026
  2. added
    enhancement
    area: cli
    area: desktop
    on Sep 17, 2026
  3. ulises-c commented on Sep 18, 2026

    @ulises-c
    ContributorAuthor

    Plan before code — proposed first reviewable slice for #1451:

    1. Restore billing as optional per-call provenance alongside the route. Classification stays fail-closed:
      • subscription only when Hermes records the resolved cost basis as included;
      • metered when Hermes records an actual amount, or when the effective registered route is Bedrock;
      • otherwise unknown. Unknown is not coerced into either mode.
    2. Keep Bedrock as the only registered route. Do not add OpenRouter, Bedrock Mantle, direct Anthropic/OpenAI routes, or aliases without usage-bearing real sessions and fixtures.
    3. Add one shared call-level slicer, then expose --route <bedrock|direct> and --billing <metered|subscription> on models, sessions, export, and audit. The filters compose with provider/project/task filters using AND and rebuild all nested totals from only matching calls.
    4. --route direct is 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.
    5. Preserve existing pricing. Route and billing affect selection and grouping only; Bedrock profile SKUs remain separate and no call is repriced.

    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?

  4. ulises-c commented on Sep 18, 2026

    @ulises-c
    ContributorAuthor

    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.ts and returned the registered route, so this is real coding-harness traffic rather than a hand-written fixture. The explicit :free model verifies the provider with no paid-model spend. On current main, codeburn models --provider hermes --period today --format json --min-cost 0 reports both rows with route: null, confirming that Hermes selects billing_provider but CodeBurn currently drops openrouter at routeFromProviderField.

    Scope adjustment: register exactly the observed provider field openrouter as route id openrouter, label OpenRouter, billing default metered; 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: cliarea: desktopenhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions