Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

modelUsage

modelUsage is a Rust CLI for local token/cost reports from Claude Code, Codex, GitHub Copilot CLI, and OpenCode.

Example output

modelUsage --claude

modelUsage v0.1.7
Daily Token Usage Report

┌────────────┬─────────────────────────────────┬────────┬─────────┬─────────────┬────────────┬──────────────┬────────────┐
│ Date       ┆ Models                          ┆ Input  ┆ Output  ┆ Cache Write ┆ Cache Read ┆ Total Tokens ┆ Cost (USD) │
╞════════════╪═════════════════════════════════╪════════╪═════════╪═════════════╪════════════╪══════════════╪════════════╡
│ 2026-02-03 ┆ haiku-4-5, opus-4-5            ┆    384 ┆     254 ┆     265,854 ┆  3,350,740 ┆    3,617,232 ┆ $2.07      │
├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌━┼╌╌╌╌╌╌╌╌╌╌╌╌━┼╌╌╌╌╌╌╌╌╌╌━━┼╌╌╌╌╌╌╌╌╌╌╌╌━━┼╌╌╌╌╌╌╌╌╌╌━━┤
│ 2026-02-04 ┆ haiku-4-5, sonnet-4-6          ┆  1,248 ┆     912 ┆     120,440 ┆  1,852,103 ┆    1,974,703 ┆ $1.08      │
├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌━┼╌╌╌╌╌╌╌╌╌╌╌╌━┼╌╌╌╌╌╌╌╌╌╌━━┼╌╌╌╌╌╌╌╌╌╌╌╌━━┼╌╌╌╌╌╌╌╌╌╌━━┤
│ Total      ┆                                 ┆  1,632 ┆   1,166 ┆     386,294 ┆  5,202,843 ┆    5,590,935 ┆ $3.15      │
└────────────┴─────────────────────────────────┴────────┴─────────┴─────────────┴────────────┴──────────────┴────────────┘

Total: 2 days, 5,590,935 tokens, $3.15

modelUsage --codex

modelUsage v0.1.7
Daily Token Usage Report

┌────────────┬───────────────┬────────────┬───────────┬───────────┬─────────────┬──────────────┬────────────┐
│ Date       ┆ Models        ┆ Input      ┆ Output    ┆ Reasoning ┆ Cache Read  ┆ Total Tokens ┆ Cost (USD) │
╞════════════╪═══════════════╪════════════╪═══════════╪═══════════╪═════════════╪══════════════╪════════════╡
│ 2026-02-03 ┆ gpt-5.2       ┆    601,961 ┆   151,564 ┆   134,331 ┆   4,275,328 ┆    5,028,853 ┆ $11.41     │
├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌━━┼╌╌╌╌╌╌╌╌╌╌━━┼╌╌╌╌╌╌╌╌╌╌━┼╌╌╌╌╌╌╌╌╌╌━┼╌╌╌╌╌╌╌╌╌╌╌━━┼╌╌╌╌╌╌╌╌╌╌╌╌━━┼╌╌╌╌╌╌╌╌╌╌━━┤
│ 2026-02-10 ┆ gpt-5.3-codex ┆  2,344,719 ┆   458,072 ┆    88,263 ┆ 112,996,096 ┆  115,798,887 ┆ $30.29     │
├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌━━┼╌╌╌╌╌╌╌╌╌╌━━┼╌╌╌╌╌╌╌╌╌╌━┼╌╌╌╌╌╌╌╌╌╌━┼╌╌╌╌╌╌╌╌╌╌╌━━┼╌╌╌╌╌╌╌╌╌╌╌╌━━┼╌╌╌╌╌╌╌╌╌╌━━┤
│ 2026-03-03 ┆ gpt-5.3-codex ┆ 11,671,017 ┆   495,864 ┆   115,215 ┆ 137,844,096 ┆  150,010,977 ┆ $51.49     │
├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌━━┼╌╌╌╌╌╌╌╌╌╌━━┼╌╌╌╌╌╌╌╌╌╌━┼╌╌╌╌╌╌╌╌╌╌━┼╌╌╌╌╌╌╌╌╌╌╌━━┼╌╌╌╌╌╌╌╌╌╌╌╌━━┼╌╌╌╌╌╌╌╌╌╌━━┤
│ Total      ┆               ┆ 14,617,697 ┆ 1,105,500 ┆   337,809 ┆ 255,115,520 ┆  270,838,717 ┆ $93.19     │
└────────────┴───────────────┴────────────┴───────────┴───────────┴─────────────┴──────────────┴────────────┘

Total: 3 days, 270,838,717 tokens, $93.19

Install

