A small CLI for checking your Anthropic credit usage and spend — in the terminal, as JSON, or as a self-contained HTML report.
Two data sources, two subcommands:
summary/usage/cost— the official Usage and Cost Admin API. Authoritative billing data, but needs an Admin API key (org-only — see Requirements below).code— reads Claude Code's own local session logs (~/.claude/projects/**/*.jsonl) and estimates spend from published per-model pricing. No credentials needed at all — use this if you don't have (or can't get) an Admin API key, or if what you actually want is your localclaudeCLI usage rather than org-wide API billing.
Neither shows Claude.ai Pro/Max subscription usage — Anthropic doesn't publish an API for that.
- For
summary/usage/cost: an Admin API key for your organization (starts withsk-ant-admin...). This is different from a normal API key — only an org admin can create one, from the Claude Console under Settings → Organization → Admin keys. See Create an Admin API key if you don't have one yet. (The Admin API is unavailable for individual / non-organization accounts — you can self-serve one by setting up an organization under Console → Settings → Organization, or just usecodebelow instead.) - For
code: nothing — it only reads files already on disk.
cargo build --release
# binary at target/release/claude-usageSet your key once:
export ANTHROPIC_ADMIN_KEY=sk-ant-admin-...Show the last 7 days (default) as a terminal summary:
claude-usagePick a different range:
claude-usage --days 30
claude-usage --since 2026-08-01 --until 2026-08-15Write an HTML report (dark-mode aware, no external dependencies — safe to
email or open offline). It opens automatically in your default browser.
Omit the filename (or pass -) to get one generated from a random UUID:
claude-usage --days 30 --html report.html
claude-usage --days 30 --htmlMachine-readable output, for piping into other tools:
claude-usage --json | jq '.total_spend_dollars'For finer-grained access to the underlying API, usage and cost expose the
raw, groupable reports directly:
# Token usage grouped by workspace, hourly
claude-usage usage --group-by workspace_id --bucket-width 1h --days 1
# Cost grouped by workspace
claude-usage cost --group-by workspace_id,description --days 30 --jsonCost figures for summary/usage/cost come straight from the Cost Report
API (amount is USD, already converted from the API's cents-denominated
decimal string) — this is real billing data. Priority Tier usage is billed
differently and isn't included in the cost endpoint — track it via
usage --group-by service_tier instead, per Anthropic's docs.
If you don't have an Admin API key (individual account, no org), or you just want to know how much your local Claude Code usage is costing you:
claude-usage code # last 7 days, all projects
claude-usage code --days 30 --html report.htmlThis reads the JSONL session transcripts Claude Code already writes to
~/.claude/projects/ (override with --claude-dir or $CLAUDE_CONFIG_DIR)
and estimates cost from Anthropic's published per-model pricing — the same
approach community tools like ccusage use. It needs no credentials because
it never talks to the network.
This is an estimate, not a bill: it uses list pricing (no negotiated
discounts), and a model released after this tool was built will show up with
its tokens counted but no dollar figure (flagged in the output) until the
pricing table is updated. For authoritative numbers, use summary instead.
The report additionally breaks spend down by project (the working directory Claude Code was run from), which the Admin API has no concept of.
- Data typically lands within ~5 minutes of a request completing.
- Ranges longer than the API's per-request bucket limit (31 daily buckets) are paginated automatically — ask for as wide a range as you like.
- Only
summarysupports--html;usage/costare table/JSON only.