claudeers.

๐Ÿ”“ unclaimed โ€” this page was auto-generated from GitHub. Are you the creator?

Claim this page โ†’
// Automation & Workflows

tokscale

๐Ÿ›ฐ๏ธ A CLI tool for tracking token usage from OpenCode, Claude Code, ๐ŸฆžOpenClaw (Clawdbot/Moltbot), Pi, Codex, Gemini, Cursor, AmpCode, Factory Droid, Kimi, aโ€ฆ

// Automation & Workflows[ cli ][ api ][ desktop ][ web ][ claude ]#claude#ai#ai-agents#ampcode#claude-code#clawdbot#codex#cursor#automationโ—ท MIT$open-sourceupdated 15 days ago
Actively maintained
100/100
last commit 2 days ago
last release 2 days ago
releases 76
open issues 29
// install
git clone https://github.com/junhoyeo/tokscale

Tokscale

A high-performance CLI tool and visualization dashboard for tracking token usage and costs across multiple AI coding agents.

[!TIP]

v2 is here โ€” native Rust TUI, cross-platform support, and more.
I drop new open-source work every week. Don't miss the next one.

Follow @junhoyeo on GitHub for more projects. Hacking on AI, infra, and everything in between.
Come hang out in our Discord โ€” and surround yourself with the world's top-tier vibers.

๐Ÿ‡บ๐Ÿ‡ธ English | ๐Ÿ‡ฐ๐Ÿ‡ท ํ•œ๊ตญ์–ด | ๐Ÿ‡ฏ๐Ÿ‡ต ๆ—ฅๆœฌ่ชž | ๐Ÿ‡จ๐Ÿ‡ณ ็ฎ€ไฝ“ไธญๆ–‡

OverviewModels
TUI OverviewTUI Models
Daily SummaryStats
TUI Daily SummaryTUI Stats
Frontend (3D Contributions Graph)Wrapped 2025
Frontend (3D Contributions Graph)Wrapped 2025

Run bunx tokscale@latest submit to submit your usage data to the leaderboard and create your public profile!

Overview

Tokscale helps you monitor and analyze your token consumption from:

LogoClientData LocationSupported
OpenCodeOpenCode~/.local/share/opencode/opencode.db (1.2+, all channels including opencode-stable.db) or/and ~/.local/share/opencode/storage/message/ (legacy/unmigrated)โœ… Yes
ClaudeClaude Code~/.claude/projects/ and ~/.claude/transcripts/โœ… Yes
OpenClawOpenClaw~/.openclaw/agents/ (+ legacy: .clawdbot, .moltbot, .moldbot)โœ… Yes
CodexCodex CLI~/.codex/sessions/โœ… Yes
Sakana FuguSakana Fuguvia Codex โ€” ~/.codex/sessions/*.jsonl (model_provider: sakana)โœ… Yes
CopilotGitHub Copilot CLI~/.copilot/otel/*.jsonl (+ COPILOT_OTEL_FILE_EXPORTER_PATH)โœ… Yes
Hermes AgentHermes Agent$HERMES_HOME/state.db (fallback: ~/.hermes/state.db)โœ… Yes
GeminiGemini CLI$GEMINI_CLI_HOME/tmp/*/chats/*.json (fallback: ~/.gemini/tmp/*/chats/*.json)โœ… Yes
CursorCursor IDECursor API export cached at ~/.config/tokscale/cursor-cache/usage*.csv (not ~/.cursor)โœ… Yes
AmpAmp (AmpCode)~/.local/share/amp/threads/โœ… Yes
CodebuffCodebuff~/.config/manicode/ (+ manicode-dev, manicode-staging; override via CODEBUFF_DATA_DIR)โœ… Yes
DroidDroid (Factory Droid)~/.factory/sessions/โœ… Yes
PiPi~/.pi/agent/sessions/ and ~/.omp/agent/sessions/ (Oh My Pi)โœ… Yes
KimiKimi CLI / Kimi Codekimi-cli: ~/.kimi/sessions/ kimi-code: ~/.kimi-code/sessions/ (override via KIMI_CODE_HOME)โœ… Yes
QwenQwen CLI~/.qwen/projects/โœ… Yes
Roo CodeRoo Code~/.config/Code/User/globalStorage/rooveterinaryinc.roo-cline/tasks/ (+ server: ~/.vscode-server/data/User/globalStorage/rooveterinaryinc.roo-cline/tasks/)โœ… Yes
KiloKilo~/.config/Code/User/globalStorage/kilocode.kilo-code/tasks/ (+ server: ~/.vscode-server/data/User/globalStorage/kilocode.kilo-code/tasks/)โœ… Yes
Kilo CLIKilo CLI~/.local/share/kilo/kilo.dbโœ… Yes
MuxMux~/.mux/sessions/โœ… Yes
CrushCrush$XDG_DATA_HOME/crush/projects.json (project registry; fallback: ~/.local/share/crush/projects.json)โœ… Yes
GooseGoose~/.local/share/goose/sessions/sessions.db (+ macOS Application Support, legacy Block/goose paths; override via GOOSE_PATH_ROOT)โœ… Yes
AntigravityGoogle AntigravityCached via tokscale antigravity sync to ~/.config/tokscale/antigravity-cache/sessions/*.jsonl (live RPC against the local language server)โœ… Yes
Antigravity CLIAntigravity CLI~/.gemini/antigravity-cli/conversations/*.db (override the Gemini home via GEMINI_CLI_HOME; local SQLite, read directly โ€” no antigravity sync needed)โœ… Yes
TraeTrae IDE / Trae Solo (international)Cached via tokscale trae sync to ~/.config/tokscale/trae-cache/sessions/*.json (account-level usage from the official API)โœ… Yes
WarpWarp / OzCached via tokscale warp sync to ~/.config/tokscale/warp-cache/usage.json (aggregate requests and spend only; no token transcripts)โœ… Yes
Grok BuildGrok Build$GROK_HOME/sessions/*/*/updates.jsonl (fallback: ~/.grok/sessions/*/*/updates.jsonl)โœ… Yes
Zed AgentZed Agent~/.local/share/zed/threads/threads.db (macOS: ~/Library/Application Support/Zed/threads/threads.db; Windows: %LOCALAPPDATA%/Zed/threads/threads.db; hosted Zed models only, not external ACP agents)โœ… Yes
KiroKiro~/.kiro/sessions/cli/*.json (+ *.jsonl), ~/.local/share/kiro-cli/data.sqlite3 (macOS: ~/Library/Application Support/kiro-cli/data.sqlite3), and Kiro IDE globalStorage snapshots (Kiro/User/globalStorage/kiro.kiroagent; macOS Application Support, Linux ~/.config/Kiro, Windows %APPDATA%\Kiro)โœ… Yes
ClineClineVS Code globalStorage tasks (Linux: ~/.config/Code/...; macOS: ~/Library/Application Support/Code/...; Windows: %APPDATA%\Code\...; server: ~/.vscode-server/data/User/globalStorage/saoudrizwan.claude-dev/tasks/)โœ… Yes
Gajae-Codegajae-code (gjc)~/.gjc/agent/sessions/ (override via GJC_CODING_AGENT_DIR, GJC_CONFIG_DIR, PI_CONFIG_DIR; $XDG_DATA_HOME/gjc/sessions/ on Linux/macOS)โœ… Yes
JcodeJcode~/.jcode/sessions/session_*.json + session_*.journal.jsonl sidecars (override via JCODE_HOME)โœ… Yes
MiMo CodeMiMo Code~/.local/share/micode/mimocode.db (XDG data dir; SQLite)โœ… Yes
JunieJunie~/.junie/sessions/*/events.jsonlโœ… Yes
Command CodeCommand Code~/.commandcode/projects/**/*.jsonl (token usage estimated from transcripts at ~4 chars/token; not persisted on disk)โœ… Yes
SyntheticSyntheticRe-attributed from other sources via hf: model prefix or synthetic provider (+ Octofriend: ~/.local/share/octofriend/sqlite.db)โœ… Yes