Run in this repository:

cd /home/ashyearl/workspace/rust/modelUsage
cargo run -- --claude

Install to ~/.cargo/bin:

cargo install --path /home/ashyearl/workspace/rust/modelUsage --force

Download prebuilt archives from GitHub Releases:

  • modelUsage-linux-x86_64.tar.gz
  • modelUsage-linux-aarch64.tar.gz
  • modelUsage-macos-aarch64.tar.gz
  • modelUsage-windows-x86_64.tar.gz
  • modelUsage-windows-aarch64.tar.gz

Linux/macOS example:

tar -xzf modelUsage-linux-x86_64.tar.gz
install -m 755 modelUsage ~/.local/bin/modelUsage

Usage

modelUsage                 # latest 30 days, Claude + Codex + Copilot + OpenCode
modelUsage --claude        # Claude only
modelUsage --codex         # Codex only
modelUsage --copilot       # Copilot CLI only
modelUsage --opencode      # OpenCode only
modelUsage --project       # project summary (grouped by cwd only)
modelUsage --daily --project    # date -> project
modelUsage --project --daily    # project -> date
modelUsage --all           # full history
modelUsage --tz Asia/Shanghai   # aggregate by IANA timezone
modelUsage --tz UTC+8           # aggregate by UTC offset shortcut
modelUsage --json          # JSON output
modelUsage --refresh       # rebuild stats cache
modelUsage --update        # download and replace current binary

Timezone accepts:

  • IANA names, e.g. Asia/Shanghai
  • offset shortcuts, e.g. UTC+8, utc+8, +08:00, -3:30
  • local (default)
  • Codex source roots include both ~/.codex/sessions and ~/.codex/archived_sessions when present.
  • Copilot CLI settled usage is read from ~/.copilot/session-state/*/events.jsonl (requires Copilot CLI v0.0.422+).
  • Copilot cache write and in-progress session usage can be cross-filled from OTel JSONL. By default modelUsage checks COPILOT_OTEL_FILE_EXPORTER_PATH, then falls back to ~/.copilot/otel.jsonl.
  • OpenCode usage is read from its session database at ~/.local/share/opencode/opencode.db (via opencode db path); the db is opened read-only so a running OpenCode is never blocked. Cost is computed locally from pricing/official-pricing.json, so plan-profile models without a token price (e.g. glm-5.2) show N/A.
  • GPT text/code pricing covers GPT-6 Sol, GPT-6.1 Sol, GPT-6 Luna, GPT-5 variants, and GPT-4.x/legacy models listed in PRICING.md. Model versions remain distinct. Codex costs use the current bundled Standard rates, including published long-context multipliers for requests with more than 272,000 input tokens. Other sources still use short-context rates. Service-tier, regional, and tool-call surcharges are not included, and unverified model prices remain N/A.
  • Codex cache writes are included when the log supplies cache_write_input_tokens (or cache_write_tokens). In Codex-only tables, Input excludes cache reads and writes; Cache Write appears when nonzero, and Total Tokens counts each token once. JSON usage.input retains the raw input count including cache reads and writes. Reasoning is already included in Output and is not billed again. Older Codex statistics caches are rebuilt automatically after this accounting update.
  • Claude compact calls are included. When a compact_boundary lacks exact API usage, modelUsage estimates it from preTokens / postTokens, the nearby model, and the recorded 5-minute or 1-hour cache lifetime, then emits a warning.
  • Claude advisor tool calls are included. Their tokens are not part of the message's top-level usage; each advisor_message entry in usage.iterations is counted as its own row under the advisor's model (which can differ from the main model). Advisor calls interrupted before completion leave no usage in the log and cannot be counted.

Recommended Copilot CLI startup for the best available Copilot accounting:

COPILOT_OTEL_FILE_EXPORTER_PATH=$HOME/.copilot/otel.jsonl copilot
  • Some Copilot builds currently write input/output/cache_read into OTel but do not emit gen_ai.usage.cache_creation.input_tokens, so Cache Write can still remain 0 even when OTel is enabled.

Update behavior

  • Auto-check runs only on interactive terminals after the main report.
  • Checks are throttled to once per 24 hours.
  • --json and non-TTY runs skip update checks.
  • On Windows, --update currently requires manual binary replacement after download.
  • When Claude data is present, a warning describes upstream local-log omissions and whether compact usage was estimated.

Platform support

  • Linux x86_64
  • Linux arm64
  • macOS arm64
  • Windows x86_64
  • Windows arm64

Docs

Versioning

  • Current version: 0.1.37
  • Source of truth: Cargo.toml
  • Tag format: vX.Y.Z

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages