Skip to main content

Query Codex CLI token usage from local session JSONL logs.

Project description

codex-stat

一个可以读取本地 ~/.codex/sessions 日志、统计 Codex token 用量并估算价格的命令行工具。

可以通过 uvx codex-stat 直接调用。

功能

  • 统计 input_tokenscached_input_tokensoutput_tokensreasoning_output_tokens
  • today7d30dall 或自定义日期范围查询
  • 输出人类可读报表或 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


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)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

codex_stat-0.1.0-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

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

Hashes for codex_stat-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0c52a20db739130829628b8140d91e98845e959b8b70928b69c26102249438a4
MD5 e60f18e16afd430fe5eebaa13c5f5d4c
BLAKE2b-256 f34887afdc3caff0d2e5ad4e9ecf459616642dd58cd59e389304b2b00436d5c4

See more details on using hashes here.

File details

Details for the file codex_stat-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for codex_stat-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d5ea484f7082565484f2a2a36821d0ec36e591d74cdaa9d91e101ddcc1689914
MD5 dfbca367b28e7baf5c5d3b8227b0dca6
BLAKE2b-256 5699d3e93b468521539a6ff6a6e193f8f8fa4537e7065db0e3e6ddcb56a62644

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page