Get real-time pricing calculations using ๐Ÿš… LiteLLM's pricing data, with support for tiered pricing models and cache token discounts.

Why "Tokscale"?

Tokscale

This project is inspired by the Kardashev scale, a method proposed by astrophysicist Nikolai Kardashev to measure a civilization's level of technological advancement based on its energy consumption. A Type I civilization harnesses all energy available on its planet, Type II captures the entire output of its star, and Type III commands the energy of an entire galaxy.

In the age of AI-assisted development, tokens are the new energy. They power our reasoning, fuel our productivity, and drive our creative output. Just as the Kardashev scale tracks energy consumption at cosmic scales, Tokscale measures your token consumption as you scale the ranks of AI-augmented development. Whether you're a casual user or burning through millions of tokens daily, Tokscale helps you visualize your journey up the scaleโ€”from planetary developer to galactic code architect.

Contents

Features

  • Interactive TUI Mode - Beautiful terminal UI powered by Ratatui (default mode)
    • 6 interactive views: Overview, Models, Daily, Hourly, Stats, Agents (plus an optional Minutely view, opt-in via minutelyTabEnabled)
    • Keyboard & mouse navigation
    • GitHub-style contribution graph with 9 color themes
    • Real-time filtering and sorting
    • Zero flicker rendering
  • Multi-platform support - Track usage across OpenCode, Claude Code, Codex CLI, Copilot CLI, Cursor IDE, Gemini CLI, Amp, Codebuff, Droid, OpenClaw, Hermes Agent, Pi, Kimi CLI, Qwen CLI, Roo Code, Kilo, Mux, Kilo CLI, Crush, Goose, Antigravity, Antigravity CLI, Zed, Kiro, Trae, Warp/Oz, Cline, Gajae-Code, Grok Build, Jcode, MiMo Code, Command Code, Junie, and Synthetic
  • Real-time pricing - Fetches current pricing from LiteLLM with 1-hour disk cache; automatic OpenRouter fallback and Cursor model pricing for newly released models
  • Detailed breakdowns - Input, output, cache read/write, and reasoning token tracking
  • Native Rust core - All parsing and aggregation done in Rust for 10x faster processing
  • Web visualization - Interactive contribution graph with 2D and 3D views
  • Flexible filtering - Filter by platform, date range, or year
  • Task-attributed reports - LLM-powered session summarization and task grouping with multi-backend support (Apple FM, Claude, Codex, Gemini, Kiro)
  • Export to JSON - Generate data for external visualization tools
  • Social Platform - Share your usage, compete on leaderboards, and view public profiles

Installation

Quick Start

# Run directly with npx
npx tokscale@latest

# Or use bunx
bunx tokscale@latest

# Or use Deno without installing an alias
deno x npm:tokscale@latest

