Query Codex CLI token usage from local session JSONL logs.
Project description
codex-stat
一个可以读取本地 ~/.codex/sessions 日志、统计 Codex token 用量并估算价格的命令行工具。
可以通过 uvx codex-stat 直接调用。
功能
- 统计
input_tokens、cached_input_tokens、output_tokens、reasoning_output_tokens - 按
today、7d、30d、all或自定义日期范围查询 - 输出人类可读报表或 JSON
- 按每 1M token 单价估算成本
本地开发
uv run codex-stat --range today
uv run codex-stat --range 7d --limit 5
uv run codex-stat --from-date 2026-03-01 --to-date 2026-03-06
uv run codex-stat --range today --json
成本估算
uv run codex-stat \
--range today \
--input-price-per-m 2.5 \
--cached-input-price-per-m 1.25 \
--output-price-per-m 10
估价公式:
- 非缓存输入 =
input_tokens - cached_input_tokens - 总费用 = 非缓存输入费用 + 缓存输入费用 + 输出费用
reasoning_output_tokens仅做展示,通常已经包含在output_tokens中
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
codex_stat-0.1.0.tar.gz
(5.9 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file codex_stat-0.1.0.tar.gz.
File metadata
- Download URL: codex_stat-0.1.0.tar.gz
- Upload date:
- Size: 5.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.22
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0c52a20db739130829628b8140d91e98845e959b8b70928b69c26102249438a4
|
|
| MD5 |
e60f18e16afd430fe5eebaa13c5f5d4c
|
|
| BLAKE2b-256 |
f34887afdc3caff0d2e5ad4e9ecf459616642dd58cd59e389304b2b00436d5c4
|
File details
Details for the file codex_stat-0.1.0-py3-none-any.whl.
File metadata
- Download URL: codex_stat-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.22
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d5ea484f7082565484f2a2a36821d0ec36e591d74cdaa9d91e101ddcc1689914
|
|
| MD5 |
dfbca367b28e7baf5c5d3b8227b0dca6
|
|
| BLAKE2b-256 |
5699d3e93b468521539a6ff6a6e193f8f8fa4537e7065db0e3e6ddcb56a62644
|