Skip to main content

AI Usage Tracker

A comprehensive token usage and cost tracking tool for Claude Code and Codex CLI.

Overview

This tool combines usage data from both ccusage (Claude) and ccusage-codex (Codex) to provide a unified view of your AI token consumption and associated costs.

Quick Start

Install via pip (Python)

pip install ai-usage-tracker
ai-usage-tracker

Install via npm (Node.js)

npm install -g ai-usage-tracker
ai-usage-tracker-js

Install from source

git clone https://github.com/jleechanorg/ai-usage-tracker.git
cd ai-usage-tracker

# Install dependencies (ccusage and ccusage-codex)
./scripts/install-dependencies.sh

# Run the report
python3 scripts/combined-usage-report.py

# Or install as a Claude skill
ln -s $(pwd)/.claude/skills/combined-usage ~/.claude/skills/combined-usage
# Then use: /combined-usage

Features

  • Combined Reporting: View Claude and Codex usage side-by-side
  • Cost Analysis: Track spending across both platforms
  • Daily Averages: Calculate average usage over time
  • Cache Efficiency: Monitor cache read rates and savings
  • Flexible Output: Table format for humans, JSON for automation
  • Claude Skill: Invoke directly from Claude Code CLI

Installation

Option 1: pip (Recommended)

pip install ai-usage-tracker

Option 2: npm

npm install -g ai-usage-tracker

Option 3: From source

git clone https://github.com/jleechanorg/ai-usage-tracker.git
cd ai-usage-tracker
pip install .

Prerequisites

Both the pip and npm packages require ccusage and ccusage-codex CLI tools:

npm install -g ccusage @ccusage/codex

Or use the automated installation script:

./scripts/install-dependencies.sh

Optional: Claude Skill

ln -s $(pwd)/.claude/skills/combined-usage ~/.claude/skills/combined-usage

Usage

Python (pip install)

# Default: Last 7 days
ai-usage-tracker

# Custom date range
ai-usage-tracker --days 14

# JSON output
ai-usage-tracker --json

Node.js (npm install)

# Default: Last 7 days
ai-usage-tracker-js

# Custom date range
ai-usage-tracker-js --days 14

# JSON output
ai-usage-tracker-js --json

From source

python3 scripts/combined-usage-report.py
python3 scripts/combined-usage-report.py --days 14
python3 scripts/combined-usage-report.py --json

Claude Skill

If installed as a skill:

/combined-usage

Example Output

╔════════════╦═══════════════╦════════════╦═══════════════╦════════════╦═══════════════╦════════════╗
║    Date    ║ Claude Tokens ║ Claude $   ║ Codex Tokens  ║  Codex $   ║ Total Tokens  ║  Total $   ║
╠════════════╬═══════════════╬════════════╬═══════════════╬════════════╬═══════════════╬════════════╣
║ 02-11      ║    88,155,247 ║ $    37.31 ║    67,371,956 ║ $    12.82 ║   155,527,203 ║ $    50.13 ║
║ 02-10      ║   368,293,666 ║ $   160.69 ║   764,117,407 ║ $   144.86 ║ 1,132,411,073 ║ $   305.55 ║
...
╚════════════╩═══════════════╩════════════╩═══════════════╩════════════╩═══════════════╩════════════╝

DAILY AVERAGES (Last 7 complete days)
Claude:      237,410,924 tokens/day  |  $123.39/day
Codex:       511,863,756 tokens/day  |  $98.76/day
TOTAL:       749,274,679 tokens/day  |  $222.15/day

Documentation

See docs/usage-report.md for a complete example report with insights and recommendations.

Packages

Package Registry Install
ai-usage-tracker PyPI pip install ai-usage-tracker
ai-usage-tracker npm npm install -g ai-usage-tracker

Repository Structure

ai-usage-tracker/
├── README.md                           # This file
├── CHANGELOG.md                        # Version history
├── pyproject.toml                      # Python package config (PyPI)
├── ai_usage_tracker/                   # Python package source
│   ├── __init__.py
│   └── cli.py                          # CLI entry point
├── npm/                                # Node.js package source
│   ├── package.json                    # npm package config
│   ├── tsconfig.json
│   └── src/
│       ├── index.ts                    # Library exports
│       ├── tracker.ts                  # Core logic
│       └── cli.ts                      # CLI entry point
├── docs/
│   └── usage-report.md                 # Example report with analysis
├── scripts/
│   ├── install-dependencies.sh         # Automated installation script
│   └── combined-usage-report.py        # Original report generator
└── .claude/
    └── skills/
        └── combined-usage              # Claude skill definition

Key Insights

Based on typical usage patterns:

  • Token Distribution: Codex typically accounts for ~67% of total tokens
  • Cost Ratio: Claude tokens are ~2.8x more expensive than Codex tokens
  • Cache Efficiency: Both tools maintain 90%+ cache read rates
  • Average Daily Cost: Typically ranges from $150-250/day for heavy usage

Contributing

Contributions welcome! Please feel free to submit issues or pull requests.

License

MIT License - Feel free to use and modify as needed.

Credits

Built for tracking usage across:

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ai_usage_tracker-0.1.5.tar.gz (6.9 kB view details)

Uploaded Source

Built Distribution

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

ai_usage_tracker-0.1.5-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

Details for the file ai_usage_tracker-0.1.5.tar.gz.

File metadata

  • Download URL: ai_usage_tracker-0.1.5.tar.gz
  • Upload date:
  • Size: 6.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.10

File hashes

Hashes for ai_usage_tracker-0.1.5.tar.gz
Algorithm Hash digest
SHA256 0ce5e607019987891ed2c759e216780daf8f5bf8c1bacafb516bf28b5ce72157
MD5 54267f6d5e8123b15972056df039baf9
BLAKE2b-256 38f2a9739e12b4f7543830cf725c6e130c53ee386e0df2f50d42f8aaeed9ae22

See more details on using hashes here.

File details

Details for the file ai_usage_tracker-0.1.5-py3-none-any.whl.

File metadata

File hashes

Hashes for ai_usage_tracker-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 e8a726ef82ed06b614985995dab624a5b1461a8613f947c0c7b24800f53c72f2
MD5 760588a83c11ac811c8d6a6d63b913c4
BLAKE2b-256 05f90dd825e31bb82f049f62f3522f803f50906a4513aa080303ba1fc9eb9d52

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.5 This release

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

Supported by

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