Fast Codex usage analyzer written in Rust.
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source "$HOME/.cargo/env"If you want the Rust toolchain to be available in every new shell, add this to your shell profile:
export PATH="$HOME/.cargo/bin:$PATH"This is the preferred global setup. If $HOME/.cargo/bin is already in your PATH, you usually do not need an alias at all.
git clone <your-repo-url>
cd codex-usage
cargo install --path .By default, Cargo installs the binary to:
$HOME/.cargo/bin/codex-usageBefore using the command, it is worth checking whether your shell resolves codex-usage to the Cargo binary, a shell alias, or something else:
type -a codex-usage
type codex-usage
command -v codex-usageIf codex-usage is already aliased to another command, remove that alias in the current shell:
unalias codex-usage
hash -rTo make the change persistent for future terminals, remove or replace the alias in your shell profile such as ~/.zshrc, ~/.bashrc, or ~/.config/fish/config.fish.
If you still want to keep an alias, note that this command only affects the current terminal session:
alias codex-usage="$HOME/.cargo/bin/codex-usage"To make that alias persistent globally for your user, add it to your shell profile and reload the shell:
echo 'alias codex-usage="$HOME/.cargo/bin/codex-usage"' >> ~/.zshrc
source ~/.zshrcFor most setups, using PATH is cleaner than using an alias because every new shell will resolve codex-usage directly to the installed binary.
codex-usage
codex-usage daily
codex-usage daily --split-by-model
codex-usage monthly
codex-usage monthly --split-by-model
codex-usage sessionsUse --split-by-model to emit separate daily or monthly rows when multiple models were used in the same period.
codex-usageuses the LiteLLM pricing catalog when available.- Some model rules are intentionally pinned inside the app before catalog lookup.
gpt-5.3-codex-sparkis always treated as zero-cost.- If a model is still unresolved after those steps,
codex-usagefalls back to built-in family defaults.
Based on previous local measurements on the same machine, codex-usage was substantially faster than ccusage-codex for the JSON daily report path.
codex-usage daily --json --refresh-cache: about3.27scodex-usage daily --json: about0.42sccusage-codex daily --json: about109.93s
In those runs, codex-usage was roughly 33x faster on a cold run and about 260x faster on a warm run.
codex-usage is faster mainly because it does less work per session file and keeps the hot path simple.
- It scans JSONL files with a streaming reader instead of loading whole files into memory first.
- It uses a cheap byte-pattern prefilter to skip irrelevant lines before JSON deserialization.
- It only parses the event types needed for usage accounting.
- It avoids expensive global event reshuffling and aggregates usage directly during scanning.
- It processes session files in parallel with Rayon.
- It keeps binary cache files for parsed session summaries, so repeated runs can reuse unchanged files.
- It narrows the candidate file set early when date filters are provided.
codex-usage daily --since 20260301 --until 20260306codex-usage monthly --json
codex-usage sessions --jsoncodex-usage --refresh-cache
codex-usage daily --refresh-cachecodex-usage daily --codex-home /path/to/.codexYou can also set CODEX_HOME in your shell environment.
codex-usage daily --timezone UTC