dlukt/codex-usage-stats

Codex message usage statistics as markdown

★ 0Forks 0GoGitHub ↗Compare

README

Codex Usage Stats

Generate usage statistics from your OpenAI Codex CLI data.

Features

  • Message Statistics: Total messages, daily/monthly breakdowns, top 10 busiest days
  • Token Usage: Input, output, cached, and reasoning tokens per month
  • Session Tracking: Number of sessions per month
  • Copilot Pro Comparison: Compare your usage against the 1,500 messages/month limit

Requirements

Choose either:

  • Python: Python 3.6+ (no external dependencies)
  • Go: Go 1.18+ (no external dependencies)

Usage

Python

python3 generate-stats.py

Go

# Build once
go build -o codex-usage-stats

# Run
./codex-usage-stats

Or run directly:

go run main.go

Output is written to ~/.codex/usage-statistics.md.

Data Sources

The script reads from:

File/Directory Description
~/.codex/history.jsonl User message history with timestamps
~/.codex/sessions/YYYY/MM/DD/*.jsonl Session files with token usage data

Output Sections

  1. Summary - Total messages, active days, date range, averages
  2. Token Usage Summary - Total tokens broken down by type
  3. Monthly Breakdown - Messages and sessions per month
  4. Monthly Token Usage - Token consumption per month
  5. Top 10 Busiest Days - Highest activity days
  6. Daily Breakdown - All active days grouped by month
  7. Usage Pattern Analysis - Copilot Pro quota comparison

Sample Output

## Token Usage Summary

| Metric | Tokens |
|--------|--------|
| **Total Tokens** | 4,369,677,393 (4369.7M) |
| **Input Tokens** | 4,345,071,360 (4345.1M) |
| **Output Tokens** | 24,334,033 (24.3M) |
| **Cached Input** | 4,197,451,520 (4197.5M) |
| **Reasoning Output** | 16,294,128 (16.3M) |

Token Types Explained

Type Description
Input Tokens Tokens sent to the model (prompts, context)
Cached Input Input tokens served from cache (faster, cheaper)
Output Tokens Tokens generated by the model
Reasoning Output Tokens used for chain-of-thought reasoning

License

MIT

Contributors

dlukt

Issues