# Light mode (table rendering only)
npx tokscale@latest --light

That's it! This gives you the full interactive TUI experience with zero setup.

Package Structure: tokscale is an alias package (like swc) that installs @tokscale/cli. Both install the same CLI with the native Rust core (@tokscale/core) included.

Prerequisites

  • Node.js or Bun
  • (Optional) Rust toolchain for building native module from source

Development Setup

For local development or building from source:

# Clone the repository
git clone https://github.com/junhoyeo/tokscale.git
cd tokscale

# Install Bun (if not already installed)
curl -fsSL https://bun.sh/install | bash

# Install dependencies
bun install

# Run the CLI in development mode
bun run cli

Note: bun run cli is for local development. When installed via bunx tokscale, the command runs directly. The Usage section below shows the installed binary commands.

Building the Native Module

The native Rust module is required for CLI operation. It provides ~10x faster processing through parallel file scanning and SIMD JSON parsing:

# Build the native core (run from repository root)
bun run build:core

Note: Native binaries are pre-built and included when you install via bunx tokscale@latest. Building from source is only needed for local development.

Usage

Basic Commands

# Launch interactive TUI (default)
tokscale

# Launch TUI with specific tab
tokscale models    # Models tab
tokscale monthly   # Daily view (shows daily breakdown)
tokscale hourly    # Hourly tab

# Use legacy CLI table output
tokscale --light
tokscale models --light

# Launch TUI explicitly
tokscale tui

# Export contribution graph data as JSON
tokscale graph --output data.json

# Output data as JSON (for scripting/automation)
tokscale --json                    # Default models view as JSON
tokscale models --json             # Models breakdown as JSON
tokscale monthly --json            # Monthly breakdown as JSON
tokscale models --json > report.json   # Save to file

TUI Features

The interactive TUI mode provides:

  • 8 Views: Overview (chart + top models), Usage (subscription quotas), Models, Daily, Hourly, Stats (contribution graph), Agents. A per-minute view (Minutely) is hidden by default and can be enabled with minutelyTabEnabled in settings.json โ€” see Configuration
  • Keyboard Navigation:
    • โ†/โ†’/Tab/BackTab: Switch views
    • โ†‘/โ†“ or Home/End: Navigate lists
    • Enter: Open daily detail (Daily tab) / select graph cell (Stats tab)
    • Esc or Backspace: Close dialog or exit detail view
    • c/d/t: Sort by cost/date/tokens
    • j: Jump to today
    • s: Open source picker dialog
    • g: Open group-by picker dialog (model, client+model, client+provider+model, workspace+model, session+model, client+session+model)
    • h: Toggle Daily/Hourly chart granularity (Overview tab)
    • v: Toggle Table/Profile view (Hourly tab)
    • y: Copy selected row to clipboard
    • p: Cycle through 9 color themes
    • r: Refresh data; Shift+R toggles auto-refresh; +/- adjusts interval
    • e: Export to JSON
    • q or Ctrl+C: Quit
  • Mouse Support: Click tabs, buttons, and filters
  • Themes: Green, Halloween, Teal, Blue, Pink, Purple, Orange, Monochrome, YlGnBu
  • Settings Persistence: Preferences saved to ~/.config/tokscale/settings.json (see Configuration)

Group-By Strategies

Press g in the TUI or use --group-by in --light/--json mode to control how model rows are aggregated:

StrategyFlagTUI DefaultEffect
Model--group-by modelโœ…One row per model โ€” merges all clients and providers
Client + Model--group-by client,modelOne row per client-model pair
Client + Provider + Model--group-by client,provider,modelMost granular โ€” no merging
Workspace + Model--group-by workspace,modelGroup local usage by workspace key, then model
Session + Model--group-by session,modelOne row per session_id and model โ€” attribute cost to a specific agent-CLI session
Client + Session + Model--group-by client,session,modelOne row per client, session, and model โ€” useful for multi-agent runners that join on session_id

--group-by model (most consolidated)

ClientsProvidersModelCost
OpenCode, Claude, Ampgithub-copilot, anthropicclaude-opus-4-5$2,424
OpenCode, Claudeanthropic, github-copilotclaude-sonnet-4-5$1,332

--group-by client,model (CLI default)

ClientProviderModelCost
OpenCodegithub-copilot, anthropicclaude-opus-4-5$1,368
Claudeanthropicclaude-opus-4-5$970

--group-by client,provider,model (most granular)

ClientProviderModelCost
OpenCodegithub-copilotclaude-opus-4-5$1,200
OpenCodeanthropicclaude-opus-4-5$168
Claudeanthropicclaude-opus-4-5$970

--group-by session,model (per-session cost attribution)

tokscale models --json --group-by session,model emits one entry per (session_id, model). Each entry includes a top-level sessionId field so downstream tools (e.g. multi-agent IDEs) can join cost data back to a specific agent-CLI session:

{
  "groupBy": "session,model",
  "entries": [
    {
      "sessionId": "019e1e27-af49-7cd1-89b7-7bad1c3f3be2",
      "client": "codex",
      "provider": "openai",
      "model": "gpt-5",
      "input": 25251,
      "output": 47,
      "cacheRead": 1920,
      "cacheWrite": 0,
      "reasoning": 40,
      "messageCount": 12,
      "cost": 0.0123
    }
  ]
}

Use --group-by client,session,model when you also need the client name on every row (one spawn across all 20+ supported CLIs at once).

Filtering by Platform

