Skip to content
agentic-rsPublic

Repository files navigation

llm-tokei

CI crates.io docs.rs License Rust Usage

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 -h

llm-tokei terminal table output

Why Use It

  • One report across agents: Codex CLI, OpenCode, Claude Code, GitHub Copilot Chat, GitHub Copilot CLI, Pi Agent, and DeepSeek Harness.
  • 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 update refreshes 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.svg

Calendar heatmap

GitHub-style token activity calendar heatmap

Hourly and daily plots

Hourly (--24h) Daily (--month)
Hourly token activity plot Daily token activity plot

Install

npm i -g @tokn-ai/llm-tokei

Or install with Cargo:

cargo install llm-tokei

Or build a local binary:

cargo build --release
./target/release/llm-tokei --help

Quick 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-jsonl

Supported 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
DeepSeek Harness (dsh) $DSH_HOME/sessions or ~/.dsh/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.

DeepSeek Harness support reads its default Zstandard-compressed session logs and diagnostic plaintext JSONL logs. Usage samples are deduplicated using DSH's last-sample-per-step semantics.

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

Releases

Packages

Contributors

Languages