junhoyeo/tokscale
Rust-powered CLI and web dashboard for cross-agent token usage and cost estimates
Automated SPDX check for reference only — not legal advice. Disclaimer
GitHub Star History
Full-history star trajectory from GitHub official history. Switch ranges or hover any point for exact counts.
Evidence-Backed Technical Brief
AI Deep ReviewArchitecture & Core Mechanics
Tokscale is a usage collector and reporting tool, not an agent runtime or an inference gateway. The tokscale npm alias installs @tokscale/cli with the required native Rust package, @tokscale/core. The core scans client-specific sources, parses usage records, and aggregates them for the Ratatui interface, plain tables, or JSON output. The sources are heterogeneous: OpenCode has SQLite and legacy message storage, Codex has live and archived JSONL rollouts, and some clients expose usage through APIs or caches.
The web frontend under packages/frontend is a separate surface for submitted usage, with public profiles at /u/[username], SVG embeds at /api/embed/[username]/svg, a leaderboard, and group pages. Docker Compose pairs the app with PostgreSQL. For integrations, the concrete interfaces are client-specific data ingestion and CLI exports; nothing in this reporting flow requires an MCP server or sending model requests through Tokscale.
Key Capabilities & Differentiators
Tokscale brings clients such as Claude Code, Codex, OpenCode, Gemini CLI, GitHub Copilot CLI, and Cursor into one reporting surface. Its ten default Ratatui views include subscription usage, models, time breakdowns, sessions, and projects; per-minute reporting is opt-in. Reports distinguish input, output, cache-read, cache-write, and reasoning tokens. Pricing is fetched from LiteLLM and cached on disk for one hour, with OpenRouter fallback and Cursor model pricing support.
Grouping choices determine what remains visible: --group-by model consolidates clients and providers, while --group-by client,provider,model keeps them separate. Workspace reports can merge Git worktrees with --merge-worktrees; machine reports can distinguish imported session folders using scanner.extraScanPaths and scanner.machineLabels. For scripts, session-and-model exports expose sessionId, and workspace exports carry workspaceKey and workspaceLabel.
Trade-offs & Limitations
Tokscale is most useful where provider dashboards are least comparable: usage spans multiple agents, and the question is which client, workspace, or session drove it. Provider billing remains authoritative for charges. Tokscale derives estimates from observed usage and price tables, so a reported cost is not an invoice or the amount paid under a subscription. Compared with a gateway that meters requests in transit, Tokscale can analyze existing records without rerouting inference traffic, but coverage depends on what each client logs or exposes.
Scan time and resource usage depend on the size and format of session histories, including any archives imported from other machines. Copying folders and assigning machine labels gives useful attribution, but is not centralized fleet collection. Local reporting also has a different exposure profile from publishing on the leaderboard: review what is submitted and displayed before using submit or autosubmit. Self-hosting gives control of the deployment, but still leaves responsibility for access, database backups, and updates with the operator.
Hardware & Deployment Guide
Run the CLI with npx tokscale@latest, bunx tokscale@latest, or deno x npm:tokscale@latest. Published packages include native binaries for supported targets. A source build uses Bun and the Rust toolchain, with bun run build:core to compile the required native component. For supported offline reports, use tokscale --offline; prefill the pricing cache while connected with tokscale pricing refresh --no-spinner if the offline reports need cost estimates.
For self-hosting, Compose uses the tokscale:latest image built by make docker/build, alongside postgres:16-alpine and a persistent postgres_data volume. The database port is bound to host loopback by default. When replacing the development credentials, keep the three POSTGRES_* settings and DATABASE_URL aligned. On the release side, v4.23.0 added Capy sync, including subscription usage without local session logs; v4.23.1 added Zed usage on ChatGPT subscriptions; v4.24.0 added custom date ranges to public profiles.
--merge-worktrees folds Git worktrees into the parent repository for workspace reporting.--offline runs supported local reports without network requests.Developers and teams using several coding agents who want to compare usage by model, workspace, session, or machine and export the results for internal reporting.
You need invoice-grade reconciliation, enforced spending caps in the request path, or complete visibility into clients that do not log or expose usage.
Quick Start & Installation
# 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
AI Context Briefing (for Claude / Cursor / Windsurf)
Standardized architecture summary & quickstart commands ready to paste into coding agents.
curl -sL https://repoforai.com/repo/junhoyeo/tokscale.md
Active README embeds unlock Hot-Tier 6h Telemetry Refresh automatically (zero pay-to-rank).
Frequently Asked Questions about tokscale
How do I feed Tokscale data into an internal reporting pipeline?
tokscale models --json for model totals or tokscale sessions --json --today for session records. For model-level joins, tokscale models --json --group-by session,model includes a top-level sessionId in each row. These are CLI exports; they do not require an MCP server.Does Tokscale need a GPU, and what drives resource usage?
Can a company self-host or modify Tokscale?
When should I use Tokscale instead of a provider billing or quota dashboard?
Upstream README & Documentation
This profile focuses on independent engineering analysis and live telemetry. Read the full upstream README, changelog, and examples directly on GitHub.
Top 10 Breakout Open-Source AI Repos, Every Thursday
Signal-only digest of fast-growing AI repos, SPDX license alerts, and architecture picks. Zero spam.
Zero spam · 1-click unsubscribe · Privacy Policy