Born from our own $800 OpenAI bill — AgentCost found the runaway agent and cut our spend 44% in two weeks. Read the story
$ pip install agentcostfrom agentcost import track_costsimport openai # Initializetrack_costs.init(api_key="ac_kp...") # Use your LLM as usual — calls are tracked automaticallyclient = openai.OpenAI()response = client.chat.completions.create( model="gpt-4o", messages=[...])Supporting 2,900+ models across all major providers
Capabilities
Real-Time Tracking
Every LLM call is captured the moment it completes. Token counts, costs, and latency are recorded and available in your dashboard in real time.
Integration
The SDK intercepts LLM calls transparently. No wrappers, no decorators. Your agents, chains, and prompts stay exactly as they are.
Multi-Agent
Attribute spend to individual agents via async-safe context variables. Concurrent pipelines stay fully isolated.
Anomaly Detection
Z-score analysis flags spend deviations across cost, latency, and error rate with configurable severity thresholds.
Streaming
Chunks are accumulated transparently. Token counts and costs are recorded atomically after stream completion.
Optimization
SHA-256 prompt hashing surfaces duplicate queries. Model-swap analysis quantifies potential savings.
How it works
pip install agentcost
A lightweight Python package. Add the import and call init() with your API key. Your existing LangChain code continues to work unchanged — the SDK intercepts calls transparently via monkey-patching.
No wrappers, no decorators, no middleware.
from agentcost import track_costs track_costs.init(api_key="ac_...") # That's it. Your code stays the same.
Integration
No wrappers, no decorators, no middleware. AgentCost uses lightweight interception to instrument OpenAI, Anthropic, and LangChain calls transparently. Your code stays clean.
Install the SDK
pip install agentcost
Add two lines
import + init — done
See your costs
Open the dashboard at localhost:3000
FAQ
Getting Started
Technical
Pricing & License
Have another question? Read the docs · Open a GitHub issue
Set up in under two minutes. Self-host on your infrastructure. No credit card, no vendor lock-in.
MIT License · Docker-ready · No telemetry