Skip to main content

Track AI API costs, token usage, and prompt quality across all providers

Project description

AI Cost Auditor

Track AI API costs, token usage, and prompt quality across all providers — Anthropic, OpenAI, Google, Mistral, and more.

Install

pip install ai-cost-auditor

With provider SDKs:

pip install "ai-cost-auditor[anthropic]"
pip install "ai-cost-auditor[openai]"
pip install "ai-cost-auditor[all]"

Quick Start

from ai_cost_auditor import CostTracker
import anthropic

tracker = CostTracker()
client  = tracker.wrap_anthropic(anthropic.Anthropic())

# Use exactly like the normal client — tracking is automatic
resp = client.messages.create(
    model="claude-sonnet-4-6",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Explain async/await in Python"}]
)

# View stats
stats = tracker.get_stats(days=7)
print(f"Cost: ${stats['period']['total_cost_usd']:.4f}")

# Generate HTML report with charts
tracker.generate_report("report.html")

Features

  • Cost tracking — automatic pricing for 30+ models
  • Token tracking — input/output tokens per call, by day/model/provider
  • Prompt quality — 5-dimension scoring (clarity, specificity, context, structure, efficiency)
  • HTML reports — interactive Chart.js charts: cost over time, provider breakdown, model usage
  • Language-agnostic — works with any provider via manual tracker.track()
  • VSCode extension — live cost status bar + interactive dashboard

Supported Providers & Models

Provider Models
Anthropic claude-opus-4-7, claude-sonnet-4-6, claude-haiku-4-5, claude-3.x
OpenAI gpt-4o, gpt-4o-mini, gpt-4-turbo, gpt-3.5-turbo, o1, o3-mini
Google gemini-1.5-pro, gemini-1.5-flash, gemini-2.0-flash
Mistral mistral-large, mistral-small, codestral
Cohere command-r-plus, command-r

CLI

# Analyze prompt quality
ai-cost-auditor analyze "Write a function to validate email addresses"

# Show stats
ai-cost-auditor stats --days 7

# Generate report and open in browser
ai-cost-auditor report --days 30 --open

Manual Tracking (any provider)

tracker.track(
    provider="google",
    model="gemini-1.5-flash",
    input_tokens=300,
    output_tokens=120,
    prompt_text="Your prompt here",
)

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_cost_auditor-0.1.0.tar.gz (61.9 kB view details)

Uploaded Source

Built Distribution

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

ai_cost_auditor-0.1.0-py3-none-any.whl (22.9 kB view details)

Uploaded Python 3

File details

Details for the file ai_cost_auditor-0.1.0.tar.gz.

File metadata

  • Download URL: ai_cost_auditor-0.1.0.tar.gz
  • Upload date:
  • Size: 61.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for ai_cost_auditor-0.1.0.tar.gz
Algorithm Hash digest
SHA256 103372b6f62c4780cb01bacb2ebec12465748c77ae6b7595c47dcea4fff5d6c2
MD5 85b67239ca9c25a018f1ff3291818f25
BLAKE2b-256 f919c305bfb7d58b5a1dbb27e8640e3ecb2d99031d4b12da116afd15f5ecf376

See more details on using hashes here.

File details

Details for the file ai_cost_auditor-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for ai_cost_auditor-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 77058a5c38272d079c91f89adcea18168831774dd1945196689f2d639c98e83f
MD5 26ef6279f26c8669c957cc19bbb67017
BLAKE2b-256 e26bfed026eb402b3a606a71e5dc29cd4dbde9ad29da43e541ef3e99c45d4cae

See more details on using hashes here.

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