Report CLI & sync

Everything renders from a local SQLite file — no server, no account.

stepcost report

stepcost report <db>                 # account summary across all traces
stepcost report <db> --trace <id>    # one trace's cost tree (per-node tokens + $)
stepcost report <db> --top 10        # top-N most expensive traces
stepcost report <db> --multiplier 30 # scale waste $ estimates (e.g. day → month)
stepcost report <db> --json          # machine-readable (incl. the span tree)

<db> accepts a plain path or a sqlite:///path URL.

Summary anatomy

stepcost sync — the two-sided ledger

Pulls what your provider says it will bill (their organization cost APIs) into the same database, per day per model:

export ANTHROPIC_ADMIN_KEY=sk-ant-admin01-...   # Console → Settings → Organization → Admin keys
stepcost sync anthropic <db> --days 7

export OPENAI_ADMIN_KEY=...                     # platform.openai.com → Settings → Organization
stepcost sync openai <db> --days 7

The next stepcost report gains a reconciliation section:

Provider reconciliation (SDK-observed vs provider-billed):
  anthropic  2026-07-08   SDK $0.0190   billed $0.0190   drift 0.2%   coverage 100%
  2% gate (worst day): 0.23% — PASS ✅
Admin keys are a different key type from regular API keys (Anthropic: sk-ant-admin01-…, organization accounts only). Provider cost data appears with a delay — typically minutes, but new organizations can lag longer. Re-syncs are idempotent per provider-day.

Reading the trace view

stepcost report ~/.stepcost/my-app.db --trace 47b3783e
trace support-bot                           12,480 tok  $0.0152
├─ agent_step: plan                            1,380 tok  $0.0003
│  └─ llm gpt-4o-mini                          1,380 tok  $0.0003
└─ agent_step: execute                         4,100 tok  $0.0148
   └─ llm gpt-4o                               4,100 tok  $0.0148

Each node shows subtree tokens and dollars; the most expensive step is where to look first. --json emits the same tree machine-readably for your own tooling.