CLI for OpenAI and Anthropic organization cost reports
Project description
llm-org-cost-monitor
Local Python 3.12 CLI for checking organization-level costs across one OpenAI organization and one Anthropic organization.
The primary installed command is llm-org-cost-monitor. The shorter llm-org-cost command is also provided as a compatibility alias. The project name includes org because it reads provider organization cost reports rather than estimating individual request or model costs.
Setup
uv sync --dev
cp .env.example .env
Fill .env with local admin keys:
OPENAI_ADMIN_KEY=...
ANTHROPIC_ADMIN_KEY=...
OPENAI_ACCOUNT_LABEL=OpenAI
ANTHROPIC_ACCOUNT_LABEL=Anthropic
.env is ignored by git and must not be committed.
Configuration
The CLI reads configuration from environment variables. For local use, you can either export variables in your shell or put them in a .env file in the directory where you run the command.
export OPENAI_ADMIN_KEY=...
export ANTHROPIC_ADMIN_KEY=...
export OPENAI_ACCOUNT_LABEL=OpenAI
export ANTHROPIC_ACCOUNT_LABEL=Anthropic
OPENAI_ADMIN_KEY=...
ANTHROPIC_ADMIN_KEY=...
OPENAI_ACCOUNT_LABEL=OpenAI
ANTHROPIC_ACCOUNT_LABEL=Anthropic
Only one provider key is required if you only want reports for that provider. The account label variables are optional and default to OpenAI and Anthropic.
The CLI does not accept API keys as command-line flags. This keeps secrets out of shell history, terminal scrollback, and process listings.
Usage
Local development:
uv run llm-org-cost-monitor doctor
uvx --from . llm-org-cost-monitor doctor
After the package is published to PyPI:
uvx llm-org-cost-monitor doctor
uvx llm-org-cost-monitor summary --period mtd
Installed command examples:
llm-org-cost-monitor doctor
llm-org-cost-monitor summary --period mtd
llm-org-cost-monitor summary --period mtd --provider openai
llm-org-cost-monitor summary --period mtd --provider anthropic
llm-org-cost-monitor summary --period mtd --group project-workspace
llm-org-cost-monitor summary --period mtd --group api-key
llm-org-cost-monitor summary --period mtd --group day-project-workspace
llm-org-cost-monitor summary --period last-7d --format json
llm-org-cost-monitor summary --start 2026-07-01 --end 2026-07-05 --group line-item --format csv
--start and --end are calendar dates. The end date is inclusive for the CLI and converted to the provider APIs' exclusive end timestamp.
Use --provider openai or --provider anthropic to fetch and show only one provider. The default is --provider all.
Supported summary groups:
providerprojectworkspaceline-itemdayproject-workspaceapi-keyday-project-workspace
project-workspace combines the two provider-native ownership views: OpenAI costs are grouped by project and Anthropic costs are grouped by workspace. api-key groups OpenAI costs by api_key_id; Anthropic rows are reported as Unsupported/Unattributed because Anthropic cost reports do not currently expose API key attribution. day-project-workspace applies the combined project/workspace view per day.
Supported output formats:
tablejsoncsv
Provider APIs
OpenAI uses GET /v1/organization/costs with bucket_width=1d, Unix UTC timestamps, pagination via next_page, and grouping by project_id, api_key_id, and line_item.
Anthropic uses GET /v1/organizations/cost_report with RFC3339 UTC timestamps, pagination via next_page, and grouping by workspace_id and description.
The tool best-effort maps OpenAI project IDs and Anthropic workspace IDs to names. If mapping fails, it keeps IDs and prints a warning without exposing secrets.
Official references:
- OpenAI costs API: https://developers.openai.com/api/reference/resources/admin/subresources/organization/subresources/usage/methods/costs
- OpenAI admin API auth: https://developers.openai.com/api/docs/guides/admin-apis
- Anthropic Usage and Cost API: https://platform.claude.com/docs/en/manage-claude/usage-cost-api
- Anthropic Admin API: https://platform.claude.com/docs/en/api/admin
Security
- Keys are read from
.envwithpython-dotenv. - Full keys are never printed.
doctorreports provider, label, auth status, and metadata counts only.- JSON output preserves provider amount fields under
raw_amount, but does not include request headers or keys.
Development
uv sync --dev
uv run pytest
uv run llm-org-cost-monitor --help
uv run llm-org-cost --help
uvx --from . llm-org-cost-monitor --help
uv build
Release
Releases are published by GitHub Actions when a version tag matching v* is pushed. The workflow installs uv, syncs locked development dependencies, runs the test suite, builds the source and wheel distributions, and publishes to PyPI with Trusted Publishing.
Before the first release, configure PyPI Trusted Publishing for:
Repository owner: yang3kc
Repository name: llm-org-cost-monitor
Workflow filename: release.yml
Environment name: <blank>
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file llm_org_cost_monitor-0.1.2.tar.gz.
File metadata
- Download URL: llm_org_cost_monitor-0.1.2.tar.gz
- Upload date:
- Size: 17.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7df0480c276a666a62830d72ee832cf33f675b59c749f19469f59d332d4ef739
|
|
| MD5 |
4aae92e20c254eaf1baddf147498f140
|
|
| BLAKE2b-256 |
44fe8cb5d66df1c6bd45004c8878db871c7d3798cd6a4c6b3d3de6afbe91775b
|
Provenance
The following attestation bundles were made for llm_org_cost_monitor-0.1.2.tar.gz:
Publisher:
release.yml on yang3kc/llm-org-cost-monitor
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
llm_org_cost_monitor-0.1.2.tar.gz -
Subject digest:
7df0480c276a666a62830d72ee832cf33f675b59c749f19469f59d332d4ef739 - Sigstore transparency entry: 2083419229
- Sigstore integration time:
-
Permalink:
yang3kc/llm-org-cost-monitor@cfd746cc23a2d606ee3446b764823ce853761d26 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/yang3kc
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@cfd746cc23a2d606ee3446b764823ce853761d26 -
Trigger Event:
push
-
Statement type:
File details
Details for the file llm_org_cost_monitor-0.1.2-py3-none-any.whl.
File metadata
- Download URL: llm_org_cost_monitor-0.1.2-py3-none-any.whl
- Upload date:
- Size: 12.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ecbf501a5e3e97da1e2653acdee48064a5ffb5e97205da626ef2f68464e48c45
|
|
| MD5 |
c845736d64d2f49c31c74417dd717140
|
|
| BLAKE2b-256 |
96861ca8a67973cdb5322784025ea3c03cb595735bbd9bdaae83d9549af1e72f
|
Provenance
The following attestation bundles were made for llm_org_cost_monitor-0.1.2-py3-none-any.whl:
Publisher:
release.yml on yang3kc/llm-org-cost-monitor
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
llm_org_cost_monitor-0.1.2-py3-none-any.whl -
Subject digest:
ecbf501a5e3e97da1e2653acdee48064a5ffb5e97205da626ef2f68464e48c45 - Sigstore transparency entry: 2083419284
- Sigstore integration time:
-
Permalink:
yang3kc/llm-org-cost-monitor@cfd746cc23a2d606ee3446b764823ce853761d26 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/yang3kc
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@cfd746cc23a2d606ee3446b764823ce853761d26 -
Trigger Event:
push
-
Statement type: