Real-time token usage & cost tracker for Claude Code. Multi-provider pricing, 2700+ models.
- StatusLine — Real-time display in Claude Code's status bar: model, tokens, cache hit rate, cost, context usage
- Multi-provider — Anthropic / DeepSeek / OpenAI / Gemini / MiMo / MiniMax / GLM / Kimi, 2700+ models
- Smart pricing — Auto-detects pricing mode: Anthropic 4-tier, DeepSeek cache-hit, standard 2-tier, >200K tiered pricing
- Project stats — Cost breakdown by project and session
- JSONL import — Historical data from Claude Code's local logs
- Live interception — Patches
fetchon Unix/macOS for real-time API capture (Windows uses JSONL fallback) - One-click update —
update-pricingpulls latest model pricing from LiteLLM
git clone https://github.com/2eeYuan/tokenwise.git
cd tokenwise
npm install
npm run build
# Optional: install globally
npm linkRequires Node.js >= 20, better-sqlite3 (needs C++ build tools).
tokenwise setupRestart Claude Code and the status bar appears at the bottom:
deepseek-v4-pro | In: 26.1K | Out: 6.8K | Cache: 100% hit | $0.0342 | ctx 6%
Fields: model name | input tokens | output tokens | cache hit rate | session cost | context window usage %.
# All sessions
tokenwise import
# Specific session
tokenwise import --session <session-id>
# Verbose output
tokenwise import --verboseData source: Claude Code automatically writes session logs to ~/.claude/projects/<project>/<session>.jsonl.
# Current project
tokenwise stats
# All projects
tokenwise stats --all
# Specific session
tokenwise stats --session <session-id>
# JSON output (for scripting)
tokenwise stats --all --jsonExample output:
Project: D--test-claude-prj-money-cal
──────────────────────────────────────────────────────────────────
deepseek-v4-pro 42 reqs 156.2K in 8.4K out $0.2340
mimo-v2.5-pro 15 reqs 51.2K in 104 out $0.0342
──────────────────────────────────────────────────────────────────
Total 57 reqs 207.4K in 8.5K out $0.2682
tokenwise update-pricingFetches the latest pricing JSON from the LiteLLM community (updated near-daily).
| Feature | Unix / macOS | Windows |
|---|---|---|
| StatusLine | ✓ | ✓ |
tokenwise stats |
✓ | ✓ |
tokenwise import |
✓ | ✓ |
tokenwise update-pricing |
✓ | ✓ |
| Live interception (fetch patch) | ✓ | ✗ |
On Windows, the status bar reads JSONL files directly for token counts. Functionally identical.
Unix/macOS: Use tokenwise as a wrapper for claude to inject the interceptor:
tokenwise # Launch Claude Code with live tracking
tokenwise -c "explain this" # Pass arguments to claude
tokenwise --mc-verbose # Print per-request token breakdown| Command | Description |
|---|---|
tokenwise |
Launch Claude Code (Unix: with interceptor; Windows: direct) |
tokenwise setup |
Install status bar to ~/.claude/settings.json |
tokenwise setup --uninstall |
Remove status bar, restore previous config |
tokenwise stats |
Show current project usage by model |
tokenwise stats --all |
Show all projects |
tokenwise stats --session <id> |
Show session details |
tokenwise stats --json |
Output as JSON |
tokenwise import |
Import all JSONL data |
tokenwise import --session <id> |
Import specific session |
tokenwise import --verbose |
Show each imported entry |
tokenwise update-pricing |
Fetch latest pricing from LiteLLM |
tokenwise update-pricing --dry-run |
Preview update (no file write) |
tokenwise setup --uninstallThis removes the status bar script and the statusLine config from settings.json. The database at ~/.claude/money-calc/usage.db is preserved.
- Usage data:
~/.claude/money-calc/usage.db(SQLite) - Status bar script:
~/.claude/money-calc-statusline.js - Pricing data:
model_prices_and_context_window.json(in project directory)
Claude Code's original JSONL logs at ~/.claude/projects/ are unaffected.
- 2700+ models: LiteLLM community maintains
model_prices_and_context_window.json, updated near-daily - Hardcoded fallbacks (6 common models): official source URLs annotated in
src/pricing.ts- Anthropic: anthropic.com/pricing
- DeepSeek: api-docs.deepseek.com/quick_start/pricing
- MiMo: mimo.xiaomi.com/pricing
- Run
tokenwise update-pricingto stay current
Q: Status bar shows In: 0 Out: 0 but cost is non-zero?
A: Known Windows behavior — the status bar uses JSONL fallback for token counts (fixed in v0.1.1). Run tokenwise setup to reinstall if needed.
Q: Status bar disappeared after switching models?
A: Manually editing ~/.claude/settings.json may overwrite the statusLine field. Run tokenwise setup again.
Q: Cost doesn't match my actual bill?
A: Possible causes: ① run tokenwise update-pricing for latest rates; ② Pro/Max plan users — status bar prefers Claude Code's built-in cost; ③ some models include search/tool-call surcharges.
Q: better-sqlite3 fails to compile?
A: Install C++ build tools — Microsoft Visual C++ Build Tools on Windows, or xcode-select --install on macOS.
src/
├── types.ts # Type definitions
├── pricing.ts # Pricing engine (LiteLLM JSON + hardcoded fallbacks)
├── db.ts # SQLite data layer
├── interceptor.ts # fetch() patch interceptor (Unix)
├── interceptor-loader.js # CJS bootstrap for --require preload
├── jsonl-reader.ts # JSONL parser
├── cli.ts # CLI entry point
└── statusline.ts # Embedded StatusLine script
MIT