@tokn-ai/llm-tokei
v0.1.13
Published
Token usage stats CLI for local coding-agent sessions
Readme
llm-tokei
See where your local coding-agent tokens went.
Website: agentic.tokn-ai.dev/llm-tokei
llm-tokei scans the session files already on your machine and turns them into
fast, grouped usage reports: input, output, reasoning, cache tokens, sessions,
turns, and estimated cost.
llm-tokei --cost-per provider --cost official --month -hWhy Use It
- One report across agents: Codex CLI, OpenCode, Claude Code, GitHub Copilot Chat, GitHub Copilot CLI, and Pi Agent.
- Useful default table: grouped by source and model, with cost columns included.
- Time windows that match how people ask:
--24h,--7d,--1m,--today,--week,--month. - Activity at a glance: hourly and daily plots for short windows, plus GitHub-style heatmaps for longer ones.
- Cost visibility: bundled timestamp-aware price history works offline;
llm-tokei updaterefreshes it. - Table and automation output: readable terminal tables or stable JSON for scripts.
- Replayable transcripts: dump Codex and Copilot sessions into JSONL message streams.
- Safe local reads: parses local files and opens OpenCode's SQLite database read-only.
Activity Graphs
Use llm-tokei graph for a GitHub-style calendar heatmap of the trailing year.
Shorter ranges automatically switch to plots: hourly below 30 hours and daily
for ranges up to 30 dates.
llm-tokei graph --format svg > activity.svgCalendar heatmap
Hourly and daily plots
| Hourly (--24h) | Daily (--month) |
| --- | --- |
| |
|
Install
npm i -g @tokn-ai/llm-tokeiOr install with Cargo:
cargo install llm-tokeiOr build a local binary:
cargo build --release
./target/release/llm-tokei --helpQuick Examples
# Default report: source x model
llm-tokei
# Human-readable numbers for this week
llm-tokei --week -h
# Last 24 hours by project
llm-tokei --24h --group-by project,source,model
# Top expensive sessions in the last 7 days
llm-tokei --7d --group-by session,source,model --sort cost --limit 10
# Daily trend for the current month
llm-tokei --month --group-by date,source --date-bucket day
# GitHub-style activity graph for the trailing year
llm-tokei graph
# Daily activity plot for a short range
llm-tokei graph --7d
# Hourly activity plot for a sub-30-hour range
llm-tokei graph --24h
# Native SVG activity graph
llm-tokei graph --format svg > activity.svg
# Set the SVG's default palette (it still adapts automatically)
llm-tokei graph --format svg --svg-theme light > activity.svg
# JSON for scripts
llm-tokei --7d --format json --group-by source,model,project
# Show input/output as bytes instead of tokens
llm-tokei --bytes
# Dump replayable messages
llm-tokei dump --codex ~/.codex/sessions/2026/05/12/rollout-example.jsonl
llm-tokei dump --copilot --out ./sessions-jsonlSupported Sources
| Source | Default location |
| --- | --- |
| Codex CLI | $CODEX_HOME/sessions or ~/.codex/sessions |
| OpenCode | $OPENCODE_DATA_DIR/opencode.db, $XDG_DATA_HOME/opencode/opencode.db, or ~/.local/share/opencode/opencode.db |
| Claude Code | $CLAUDE_HOME/projects or ~/.claude/projects |
| GitHub Copilot Chat | VS Code, Insiders, VSCodium, and Cursor workspaceStorage roots |
| GitHub Copilot CLI | ~/.copilot/session-state |
| Pi Agent | ~/.pi/agent/sessions |
Use --source and source path flags to narrow or override discovery.
Pi Agent support includes exact assistant usage records and estimated
pi-web-access summary-review tool results when the plugin stores the
curated search payload and summary metadata.
Learn More
Read the full usage guide: docs/usage.md.
The guide covers config defaults, periods, filters, grouping, table fitting,
JSON output, pricing overrides, token semantics, source caveats, caching, and
the dump subcommand.
To regenerate the showcase SVG from real CLI output:
cargo run --example gen-showcase -- --args "--cost-per provider --cost official --month -h" --out docs/assets/showcase.svg