Local Codex cost estimator. It scans Codex Desktop JSONL logs under ~/.codex,
extracts token usage snapshots, and estimates USD cost from prices.json.
This is an estimate, not an official bill. Codex subscription accounting may differ from API list pricing, and local logs do not expose every possible plan-specific adjustment. The useful part is relative visibility: which sessions, workspaces, or days are consuming the most tokens.
This tool runs locally and reads local Codex session logs. Those logs can
contain prompts, workspace paths, model names, and timing metadata. The
generated dashboard.html and CSV reports are ignored by git by default
because they may include private local usage details.
Review any screenshots, exported reports, or generated dashboards before sharing them publicly.
python3 scan_codex_cost.py --today
python3 scan_codex_cost.py --since 2026-05-01 --group-by session
python3 scan_codex_cost.py --since 2026-05-01 --group-by turn --limit 30
python3 scan_codex_cost.py --cwd /path/to/workspace --group-by day
python3 scan_codex_cost.py --today --export-csv reports/codex-cost-today.csvGenerate a self-contained local HTML dashboard:
python3 generate_dashboard.py
open dashboard.htmlBy default this includes records from the first day of the current month through now. To change the period:
python3 generate_dashboard.py --since 2026-05-01
python3 generate_dashboard.py --since 2026-05-01 --fallback-model gpt-5.3-codexThe dashboard embeds a data snapshot. Re-run generate_dashboard.py whenever
you want to refresh it.
For live updates, run the local server instead:
python3 serve_dashboard.py --openThen leave the terminal running. The browser page calls /api/data every 30
seconds and keeps your current filters while refreshing the charts and table.
The session table defaults to newest-opened sessions first, with cost, token,
and turn-count sorting still available. Stop it with Ctrl-C.
input_tokens: total input tokens from local Codex logs.cached_input_tokens: subset of input tokens logged as cached.billable_input_tokens:input_tokens - cached_input_tokens.output_tokens: output tokens from local Codex logs. Reasoning tokens are already included inoutput_tokensin the observed Codex log format.estimated_usd: local estimate usingprices.json.
prices.json was seeded from the OpenAI API pricing page checked on
2026-05-15: https://openai.com/api/pricing/.
Update prices.json when model pricing changes or when you want to use a
custom internal rate.
gpt-5.3-codex-spark is intentionally not priced in the default table because
the OpenAI Codex rate card describes it as a research preview with non-final
rates. Use --fallback-model gpt-5.3-codex if you want a rough placeholder.