| Crates.io | oai-usage |
| lib.rs | oai-usage |
| version | 0.1.0 |
| created_at | 2025-08-19 20:05:26.234668+00 |
| updated_at | 2025-08-19 20:05:26.234668+00 |
| description | CLI tool for monitoring OpenAI API usage |
| homepage | |
| repository | |
| max_upload_size | |
| id | 1802384 |
| size | 66,752 |
Simple cli tool that fetches and displays OpenAI API usage data (for completions) for the last N days. Written by claude and gpt-5. PRs welcome.
Fetching OpenAI usage data for the past 3 days...
+------------+------------------+----------+--------------+--------------+---------------+----------+
| Date | Model | Requests | Input Tokens | Cached Input | Output Tokens | Cost ($) |
+===================================================================================================+
| 2025-08-17 | gpt-5-2025-08-07 | 134 | 467,885 | 9,734,144 | 53,800 | 2.3396 |
|------------+------------------+----------+--------------+--------------+---------------+----------|
| 2025-08-18 | gpt-5-2025-08-07 | 111 | 120,039 | 5,645,568 | 38,326 | 1.2390 |
|------------+------------------+----------+--------------+--------------+---------------+----------|
| 2025-08-19 | gpt-5-2025-08-07 | 38 | 52,319 | 646,272 | 20,614 | 0.3523 |
|------------+------------------+----------+--------------+--------------+---------------+----------|
| TOTAL | | 283 | 640,243 | 16,025,984 | 112,740 | 3.9310 |
+------------+------------------+----------+--------------+--------------+---------------+----------+
Use with the watch command to see the pennies flow in real time, eg watch -c -n 5 -d oai-usage.
Install rust. https://www.rust-lang.org/tools/install
cargo install oai-usage
OPENAI_ADMIN_KEY in your environment. Note that this needs to be an "admin key", which is distinct from the API key you'd use for calling a model. You can create an admin key in the openai settings (not the Dashboard). We recommend creating an admin key with read-only permissions to the usage api, and no other permissions.oai-usage [days] (default: 3).Example: OPENAI_ADMIN_KEY=... oai-usage 7
Note: The pricing table is embedded and may not always match the most recent public prices.
Dual-licensed under MIT or Apache-2.0 at your option.