OSS · Python · works offline
See what every agent step costs.
StepCost is FinOps for LLM agents — a priced economics graph per run, not another flat trace viewer. Unit economics by step, feature, and customer.
$ pip install stepcost $ python examples/quickstart.py trace total: $0.0152 by step: {'plan': 0.000288, 'retrieve': 0.00016, 'execute': 0.01475} $ stepcost report ~/.stepcost/quickstart.db StepCost report — quickstart.db Total: $0.0152 across 1 traces / 7 spans By feature: support-bot $0.0152 By customer: acme $0.0152 By kind: llm_generation $0.0150 embedding $0.0002 Top traces: 47b3783e-22d $0.0152 Waste signals: (no waste flags) $ stepcost report ~/.stepcost/quickstart.db --trace 47b3783e trace support-bot 12,480 tok $0.0152 ├─ agent_step: plan 1,380 tok $0.0003 │ └─ llm gpt-4o-mini 1,380 tok $0.0003 ├─ agent_step: retrieve 8,000 tok $0.0002 │ └─ embedding text-embedding-3-small 8,000 tok $0.0002 └─ agent_step: execute 4,100 tok $0.0148 └─ llm gpt-4o 4,100 tok $0.0148
How it works
1. Instrument
Wrap agent steps and LLM calls. call.record(response) extracts invoice-safe tokens from OpenAI & Anthropic.
2. Attribute
First-class customer_id, feature_id, and agent-step graph — not loose metadata tags.
3. Report
stepcost report renders the cost tree, rollups, and waste heuristics. Stays local in SQLite.
Why StepCost
| StepCost | Langfuse / Helicone | |
|---|---|---|
| Agent step economics | Typed cost graph | Flat traces + metadata |
| Finance ledger | Versioned price table | Dashboard estimates |
| Billing accuracy | Cache read vs 5m/1h write, reasoning, Responses API | Often flat input × output math |
| Privacy | Metadata-only default | Often full prompt capture |
| Offline | SQLite, no cloud required | Usually SaaS-first |
Invoice-grade by design
Priced like your provider prices it
Cache reads at 0.1×, 5-minute cache writes at 1.25×, 1-hour writes at 2×, reasoning tokens split from output — for OpenAI (Chat Completions, Responses API, embeddings) and Anthropic. Verified on live Anthropic invoices: the latest 160-call run matched to the microdollar ($0.401618 = $0.401618); first run 0.0016% error.
Never a silent $0
Unrecognized usage shapes raise instead of recording zero. Models missing from the price table warn at runtime and show as "unpriced spans" in every report.
Doesn't lose your data
Spans persist at trace and process exit — no manual flush. Sink failures re-queue instead of dropping. Concurrent async agents keep correct parent/child cost attribution. <5ms p99 emit overhead.
Install
pip install stepcost # or: pip install "stepcost[langchain]" curl -sO https://raw.githubusercontent.com/bronette/stepcost/main/sdk/python/examples/quickstart.py python quickstart.py # $0, no API key stepcost report ~/.stepcost/quickstart.db
On PyPI · source on GitHub · Integrations: LangChain/LangGraph, LiteLLM, OpenAI & Anthropic client wrappers — zero code changes.
Pricing
SDK — free forever
MIT-licensed Python SDK, local SQLite sink, stepcost report
viewer, waste flags. Works fully offline. No account, no meter.
Hosted dashboard — early access
Team dashboard, alerts, and PR cost comments are being built with design partners, who get it free and set the price with us. Public pricing lands after that — usage-tiered, never a percent-of-spend tax.
Design partners
Shipping agents and burning API tokens?
We're looking for 3 teams to instrument one agent for 2 weeks — free. You get per-step cost + waste flags; we get honest feedback on whether this beats your existing observability bill.
Email us →