Skip to content
Reality Graph

Economics

Measuring LLM Token Costs

Last updated: 2026-07-173 min read

A lower token count is one measurement, not a savings or quality result. Separate uncached input, cached input, output, model requests, tool activity, latency, provider charges, review, and rework. Apply current account rates, then judge task acceptance independently.

Contents

Start from raw usage and the invoice boundary

Provider schemas do not expose one universal “token cost” number. The OpenAI Usage API separates input, cached input, output, and request counts and notes that financial reconciliation belongs to costs or invoice data. Anthropic’s documentation separates base input, cache creation, cache reads, output, and tool-related usage. Checked 17 July 2026. Field semantics, rates, models, tiers, contracts, and tools change, so retain raw usage and the rate source used for each calculation.

An illustrative ledger with replaceable assumptions

Example only-not a benchmark, invoice, forecast, or Reality Graph measurement. Assume one accepted change uses 8 model requests, 60,000 uncached input tokens, 40,000 confirmed cached-input tokens, 8,000 output tokens, and 12 tool calls. Let Pᵤ, P𝚌, and Pₒ be the account’s current per-million rates for those mutually exclusive token categories. The illustrative model charge is (60,000 × Pᵤ + 40,000 × P𝚌 + 8,000 × Pₒ) / 1,000,000.

If a proposed context change produces 48,000 uncached input tokens while every other assumption is held fixed, the arithmetic delta is 12,000 × Pᵤ / 1,000,000. That is not measured savings. Tool usage, latency, cache behavior, output, review, failures, and rework may also change. Replace every count and symbol with observed usage and invoice terms, and reject the comparison if task scope or acceptance criteria changed.

Do not collapse the cost dimensions

Measure each dimension in its own unit before asking whether a change reduced total workflow cost without degrading acceptance outcomes.
Observed unitCost treatmentWhat it does not show
Uncached input tokensProvider usage after removing overlapping cached categoriesMeasurement unit · 2026-07-17Map the provider's raw fields before normalization.Apply the current uncached-input rateBookkeeping ruleUse current account and invoice terms, not this page, for rates.Output quality, latency, or total costClaim boundary · 2026-07-17No automatic cross-metric conclusion.
Cached input tokensConfirmed cache reads/hits under the provider's schemaMeasurement unit · 2026-07-17Map the provider's raw fields before normalization.Apply the applicable cache rule only to confirmed cached usageBookkeeping ruleUse current account and invoice terms, not this page, for rates.That the cache was fresh, useful, or cheaper overallClaim boundary · 2026-07-17No automatic cross-metric conclusion.
Output tokensProvider-reported generated or reasoning categories as billedMeasurement unit · 2026-07-17Map the provider's raw fields before normalization.Apply the matching output-category rateBookkeeping ruleUse current account and invoice terms, not this page, for rates.Correctness, completeness, or review effortClaim boundary · 2026-07-17No automatic cross-metric conclusion.
Tool callsCalls, schemas, arguments, outputs, errors, and server-tool usageMeasurement unit · 2026-07-17Map the provider's raw fields before normalization.Add token effects and any tool-specific charge or runtimeBookkeeping ruleUse current account and invoice terms, not this page, for rates.That a call was necessary or successfulClaim boundary · 2026-07-17No automatic cross-metric conclusion.
LatencyWall time and, where available, model/tool spansMeasurement unit · 2026-07-17Map the provider's raw fields before normalization.Treat as a separate operational measureBookkeeping ruleUse current account and invoice terms, not this page, for rates.Spend or output qualityClaim boundary · 2026-07-17No automatic cross-metric conclusion.
Total workflow costModel, tools, infrastructure, human review, rework, and failed attemptsMeasurement unit · 2026-07-17Map the provider's raw fields before normalization.Sum comparable observed costs for the declared windowBookkeeping ruleUse current account and invoice terms, not this page, for rates.Future savings or causation without a controlled comparisonClaim boundary · 2026-07-17No automatic cross-metric conclusion.
Measure each dimension in its own unit before asking whether a change reduced total workflow cost without degrading acceptance outcomes.

Optimize only against an independent acceptance gate

Context selection, cache layout, model routing, session boundaries, and batching are hypotheses to test-not universal levers with fixed effects. A smaller context can remove noise or remove a required interface. A different model can change charge, latency, and failure rate in different directions. Keep task scope and acceptance stable, then compare the complete ledger alongside tests, review findings, defects, and rework. A written machine-checkable task boundary helps make that comparison repeatable; it does not predict the result.

Where Reality Graph fits

Reality Graph can retain one run’s task boundary, selected checks, usage artifacts supplied to it, observed results, changed files, and operator decision. The material it hands an agent is assembled as a scoped pack with secrets stripped before the prompt is built, so what a run carries is a recorded selection rather than whatever the editor had open. It does not meter every provider or tool automatically, set current prices, or prove that a smaller prompt lowered total cost or improved quality.

A bounded measurement can record

  • Raw provider usage, cache categories, model requests, tool calls, and elapsed time
  • The account-specific rate source and invoice date used in arithmetic
  • Observed tests, review findings, failures, rework, and task acceptance

It cannot establish by itself

  • A recurring or future saving from one illustrative token delta
  • Lower latency or total cost merely because one token category fell
  • Better output quality merely because fewer tokens were processed
A governed run can retain usage and acceptance evidence; it cannot turn an illustrative scenario into measured savings or quality improvement.

FAQ

What should an AI-coding cost measurement separate?
At minimum: uncached input, cached input, output, model requests, tool calls, tool-specific charges, latency, infrastructure, human review, and rework. Vendor schemas differ, so preserve the raw usage and invoice fields before normalizing them.
Does reducing input tokens reduce total workflow cost?
It can reduce one charge when the applicable rate and billed category remain constant. It does not by itself establish lower latency, fewer tool calls, less review, less rework, or lower total cost. Compare the complete workflow under an explicit measurement window.
How should prompt caching be counted?
Use the provider's actual usage fields and invoice rules. Some usage schemas report cached tokens as a subset of input; others expose cache creation and cache reads separately. Do not add overlapping fields twice, and do not apply a cached rate without a confirmed cache hit.
Do fewer tokens improve output quality?
No automatic relationship follows. Removing irrelevant context may help a specific task; removing required context may harm it. Quality needs an independent acceptance measure such as passed tests, review findings, defects, or rework-not token count as a proxy.
Can the example on this page predict savings?
No. It is labeled illustrative and uses symbols for current prices. Replace every count and rate with your observed usage and invoice data, then compare quality and total workflow cost. The arithmetic demonstrates bookkeeping, not a forecast.

Keep reading

Sources

Want to see what your last agent run would have looked like?

Request access