Use --client (short -c) to scope reports to one or more clients. The flag is repeatable, accepts comma-separated values, and works with every report command:

# Show only OpenCode usage
tokscale --client opencode

# Comma-separated: combine multiple clients
tokscale --client opencode,claude

# Repeated: same effect, useful with shell aliases
tokscale -c opencode -c claude

# Cursor IDE uses Tokscale's API cache; run login + sync --json first
tokscale --client cursor

# Synthetic (synthetic.new) is detected from other agent sessions
tokscale --client synthetic

# Combine with other filters
tokscale --client opencode,claude --week --json

Possible values: opencode, claude, codex, copilot, gemini, cursor, amp, codebuff, droid, openclaw, hermes, pi, kimi, qwen, roocode, kilocode, kilo, mux, crush, goose, antigravity, antigravity-cli, zed, kiro, trae, warp, cline, gjc, grok, jcode, micode, commandcode, junie, synthetic.

Breaking change (v4.0.0): The per-client boolean flags (--opencode, --claude, --codex, etc.) have been removed and now error. Use the canonical --client/-c flag instead โ€” e.g. tokscale --client opencode,claude.

Date Filtering

Date filters work across all commands that generate reports (tokscale, tokscale models, tokscale monthly, tokscale graph):

# Quick date shortcuts
tokscale --today              # Today only
tokscale --yesterday          # Yesterday only
tokscale --week               # Last 7 days
tokscale --month              # Current calendar month

# Custom date range (inclusive, local timezone)
tokscale --since 2024-01-01 --until 2024-12-31

# Filter by year
tokscale --year 2024

# Combine with other options
tokscale models --week --client claude --json
tokscale monthly --month --benchmark

Note: Date filters use your local timezone. Both --since and --until are inclusive. v2.2.0 note: Session active-time daily buckets also use your local timezone, so users outside UTC may see active-time dates align with local token/cost report days instead of UTC day boundaries.

Pricing Lookup

Look up real-time pricing for any model:

# Look up model pricing
tokscale pricing "claude-3-5-sonnet-20241022"
tokscale pricing "gpt-4o"
tokscale pricing "grok-code"

# Force specific provider source
tokscale pricing "grok-code" --provider openrouter
tokscale pricing "claude-3-5-sonnet" --provider litellm

# Inspect custom pricing overrides
tokscale pricing list-overrides

Lookup Strategy:

The pricing lookup uses a multi-step resolution strategy:

  1. Custom Pricing Overrides - Exact user-defined entries from ~/.config/tokscale/custom-pricing.json
  2. Exact Match - Direct lookup in LiteLLM/OpenRouter databases
  3. Alias Resolution - Resolves friendly names (e.g., big-pickle โ†’ glm-4.7)
  4. Tier Suffix Stripping - Removes quality tiers (gpt-5.2-xhigh โ†’ gpt-5.2)
  5. Version Normalization - Handles version formats (claude-3-5-sonnet โ†” claude-3.5-sonnet)
  6. Provider Prefix Matching - Tries common prefixes (anthropic/, openai/, etc.)
  7. Cursor Model Pricing - Hardcoded pricing for models not yet in LiteLLM/OpenRouter (e.g., gpt-5.3-codex)
  8. Fuzzy Matching - Word-boundary matching for partial model names

Custom Pricing Overrides

Create custom-pricing.json in Tokscale's config directory (~/.config/tokscale/custom-pricing.json on macOS/Linux by default; the same directory resolved by TOKSCALE_CONFIG_DIR when set) to override prices for model IDs that upstream pricing databases do not yet cover correctly.

{
  "$schema": "https://tokscale.ai/custom-pricing.schema.json",
  "models": {
    "accounts/fireworks/routers/kimi-k2p6-turbo": {
      "input_cost_per_million_tokens": 2.00,
      "output_cost_per_million_tokens": 8.00,
      "cache_read_input_token_cost_per_million_tokens": 0.30,
      "source": "https://docs.fireworks.ai/serverless/pricing",
      "notes": "Fireworks Kimi K2.6 Turbo (preview)"
    },
    "accounts/fireworks/models/kimi-k2p6": {
      "input_cost_per_million_tokens": 0.95,
      "output_cost_per_million_tokens": 4.00,
      "cache_read_input_token_cost_per_million_tokens": 0.16
    },
    "kimi-k2p6-turbo": {
      "input_cost_per_million_tokens": 2.00,
      "output_cost_per_million_tokens": 8.00
    }
  }
}

Override prices are entered in dollars per million tokens, matching how most API providers publish pricing; Tokscale converts them to per-token rates internally. At least one of input_cost_per_million_tokens or output_cost_per_million_tokens must be present and positive, and cache-read/cache-creation fields are optional. LiteLLM-style per-token field names such as input_cost_per_token, output_cost_per_token, and cache_read_input_token_cost are also accepted for copy/paste compatibility, but the per-million names are the recommended user-facing form. To omit a tier or cache price, leave the field out; negative or non-finite values are treated as invalid and the whole model entry is skipped so typos do not silently alter accounting. Optional source and notes fields are ignored by Tokscale and can be used for your own bookkeeping.

Overrides are exact-only and case-insensitive. Tokscale checks the raw model ID first, then the existing synthetic /models/ normalization, then falls through to LiteLLM, OpenRouter, Cursor pricing, and fuzzy matching if no override matches. Raw exact matches beat normalized exact matches, so accounts/fireworks/routers/kimi-k2p6-turbo can override one gateway-specific model while kimi-k2p6-turbo can cover normalized /models/ paths. Overrides are loaded once at startup; restart the command after editing the file. This is the recommended local fix for wrong-model pricing bugs while waiting on upstream LiteLLM pricing updates.

