Skip to main content

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 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.

Supported summary groups:

  • provider
  • project
  • workspace
  • line-item
  • day

Supported output formats:

  • table
  • json
  • csv

Provider APIs

OpenAI uses GET /v1/organization/costs with bucket_width=1d, Unix UTC timestamps, pagination via next_page, and grouping by project_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:

Security

  • Keys are read from .env with python-dotenv.
  • Full keys are never printed.
  • doctor reports 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


Download files

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

Source Distribution

llm_org_cost_monitor-0.1.1.tar.gz (16.4 kB view details)

Uploaded Source

Built Distribution

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

llm_org_cost_monitor-0.1.1-py3-none-any.whl (11.7 kB view details)

Uploaded Python 3

File details

Details for the file llm_org_cost_monitor-0.1.1.tar.gz.

File metadata

  • Download URL: llm_org_cost_monitor-0.1.1.tar.gz
  • Upload date:
  • Size: 16.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for llm_org_cost_monitor-0.1.1.tar.gz
Algorithm Hash digest
SHA256 021d324eddb7033e65ff6640946079f75fde5bc3f23d144bcf1f9cbb16df8357
MD5 1fb05fe728a8d75307fd1191b1a29a52
BLAKE2b-256 a1d7e1145c93ce85ff6f42d481c330b80ba361300f068b5fb86fd8a07d6a6c56

See more details on using hashes here.

Provenance

The following attestation bundles were made for llm_org_cost_monitor-0.1.1.tar.gz:

Publisher: release.yml on yang3kc/llm-org-cost-monitor

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file llm_org_cost_monitor-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for llm_org_cost_monitor-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a21e2dc48e2b88b89211a900a27674d427ed1bf9779553b3740a595ac534e237
MD5 6993c518b0d7df4051bfd86f8e9b9991
BLAKE2b-256 06876097c36a802fcd414831cd8f5c76bb2a840d10a6a9f989cbb65f204fe403

See more details on using hashes here.

Provenance

The following attestation bundles were made for llm_org_cost_monitor-0.1.1-py3-none-any.whl:

Publisher: release.yml on yang3kc/llm-org-cost-monitor

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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