Local and SSH remote monitoring tool for AI coding agents — track token usage and costs across Claude Code and Codex
pip install agentic-metric-x==0.8.24 Copy PIP instructions
A local and SSH remote monitoring tool for AI coding agents — like top, but for your coding agents. Track token usage and costs across Claude Code and Codex — with a TUI dashboard and CLI.
Supported platforms: Linux, macOS, and Windows.
All data stays under your control. No telemetry is sent anywhere. By default the tool only reads local agent data files (~/.claude/, ~/.codex/). If SSH remotes are configured, it reads those remote agent data files over SSH and caches a local copy for aggregation.
¹ Codex's input_tokens already includes cached tokens, so the collector stores input_tokens − cached_input_tokens to avoid double-charging at both input and cache-read pricing. GPT-5.6+ additionally reports cache_write_input_tokens (a subset of input): those tokens move to the cache-write bucket at the official 1.25x write rate. Earlier models have no cache-write fee, so their written tokens stay billed as normal input.
uvx agentic-metric-x # Run directly without installing uv tool install agentic-metric-x # Or install persistently uv tool upgrade agentic-metric-x # Upgrade to latest version Usage agentic-metric # Launch TUI dashboard (default when no command given) agentic-metric tui # Launch TUI dashboard explicitly agentic-metric sync # Force sync collectors to the local database agentic-metric sync --rebuild # Rebuild the derived database from source session logs agentic-metric report --today # Today's usage report agentic-metric report --week # This week (Mon → today) agentic-metric report --month # This month agentic-metric report --range 2026-04-01:2026-04-23 # Custom date range agentic-metric today # Shortcut for `report --today` agentic-metric week # Shortcut for `report --week` agentic-metric month # Shortcut for `report --month` agentic-metric history -d 30 # Last N days (default 14) agentic-metric pricing # Manage model pricing The TUI opens cached data first. Press q to cancel unfinished background work and exit; completed transfers and committed usage remain available, and the next sync retries unfinished work. agentic-metric tui --no-sync opens only cached data.
report shows a header with total cost / sessions / turns / tokens / cache-hit rate, a delta vs. the previous equivalent period, a compact provider cost rollup, a heatmap strip (hours for --today, days for --week and --month), plus a default agent × provider × model breakdown, top projects, and optional extra drill-down tables.
Model pricing is used for cost estimation at official standard list rates (ignoring introductory, promotional, and reseller discounts). Builtin standard rates are verified against official provider docs, while a local first-party catalog from models.dev is refreshed daily during normal sync/report/TUI startup to cover newer models automatically. You can add new models, override builtin or catalog prices, configure long-context rates, and configure observable cache-duration rates via CLI. The catalog snapshot is stored in $DATA/agentic_metric/pricing-catalog.json; manual overrides are stored in $DATA/agentic_metric/pricing.json. User overrides take precedence, followed by builtin standard rates and then the cached first-party catalog for models not in the builtin table. A catalog model's own context tiers and premium modes are used when present; catalog rates are not mixed with another model's builtin context tiers. Explicit service_tier markers and model-name mode suffixes use the same rates. The TUI shows cached data before checking for pricing updates in the background. Failed automatic checks retry after 60 seconds; manual updates bypass this delay. Changes to unused catalog models preserve parsing checkpoints. Effective pricing changes for stored models still trigger repricing and safe checkpoint invalidation.
Run agentic-metric accounts report or press a in the TUI for account totals. The CLI defaults to the current month; the TUI uses its selected date range. Run agentic-metric sync to collect new usage. --json preserves full account keys and distinguishes unpriced usage from a zero-dollar estimate.
New WCC Codex transcripts carry a request-bound anonymous account fingerprint. Account switches within a session stay separate. The same explicit marker format accepts provider: "claude" for sources that supply Claude account fingerprints; native Claude Code logs do not currently provide reliable historical identity. The tool never reads OAuth tokens or assigns history to the currently logged-in account. Configure WCC's projects directory as a Claude Code collector root.
For a directory dedicated to one account, explicitly set its account_key:
{ "collectors": { "claude_code": {"roots": [{"path": "~/.claude-personal", "account_key": "manual:cc-personal"}]}, "codex": {"roots": [{"path": "~/.codex-work", "account_key": "manual:codex-work"}]} } } This user-declared binding applies to otherwise unattributed usage in that root, including its history. Explicit request markers take precedence. Changing the binding reparses that scope without changing total usage or manual payments. Set remote bindings explicitly: local account bindings are never inherited by another host. Unmarked logs without a binding remain Unknown account; a mixed-account directory cannot be separated reliably without request markers. Account keys accept codex: , claude: , or manual: . Use agentic-metric accounts set manual:cc-personal --label "Personal CC" to name the account.
agentic-metric accounts report --start 2026-10-01 --end 2026-10-31 --json agentic-metric accounts set "codex: " --label "Work" --plan "Pro 200" agentic-metric accounts payments add "codex: " 200 --date 2026-10-01 --kind subscription --plan "Pro 200" --id invoice-october agentic-metric accounts payments add "codex: " 40 --date 2026-10-12 --kind credits --currency USD agentic-metric accounts payments list --start 2026-10-01 --end 2026-10-31 agentic-metric accounts payments remove invoice-october Replace the fingerprint with the exact key printed by accounts report --json. For an account without attributable logs, use a key such as manual:personal; creating a profile or payment alone does not reassign unknown usage. Profile plan labels are manual, current labels, not verified historical entitlements. Each payment retains its own optional plan label.
API-equivalent cost and cash outlay are separate. The ledger records only payments you enter, by payment date: no recurring charges are generated, no proration is inferred, and a credits purchase is not measured credit consumption. Currencies are totaled separately without conversion; amounts accept at most two decimal places. Reusing --id with identical details is idempotent; conflicting details are rejected. No payment records means actual spend is unknown, not zero. Subscription allowance multipliers (such as Fast 2.5× / Ultrafast 8×) are not applied to the API-equivalent cost calculation.
agentic-metric pricing update # Refresh the models.dev catalog now agentic-metric pricing list # List pricing for used/configured models agentic-metric pricing list --all # List full builtin + catalog pricing agentic-metric pricing list gemini # Filter models by name substring agentic-metric pricing list --source user # Filter by source (builtin/catalog/user) agentic-metric pricing set deepseek-r2 -i 0.5 -o 2.0 # Add a new model agentic-metric pricing set claude-opus-4-7 -i 4.0 -o 20.0 -cr 0.4 -cw 5.0 # Override builtin agentic-metric pricing reset deepseek-r2 # Reset one model to builtin agentic-metric pricing reset --all # Reset all overrides Long-context pricing Some models charge higher rates when a single request exceeds a token threshold. The tool applies these rates per-event when collectors provide event-level usage.
agentic-metric pricing long-context set gpt-5.5 --threshold 272000 -i 10 -o 45 -cr 1 -cw 0 agentic-metric pricing long-context reset gpt-5.5 # Remove user override agentic-metric pricing long-context disable gpt-5.5 # Disable builtin rule agentic-metric pricing long-context enable gpt-5.5 # Re-enable builtin rule Cache-duration pricing Anthropic charges different cache-write prices depending on cache TTL. By default the tool uses the 5-minute rate; override for 1-hour cache duration when applicable.
agentic-metric pricing cache set claude-sonnet-4 --write-1h 6 # Set 1h cache write price agentic-metric pricing cache reset claude-sonnet-4 # Remove override Unknown models are not priced by default. Their usage and tokens remain in the report, but cost totals exclude them until you add explicit pricing with agentic-metric pricing set. The CLI and TUI show a Pricing missing warning with the affected model names instead of mixing ? into numeric cost fields.
Costs are always API list prices; per-request costs reported by gateways in session logs (which may include vendor discounts) are ignored. Non-standard speed/priority modes are billed from the official premium tables when the history exposes an explicit marker: Codex sessions record thread_settings_applied.service_tier (priority, or fast which bills at the OpenAI priority token rate), and Claude sessions record the per-request usage.speed served by the API (fast mode premium for supported Opus models). History without such markers is billed at standard rates.
After a pricing change, the command resyncs local history so event-level costs such as long-context requests are recalculated from the original JSONL data.
If cached history ever looks stale after changing roots/providers, run agentic-metric sync --rebuild. This deletes only this tool's derived SQLite database and rebuilds it from the original Claude Code and Codex session files; config.json, pricing.json, and agent data directories are left untouched.
Shown in the footer as: PgUp/PgDn Range · ←→ View · . Now · r Auto-refresh · p Pricing · ? Help · q Quit.
Refresh intervals can be overridden in the config file ($DATA/agentic_metric/config.json):
{ "intervals": { "data_sync": 300, "auto_refresh": 30 } } Builtin Model Pricing Prices are USD per 1M tokens. Verified against official pricing docs (2026-04-25; Claude Fable 5 on 2026-06-12; Claude Opus 4.8 on 2026-06-02; Claude Opus 5 on 2026-07-28; GPT-5.6 on 2026-07-31, after OpenAI's 2026-07-30 price cut; GPT-6 Sol/Luna and Claude Opus 5.5 on 2026-09-23). The table uses regular published rates, excluding time-limited promotions.
| claude-fable-5-1 | $10.00 | $50.00 | $0.25 | $12.50 | | claude-fable-5 | $10.00 | $50.00 | $1.00 | $12.50 | | claude-sonnet-5 | $2.00 | $10.00 | $0.20 | $2.50 | | claude-opus-5-5 | $4.00 | $20.00 | $0.20 | $5.00 | | claude-opus-5 / claude-opus-4-8 / claude-opus-4-7 / claude-opus-4-6 / claude-opus-4-5 | $5.00 | $25.00 | $0.50 | $6.25 | | claude-opus-4-1 / claude-opus-4 / claude-3-opus | $15.00 | $75.00 | $1.50 | $18.75 | | claude-sonnet-4-6 / claude-sonnet-4-5 / claude-sonnet-4 / claude-sonnet-3-7 / claude-3-7-sonnet / claude-3-5-sonnet | $3.00 | $15.00 | $0.30 | $3.75 | | claude-haiku-4-5 | $1.00 | $5.00 | $0.10 | $1.25 | | claude-haiku-3-5 / claude-3-5-haiku | $0.80 | $4.00 | $0.08 | $1.00 | | claude-3-haiku | $0.25 | $1.25 | $0.03 | $0.30 |
| gpt-6-astra | $10.00 | $50.00 | $1.00 | $12.50 | | gpt-6-sol | $2.00 | $10.00 | $0.20 | $2.50 | | gpt-6-luna | $0.10 | $0.50 | $0.01 | $0.125 | | gpt-5.6-sol | $5.00 | $30.00 | $0.50 | $6.25 | | gpt-5.6-terra | $2.00 | $12.00 | $0.20 | $2.50 | | gpt-5.6-luna | $0.20 | $1.20 | $0.02 | $0.25 | | gpt-5.5 | $5.00 | $30.00 | $0.50 | — | | gpt-5.4-mini | $0.75 | $4.50 | $0.075 | — | | gpt-5.4-nano | $0.20 | $1.25 | $0.02 | — | | gpt-5.4 | $2.50 | $15.00 | $0.25 | — | | gpt-5.2-codex / gpt-5.2-chat-latest / gpt-5.2 / gpt-5.3-codex / gpt-5.3-chat-latest / gpt-5.3 | $1.75 | $14.00 | $0.175 | — | | gpt-5.1-codex-max / gpt-5.1-codex / gpt-5.1-chat-latest / gpt-5.1 / gpt-5-codex / gpt-5-chat-latest / gpt-5 | $1.25 | $10.00 | $0.125 | — | | gpt-5-mini | $0.25 | $2.00 | $0.025 | — |
| grok-4.7 / grok-4.6 | $2.00 | $6.00 | $0.50 | — | | grok-4.5 | $2.00 | $6.00 | $0.30 | — |
| gemini-4-neon | $3.00 | $15.00 | $0.15 | — | | gemini-4-carbon / gemini-4-argon | $4.00 | $20.00 | $0.20 | — | | gemini-4-hydrogen | $1.50 | $7.50 | $0.075 | — | | gemini-3.8-flash / gemini-3.7-flash / gemini-3.6-flash | $1.50 | $7.50 | $0.15 | — | | gemini-3.5-flash | $1.50 | $9.00 | $0.15 | — | | gemini-3.1-pro / gemini-3-pro | $2.00 | $12.00 | $0.20 | — | | gemini-3.1-flash-lite | $0.25 | $1.50 | $0.025 | — | | gemini-3-flash | $0.50 | $3.00 | $0.05 | — | | gemini-2.5-flash | $0.30 | $2.50 | $0.03 | — | | gemini-2.5-flash-lite | $0.10 | $0.40 | $0.01 | — | | gemini-2.0-flash | $0.10 | $0.40 | $0.025 | — | | gemini-2.0-flash-lite | $0.075 | $0.30 | $0.00 | — |
Run agentic-metric pricing list for the full table including your overrides.
src/agentic_metric/ ├── cli.py # Typer CLI commands and Rich report rendering ├── config.py # Platform paths, collector roots, SSH remote specs ├── pricing.py # Builtin + user pricing, cost estimation engine ├── formatting.py # Pure formatting helpers (cost/tokens, source/host labels) ├── collectors/ │ ├── __init__.py # Collector registry and base class │ ├── claude_code.py # Claude Code JSONL history parser │ ├── codex.py # Codex JSONL history parser │ └── remote.py # SSH-backed wrapper: mirror a remote root, then parse ├── store/ │ ├── __init__.py │ ├── database.py # SQLite database (sessions, session_usage buckets) │ └── aggregator.py # Query layer: range totals, heatmaps, breakdowns └── tui/ ├── __init__.py ├── app.py # Textual TUI application ├── widgets.py # Custom TUI widgets (summary cells, heatmap, trend) ├── help_screen.py # Keybinding cheatsheet modal ├── pricing_screen.py # Pricing for used models, with in-app price update └── styles.tcss # Textual CSS Data flow Collectors read agent data files (~/.claude/, ~/.codex/) and sync session history into the database. Database stores sessions and per-day session_usage buckets in SQLite. Aggregator runs SQL queries for reports (range totals, heatmaps, breakdowns by agent/model/project). CLI renders Rich tables and panels. TUI uses Textual for the dashboard. Pricing engine calculates costs per-event (long-context aware). Data Sources Paths differ by platform. $DATA refers to:
By default, Claude Code honors CLAUDE_CONFIG_DIR and Codex honors CODEX_HOME. To scan multiple roots, assign a provider explicitly, or include SSH remotes, create this tool's own config file:
{ "collectors": { "codex": { "roots": [ {"path": "~/.codex", "provider": "openai"}, {"path": "~/.codex-custom", "provider": "custom"} ] }, "claude_code": { "roots": [ {"path": "~/.claude"}, {"path": "~/.claude-alt"}, {"path": "~/.claude-provider-b", "provider": "provider-b"} ] } }, "remotes": [ { "name": "remote-dev", "host": "remote-dev", "collectors": { "codex": { "roots": [{"path": "~/.codex", "provider": "openai"}] }, "claude_code": { "roots": [{"path": "~/.claude"}] } } } ] } The default config path is $DATA/agentic_metric/config.json; set AGENTIC_METRIC_CONFIG to point at another JSON file. For Claude Code / WCC roots, auto_provider is enabled by default: model ids carrying routing prefixes (codex/ , google-ai/ , cursor/ , custom/ / ) split automatically into their sub-provider, while bare model names fall back to the root's configured provider. You can set "auto_provider": false to force one static provider per root, or add ordered "provider_rules": [{"prefix": "...", "provider": "..."}] overrides. Codex roots without a provider still fall back to the JSONL model_provider.
Remote entries use your existing ssh config. host may be an SSH alias or a hostname; optional fields are name, user, port, timeout, ssh_options, and archived (set "archived": true to stop SSH syncing for a retired host while keeping its historical data and local cache intact). If a remote does not configure collector roots, it reuses the local collector root configuration; with no local config that means ~/.claude and ~/.codex on the remote. Remote sync expands ~ on the remote host, reads projects/ and sessions/ over SSH, stores a cache under $DATA/agentic_metric/remote-cache/, and aggregates those rows with local usage. It also keeps a remote file manifest in the cache, so repeated syncs only download changed session/index files instead of transferring full agent directories again. When both hosts have rsync, ordinary remote paths use verified block deltas instead of retransferring growing logs in full; otherwise sync uses SSH/tar. The remote files are read-only in either case. Downloads run in size-bounded batches, with at most four rsync transfers across all roots. The largest batches start first, and the manifest advances after each completed batch, so timeout applies per batch and interrupted syncs resume. A recent rsync version can substantially improve large-log delta performance; it is optional, and the system rsync or SSH/tar fallback remains supported. Claude parsing checkpoints persist in the local database. Growing logs verify the complete previously parsed prefix before processing new records; rewrites, truncation, replay ownership, pricing, or timezone changes trigger a full parse. The first sync after upgrade builds checkpoints for affected files; subsequent syncs reuse them. Cached files that disappear from the remote manifest are moved under .stale/ and no longer parsed; usage already recorded from them stays in the database, so historical reports keep it. If a remote path is missing, that collector is skipped rather than reusing old cache contents. CLI/TUI totals stay merged, while breakdowns and top projects retain the host/source dimension.
Reports keep the headline totals merged across local and remote data. Detail tables use a compact Source label: local rows show the root (~/.codex), and remote rows show host:root (remote-dev:~/.codex). Top projects use the same prefix for remote paths (remote-dev:/workspace/project) so matching local and remote project paths are never silently merged. Multiple local roots that share a project path collapse into one row (they would render identically), so the same project worked on through two local agent homes is not double-listed. --full adds a provider rollup by source; the default report keeps the source × agent × provider × model breakdown plus top projects.
All aggregated data is stored locally in $DATA/agentic_metric/data.db (SQLite).
git clone https://github.com/xihuai18/agentic-metric cd agentic-metric pip install -e ".[dev]" pytest License MIT — see LICENSE.
Forked from MrQianjinsi/agentic-metric (v0.1.8 upstream). See CHANGELOG.md for what changed in this fork.
Both files in this release have provenance metadata.
ai claude-code codex coding-agent metrics tui
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 19, 2026.
Both files in this release have been uploaded with provenance metadata.
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.




