Open Source · MIT License · v1.2

Your AI bill just became predictable.

AgentCost gives engineering teams real-time cost visibility, automatic budget controls, and intelligent model routing. One line of code. Zero config.

$ pip install agentcostin click to copy
app.py
from agentcost.sdk import trace
from openai import OpenAI

# One line. Every call tracked.
client = trace(OpenAI(), project="my-app")

response = client.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "user", "content": "Hello!"}]
)
# Cost, tokens, latency — recorded automatically.
2,610+
Models priced
40+
Providers supported
590+
Tests passing
0
External dependencies

The Problem

AI costs are invisible until they're not.

Teams deploy agents across multiple providers with no centralized view of spend, no budget controls, and no way to know if cheaper models would work.

🔥

Shadow AI spend

Developers pick models by habit, not cost. GPT-4o for classification tasks that GPT-4o-mini handles.

+$2,400/mo wasted
📈

Surprise invoices

Usage grows 3x in a sprint and nobody notices until the cloud bill arrives. No forecasting, no warnings.

$47K instead of $15K
🤷

No cost attribution

CFO asks "what did we spend on the chatbot?" and engineering has no answer. No breakdown by team or goal.

??? per project

The Dashboard

See everything. Control everything.

Seven intelligence views — from real-time spend to 30-day forecasts to model optimization.

localhost:8000 — AgentCost Dashboard
Total Spend
$4,287
↓ 12% vs last month
API Calls
847K
↑ 23% growth
Efficiency
82/100
↑ 15 pts improved
Savings Found
$1,340
via model downgrades
Daily Cost · Last 14 Days

Features

Cost governance, not just tracking.

AgentCost prevents overruns, routes to cheaper models, and blocks wasteful calls — before they happen.

🧠

Intelligent Model Routing

Auto-classify prompts by complexity. Simple questions route to economy models, reasoning to premium. Saves 30-60%.

complexity_router.py
🚧

Budget Gates

Pre-execution checks: ALLOW <80%, WARN at 80%, auto-DOWNGRADE at 90%, BLOCK at 100%. Overruns become impossible.

budget_gate.py
📊

Cost Forecasting

Predict next 7/14/30 days using ensemble methods. "At current rates, your $5K budget runs out March 22nd."

forecast/

Token Efficiency Analyzer

Scores 0-100 for each project. Detects waste: excessive system prompts, under-used context, low output ratios.

token_analyzer.py
🎯

Goal Cost Attribution

Tag calls to business objectives. "How much did Feature X cost?" Hierarchical rollup: task → sprint → OKR.

goals/
⚙️

YAML Reactions Engine

Event-driven automation: budget exceeded → Slack + suspend agent + escalate. No code needed.

reactions/defaults.yaml
🔌

8-Slot Plugin System

Notifier, Policy, Exporter, Provider, Tracker, Reactor, Runtime, Agent — every point is swappable.

agentcost plugin create
📋

Governance Templates

One-click: Startup ($500/mo), Enterprise (5 cost centers), SOC 2 (audit trail, no free tier).

templates/

Setup

Three commands. Five minutes.

1

Install

One dependency. No infrastructure. No signup.

pip install agentcostin
2

Wrap your client

One function call. Zero changes to application code.

client = trace(OpenAI(), project="my-app")
3

Open the dashboard

Costs, forecasts, and optimization recommendations — instantly.

agentcost dashboard

Integrations

Works with your stack.

OpenAI Anthropic Google Gemini DeepSeek AWS Bedrock Azure AI Ollama Groq Mistral LangChain CrewAI AutoGen LlamaIndex OpenTelemetry Prometheus +30 more

Pricing

Open source. Self-hosted. Your data.

Free forever for developers and small teams.

Popular
MIT License
Community
$0 / forever

Everything you need to track and optimize AI costs.

  • Python + TypeScript SDKs
  • Real-time dashboard (7 views)
  • 2,610+ model pricing
  • Intelligent routing & budget gates
  • Forecasting & optimizer
  • Goal attribution & templates
  • Plugin system & reactions
  • All integrations & exporters
Get Started — Free
BSL 1.1 · Source Available
Enterprise
Custom

Governance and compliance for organizations.

  • Everything in Community
  • SSO (Okta, Auth0, Azure AD, SAML)
  • Budget enforcement & cost centers
  • Policy engine & approvals
  • Anomaly detection
  • AI gateway proxy
  • PostgreSQL & audit logs
  • Heartbeat monitoring
Contact Sales

Stop guessing. Start governing.

Your next AI invoice doesn't have to be a surprise.