headroom-token-view
A small, local token viewer for LLM API calls.
It runs a tiny proxy on your laptop. Point your apps at it (one env var) and it shows the exact token usage and cost of every call you make to Claude, OpenAI, Gemini, and any other provider you configure, in a simple dashboard.
That's it. No accounts. No cloud. No Docker. One pipx install.
Quick start
pipx install headroom-token-view
htv start
You'll see:
+--------------------------------------------------------------------------+
| Headroom Token View v0.0.1 |
| |
| started in background (pid 12345) |
+--------------------------------------------------------------------------+
Logs: /Users/you/.headroom-token-view/htv.log
Proxy: http://127.0.0.1:4000
Dashboard: http://127.0.0.1:3000
Point any app at the proxy:
export ANTHROPIC_BASE_URL=http://localhost:4000
export OPENAI_BASE_URL=http://localhost:4000/v1
export GOOGLE_BASE_URL=http://localhost:4000
Open the dashboard: http://localhost:3000.
Now make calls as usual (Anthropic SDK, OpenAI SDK, curl, Claude Code, whatever). They flow through the proxy. The dashboard fills in within milliseconds.
Track Claude Code itself
ANTHROPIC_BASE_URL=http://localhost:4000 claude
Every Claude Code interaction lands in the dashboard.
What it shows
- $ spent today / this week / month-to-date
- Per-provider, per-model, per-session, per-tag breakdowns
- Cache hit visibility (Anthropic prompt caching, OpenAI cached input tokens, Gemini context cache)
- Reasoning-token costs (o-series, Claude extended thinking)
- A live tail of recent calls with status + latency
- Real-time updates via SSE — no refresh needed
What it doesn't do (intentionally)
- No team / multi-user features. Single user, localhost only.
- No virtual API keys. Your real provider keys are read from env vars and forwarded straight to the provider.
- No alerting / Slack integration. Not yet.
- No data leaves your machine. Everything in
~/.headroom-token-view/db.sqlite. - No prompt content stored by default. (Opt-in with redaction; see Privacy below.)
Want any of these? Open an issue. The architecture is designed to evolve into a Postgres + Docker + auth setup later — see the design spec for the "🅑 path".
How it works
Your apps ──► headroom-token-view ──► Provider APIs
│
├─ writes a row → SQLite
└─ pushes a spend event → SSE → Dashboard
The proxy reads the exact token usage and cost from each provider's response object — Anthropic's cache_creation_input_tokens / cache_read_input_tokens, OpenAI's prompt_tokens_details.cached_tokens, Gemini's usageMetadata, the reasoning-tokens fields on o-series and Claude extended-thinking — and applies the right pricing tier for each. Cost is provider-truth, not a tokenizer estimate.
Your SDK doesn't know it's talking to a proxy. The response bytes are forwarded unchanged; the proxy tees the stream as it flies by so token capture never adds latency to your request.
CLI
htv start [-f] start the proxy + dashboard (daemonizes; -f for foreground)
htv stop graceful SIGTERM
htv status pid, uptime, request counts, errors, diagnostics
htv logs [-f] [-n N] tail the server log
htv export --since DATE csv/json dump of all calls since DATE
htv reset wipe the SQLite database (with confirmation)
htv version
htv config-path
Configuration
~/.headroom-token-view/config.yaml is auto-generated on first start. Defaults are localhost-only on ports 3000 / 4000.
proxy: { port: 4000, bind: 127.0.0.1 }
dashboard: { port: 3000, bind: 127.0.0.1 }
storage: { path: ~/.headroom-token-view/db.sqlite }
retention: { days: 90 }
capture: { prompts: false, responses: false }
Provider API keys come from environment variables (ANTHROPIC_API_KEY, OPENAI_API_KEY, GOOGLE_API_KEY). HTV never reads or persists them.
Privacy
Default: only token counts + cost + metadata. No prompt text. No response text.
If you want full request/response logging, enable it in the config — regex-based redaction runs before persistence, so the DB never holds raw secrets:
capture:
prompts: true
responses: true
redact_patterns:
- '(sk|pk)-[A-Za-z0-9]{20,}'
- '[\w.+-]+@[\w-]+\.[\w.-]+'
Security stance
- All dependencies on the data path (proxy engine, web framework, ASGI server) are version-pinned. Patches arrive automatically on
pipx upgrade; major-version jumps require an HTV release. - Runtime fetching of model-pricing data is disabled — prices come from the pinned wheel, not a network fetch.
- Default bind is
127.0.0.1; non-loopback binds require explicithtv start --allow-remoteand the matching config setting.
Full threat model in SECURITY.md.
Status
v0.0.x — alpha. Single-user laptop tool. Works against Claude, OpenAI, Gemini, and 100+ other providers.
Roadmap lives in CHANGELOG.md. Near-term:
- Cost-map refresh with hash verification
htv test-providers— smoke each configured provider with a $0.001 token- Optional Postgres backend for multi-user use
Contributing
PRs welcome. The loop is:
pip install -e ".[dev]"
ruff check src tests
pytest -q
See CONTRIBUTING.md.
License
MIT. © 2026 Tejas Chopra.
Bundled open-source dependencies are credited in NOTICES.md.
Metadata
Release files for headroom-token-view 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| headroom_token_view-0.0.1.tar.gz | 447.2 kB | Without provenance | Details for headroom_token_view-0.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| headroom_token_view-0.0.1-py3-none-any.whl | Python 3 | none | any | Details for headroom_token_view-0.0.1-py3-none-any.whl |
Total release size: 865.1 kB
Release files / headroom_token_view-0.0.1.tar.gz
| Download URL | headroom_token_view-0.0.1.tar.gz |
|---|---|
| Size | 447.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
51129108b0d9ed0ac300570e1207fc80f1c2933846222d3fc3e01ef78caa54ee
|
|
BLAKE2b-256 checksum How to use checksums |
6da73be597fba39d6f99ad0f3c1ec09668833615e53b0c8f6072aefcb7006900
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.3
|
Release files / headroom_token_view-0.0.1-py3-none-any.whl
| Download URL | headroom_token_view-0.0.1-py3-none-any.whl |
|---|---|
| Size | 417.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
443268c63a26b8bd8471c12e5b7f03b3406addb0e0f9717a77a6c0776b67ec96
|
|
BLAKE2b-256 checksum How to use checksums |
47945e625483f98f8561e9ca050c5e7b14c59e2b47fcf5607f42e9d5a9c425bf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.3
|
Security for headroom-token-view 0.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.