Product · Methodology

How Weckr Calculates LLM Cost, and Why You Can Check Every Number

By Ghiles Asmani, founder of Weckr · Published August 15, 2026

Short version:cost is recomputed on the server from the provider’s own token counts times a centrally maintained price table, cache aware, with client supplied figures ignored. The table is watched weekly against published rates and is public as JSON, the math ships open source in the SDKs, and every dashboard row is hand checkable. Trust built from architecture and verifiability, not promises.

The formula, exactly

cost = (fresh_input_tokens  / 1e6) * input_rate
     + (cached_input_tokens / 1e6) * cached_rate
     + (cache_write_tokens  / 1e6) * cache_write_rate   // Anthropic
     + (output_tokens       / 1e6) * output_rate

Token counts come from the provider’s usage object on each response, the ground truth, not an estimate. The general arithmetic, including the unit conventions that trip people up, is in tokens to dollars; Weckr applies exactly that math with two additions: the recompute happens server side, and the rates are kept current automatically.

Why server side recompute matters

  • Anti forgery:the client’s opinion of cost is ignored, so a buggy or malicious client cannot deflate its own bill in your dashboard. What clients report is tokens, and those are cross checkable against provider reporting.
  • Anti drift:shipped SDKs age; the server table does not. When a provider reprices, one central update corrects every project’s numbers with no client redeploy.
  • Uniformity: TypeScript and Python callers, batched and streamed calls, all land in the same math.

Keeping the one fragile input honest

Everything reduces to the price table, and price tables rot: providers reprice suddenly, per LLM price history. So the table is infrastructure: a weekly automated watcher diffs it against published rates and opens a reviewed pull request on any change, and the table itself is public at useweckr.com/pricing.json, the feed described in the pricing JSON article. This machinery caught the July 2026 cut, including a drift in our own table, which was corrected and shipped the same day, in public. Edge handling worth knowing: dated model ids resolve to their family by longest prefix (never priced as zero), unknown models log with zero cost rather than a guess, and cached versus fresh tokens are always split.

Verify it yourself

The math is open source in the MIT licensed SDKs (calculateCost, resolvePricing, PRICING), the rates are public JSON, and any row in the dashboard is tokens times rates by hand. Our own release verification runs the published SDKs against production and checks costs to the cent, a process that has caught real bugs and shipped real fixes, documented as it happened. If a number ever looks wrong to you, the entire chain is inspectable, and the security model covers what we can and cannot see while computing it.

FAQ

How does Weckr calculate the cost of an LLM call?

From token counts, on the server, at current prices. The SDK reports the provider’s own usage numbers, fresh input, cached input, cache writes, and output tokens, and the API recomputes cost as tokens divided by a million times each rate, using a maintained price table. Whatever cost figure a client might send is ignored, so the number in your dashboard cannot be forged or drift with a stale client.

Why recompute on the server instead of trusting the SDK?

Two reasons: honesty and freshness. A compromised or buggy client could otherwise report any cost it liked, and even an honest client ships with a price table that ages. Server side recompute means one authoritative table, updated centrally, applied uniformly, and clients that never need a redeploy when providers reprice.

How does Weckr keep model prices current?

With machinery, not vigilance: an automated weekly watcher diffs the price table against published provider rates and opens a reviewed pull request when anything moves, and the same table is published as a free live feed at useweckr.com/pricing.json. This pipeline caught OpenAI’s July 2026 cut of up to 80 percent and had it shipped the same day, including one of our own tables that had drifted.

How are cached tokens and dated model ids handled?

Cached input bills at the provider’s cached rate (roughly a tenth of fresh input), Anthropic cache writes bill at their premium, and both come straight from the usage object. Dated or aliased model ids like gpt-5.4-mini-2026-05-01 resolve to their family by longest prefix match, so a date suffix never causes a call to be priced at zero.

Can I verify Weckr’s numbers independently?

Yes, three ways: the price table is public JSON at useweckr.com/pricing.json, the same math ships open source in the MIT licensed SDKs (PRICING, resolvePricing, calculateCost), and any dashboard row can be checked by hand, tokens times rates. Our release verification does exactly that against production, and it once caught a real pricing bug this way, which is the point of keeping everything checkable.

Keep reading

Checkable beats trustable

Every margin decision downstream is only as good as this math, which is why all of it is public. See it applied on the live demo, or put it on your own traffic with the ten minute integration.

See the dashboard with real data, no signup needed.

Try the demo →