A command-line tool to inspect token usage and estimated cost for your OpenAI projects.
βββββββββββββββββββββββ ββββββββββββββββββββ
β OPENAI_ADMIN_API_KEY β β litellm Pricing β
βββββββββββ¬ββββββββββββ ββββββββββ¬ββββββββββ
β β
βΌ βΌ
βββββββββββββββββββββββ ββββββββββββββββββββ
β Fetch Projects & β β Local Cache β
β Usage Data β β (~/.cache/...) β
βββββββββββ¬ββββββββββββ ββββββββββ¬ββββββββββ
β β
ββββββββββββ¬ββββββββββββββββ
βΌ
ββββββββββββββββββββββββ
β Calculate Costs β
ββββββββββββ¬ββββββββββββ
βΌ
ββββββββββββββββββββββββ
β Color-coded Terminal β
β Table β
ββββββββββββββββββββββββ
| Feature | Description |
|---|---|
| π List Projects | See all projects accessible with your admin API key |
| π Detailed Usage | Usage data broken down by day or month, model, and API key |
| π° Auto-Updated Pricing | Pricing fetched from litellmβ and cached locally |
| π Flexible Grouping | Group and sort by day, month, project, key, or model |
| π Custom Date Ranges | Focus on a specific time period |
| π¨ Colorful Output | Clear, color-coded table for easy reading |
# With uv (recommended)
uv tool install openai-usage-report
# With pipx
pipx install openai-usage-report
# With uv
uv tool install git+https://github.com/obeone/scripts#subdirectory=openai-usage
# With pipx
git clone https://github.com/obeone/scripts
cd scripts
pipx install ./openai-usage
docker run --rm -e OPENAI_ADMIN_API_KEY="..." obeoneorg/openai-usage-report
This tool requires an admin-level OpenAI API key:
export OPENAI_ADMIN_API_KEY="your_admin_api_key_here"
openai-usage --list-projects
openai-usage
openai-usage --projects proj_xxxxxxxxxxxx --start-date 2024-01-01 --end-date 2024-01-31
openai-usage --group-by project day
Pricing is automatically fetched from litellm on first run and cached locally (~/.cache/openai-usage/pricing.json). To update manually:
openai-usage --update-pricing
To check cache status:
openai-usage --pricing-info
A warning is displayed if the cache is older than 30 days.
| Command | Description |
|---|---|
docker run --rm -e OPENAI_ADMIN_API_KEY="..." obeoneorg/openai-usage-report | View all projects usage |
docker run --rm -e OPENAI_ADMIN_API_KEY="..." obeoneorg/openai-usage-report -l | List projects |
docker run --rm -e OPENAI_ADMIN_API_KEY="..." obeoneorg/openai-usage-report -p proj_xxx | Specific project |
Build locally:
docker build -t openai-usage-report ./openai-usage
| Argument | Short | Description | Default |
|---|---|---|---|
--help | -h | Show the help message and exit | |
--list-projects | -l | List available projects and exit | |
--projects [ID ...] | -p | One or more project IDs to analyze | All projects |
--start-date YYYY-MM-DD | -sd | Start date for the usage report | Start of current month |
--end-date YYYY-MM-DD | -ed | End date for the usage report | End of current month |
--group-by [CRITERIA ...] | -gb | Criteria to group and sort results (order matters) | day |
--update-pricing | Fetch latest pricing from litellm and update local cache | ||
--pricing-info | Show pricing cache path, last update date, and model count |
Available Grouping Criteria: day, month, project, key, model
MIT β GrΓ©goire Compagnon (@obeoneβ )
Content type
Image
Digest
sha256:ea1f9b32eβ¦
Size
44 MB
Last updated
about 1 month ago
docker pull obeoneorg/openai-usage-report