Provider Preference:

When multiple matches exist, original model creators are preferred over resellers:

Preferred (Original)Deprioritized (Reseller)
xai/ (Grok)azure_ai/
anthropic/ (Claude)bedrock/
openai/ (GPT)vertex_ai/
google/ (Gemini)together_ai/
meta-llama/fireworks_ai/

Example: grok-code matches xai/grok-code-fast-1 ($0.20/$1.50) instead of azure_ai/grok-code-fast-1 ($3.50/$17.50).

Social

# Login to Tokscale (opens browser for GitHub auth)
tokscale login

# Save an existing Tokscale API token without browser auth
tokscale login --token tt_xxx

# Check who you're logged in as
tokscale whoami

# Display your saved API token as a QR code (useful for sharing to another device)
# Encodes {"token":"tt_xxx","username":"..."} โ€” scan with any QR reader
tokscale qr

# Submit your usage data to the leaderboard
tokscale submit

# Submit in CI/headless environments without writing credentials
# Precedence: TOKSCALE_API_TOKEN env > saved credentials file (~/.config/tokscale/credentials.json).
# When the env var is set, the saved file is ignored for that invocation.
TOKSCALE_API_TOKEN=tt_xxx tokscale submit

# Revoke a token: visit Settings > API Tokens on the leaderboard site
# (https://tokscale.ai/settings) and click "Revoke" on the token row.
# Revocation takes effect immediately โ€” subsequent requests with that
# token will get HTTP 401 "Invalid API token".

# Submit with filters
tokscale submit --client opencode,claude --since 2024-01-01

# Preview what would be submitted (dry run)
tokscale submit --dry-run

# Logout
tokscale logout
CLI Submit

Cursor IDE Commands

Cursor IDE support uses Cursor's web API export, cached by Tokscale at ~/.config/tokscale/cursor-cache/usage*.csv. Tokscale does not parse local Cursor Agent CLI state under ~/.cursor.

