Guide

Training spends make headlines. Inference spends the money. Once a model is in production, every user message burns GPU-seconds, and the gap between a naive deployment and a tuned one is routinely an order of magnitude in cost per token. Product pricing, "should we self-host?", and "is this feature affordable?" all collapse to the same arithmetic.

For application-level latency/cost tradeoffs see latency and cost. For the fleet that feeds utilization, see autoscaling.

Concepts in this section

Read them in order. Each one builds on the one before.

StepConceptWhat it answers
1The token cost formulaHow do you go from $/GPU-hour to $/M tokens?
2Input vs output costWhy do prefill, cache hits and decode price differently?
3API vs self-hostWhen does owning GPUs beat paying per token?
4Pricing inference productsHow do you set a price that keeps margin?

A one-page cost model

Build this and revisit it after every major optimization or GPU price change:

  • GPU SKU and $/h, GPUs per model
  • Measured output tok/s at the concurrency you will actually run
  • Utilization assumption (often 40–70% of peak)
  • Separate lines for fresh input, cached input and output
  • Compare to API list prices on the same workload mix

Worked scale from the formula page: ~8B on one H100 at $2.50/h and 2,500 tok/s ≈ $0.28 / M; at half util ≈ $0.56 / M.

The levers that move the number are the same ones in the rest of this topic: continuous batching, quantization, prefix caching and speculative decoding. Each should show up as higher sustained tok/s on the same GPU, not as a slide that quotes peak.

As of 2025–2026, three curves move at once: API token prices trend down, GPU rental swings with supply, and software efficiency (MLA, FP4, disaggregation) raises tokens per GPU. Treat any absolute $/M in a blog post as a snapshot. Recompute from your GPU quote and your sustained tok/s quarterly.

Walking through $/M = ($/h) / (tok/s × 3600) × 1e6 with a utilization caveat beats vague talk about "GPUs being expensive."

Common mistakes

  • Peak tok/s in the denominator. Real $/M is often 2× the spreadsheet.
  • One token counter. Prefill-heavy agents and decode-heavy chat need different fixes.
  • Self-hosting on 20% util to beat an API. You will lose, then add on-call.

Key takeaways

  • $/M tokens = pool $/hour ÷ tokens per second × 1e6. Utilization is half the battle.
  • Meter fresh input, cached input and output separately.
  • API vs self-host hinges on volume, utilization, eng cost and quality.
  • Product-price from p95 COGS and cache-friendly design, or margin disappears at scale.

Further learning

SemiAnalysis × WEKA on token economics, interactivity vs $/token, and why prompt caching reshapes agent bills:

AI Token Economics and Prompt Caching Optimization | SemiAnalysis x WEKAWEKA
LLM Inference Performance Engineering: Best Practices (Databricks)databricks.com SemiAnalysisResearch, industry models, and advisory for the teams building, funding, and analyzing the AI buildout.semianalysis.com Artificial AnalysisComparison and analysis of AI models and API hosting providers. Independent benchmarks across key performance metrics including quality, price, output speed & latency.artificialanalysis.ai