Skip to content

Chapter 6.1 — Total cost of AI systems

🧠 Conceptual formula

Total cost =
  input_tokens + cache_read_tokens + cache_write_tokens
  + output_tokens (includes reasoning tokens)
  + embeddings + retrieval + reranking
  + tool calls + storage
  + observability + evals
  + retries + retraining
  + human review
  + serving_infra
  + incidents

💳 Token categories the invoice distinguishes

The "tokens" line of the formula hides four different prices. Order of magnitude across the three large API providers (prices checked on 2026-10-25; they change by model generation, so check the pricing page before budgeting):

Category Price relative to normal input Notes
Uncached input 1× Baseline
Cache read (prefix already cached) ≈0.1× Across the three providers; newer families reach lower multipliers. Requires a stable prefix and a per-model minimum (from 512 to 4,096 tokens)
Cache write Varies by provider Anthropic charges writes at 1.25× (5-min TTL) or 2× (1-h TTL) of the input price; Google charges storage per hour, which can exceed the savings on rarely reused caches; at OpenAI the cache is automatic on prefixes from 1,024 tokens
Reasoning tokens (thinking) Usually as output On providers with extended reasoning, reasoning tokens are usually charged as output (check each provider's pricing page); the user does not see them but pays for them; reasoning blocks are not directly cacheable
Batch (asynchronous) −50% on input and output Across the three providers, with a completion window of up to 24 h and per-batch request and size limits; only for load that tolerates waiting

Consequence for the cost model: estimate separately the fraction of input tokens served from cache (depends on the prompt architecture, Ch. 6.4), the share of reasoning in the output (depends on the model and the configured effort level) and the portion of the load that can go to batch. Three systems with the same raw token volume can differ several-fold in cost.

📊 Cost units

Unit Why it matters
Cost per call Basic estimate
Cost per step Bottlenecks in the agent
Cost per task The main product metric
Cost per journey Long workflows
Cost per tenant Chargeback / showback
Cost per error Retries and failures can dominate spend
Cost per eval Continuous tests consume budget
Cost per success Real efficiency (cost/success, not cost/call)
Cost per human review Latency and human operation enter

📚 References