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.

Run a free scan

Mistakes that cost the most

MistakeWhy it hurtsDo 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

  1. List every capture path you're running and note how much each one translates.
  2. Reconcile each against last month's invoice and rank them by how close they land.
  3. Check how far back your LiteLLM logs go. That's how much history you can price today.
  4. Import a single month first and confirm the total matches that month's invoice.
  5. 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.

Month 1: (180 x $2.50) + (30 x $15.00) = $450 + $450 = $900
Month 6 after 5% monthly input growth: 180 x 1.05^5 = 229.7M input, so (229.7 x $2.50) + (30 x $15.00) = $574.25 + $450 = $1,024.25
Six months of history totals $5,761 priced from logs already on disk
The finding isn't the total, it's that input grew 27.6% while output held flat
Waiting to accumulate that trend live would have taken six months and cost the same money

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

FigureWhat it meansConfidenceSource
$900 to $1,024.25modelled monthly spend at the start and end of six months of imported historyestimatedBoth 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 unchangedcalculated1.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.

1

Change one base URL.

Or drop in the Python or TypeScript library.

2

Find your most expensive conversation.

In the first session, not the first week.

3

Cost your next feature before you ship it.

Base URLhttp://localhost:4545/v1Your traffic keeps flowing if Culpa ever stops.

Why the bill went up

Example dashboard

Calls 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

$0$20$40$60$8024262830020406
user_384report_generatorconv_91fprompt_v1894,220 tokens3 retries$6.81

Most expensive users

user_384$38.42
user_119$21.07
user_562$14.90
user_204$8.30
user_871$5.10

Next week forecast

Best$180
Median$240
p90$310
p99$395

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.

Run a free scan

Keep reading


Sources: OpenAI API pricing. Last reviewed 2026-08-02. Plain text version.