
tokenomics-viewer
View token usage, costs, and rate-limit metrics from Codex and Claude Code sessions
Install with your AI
Paste into Claude Code, Cursor, or any agent — it reads the repo and wires the tool into your project.
Install and set up tokenomics-viewer (git-clone project) into my current project. Found on https://claudeers.com/tokenomics-viewer Repo: https://github.com/ClickHouse/tokenomics-viewer Homepage/docs: — Detected install method: git-clone → git clone https://github.com/ClickHouse/tokenomics-viewer Category: data. Platforms: cli, api, web. Read the repo's README for exact setup and env vars, then install it and wire it into my project. Claudeers Health Verdict: active; community-verified: false. Confirm the source before running anything.
git clone https://github.com/ClickHouse/tokenomics-viewer
// compatibility
| Platforms | cli, api, web |
|---|---|
| Operating systems | — |
| AI compatibility | claude |
| License | ISC |
| Pricing | open-source |
| Language | JavaScript |
Tokenomics Viewer
Local-first cost and token analytics for Codex, Claude Code, and omp (oh-my-pi), powered by ClickHouse. Tokenomics reads local session logs, removes replayed parent traces from forked Codex sessions, normalizes usage, and estimates costs from an editable pricing catalog.
The dashboard and database run on your machine. Tokenomics does not upload session logs or reports.
Quick Start
Install or update Tokenomics on macOS or Linux, run the initial sync, and open the dashboard:
/bin/sh -c "$(curl -fsSL https://raw.githubusercontent.com/skuznetsov/tokenomics-viewer/main/install.sh)"
Automatic setup supports arm64 and x86-64 macOS or Linux. It expects the
standard curl, tar, sed, awk, and find tools; installing the private
Node.js runtime also requires shasum or sha256sum for verification.
The installer does not use sudo or install npm packages. On the first run it:
- Installs Tokenomics under
~/.local/share/tokenomics-viewer. - Adds launchers under
~/.local/bin. - Installs a private Node.js 26 runtime when the system Node.js is too old.
- Installs
clickhousectl, selects stable ClickHouse, and starts the namedtokenomicsserver. - Imports local Codex, Claude Code, and omp sessions into ClickHouse.
- Starts the dashboard on a loopback address and opens it in your browser.
Subsequent launches are one command:
tokenomics-launch
Run the one-line installer again to update Tokenomics. To install or update without launching the application:
TOKENOMICS_NO_LAUNCH=1 /bin/sh -c "$(curl -fsSL https://raw.githubusercontent.com/skuznetsov/tokenomics-viewer/main/install.sh)"
If ~/.local/bin is not on PATH, the installer prints the exact export
command to use. It does not edit shell startup files.
What You Get
- Cost, request, and input/cache/output token totals with compact units.
- Adaptive Token Flow and Project Cost charts from daily down to 15-minute resolution, with pointer-centered wheel zoom, drag pan, range selection, and absolute or relative dates.
- Model-colored points and lines, gaps when a model was not used, and interval tooltips with cost, token, and share breakdowns.
- Model and effort tables with input/cache/output costs, tokens, and shares.
Overviewfor a compact report andAnalystfor project, model, effort, and resource diagnostics.- Deterministic recommended actions with evidence, confidence, and caveats.
- An editable, database-backed provider and model pricing catalog.
- Codex fast-mode credit-equivalent pricing when a session records its service tier.
- Codex rate-limit consumption summaries when snapshots are present.
Cost estimates are analytical aids, not billing statements. Subscription usage, negotiated rates, batch pricing, missing service-tier markers, and unrecognized models can differ from the standard API-equivalent catalog.
Common Commands
Start with ClickHouse, sync changed sessions, and open the browser:
tokenomics-launch
Start without opening a browser, or prefer another dashboard port:
tokenomics-launch --no-open
tokenomics-launch --port 8790
Limit discovery to one source. Tokenomics options follow --:
tokenomics-launch -- --source codex
tokenomics-launch -- --source claude
tokenomics-launch -- --source omp
The default --source all scans Claude Code, Codex, and omp together.
Serve the current ClickHouse database without scanning source files:
tokenomics --db-engine clickhouse --webserver --no-sync
Print a JSON report from the current ClickHouse database:
tokenomics --db-engine clickhouse --json
Scan explicit files or archives directly and print an in-memory report:
tokenomics /path/to/session.jsonl /path/to/archived_sessions.zip
tokenomics --json --output report.json /path/to/sessions
When running from a source checkout, replace tokenomics-launch with
./launcher.js and tokenomics with ./app.js.
ClickHouse
ClickHouse is the default and recommended database. The launcher normally installs and manages it, so manual setup is not required.
The local defaults are:
| Setting | Value |
|---|---|
| Server name | tokenomics |
| HTTP endpoint | http://127.0.0.1:8123 |
| Native TCP port | 9000 |
| Database | tokenomics |
Check and Control the Local Server
chctl --version
chctl local server list
curl -fsS http://127.0.0.1:8123/ping
chctl local client --name tokenomics --query "SELECT version()"
Start or stop the named server:
chctl local server start --name tokenomics --http-port 8123 --tcp-port 9000
chctl local server stop tokenomics
clickhousectl stores local server state under .clickhouse/ in the directory
where it is run. Run control commands from the same directory where you started
tokenomics-launch. If chctl local server list is unexpectedly empty, check
your current directory first.
To install clickhousectl manually:
curl -fsSL https://clickhouse.com/cli | sh
export PATH="$HOME/.local/bin:$PATH"
chctl local use stable
See the official
clickhousectl getting-started guide
for version and local-server management details.
Use an Existing ClickHouse Server
The low-level CLI accepts an alternate endpoint, database, and credentials:
tokenomics --sync --webserver --db-engine clickhouse \
--clickhouse-url http://127.0.0.1:8123 \
--clickhouse-database tokenomics \
--clickhouse-user default
Credentials can also be supplied through TOKENOMICS_CLICKHOUSE_USER and
TOKENOMICS_CLICKHOUSE_PASSWORD. The endpoint and database have matching
TOKENOMICS_CLICKHOUSE_URL and TOKENOMICS_CLICKHOUSE_DATABASE variables.
Prefer environment variables to command-line passwords so credentials do not
appear in shell history or process listings.
Batching, Compression, and Reset
ClickHouse inserts are bounded by both row count and request size: 100,000 rows or 32 MiB by default, whichever is reached first. Tune memory and server load with:
tokenomics --sync --db-engine clickhouse \
--clickhouse-insert-batch-rows 50000 \
--clickhouse-insert-batch-bytes 16MiB
Tokenomics uses ZSTD-based per-column codecs, plus Delta, Gorilla, or T64 where appropriate for timestamps, counters, floats, and flags.
As a last resort, discard and rebuild every Tokenomics-owned ClickHouse table:
tokenomics --sync --db-engine clickhouse --clickhouse-reset
This is destructive for the selected Tokenomics database. Normal upgrades, pricing changes, and incremental syncs do not require a reset.
How Sync Works
With no explicit paths, Tokenomics discovers:
~/.claude/projects/**/*.jsonl${CODEX_HOME:-~/.codex}/sessions/**/*.{jsonl,jsonl.zst}${CODEX_HOME:-~/.codex}/archived_sessions/**/*.{jsonl,jsonl.zst,zip}${OMP_HOME:-~/.omp/agent}/sessions/**/*.jsonl(omp/oh-my-pi)
Use --source claude, --source codex, --source omp, --archives, or --no-archives to
control default discovery. ZIP and Zstandard-compressed rollouts are read
directly without extracting them. If both .jsonl and .jsonl.zst versions
exist during a compression transition, the plain file is read once.
Sync is incremental by source fingerprint. Unchanged sessions are skipped; changed files or archive entries replace their previous normalized data. Codex fork metadata and replay traces are used to avoid counting inherited parent history again in subagent sessions.
All calendar buckets and range boundaries use UTC: day, ISO week, month, year, and the existing 15-minute timeline. A version upgrade that changes a derived field such as UTC calendar keys or service tier causes one full source reimport; later syncs return to normal fingerprint-based incrementality.
ClickHouse source versions are immutable. A sync stages changed sources and a complete source manifest, then publishes one global generation marker last. Reports pin that generation, so a failed multi-source sync leaves the previous complete report visible instead of exposing a partial import.
Pricing revisions are deliberately excluded from source fingerprints. Editing a rate or adding a model updates normalized database costs without reopening JSONL, ZIP, or Zstandard source files.
omp (oh-my-pi)
omp is a coding-agent harness that runs Zhipu AI (Z.AI) GLM models. Each omp
session is one append-only JSONL transcript at
~/.omp/agent/sessions/<project-slug>/<ISO-timestamp>_<session-uuid>.jsonl, with
one subdirectory per working directory.
The default root is relocatable. Override it with --omp-home (or the OMP_HOME
variable), which points at the agent data directory that contains sessions/,
the same role --codex-home plays for Codex. omp's native relocation variables
are also honored: PI_CODING_AGENT_DIR moves ~/.omp/agent outright, and
PI_CONFIG_DIR renames the config root (default .omp).
Ingest walks every .jsonl file under the sessions tree, so a session's parent
transcript and omp's own subagent sidecars are both counted. Totals are flat per
session: each assistant and tool-result line carrying a usage block is summed
into one input, cache-read/write, and output total. omp transcripts carry no
rate-limit or quota snapshots, and subscription-plan detection is not supported
for omp, so no rate-limit summaries appear for it (Codex shows rate-limit
summaries only when its snapshots are present).
Dashboard
The dashboard has three modes:
Overviewshows headline totals, recommendations, Token Flow, and a compact model ranking.Analystadds per-project timelines, the full model/effort table, and Cost & Resource Diagnostics.Settingsedits pricing and analytics configuration.
Each source's usage surfaces under its provider in the model and effort tables.
omp models appear as omp/<model> (for example, omp/glm-5.2), next to Codex
and Claude Code entries.
Token Flow and Project Cost load compact timeline buckets on demand. Hover
anywhere in a chart to inspect the nearest interval; use the wheel to zoom at
the pointer, drag in Pan mode to move through history, drag in Zoom mode to
select a range, and double-click to reset. Relative and absolute date controls
bound the data before interactive zooming.
The dashboard exposes these local endpoints:
/api/summaryfor dashboard aggregates./api/timelinefor range- and project-filtered timeline data./api/reportfor the complete normalized report./api/syncand/api/sync/eventsfor protected sync and live progress.
The server binds to 127.0.0.1 by default. Dashboard-triggered sync and pricing
changes are enabled only on loopback bindings. A server exposed through
0.0.0.0 or a LAN address is intentionally read-only because Tokenomics does
not provide remote-user authentication.
Pricing and Diagnostics
The first database open seeds a packaged pricing catalog from
lib/core/pricing.js. The active catalog and analytics settings then live in
the selected database.
In Settings, you can:
- select a
Work APIprofile for estimated billed cost and an optional monthly USD limit, or aHome Subscriptionprofile for observed quota windows and API-equivalent list-price economics; - edit per-million-token input, cache-write, cache-read, and output rates;
- add providers and models;
- choose exact, prefix, or dated-snapshot model matching;
- select OpenAI short/long context pricing;
- apply a global rate multiplier.
Saves use optimistic revisions. SQLite derives new costs from normalized rows;
ClickHouse creates a compact revisioned cost overlay with one INSERT SELECT
and publishes the configuration marker last. Neither backend rereads session
files after a pricing-only change. Profile-name, profile-mode, and monthly-limit
changes do not alter prices, so they reuse the current pricing revision and do
not create a new ClickHouse cost overlay.
API Cost is the estimated billed amount for an API profile. API Equivalent
applies the same active catalog to subscription usage as a counterfactual value;
it is not an invoice. Subscription windows are shown only when the provider
reports them, and per-quota-point projections require near-complete pricing and
time coverage. The current frontier supports one usage profile per database;
mixed local and work sources require separate databases until source-level
profile assignment is implemented.
Custom providers can be priced only when an ingested record contains the same
provider slug. Adding a catalog row cannot infer provider identity missing from
the source log. Set the pricing basis to custom for negotiated, batch,
subscription, or other non-standard rates.
Diagnostics compare effort levels only inside one provider/model cohort and within the selected model date range. They report usage-event count, tariff coverage, estimated spend, covered input/cache/output per event, amortized spend per output token, cache-read share, and reasoning share. A usage event is not necessarily a user request or completed task, and tariff coverage means only that the local catalog recognized an event. Without outcome or quality data, Tokenomics does not rank effort levels as objectively better or worse.
GPT-5.6 Sol, Terra, and Luna support separate input, cache-write, cache-read, and
output rates. Legacy Codex input_tokens plus cached_input_tokens records are
treated as total input with cached input as a read subset. Explicit
cache_creation_input_tokens plus cache_read_input_tokens records preserve
cache writes separately. Tokenomics does not invent cache-write volume for
legacy records that cannot prove it.
For standard pricing, Codex thread_settings_applied.service_tier=priority
applies the documented ChatGPT fast-mode credit multipliers: 2.5x for
GPT-5.6 and GPT-5.5, and 2x for GPT-5.4
(official fast-mode documentation).
This is deliberately separate from API Priority processing. Missing or unknown
tiers remain standard-priced instead of silently assuming fast mode. In
particular, a forked child rollout that omits its own service tier does not
inherit the parent's tier, so such local logs can understate workspace billing.
Custom pricing is used as entered and does not receive these packaged
multipliers.
codex-auto-review is included at effective rates of $2.50 input, $0.25
cached input, and $15.00 output per million tokens. Those rates are derived
from an observed OpenAI workspace billing export; OpenAI does not currently
publish a separate public model-rate page for this internal model id.
omp (oh-my-pi) cost is estimated from the packaged omp pricing catalog using
official Z.AI (Zhipu AI) GLM rates in USD per million tokens
(source). The catalog covers the
glm-4.5, glm-4.6, glm-4.7, glm-5, glm-5.1, and glm-5.2 models and
their variants, plus free tiers such as glm-4.5-flash and glm-4.7-flash.
omp writes a precomputed cost into each transcript, but Tokenomics ignores it
and re-derives cost from this catalog so unpriced or repriced models stay
accurate.
The proposed compressed session store and project-scoped session viewer are not
implemented. Their intended safety boundary is documented in
docs/PRICING_CONFIGURATION_FRONTIER.md.
Troubleshooting
The First Sync Takes a Long Time
The initial import must parse all discovered sessions and archives. Watch the terminal for per-session progress. Later syncs use source fingerprints and should skip unchanged data. Large ClickHouse inserts are streamed in bounded batches, so increasing the Node.js heap should not be the first response to a slow or failed import.
For a smaller diagnostic run:
tokenomics --sync --db-engine clickhouse --source codex --limit-files 20
chctl Is Not Found
export PATH="$HOME/.local/bin:$PATH"
chctl --version
Add that export to your shell startup file if needed. The Tokenomics installer prints a shell-specific suggestion but does not modify the file itself.
ClickHouse Is Not Reachable
chctl local server list
curl -fsS http://127.0.0.1:8123/ping
Run both commands from the launch directory because local clickhousectl
servers are directory-scoped. If port 8123 belongs to another service, either
stop that service or run Tokenomics directly against another ClickHouse HTTP
endpoint with --clickhouse-url.
The Dashboard Port Is Busy
The launcher tries the preferred port and the next 20 ports. Set another starting point explicitly:
tokenomics-launch --port 8790
An Installer Fails with HTML or <!doctype
Run the current one-line installer again. The launcher validates the
clickhousectl download before executing it and rejects HTML/error responses
instead of passing them to /bin/sh.
Start Without Rescanning
tokenomics --db-engine clickhouse --webserver --no-sync
SQLite Fallback
SQLite remains available for portability, small datasets, or environments where running ClickHouse is not practical. ClickHouse is the tested default and recommended path for large session histories.
Use SQLite for one launch:
tokenomics-launch --sqlite
Install or update and immediately opt out of ClickHouse:
/bin/sh -c "$(curl -fsSL https://raw.githubusercontent.com/skuznetsov/tokenomics-viewer/main/install.sh)" -- --sqlite
Or manage the SQLite database directly:
tokenomics --sync --webserver --db-engine sqlite --db tokenomics.sqlite
tokenomics --webserver --no-sync --db-engine sqlite --db tokenomics.sqlite
Installed-launcher SQLite data is kept across application updates at
~/.local/share/tokenomics-viewer/tokenomics.sqlite.
Privacy and Data
Session logs, reports, and databases can reveal local paths, project names, timestamps, model choices, usage patterns, and estimated spending. Keep the dashboard on loopback and review generated output before publishing it.
The installer writes application versions beneath
~/.local/share/tokenomics-viewer and launchers beneath ~/.local/bin. Local
ClickHouse server data is managed by clickhousectl beneath the launch
directory's .clickhouse/ tree. SQLite files and generated reports in the
repository are ignored by .gitignore.
Development
Requirements:
- Node.js 26 or newer
- No npm dependencies
Run from a source checkout:
./launcher.js
./app.js --help
Run the complete test suite and syntax checks:
node --test
node --check app.js
node --check launcher.js
The implementation is organized by responsibility:
lib/core/contains report state, usage normalization, pricing, aggregation, and rate-limit calculations.lib/ingest/contains source discovery, JSONL parsing, archive readers, and fork/replay handling.lib/storage/contains the SQLite and ClickHouse backends and shared facade.lib/report/,lib/web-server.js, andlib/cli.jscontain presentation, HTTP, and command-line boundaries.test/*.test.jsmirrors those domains; shared fixtures live intest/support/.
License
ISC. See LICENSE.
// faq
What is tokenomics-viewer?
View token usage, costs, and rate-limit metrics from Codex and Claude Code sessions. It is open-source on GitHub.
Is tokenomics-viewer free to use?
tokenomics-viewer is open-source under the ISC license, so it is free to use.
What category does tokenomics-viewer belong to?
tokenomics-viewer is listed under data in the Claudeers registry of Claude-compatible tools.
// embed badge
[](https://claudeers.com/tokenomics-viewer)
// retro hit counter
[](https://claudeers.com/tokenomics-viewer)
// reviews
// guestbook
// related in Data & Analytics
Wrap Antigravity, ChatGPT Codex, Claude Code, Grok Build as an OpenAI/Gemini/Claude/Codex compatible API service, allowing you to enjoy the free Gemini 3.1 P…
Apache Airflow - A platform to programmatically author, schedule, and monitor workflows
Marketing skills for Claude Code and AI agents. CRO, copywriting, SEO, analytics, and growth engineering.
CLI tool for configuring and monitoring Claude Code