Setup:

  1. Open https://www.cursor.com/settings in your browser and sign in.
  2. Copy the WorkosCursorSessionToken cookie value:
    • Network tab: make any request to cursor.com/api/*, then copy the value after WorkosCursorSessionToken= from the Cookie request header.
    • Application tab: open Cookies -> https://www.cursor.com, then copy the WorkosCursorSessionToken value.
  3. Run tokscale cursor login --name work and paste the token.
  4. Run tokscale cursor sync --json to populate ~/.config/tokscale/cursor-cache/usage.csv.
  5. Run tokscale --client cursor or any report command.

Treat the session token like a password. It is stored locally in ~/.config/tokscale/cursor-credentials.json.

# Login to Cursor (requires session token from browser)
# --name is optional; it just helps you identify accounts later
tokscale cursor login --name work

# Check Cursor authentication status and session validity
tokscale cursor status

# List saved Cursor accounts
tokscale cursor accounts

# Manually refresh cached Cursor usage
tokscale cursor sync --json

# Switch active account (controls which account syncs to cursor-cache/usage.csv)
tokscale cursor switch work

# Logout from a specific account (keeps history; excludes it from aggregation)
tokscale cursor logout --name work

# Logout and delete cached usage for that account
tokscale cursor logout --name work --purge-cache

# Logout from all Cursor accounts (keeps history; excludes from aggregation)
tokscale cursor logout --all

# Logout from all accounts and delete cached usage
tokscale cursor logout --all --purge-cache

By default, Tokscale aggregates usage across all saved Cursor accounts by reading cursor-cache/usage*.csv. The active account syncs to usage.csv; additional accounts sync to usage.<account>.csv.

When you log out, Tokscale moves cached usage to cursor-cache/archive/ so it is no longer aggregated. Use --purge-cache to delete cached usage instead.

Antigravity Commands

Antigravity sync currently works on macOS and Linux only. The Antigravity-enabled editor must be running and its local language server available; tokscale reads usage from that local language server and caches normalized artifacts locally.

# Check whether tokscale can see running Antigravity language servers
tokscale antigravity status

# Sync usage from local Antigravity language servers into tokscale's cache
tokscale antigravity sync

# Delete the cached Antigravity artifacts
tokscale antigravity purge-cache

Cache location: ~/.config/tokscale/antigravity-cache/

How it works: tokscale antigravity sync discovers local Antigravity session candidates, fetches confirmed usage data from the local language server RPC, and stores normalized JSONL artifacts for tokscale-core to parse later. Run sync before reports if you want the freshest Antigravity data.

Trae Commands

Trae (ByteDance's AI IDE) ships in two international product lines โ€” Trae IDE and Trae Solo. They share the same account-level usage data (same backend, same JWT), so tokscale reports them as a single trae client. You can install either or both desktop apps; tokscale auto-discovers credentials from whichever is present.

Credentials are identified per desktop app via --variant:

  • --variant ide โ€” credentials from Trae IDE (~/Library/Application Support/Trae/)
  • --variant solo โ€” credentials from Trae Solo (~/Library/Application Support/TRAE SOLO/)

tokscale trae sync calls the official query_user_usage_group_by_session API exactly once per run (regardless of how many desktop apps are installed) and persists the raw JSON to a local cache.

# Log in (auto-detects credentials from any installed Trae desktop client)
tokscale trae login

# Manual JWT entry (for environments where auto-detect can't find storage.json,
# e.g. Linux/Windows or a headless server). Open https://www.trae.ai/account-setting#usage
# in your browser, then F12 โ†’ Network โ†’ filter `query_user_usage` and copy the
# `Authorization` header value.
tokscale trae login --manual --variant solo

# Show which variants have cached credentials
tokscale trae status

# Sync usage (uses the first available credential source)
tokscale trae sync --since 30

# Forget cached credentials for one variant
tokscale trae logout --variant solo

Cache location: ~/.config/tokscale/trae-cache/

How it works: tokscale either decrypts the desktop client's iCubeAuthInfo://* blob (globalStorage/storage.json) to recover a JWT, or accepts one pasted via --manual. It then calls POST /trae/api/v1/pay/query_user_usage_group_by_session paginated and stores the raw JSON. Run sync before reports if you want the freshest Trae data.

Note on pricing: Trae cost figures are vendor-reported โ€” tokscale surfaces the dollar_float value returned by Trae's own API rather than recomputing cost from token counts through tokscale's pricing engine. Numbers will match what you see on trae.ai/account-setting#usage, not what tokscale would otherwise calculate for the same usage.

China variants: The China editions (trae.com.cn) are intentionally not supported. The CN backend does not expose a session-level usage query API. Trae CN / Trae Solo CN support will be added once an official endpoint becomes available upstream.

Warp/Oz Commands

Warp/Oz does not expose local token transcripts. Tokscale only syncs the aggregate request and spend counters returned by Warp's GraphQL API, then reports them as warp / aggregate-requests rows with zero token buckets.

# Save a bearer token or Cookie header copied from an authenticated Warp request
tokscale warp login

# Inspect credential/cache state and diagnostics
tokscale warp status

# Sync aggregate requests and spend into tokscale's local cache
tokscale warp sync

# Remove saved credentials; add --purge-cache to delete synced usage too
tokscale warp logout --purge-cache

Cache location: ~/.config/tokscale/warp-cache/usage.json

How it works: tokscale warp sync calls Warp's authenticated GraphQL API for account and workspace aggregate counters. Tokscale preserves request counts as message counts and vendor-reported spend as cost, but it never converts requests into synthetic tokens. Warp is excluded from default submit data because the public leaderboard accepts token-attributed usage, not aggregate request counters.

Task-Attributed Report

The report command generates a task-attributed usage breakdown. It uses an LLM to summarize each session into a short title and category, then groups related sessions into high-level task clusters for a bird's-eye view of where your tokens went.

# Basic report (today, default Apple FM summarizer)
tokscale report

# Last 7 days
tokscale report --week

# Use Claude Code as the summarizer backend
tokscale report --week --summarizer claude

# Use Codex, Gemini, or Kiro
tokscale report --summarizer codex
tokscale report --summarizer gemini
tokscale report --summarizer kiro

# Skip LLM summarization (show raw data only)
tokscale report --no-summarize

# Re-summarize from scratch (resets cached summaries in range)
tokscale report --week --rebuild

# Output as JSON
tokscale report --week --json

# Filter by workspace or client
tokscale report --workspace my-project --client opencode

Summarizer backends:

BackendCommandNotes
apple-fm(default)On-device Apple Foundation Models via native Rust FFI (no Python). Enabled in the prebuilt Apple Silicon (macOS arm64) binary; runs on macOS 26+ with Apple Intelligence on, and transparently falls back to a built-in Rust heuristic everywhere else (Intel Macs, older macOS, Linux, Windows) โ€” so the default works on every platform.
claudeclaude -pRequires Claude Code CLI installed and authenticated.
codexcodex --quietRequires Codex CLI installed and authenticated.
geminigemini -pRequires Gemini CLI installed and authenticated.
kirokiro --non-interactiveRequires Kiro CLI installed and authenticated.

How it works:

  1. Sessions are scanned and inserted into a local SQLite wiki database (wiki.db in your platform config dir โ€” e.g. ~/.config/tokscale/ on Linux, ~/Library/Application Support/tokscale/ on macOS)
  2. Unsummarized sessions are sent to the chosen LLM backend in batches, which returns a title, category, description, and complexity for each
  3. A second LLM pass groups all titled sessions into 3โ€“8 high-level task clusters (e.g. "Kiro Auth", "Tokscale Report", "System Config")
  4. Results are cached in the wiki DB โ€” subsequent runs skip already-summarized sessions

Example output:

  Task Group                                  Sess     Tokens     Cost
  โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
  Tokscale Development                          19      4.2B    $22.66
    Add task-attributed report command
    Implement wiki DB schema
    Fix pricing lookup for new models
  System Config                                 28      2.1B    $10.06
    Configure OpenCode workspace settings
    Update shell aliases
  Kiro Auth                                      4    890.5M     $3.10
    Implement JWT refresh flow

Subscription Usage

Tokscale can fetch and display your real-time subscription quota across AI providers. This shows how much of your plan you've used and when limits reset.

# Show subscription usage for all detected providers
tokscale usage

# Output as JSON (for scripting)
tokscale usage --json

# Lightweight terminal output (no TUI)
tokscale usage --light

In the TUI, navigate to the Usage tab to see subscription data. Use [Refresh] to refresh subscription quotas. The keyboard refresh shortcut r uses the same refresh path.

Note: Subscription quotas and balances are vendor-reported โ€” tokscale calls each provider's own quota endpoint and surfaces the response verbatim. Numbers reflect what the provider reports (which is also what shows up in their official dashboards) and are not independently verified against tokscale's own usage tracking.

Supported Providers

ProviderAuth MethodMetricsSetup
ClaudeOAuth (credentials file or macOS Keychain)Session (5hr), Weekly, Opus quotasRun claude to log in
Codex (OpenAI)OAuth (~/.config/codex/auth.json, ~/.codex/auth.json, or saved Tokscale accounts)Session, Weekly quotasUse [Add Codex] in the TUI Usage tab, run codex to log in, or import an existing auth with tokscale codex import --name work
Z.aiAPI key (env var)Token limits, Web SearchesSet ZAI_API_KEY or GLM_API_KEY
AmpAPI key (~/.local/share/amp/secrets.json)Free tier balance, CreditsRun amp to log in
GitHub CopilotGitHub token (keychain or ~/.config/gh/hosts.yml)Premium interactions, Chat quotasRun gh auth login
Grok BuildOAuth (~/.grok/auth.json)Credits, subscription planRun grok login
KimiOAuth (~/.kimi/credentials/kimi-code.json)Session, Weekly quotasRun kimi to log in
MiniMaxAPI key (env var)Prompt quotas per modelSet MINIMAX_API_KEY or MINIMAX_API_TOKEN
MiniMax Token PlanAPI key (env var)Interval + weekly remaining-percent quotas (per region: CN minimaxi.com + Global minimax.io)Set MINIMAX_TOKEN_PLAN_CN_KEY and/or MINIMAX_TOKEN_PLAN_GLOBAL_KEY
Sakana (Fugu)Session cookie (env var or file) โ€” billing-console HTML scrape, no public API5-hour, Weekly quota windows (plan tier + monthly price as metadata)Set SAKANA_SESSION_COOKIE (see docs/providers/sakana.md)

Providers are auto-detected โ€” only those with valid credentials are shown. If a provider is missing, ensure you've logged in or set the required environment variable.

Codex Multi-Account Usage

Tokscale can save multiple Codex OAuth accounts for subscription usage display. The TUI Usage tab groups saved accounts under one Codex section. The active account is marked with *; inactive accounts can be selected with [Use]; account removal uses [Remove] followed by [Confirm].

To add an account without leaving the TUI, click [Add Codex] in the Usage tab. Tokscale starts codex login with a temporary CODEX_HOME, displays the login output in the Usage tab, imports the resulting auth into Tokscale's saved account store, and then refreshes usage. This keeps the login isolated and does not switch the current Codex auth; click [Use] on a saved account when you want Tokscale to write that account into the real Codex auth file.

The CLI commands are still available for scripted or manual account management:

# Save the current Codex auth as a named Tokscale account
tokscale codex import --name work

# List saved Codex accounts
tokscale codex accounts
tokscale codex accounts --json

# Switch the active Codex account and write Codex auth.json
tokscale codex switch work

# Stop tracking a saved Codex account (removes it from Tokscale's store
# only โ€” the codex CLI's own auth.json/login is never touched)
tokscale codex remove personal

# Check subscription usage for the active or a named account
tokscale codex status
tokscale codex status --name personal --json

When saved Codex accounts exist, tokscale usage --json includes structured account metadata for each Codex entry and the TUI displays those entries under one Codex group. Without saved accounts, Tokscale falls back to the current Codex auth discovery path (CODEX_HOME/auth.json, ~/.config/codex/auth.json, ~/.codex/auth.json, then macOS Keychain).

Example Output

โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ Session    85% left  [=========---] resets in 2h 15m     โ”‚
โ”‚ Weekly     72% left  [========----] resets Fri 3pm       โ”‚
โ”‚ Plan     Max 20x                                         โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ
โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ Session    40% left  [=====-------] resets in 4h 30m     โ”‚
โ”‚ Weekly     90% left  [==========--] resets Mon 12am      โ”‚
โ”‚ Account  [email protected]                                โ”‚
โ”‚ Plan     Pro                                             โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

Example Output (--light version)

CLI Light

Configuration

Tokscale stores settings in ~/.config/tokscale/settings.json:

{
  "colorPalette": "blue",
  "includeUnusedModels": false,
  "defaultClients": ["opencode", "claude"],
  "scanner": {
    "extraScanPaths": {
      "codex": [
        "/Users/me/workspace/project-a/.codex/sessions",
        "/Users/me/workspace/project-b/.codex/archived_sessions"
      ],
      "hermes": [
        "/Users/me/.hermes/profiles/director_planning",
        "/Users/me/.hermes/profiles/research/state.db"
      ]
    }
  }
}
SettingTypeDefaultDescription
colorPalettestring"blue"TUI color theme (green, halloween, teal, blue, pink, purple, orange, monochrome, ylgnbu)
includeUnusedModelsbooleanfalseShow models with zero tokens in reports
autoRefreshEnabledbooleanfalseEnable auto-refresh in TUI
autoRefreshMsnumber60000Auto-refresh interval (30000-3600000ms)
nativeTimeoutMsnumber300000Maximum time for native subprocess processing (5000-3600000ms)
defaultClientsstring[][]Client filter applied when no --client/-c flag is passed. Accepts the same ids as --client (e.g. ["opencode", "claude", "synthetic"]). Unknown ids are silently dropped. CLI flags always override this list completely โ€” no merging.
light.writeCachebooleanfalseWhen true, tokscale --light overwrites the TUI cache atomically after rendering. CLI flags --write-cache / --no-write-cache override per-invocation.
minutelyTabEnabledbooleanfalseShow the per-minute Minutely tab in the TUI and aggregate per-minute usage during data loading. Default-off because minute-granularity is a niche/diagnostic view for most users and the per-minute bucketing has a non-trivial cost on large datasets.
scanner.extraScanPathsobject{}Additional per-client scan roots for sessions outside Tokscale's default home-root locations

Use scanner.extraScanPaths for persistent extra roots such as project-level .codex directories, imported Gemini/OpenClaw histories, or Hermes profile databases. Hermes entries may point at a profile directory containing state.db or directly at a state.db file. Tokscale merges these paths with the default scan roots on every run and deduplicates overlapping roots by canonical path.

Use defaultClients to pin a personal default โ€” for example, set it to ["opencode", "claude"] if those are the only clients you use, and tokscale (with no flags) will scope every report to them automatically. Pass --client on the command line to override for a single run.

Enabling the Minutely tab

The Minutely tab shows a per-minute breakdown of token usage and is most useful for diagnosing burst patterns, debugging a single session, or watching activity in near-real-time alongside autoRefreshEnabled. It is hidden by default because the per-minute aggregation runs over every parsed message during data loading, which adds RAM and CPU cost that most users do not need.

To enable it, set minutelyTabEnabled to true in ~/.config/tokscale/settings.json:

{
  "minutelyTabEnabled": true
}

After restart, the Minutely tab appears between Hourly and Stats in the tab strip, and Tab / BackTab / Left / Right navigation cycles through it. Set the flag back to false to hide the tab and skip the aggregation again.

Cache directory layout

The regenerable CLI/TUI/pricing/Wrapped caches now live under ~/.config/tokscale/cache/ (or ${TOKSCALE_CONFIG_DIR}/cache/ when overridden). Integration sync artifacts remain in client-specific cache roots such as ~/.config/tokscale/antigravity-cache/ and ~/.config/tokscale/trae-cache/:

  • tui-data-cache.json โ€” TUI startup cache
  • source-message-cache.bin + source-message-cache.lock โ€” source-message cache + lock file
  • pricing-litellm.json / pricing-openrouter.json โ€” pricing caches
  • opencode-migration.json โ€” OpenCode migration record
  • fonts/ and images/ โ€” Wrapped asset caches

It is safe to delete this directory. Tokscale will recreate and repopulate it on demand.

Environment Variables

Environment variables override config file values. For CI/CD or one-off use:

VariableDefaultDescription
TOKSCALE_NATIVE_TIMEOUT_MS300000 (5 min)Overrides nativeTimeoutMs config
TOKSCALE_API_TOKENunsetTokscale personal API token for non-interactive submit and delete-submitted-data runs. Create one from Settings > API Tokens or save it locally with tokscale login --token tt_xxx.
TOKSCALE_EXTRA_DIRSunsetOne-off extra session roots as client:/abs/path,client:/abs/path

โ€ฆview the full README on GitHub.

// compatibility

Platformscli, api, desktop, web
Operating systemsโ€”
AI compatibilityclaude
LicenseMIT
Pricingopen-source
LanguageRust

// faq

What is tokscale?

๐Ÿ›ฐ๏ธ A CLI tool for tracking token usage from OpenCode, Claude Code, ๐ŸฆžOpenClaw (Clawdbot/Moltbot), Pi, Codex, Gemini, Cursor, AmpCode, Factory Droid, Kimi, and more! โ€ข ๐Ÿ…Global Leaderboard + 2D/3D Contributions Graph. It is open-source on GitHub.

Is tokscale free to use?

tokscale is open-source under the MIT license, so it is free to use.

What category does tokscale belong to?

tokscale is listed under devtools in the Claudeers registry of Claude-compatible tools.

0 views
โ˜… 4,160 stars
unclaimed
updated 15 days ago

// embed badge

tokscale on Claudeers
[![Claudeers](https://claudeers.com/api/badge/tokscale.svg)](https://claudeers.com/tokscale)

// retro hit counter

tokscale hit counter
[![Hits](https://claudeers.com/api/counter/tokscale.svg)](https://claudeers.com/tokscale)

// reviews

// guestbook

0/500

// related in Automation & Workflows

๐Ÿ”“

The API to search, scrape, and interact with the web at scale. ๐Ÿ”ฅ

// automationfirecrawl/โŸจTypeScriptโŸฉโ˜… 143,720โ—ท AGPL-3.0[ claude ]
๐Ÿ”“

The agent that grows with you

// automationNousResearch/โŸจPythonโŸฉโ˜… 211,605โ—ท MIT[ claude ]
๐Ÿ”“

An open-source long-horizon SuperAgent harness that researches, codes, and creates. With the help of sandboxes, memories, tools, skill, subagents and messageโ€ฆ

// automationbytedance/โŸจPythonโŸฉโ˜… 76,016โ—ท MIT[ claude ]
๐Ÿ”“

๐Ÿ—‚ The essential checklist for modern web development, for humans and AI agents

// automationthedaviddias/โŸจMDXโŸฉโ˜… 73,123[ claude ]

// built by

Connectorlinks several projects together across the ecosystem ยท 6 connections
โ†’ see how tokscale connects across the ecosystem