Training an LLM is a one-time compute event. Inference — running the trained model to generate responses — is the ongoing cost that scales with every user, every query, every token. It's where most of the money goes in production AI systems.
Inference is the process of passing input tokens through a trained model's neural network layers to generate output tokens. Each forward pass through the model produces one token at a time — that's why LLMs generate text sequentially rather than all at once.
The key parameters that drive inference cost:
Most providers charge 3-5x more per output token than input token. The reason: input tokens can be processed in parallel (the whole prompt at once), but output tokens are generated sequentially — each token must be generated before the next one can start. This sequential decoding is more compute-intensive per token.
| Provider | Model | Input per 1M | Output per 1M | Output/Input ratio |
|---|---|---|---|---|
| OpenAI | gpt-4o | $5.00 | $15.00 | 3x |
| OpenAI | gpt-4o-mini | $0.15 | $0.60 | 4x |
| Anthropic | claude-sonnet-4-6 | $3.00 | $15.00 | 5x |
| gemini-2.5-flash | $0.10 | $0.40 | 4x | |
| Mistral | mistral-large-latest | $2.00 | $6.00 | 3x |
The model processes all input tokens in parallel. This is fast but memory-intensive — the entire key-value (KV) cache for the input must be held in GPU memory.
The model generates output tokens one at a time, each depending on all previous tokens. This is the slow, expensive phase — and it's why keeping outputs concise matters so much for cost.
The key-value cache stores intermediate computations so the model doesn't reprocess the full context for every new token. It's the main bottleneck for long-context inference — a 128K context window can consume gigabytes of GPU memory just for the KV cache.
max_tokens and explicit instructions like "answer in one sentence"The average production prompt is 40-70% waste tokens. Inference optimization starts with knowing which tokens are doing work and which aren't.
Tokoscope tracks token usage, waste scores, and cost attribution per endpoint across OpenAI, Anthropic, Gemini, and Mistral.
Get started free →