NewClaude Code & Codex tracking

Your AI bill spiked.Which agent did it?

AgentCost is open-source LLM cost tracking: every call traced to the agent that made it. Python and TypeScript, 3,500+ models, MIT licensed.

AgentCost Agents page: nine agents ranked by spend, including Claude Code and Codex
Try it on your numbers

Before you sign up,see what you’d find.

Pick the one that sounds like you. Every answer uses live model prices or runs on your own machine.

No account

What were your sessions worth?

Priced from the logs Claude Code, Codex and Antigravity already keep on your machine. No key, nothing sent.

Example: last 30 days, at API rates

$370.58

Claude Code$312.46

2,418 calls · 41 sessions

  • claude-opus-5$241.80
  • claude-sonnet-5-5$70.66
Codex$58.12

655 calls · 12 sessions

  • gpt-5.5$58.12

On a subscription, this is what the usage is worth, not a bill.

Tracks every major provider, 3,500+ models supported

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

Your invoice says what you spent. AgentCost answers who spent it, on what, and whether it had to.

Attribution

Which agent spiked the bill?

Every call priced and tied to the agent, model, workflow and developer that made it, even with twenty running at once. The one that moved is the one that's flagged.

Overview page: the three agents behind the bill. claude-code is up 19.6% on the previous window; support-triage-agent re-ran an identical call in 278 runs.
Tracing

Which runs are the expensive ones?

Every run priced, not just the average. The 478 runs that cost 4.5× the typical one, and the step looping inside them.

Workflows page: distribution of what one run costs, median $0.035, with the most expensive 5% (478 runs) highlighted.
Model fit

Did that call need that model?

Calls that only ever classify, on a model priced to reason. Spotted from token counts alone, with the switch and what it saves.

Optimizations: sentiment-classifier looks like classification, not generation; max output 14 tokens; $135.30 a month to save.
Guardrails

Can it stop before it spends?

Declare which tools, models and cost per run each agent may use. On Claude Code and Codex, a call that breaks the rule is refused before it runs.

Guardrails page: 119 breaching calls, 24 runs over a limit; email-drafter breached its read-only boundary 119 times.
Optimizations

What can we cut this month?

Each saving as a slice of the bill, with the change to make. Derived from your own usage. No model calls, no prompt content.

Optimizations page: $1,659.05 recoverable each month, 45.6% of a $3,640.70 bill, split into five changes.
  • Priced before it ships

    agentcost analyze prices the next version locally, and fails CI on a high finding.

  • New models, same week

    Prices for 3,500+ models, synced daily.

  • Python and TypeScript

    OpenAI, Anthropic, Gemini, LangChain, AI SDK. Streaming included.

  • Metadata only

    Token counts and timings. Never your prompts.

Week one

What a team findsin its first seven days.

Not a forecast. Each of these was raised on the NovaDesk demo project this week, on the row you see marked.

  1. Optimizationswhole project

    $1,659

    a month in savings across 5 suggestions: 45% of the project's spend, each with the change to make.

  2. Agentsclaude-code

    +21.7%

    week on week for claude-code, the fastest-growing line on the bill.

  3. Repeated worksupport-triage-agent

    283

    runs re-ran a call they had already made, word for word: $18.29 this week for nothing new.

  4. Failed spendfaq-bot

    3.4%

    of calls fail and are billed anyway: 848 failed calls this week.

  5. Model fitsentiment-classifier

    14 tok

    the longest answer in 33,451 calls. It classifies; it never needed a model priced to write.

  6. Guardrailsemail-drafter

    122

    guardrail breaches this week: send_email called in read-only mode.

The demo project's Agents page: nine agents ranked by spend over 7 days, with the signal AgentCost raised on each.
How it works

Two lines to add.Every call after, priced and named.

Step 1

Install, then init once

Call init before your clients are created. OpenAI, Anthropic, Gemini and LangChain calls are priced from then on. Your code, and what it returns, stays the same.

agent.py+2 lines
from agentcost import track_costs
from openai import OpenAI
track_costs.init(api_key="sk_...", project_id="your-project-id")
client = OpenAI()
client.chat.completions.create(
model="gpt-5.5",
messages=[{"role": "user", "content": ticket}],
)
# priced and sent in the background
Step 2

Name the work

Wrap a run to get its cost per run, per step and per tool, and to see loops. Optional: an unnamed call is still priced, just not attributed.

agent.py+5 lines
with track_costs.agent("support-triage-agent"):
with track_costs.workflow("support-triage"):
with track_costs.step("classify"):
queue = classify(ticket)
with track_costs.tool("search_docs"):
docs = search_docs(ticket)
with track_costs.step("draft_reply"):
reply = draft(ticket, docs)
Step 3

See where it went

Spend by agent, model, workflow and step, what moved, and what to change. Also as a weekly PDF for finance, or ask from Claude or Cursor through the MCP server.

The demo project's Overview: $880.25 spent in 7 days, up 5.6%, and $1,659.05 a month of recoverable spend.
Never in the way
Events are batched and sent in the background. Tracking never blocks a call.
Metadata only
Token counts, timings and cost. Prompts and responses never leave your process.
Hosted, or yours
Free cloud at agentcost.tech, or the same MIT-licensed stack on your servers.
Privacy

Built to know what your agents cost.Never what they said.

The SDK is a metadata-only tracker. Below is the event log as you'd see it: what each call cost, and how. Look for the prompt or the response. Neither is there.

One call, as storedAgent, model, tokens, cost, latency, status.Events page
The demo project's Events log: agent, model, tokens in and out, cost, latency and status for each call. No prompt or response column.

Verifiable, not promised

The wire payload is documented field by field, and each field links to the open-source SDK line that builds it.

Hashed, not stored

Duplicate detection uses a SHA-256 digest computed locally from the prompt. Only the one-way digest leaves your process.

Self-host for zero exposure

The same MIT-licensed stack runs on your infrastructure with Docker. No telemetry, no phone-home.

FAQ

Frequently asked questions

Getting Started

Technical

Pricing & License

Weighing up alternatives? Honest side-by-side breakdowns:

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

Ready now

Start with the agent that costs the most.

Free hosted cloud, or the same MIT-licensed stack on your servers. Two minutes to the first priced call. No card.

Not yet?

Watch the models you pay for.

One email when one of them changes price or gets a retirement date. Nothing else, and one click to stop.

Models · 2 picked

Used only for these alerts. See the privacy policy.