Skip to main content

Aggregate AI API costs across providers into a single CLI dashboard

Project description

ai-spend

CI CodeQL Python 3.10+ License: MIT

Your AI bills, in your terminal. No proxies. No dashboards. No SDK changes.

ai-spend pulls usage data directly from Anthropic and OpenAI's official billing APIs and displays it in your terminal. Your API keys stay on your machine. Your prompts are never seen.

$ ai-spend summary

  Provider       This Month    vs Last Month
  ─────────────────────────────────────────
  Anthropic        $47.23       +12%
  OpenAI           $31.88        -4%
  ─────────────────────────────────────────
  Total            $79.11

  Top models:
  claude-opus-4-6       $31.44   (67% of Anthropic)
  gpt-4.1               $18.22   (57% of OpenAI)

$ ai-spend daily --last 7

  Date         Anthropic    OpenAI    Total
  ──────────────────────────────────────────
  2026-02-28     $8.12      $4.33    $12.45
  2026-02-27     $6.88      $5.11    $11.99
  ...

How It's Different

Unlike gateway-based trackers, ai-spend never sees your prompts. It reads token counts and costs from your provider's billing API — the same data that appears on your invoice. Nothing more.

Reads billing API directly No proxy/SDK Prompts stay local CLI-native
ai-spend Yes Yes Yes Yes
Langfuse No (intercepts calls) No No No
Helicone No (proxy) No No No
OpenAI dashboard Yes Yes Yes No (web only)

Install

pip install ai-spend

Quick Start

# Add your providers (keys stored locally with 0600 perms)
ai-spend config add anthropic
ai-spend config add openai

# Pull latest usage data
ai-spend sync

# See your spend
ai-spend summary
ai-spend daily --last 30

Usage

# Provider management
ai-spend config add <provider>     # Add a provider (anthropic, openai)
ai-spend config remove <provider>  # Remove a provider
ai-spend config list               # List configured providers

# Sync usage data from provider APIs
ai-spend sync

# View spend
ai-spend summary                   # Aggregated totals
ai-spend summary --json            # JSON output
ai-spend daily                     # Daily breakdown
ai-spend daily --last 7            # Last 7 days

# Budgets
ai-spend budget set 100            # Set monthly budget ($100)
ai-spend budget check              # Check against budget

# Manual entries (for providers without billing APIs)
ai-spend manual add 12.50 --provider ollama --note "local GPU costs"

# Export (Pro)
ai-spend export --format csv
ai-spend export --format json

# Status
ai-spend status                    # License tier + system info

How It Works

Provider APIs ──→ ai-spend sync ──→ Local SQLite
(Anthropic)                         (~/.ai-spend/spend.db)
(OpenAI)                                  │
                                          ▼
                              ai-spend summary/daily/budget
  1. Configure — Add provider API keys (stored locally in ~/.ai-spend/config.yaml with 0600 permissions)
  2. Sync — Pulls usage records from official billing APIs into a local SQLite database
  3. Query — All read commands (summary, daily, budget, export) hit the local database only

No background processes. No network calls except during sync. Run it in a cron job, pipe it into monitoring, or check it before standups.

Free vs Pro

Feature Free Pro
Sync + summary + daily Yes Yes
Budget tracking Yes Yes
Manual entries Yes Yes
JSON output Yes Yes
CSV/JSON export -- Yes

License

MIT

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

ai_spend-0.2.0.tar.gz (36.8 kB view details)

Uploaded Source

Built Distribution

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

ai_spend-0.2.0-py3-none-any.whl (25.4 kB view details)

Uploaded Python 3

File details

Details for the file ai_spend-0.2.0.tar.gz.

File metadata

  • Download URL: ai_spend-0.2.0.tar.gz
  • Upload date:
  • Size: 36.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ai_spend-0.2.0.tar.gz
Algorithm Hash digest
SHA256 26055292ee485ffea231291656bcb4fbc095e601a0e3a45ad00b735ef4280f82
MD5 68ebad9f198c417426bd3a0f0633fd01
BLAKE2b-256 aefb3c4f3eff92440ef87f9ccb403664636de1c7cd90edb6f9cc9d37525be611

See more details on using hashes here.

Provenance

The following attestation bundles were made for ai_spend-0.2.0.tar.gz:

Publisher: release.yml on AreteDriver/ai-spend

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

File details

Details for the file ai_spend-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: ai_spend-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 25.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ai_spend-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0ab1c3636acab72eda2576162a9a51d28d1667367e6f0e637de7ba51542e977b
MD5 9aec6f0f77167274496d5cc2191b0c56
BLAKE2b-256 a5eae4b26fd7e0b7b07da91092233e9c0988a7f711144aada934eae724168678

See more details on using hashes here.

Provenance

The following attestation bundles were made for ai_spend-0.2.0-py3-none-any.whl:

Publisher: release.yml on AreteDriver/ai-spend

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