Guides / track llm cost litellm
How to track LLM cost in LiteLLM
Culpa's LiteLLM adapter is a logger you register on litellm.callbacks, and it carries more of the truth than any other framework path. LiteLLM's own response object is already openai-shaped, so it passes through nearly verbatim rather than being summarised. Culpa, a local-first LLM cost, margin, and forecast ledger, prices that response the same way it prices a call captured on the request path.
Why this happens
Fidelity across capture paths comes down to how much translation happens before the numbers arrive. A framework that invents its own usage shape has to summarise, and summarising loses the fields that set the price. LiteLLM already speaks the shape Culpa normalizes, so there's nothing to collapse, which makes it the path to trust when two of your ledgers disagree. That property is worth knowing before you pick which measurement to reconcile everything else against.
What this usually looks like
- Two capture paths report different totals for the same traffic and nobody knows which to believe.
- You've run LiteLLM for months with no cost history behind it.
- Historic spend exists only as provider invoices with no feature or customer attached.
- A trend line would decide a pricing question and there's no data old enough to draw one.
Free, no card, no account
Run the free Cost Leak Scan
It shows your most expensive conversation before you install anything.
Mistakes that cost the most
| Mistake | Why it hurts | Do instead |
|---|---|---|
| Picking a reference measurement by which number looks best. | The flattering number is usually the one that saw least, and you'll plan against a floor. | Pick the path that translates least, then reconcile the others against it and the invoice. |
| Starting your cost history on the day you install a ledger. | You wait months for a trend that already exists in logs you're keeping anyway. | Export your existing LiteLLM history and import it, so the trend line starts today. |
| Throwing away provider exports once the invoice is paid. | They're the only record of what you actually spent before you started measuring. | Keep them. An import can price them later against a dated price book. |
Run this check tonight
- List every capture path you're running and note how much each one translates.
- Reconcile each against last month's invoice and rank them by how close they land.
- Check how far back your LiteLLM logs go. That's how much history you can price today.
- Import a single month first and confirm the total matches that month's invoice.
- Once it does, import the rest and read the trend rather than the level.
Six months of history, priced on the day you install
Illustrative example
A team that's run LiteLLM for six months on GPT-5.4 at real rates of $2.50 per million input and $15.00 output. Volumes below are modelled and grow 5% a month on the input side.
An import turns six months of logs into a trend line on day one. The trend is the useful part, and it says input is growing and output isn't, which points the next investigation at prompt size.
Every number, with its confidence and source
| Figure | What it means | Confidence | Source |
|---|---|---|---|
| $900 to $1,024.25 | modelled monthly spend at the start and end of six months of imported history | estimated | Both endpoints from the teardown arithmetic at real GPT-5.4 rates from the price book, effective 2026-07-02. A range because the volumes and the growth rate are modelled. |
| 27.6% | modelled input growth across six months with output volume unchanged | calculated | 1.05 to the power of 5 equals 1.2763, from the teardown arithmetic. |
What a generic answer can’t know
Your provider invoices know totals and your framework logs know calls, and no party holds both with your features attached. Pricing old logs against a dated price book is what turns them into a trend. Culpa does that on your infrastructure, keeps your prompts and responses there, and counts the calls to run your plan.
Questions founders ask next
Why is the LiteLLM path more faithful than other framework adapters?
Because LiteLLM's response object is already openai-shaped, so Culpa's adapter passes it through nearly verbatim instead of rebuilding it from summarised token counts. Less translation means fewer fields lost on the way.
Can I import LiteLLM history rather than only capturing live?
Yes. A LiteLLM export is one of the accepted import formats, alongside provider usage exports, other observability exports and plain CSV. Culpa prices imported history with its own price book, so old calls get the rates that applied then.
Does registering the logger risk my completion calls?
No. Both hooks swallow their own failures, so a problem inside Culpa can never break a completion. That fail-open contract is deliberate and it applies across every capture path.
On your infrastructure
Culpa runs on your infrastructure. Your prompts and responses never leave it. Culpa counts calls to run your plan, and it fails open, so if it ever breaks your app keeps running.
How Culpa works
Find the culprit. Not just the total.
Your dashboard shows what you spent. It stops short of who spent it. Culpa shows the conversation, the user and the feature behind it.
Your prompts stay local.
Culpa runs on your own infrastructure. What you send to a model reaches us at no point.
Every dollar has a name.
Follow any charge to the conversation, the user, the feature and the customer behind it.
See the bill before it lands.
Cost your next feature before you ship it. You get the likely bill and the worst case, at best, median, p90 and p99.
Three steps to your first answer.
Change one base URL.
Or drop in the Python or TypeScript library.
Find your most expensive conversation.
In the first session, not the first week.
Cost your next feature before you ship it.
Why the bill went up
Example dashboardCalls traced
418,209
across 3 projects
Spend this week
$378.41
+ $182 vs last week
Failed calls
312
74% retried, and you paid for all of them
+ $182 this week traced to one culprit
Spend over 14 days
Most expensive users
Next week forecast
Graded against reality. Accuracy shown as results land.
Free, no card, no account
Run the free Cost Leak Scan
It shows your most expensive conversation before you install anything.
Keep reading
Sources: OpenAI API pricing. Last reviewed 2026-08-02. Plain text version.