REAL-TIME
COST ENFORCEMENT
FOR AI AGENTS
Set a hard dollar limit on any AI agent session with one line of code. Automatic tracking, circuit breaking, and cost reports across every LLM provider.
Works with every LLM provider
Code Examples
A few lines. Full control.
Drop-in auto-tracking, manual wrapping, async agents, and nested budgets.
import agentbudget
import openai
agentbudget.init("$5.00")
# Your existing code. Zero changes needed.
client = openai.OpenAI()
response = client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "Analyze this market..."}]
)
# ^ Automatically tracked. Budget enforced.
print(agentbudget.spent()) # 0.0035
print(agentbudget.remaining()) # 4.9965
print(agentbudget.report()) # Full cost breakdown
agentbudget.teardown()The Problem
Agents are unpredictable by design.
Your bill shouldn't be.
Traditional software has deterministic costs. Agent software doesn't. An agent might make 3 LLM calls or 300.
The Loop Problem
Agent gets stuck retrying the same call. 200 LLM calls in 10 minutes. $50–$200 before anyone notices.
The Invisible Spend
Tokens aren’t dollars. GPT-4o costs 15x more than GPT-4o-mini. Mix in tool calls, nobody knows the real cost.
Multi-Provider Chaos
One session calls OpenAI, Anthropic, Google, and 3 APIs. Each has its own billing. No unified real-time view.
The Scaling Problem
1,000 concurrent sessions. 5% failure rate = 50 runaway agents. Your bill becomes your worst case times your user count.
Features
Everything you need. Nothing you don't.
A single library. No infrastructure. Works with your existing code.
Drop-in Auto-Tracking
One line patches OpenAI and Anthropic SDKs. Your existing code stays completely untouched.
Learn moreDollar-Denominated
Tracks real dollars, not tokens. Across LLM calls, tool calls, and external APIs in one balance.
Learn moreCircuit Breaker
Soft limit warnings, hard limit enforcement, and automatic loop detection kills runaway sessions.
Learn moreMulti-Provider
Built-in pricing for 30+ models across OpenAI, Anthropic, Google, Mistral, and Cohere.
Learn moreAsync Native
Full async/await support with AsyncBudgetSession. Works with async agents and concurrent sessions.
Learn moreNested Budgets
Parent sessions allocate sub-budgets to child agents. Costs roll up to the parent automatically.
Learn moreFramework Integrations
LangChain callback handler, CrewAI middleware. Drop into your existing agent framework.
Learn moreZero Infrastructure
No Redis. No servers. No cloud account. Pure Python library that runs in your process.
Learn moreLive Monitoring
See exactly what your agent spends.
Every LLM call, tool call, and cost event is logged in real time with a structured report.