Skip to main content

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

Metadata

Release files for ai-spend 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ai-spend 0.2.0
File Size Uploaded Provenance Actions
ai_spend-0.2.0.tar.gz 36.8 kB With provenance Details for ai_spend-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ai-spend 0.2.0
File Interpreter ABI Platform Actions
ai_spend-0.2.0-py3-none-any.whl Python 3 none any Details for ai_spend-0.2.0-py3-none-any.whl

Total release size: 62.2 kB

Release files / ai_spend-0.2.0.tar.gz

Download URL ai_spend-0.2.0.tar.gz
Size 36.8 kB
Tags Source
SHA-256 checksum
How to use checksums
26055292ee485ffea231291656bcb4fbc095e601a0e3a45ad00b735ef4280f82
BLAKE2b-256 checksum
How to use checksums
aefb3c4f3eff92440ef87f9ccb403664636de1c7cd90edb6f9cc9d37525be611
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 8, 2026.

Transparency log

Release files / ai_spend-0.2.0-py3-none-any.whl

Download URL ai_spend-0.2.0-py3-none-any.whl
Size 25.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0ab1c3636acab72eda2576162a9a51d28d1667367e6f0e637de7ba51542e977b
BLAKE2b-256 checksum
How to use checksums
a5eae4b26fd7e0b7b07da91092233e9c0988a7f711144aada934eae724168678
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 8, 2026.

Transparency log

Security for ai-spend 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for ai_spend-0.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 8, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page