See what Claude Code actually spends
Point Claude Code at Busbar with two environment variables and the black box turns into a dashboard: every token, every dollar, per key and per team, with budgets that actually stop the spend.
Claude Code is the best coding agent I’ve used, and until recently it was also the one I understood the least. It runs, it burns tokens, and the number shows up on an invoice at the end of the month. Who spent it? On what? Which repo, which teammate, which runaway loop at 2am? No idea. It’s a black box pointed straight at a provider, and the only feedback loop is the bill.
Run it through Busbar and that changes on the first request.
The payoff
Busbar speaks the Anthropic protocol natively, so Claude Code can’t tell it isn’t talking to
Anthropic. Put Busbar in the middle and the agent runs exactly as well as before, except now you can
see it. Every request and every token, priced as it happens, in Busbar’s /metrics and OTLP
traces. Broken out per key and per pool, which in practice means per person and per team. The token
bill stops being a surprise and starts being a live number you can watch.
And once you can see the spend, you can stop it. A budget on a key isn’t a report you read after the money’s gone. It’s a ceiling Busbar enforces on the request path, so a key that hits its cap gets refused, cleanly, before the spend happens rather than after.
The setup
Two environment variables. One points Claude Code at Busbar, the other is the key it already uses, swapped for a Busbar-minted one:
export ANTHROPIC_BASE_URL="http://localhost:8080/claude-code" # your Busbar, the claude-code poolexport ANTHROPIC_API_KEY="bbk_…" # a Busbar virtual key you mintedclaudeThat’s the whole integration. The bbk_ key is scoped to whoever you handed it to, so from the
first request every token is attributed to a real person, not to one shared secret nobody can trace.
The governance that comes with it
Because the key is the unit of accounting, it’s also the unit of control. Give it a budget and Busbar holds the line. Grant it a set of pools and it can reach those models and no others. Every request it makes lands in a hash-chained audit log, so “who spent what, on which model, when” is a query, not a forensics project. Same agent you already trust, now with a meter, a spending limit, and a receipt.
Step by step
Start to finish, this is about five minutes.
1. Run Busbar. Grab the single binary, mint a signing key, and start it — the data plane on :8080, the admin plane on :8081.
busbar --generate-signing-key > signing.keyBUSBAR_SIGNING_KEY=$(cat signing.key) busbar --config config.yaml2. Point it at Anthropic. In config.yaml, add your upstream provider, a model, and a claude-code pool:
providers: anthropic: api_key: { env: ANTHROPIC_UPSTREAM_KEY } # your real sk-ant-… keymodels: claude-sonnet: provider: anthropic upstream_model: claude-sonnet-4-20250514pools: claude-code: members: - { model: claude-sonnet, weight: 1 }3. Mint a virtual key — with a budget. One call on the admin port. Give it to a person or a team; the budget is the ceiling Busbar enforces on the path.
curl -s -X POST http://127.0.0.1:8081/api/v1/admin/keys \ -H "authorization: Bearer $BUSBAR_ADMIN_TOKEN" \ -d '{"name":"ada","allowed_pools":["claude-code"],"budget":{"usd":50,"per":"month"}}'# → {"token":"bbk_…"} (shown once)4. Point Claude Code at it. Two variables, then run it exactly as you always do:
export ANTHROPIC_BASE_URL="http://localhost:8080/claude-code"export ANTHROPIC_API_KEY="bbk_…"claude5. Watch the spend. It’s live from the first request — scrape /metrics, or wire the OTLP traces into whatever dashboard you already run. Every token is attributed to that key, so you see who spent what, on which model, as it happens. When the key hits its budget, the next request is refused before the money’s gone.
Want Claude Code’s
/modelswitching to route for real (Opus vs Sonnet vs Haiku, each metered on its own lane)? Drop the/claude-codesuffix so Busbar routes on the model in the request, and add each model ID as its ownmodels:entry. The pool URL above is the simplest path to spend visibility; the bare URL unlocks per-model routing.
Onward
Seeing the spend is the boring, load-bearing part. Once Claude Code is on the path, everything else Busbar does, failover, redaction, routing to a different model entirely, comes along for the ride. But start with the meter. It’s the two variables that turn “how much did the agent cost this month” into a question you can already answer.
Get it at getbusbar.com.
Comments
Comments live in GitHub Discussions, so the conversation stays next to the code.
Join the discussion on GitHub