Observed since 20 Oct, 21:44 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
AI Agent Cost Governance — track, control, and optimize LLM spending
Track, control, and optimize your AI spending.
AI costs are invisible, unpredictable, and uncontrolled. Teams deploy agents across OpenAI, Anthropic, Google, and open-source models with no idea what they're actually spending — or whether cheaper models would work just as well. AgentCost fixes that.
pip install agentcostin
from agentcost.sdk import trace
from openai import OpenAI
client = trace(OpenAI(), project="my-app")
response = client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "Hello!"}]
)
# Every call is now tracked. Open the dashboard:
# agentcost dashboard
# → http://localhost:8500
That's it. One line wraps your client, and every LLM call is tracked with model, tokens, cost, latency, and status.
# Seed demo data and launch
curl -X POST http://localhost:8500/api/seed -H "Content-Type: application/json" -d '{"days": 14}'
agentcost dashboard
The dashboard gives you six intelligence views:
| View | What it shows |
|---|---|
| Overview | Total spend, call volume, error rate, cost-over-time charts |
| Cost Breakdown | Spend by model, project, and provider with trend analysis |
| Forecasting | Predicted costs for next 7/14/30 days, budget exhaustion alerts |
| Optimizer | Model downgrade recommendations with estimated savings |
| Analytics | Token efficiency, top spenders, chargeback reports |
| Estimator | Pre-call cost estimation — compare 42 models before you call |
AgentCost integrates with the frameworks you already use:
# LangChain
from agentcost.sdk.integrations import langchain_callback
chain.invoke(input, config={"callbacks": [langchain_callback("my-project")]})
# CrewAI
from agentcost.sdk.integrations import crewai_callback
crew = Crew(agents=[...], callbacks=[crewai_callback("my-project")])
# AutoGen
from agentcost.sdk.integrations import autogen_callback
agent = AssistantAgent("assistant", llm_config={..., "callbacks": [autogen_callback("my-project")]})
# LlamaIndex
from agentcost.sdk.integrations import llamaindex_callback
service_context = ServiceContext.from_defaults(callback_manager=llamaindex_callback("my-project"))
# Benchmark models on real professional tasks
agentcost benchmark --model gpt-4o --tasks 10
# Compare models head-to-head
agentcost compare --models "gpt-4o,gpt-4o-mini,claude-sonnet-4-6" --tasks 5
# View the leaderboard
agentcost leaderboard
# Check traces and budgets
agentcost traces --project my-app --summary
agentcost budget --project my-app --daily 50 --monthly 1000
# Manage plugins
agentcost plugin list
agentcost plugin install agentcost-slack-alerts
┌─────────────────────────────────────────────┐
│ Your Application │
└─────┬──────────┬──────────┬────────────────┘
│ │ │
┌─────▼──┐ ┌─────▼──┐ ┌────▼───┐
│ Python │ │ Node.js│ │ Proxy │
│ SDK │ │ SDK │ │Gateway │
└───┬────┘ └───┬────┘ └───┬────┘
│ │ │
└──────────┼──────────┘
│
┌──────────────▼──────────────┐
│ AgentCost API Server │
│ (FastAPI) │
├─────────────────────────────┤
│ Traces │ Forecasts │ Optim │
│ Budget │ Analytics │ Estim │
├─────────────────────────────┤
│ SQLite / PostgreSQL │
└──────────────┬──────────────┘
│
┌────────────────────┼────────────────────┐
│ │ │
┌─────▼─────┐ ┌──────▼──────┐ ┌──────▼──────┐
│ Dashboard │ │ OTel / │ │ Prometheus │
│ (React) │ │ Grafana │ │ /metrics │
└────────────┘ └─────────────┘ └─────────────┘
Send cost data to your existing observability stack:
# OpenTelemetry (Datadog, Jaeger, Grafana Tempo)
from agentcost.otel import install_otel_exporter
install_otel_exporter(endpoint="http://localhost:4317")
# Prometheus (Grafana, AlertManager)
# Enabled automatically at /metrics when server is running
Extend AgentCost with plugins:
# Install community plugins
agentcost plugin install agentcost-slack-alerts
agentcost plugin install agentcost-s3-archive
# Create your own plugin
agentcost plugin create my-plugin
Plugins can export data, add alerting, create custom views, and more. See the Plugin Development Guide.
npm install @agentcost/sdk
import { AgentCost } from "@agentcost/sdk";
const ac = new AgentCost({ project: "my-app", apiUrl: "http://localhost:8500" });
// Trace any LLM call
const traced = await ac.trace({
model: "gpt-4o",
inputTokens: 150,
outputTokens: 80,
cost: 0.0035,
latencyMs: 450,
});
git clone https://github.com/agentcostin/agentcost.git
cd agentcost
docker compose -f docker-compose.dev.yml up
# → http://localhost:8100
# Full stack: PostgreSQL + Keycloak SSO + API
docker compose up -d
# Configure SSO
export AGENTCOST_EDITION=enterprise
export AGENTCOST_AUTH_ENABLED=true
export KEYCLOAK_URL=http://localhost:8180
For teams and organizations that need governance:
| Feature | Description |
|---|---|
| SSO/SAML | Keycloak integration, OIDC + SAML 2.0 |
| Organizations | Multi-tenant team management with roles |
| Budget Enforcement | Cost centers, allocations, pre-call validation |
| Policy Engine | JSON rules: block models, cap costs, require approval |
| Approval Workflows | Human-in-the-loop for policy exceptions |
| Notifications | Slack, email, webhook, PagerDuty alerts |
| Agent Scorecards | Monthly agent grading (A–F) with recommendations |
| Audit Log | Hash-chained compliance trail |
| Anomaly Detection | ML-based cost/latency spike detection |
| AI Gateway | Transparent LLM proxy with policy enforcement |
Enterprise features are source-available under BSL 1.1. See enterprise/LICENSE.
→ Contact us or read the docs
| Variable | Default | Description |
|---|---|---|
AGENTCOST_PORT | 8500 | Server port |
AGENTCOST_EDITION | auto | community, enterprise, or auto |
AGENTCOST_AUTH_ENABLED | false | Enable SSO (enterprise) |
AGENTCOST_DB_URL | SQLite | PostgreSQL connection string |
KEYCLOAK_URL | — | Keycloak server URL |
We welcome contributions! See CONTRIBUTING.md for setup instructions.
git clone https://github.com/agentcostin/agentcost.git
cd agentcost
pip install -e ".[dev,server]"
pytest tests/ -v
Documentation · Issues · Discord · Twitter
Download counts and popularity will appear here as the collector receives them.
| Version | Published | Direct dependencies | Open version |
|---|---|---|---|
| 1.0.0 | 1 Mar 2026 | 24 |
This describes our collected data; it is not a security assessment.
Observed since 20 Oct, 21:44 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package:65fb0c657a0542115589838329f556a84a44586c01c559250d4c686301ed1985