Your AI bill spiked. Which agent did it?

AgentCost traces every LLM call back to the agent that made it — OpenAI, Anthropic, LangChain, 2,900+ models. Two lines of Python. Open source. Self-hosted.

Born from our own $800 OpenAI bill — AgentCost found the runaway agent and cut our spend 44% in two weeks. Read the story

Quick Start
1. Install
$ pip install agentcost
2. Add two lines to your code
from agentcost import track_costs
import openai
 
# Initialize
track_costs.init(api_key="ac_kp...")
 
# Use your LLM as usual — calls are tracked automatically
client = openai.OpenAI()
response = client.chat.completions.create(
model="gpt-4o",
messages=[...]
)

Supporting 2,900+ models across all major providers

OpenAI
Anthropic
Google
Mistral
DeepSeek
Groq
Cohere
Together AI
AWS Bedrock
Azure OpenAI
Perplexity
Replicate
Fireworks AI
Meta Llama
OpenAI
Anthropic
Google
Mistral
DeepSeek
Groq
Cohere
Together AI
AWS Bedrock
Azure OpenAI
Perplexity
Replicate
Fireworks AI
Meta Llama

Capabilities

Everything you need to
control AI spend.

Real-Time Tracking

See every dollar
as it's spent.

Every LLM call is captured the moment it completes. Token counts, costs, and latency are recorded and available in your dashboard in real time.

Live Feedstreaming
awaiting...

Integration

Two lines of code.
Zero refactoring.

The SDK intercepts LLM calls transparently. No wrappers, no decorators. Your agents, chains, and prompts stay exactly as they are.

my_agent.py
1
from agentcost import track_costs
2
track_costs.init(api_key="ac_...")
3# that's it — your code stays unchanged
4 
5
# your existing LangChain code
6
from langchain_openai import ChatOpenAI
7
llm = ChatOpenAI(model="gpt-4o")

Multi-Agent

Per-agent cost isolation

Attribute spend to individual agents via async-safe context variables. Concurrent pipelines stay fully isolated.

planner
$4.21
executor
$5.82
reviewer
$1.03

Anomaly Detection

Statistical cost baselines

Z-score analysis flags spend deviations across cost, latency, and error rate with configurable severity thresholds.

Alert triggered
Baseline$0.012/call
Observed$0.087/call
Z-score+3.2σ

Streaming

Native stream() support

Chunks are accumulated transparently. Token counts and costs are recorded atomically after stream completion.

7-day cost-23%

Optimization

Actionable cost reduction

SHA-256 prompt hashing surfaces duplicate queries. Model-swap analysis quantifies potential savings.

Duplicate queries34%
Projected savings$214/mo
Model swaps3 suggested

How it works

From call to insight
in four steps.

pip install agentcost

Install the SDK

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.

step-01.sh
from agentcost import track_costs

track_costs.init(api_key="ac_...")

# That's it. Your code stays the same.

Integration

Two lines. That's it.

No wrappers, no decorators, no middleware. AgentCost uses lightweight interception to instrument OpenAI, Anthropic, and LangChain calls transparently. Your code stays clean.

01

Install the SDK

pip install agentcost

02

Add two lines

import + init — done

03

See your costs

Open the dashboard at localhost:3000

my_agent.py
from agentcost import track_costs
 
# Initialize tracking — that's it
track_costs.init(api_key="ac_...", project_id="my-app")
 
# Your existing code works unchanged
from langchain_openai import ChatOpenAI
 
llm = ChatOpenAI(model="gpt-4o")
response = llm.invoke("Analyze this data...")
# ↑ Automatically tracked: tokens, cost, latency
0+models trackedOpenAI · Anthropic · Google · Mistral · and 50+ providers
<0msoverhead addedAsync batching ensures your agents never slow down
0%self-hostedYour data never leaves your infrastructure. No telemetry.

FAQ

Frequently asked questions

Getting Started

Technical

Pricing & License

Have another question? Read the docs · Open a GitHub issue

Stop guessing.
Start tracking.

Set up in under two minutes. Self-host on your infrastructure. No credit card, no vendor lock-in.

MIT License · Docker-ready · No telemetry