Skip to main content

Fast Rust CLI/TUI/GUI token usage tracker for Codex, Claude Code, and Antigravity usage.

Project description

tokenusage logo

tokenusage

Fast Rust CLI/TUI/GUI token usage tracker for Codex, Claude Code, and Antigravity

CI Release crates.io npm PyPI License

214x faster than ccusage on Claude logs · 138x faster on Codex logs (warm cache) · See benchmark

If tokenusage saves you time, star the repo. That directly improves discovery for other Codex and Claude users.

Screenshots · Install · Quick Start · Why · Benchmark


Screenshots

tu

tu cli demo

tu gui

tu gui demo

tu img day

tu img daily demo

tu img week

tu img weekly demo

tu live

tu live demo

Install

cargo (crates.io)

cargo install tokenusage --bin tu

npm

npm install -g tokenusage

pip (PyPI)

pip install tokenusage

cargo-binstall (prebuilt binary)

cargo binstall tokenusage --no-confirm

Quick Start

# Daily report (default)
tu

# Source-specific
tu codex
tu claude
tu antigravity

# Date filter
tu --since 2026-02-01 --until 2026-02-28

# Weekly / monthly
tu weekly --start-of-week monday
tu monthly

# Live monitor (tabs: Codex / Claude / Antigravity)
tu live
tu live codex
tu live claude
tu live antigravity

# Real-time per-session viewer (htop for tokens)
tu top
tu top --active-hours 12    # show sessions active in last 12h
tu top --active-hours 0     # show all sessions

# GUI dashboard
tu gui

# Share image card (for social posting)
tu img
tu img day
tu img week

Why tokenusage

  • Faster feedback loop: native Rust + parallel scan/parsing + incremental cache.
  • One dashboard for Codex, Claude, and Antigravity, with merged totals and per-model breakdown.
  • Share-ready image card (tu img) for posting your token/cost trend.
  • Works in terminal and desktop GUI without sending your logs to a cloud service.

FAQ

Where does the data come from?

From local log directories and IDE probes:

  • Claude: ~/.config/claude/projects, ~/.claude/projects
  • Codex: ~/.codex/sessions, ~/.config/codex/sessions
  • Antigravity: probed from running IDE language server (no log files needed)

You can override with --claude-projects-dir and --codex-sessions-dir.

How is cost estimated?

tu uses OpenRouter pricing when available, caches it for 6 hours, and falls back to built-in offline rates when network pricing is unavailable.

Is my data private?

Yes for usage logs: parsing is local. tu only requests pricing metadata unless you run --offline.

Benchmark Details

Setup:

  • Machine: Apple M3 Max, macOS 15.6.1
  • tu version: 1.2.6 · ccusage version: 18.0.8 · @ccusage/codex version: 18.0.8
  • Default mode (no date filters, online pricing, network enabled)

Codex — 91 JSONL files, 1.7 GB (~/.codex/sessions)

tu codex bunx @ccusage/codex Speedup
Cold (rebuild cache) 0.92s 20.76s 22.6x
Warm (best of 5 / avg of 3) 0.15s 20.76s 138x

Claude — 1 521 JSONL files, 2.2 GB (~/.claude/projects)

tu claude bunx ccusage Speedup
Cold (rebuild cache) 0.73s 17.15s 23.5x
Warm (best of 5 / avg of 3) 0.08s 17.15s 214x

Results vary by hardware, filesystem cache state, and log volume.

Command Overview

tu [daily|codex|claude|antigravity|monthly|weekly|img|session|blocks|live|statusline|gui]

Useful commands:

  • tu daily --tui
  • tu daily --json
  • tu daily --jq '.rows[0]'
  • tu blocks --active
  • tu blocks --live
  • tu live
  • tu img --output tokenusage-share.png (today, hourly)
  • tu img --period weekly --output tokenusage-week.png (7 days, daily)
  • tu img --logo ./logo.png --brand-url tokenusage.dev
  • tu statusline

Config File

Config search order:

  1. ./.tu/tu.json
  2. ~/.config/tu/tu.json
  3. ~/.config/tokenusage/tokenusage.json

Use an explicit config file:

tu --config /path/to/tu.json

Example:

{
  "defaults": {
    "timezone": "Asia/Shanghai",
    "workers": 16,
    "compact": false
  },
  "commands": {
    "daily": {
      "instances": true
    },
    "live": {
      "sessionLength": 5,
      "refreshInterval": 1
    },
    "img": {
      "period": "daily",
      "bars": 24,
      "brand": "tokenusage",
      "brandUrl": "https://github.com/hanbu97/tokenusage"
    },
    "weekly": {
      "startOfWeek": "monday"
    }
  }
}

Pricing

tu --pricing-file ./pricing.json

Offline-only mode:

tu --offline

Demo Dataset (No Real Data)

python3 examples/demo/generate_demo_data.py
tu daily --config ./examples/demo/tu.demo.json --since 2026-02-09 --until 2026-02-28
tu live --config ./examples/demo/tu.demo.json
tu gui --config ./examples/demo/tu.demo.json --since 2026-02-09 --until 2026-02-28
tu img --config ./examples/demo/tu.demo.json --since 2026-02-28 --until 2026-02-28 --output ./docs/images/share-demo.png
tu img --config ./examples/demo/tu.demo.json --period weekly --since 2026-02-22 --until 2026-02-28 --output ./docs/images/share-week-demo.png

Development

cargo fmt
cargo clippy --all-targets --all-features
cargo check

License

MIT. See LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tokenusage-1.3.2.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tokenusage-1.3.2-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

Details for the file tokenusage-1.3.2.tar.gz.

File metadata

  • Download URL: tokenusage-1.3.2.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for tokenusage-1.3.2.tar.gz
Algorithm Hash digest
SHA256 27d77abb5f992dfc03da76c0dcb875010a4c2b4a7aea08645e2fb968bc6406ce
MD5 811e9392ab3eca78742379c0a7ee69fa
BLAKE2b-256 c338e170ad2cccd6c0dd3fd085022167f1a2dae0b6a5d1e67fdb040ce607b295

See more details on using hashes here.

File details

Details for the file tokenusage-1.3.2-py3-none-any.whl.

File metadata

  • Download URL: tokenusage-1.3.2-py3-none-any.whl
  • Upload date:
  • Size: 6.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for tokenusage-1.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e505f591596231ad429d4afd7894ef27774607a921849b632e10fb6c676e9533
MD5 bd871db50d017a9ff1aedc69e93342c3
BLAKE2b-256 5603fd94a78c2b4ff9f3907eac00c7cb84dbc4e84ace8cba750cd86fa5becdfb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page