How LLM token pricing works: input, cached input and output

Updated

LLM token pricing is the rate an API charges per token processed, quoted in US dollars per 1M tokens, with separate prices for input tokens, cached input tokens and output tokens.

A request's cost is three counts multiplied by three prices. Once you know which tokens fall in which bucket, you can predict a bill to the cent.

The three prices

Prices on OpenScale, USD per 1M tokens
ModelInputCached inputOutput
DeepSeek V4.1 Flash$0.06$0.003$0.24
GLM 5.3 Flash$0.12$0.024$0.40
  • Input is every prompt token the model has to process from scratch.
  • Cached input is prompt tokens that repeat a prefix the provider processed recently, so the work is reused. It is the cheapest token. On these models it is 20x cheaper than input on DeepSeek V4.1 Flash and 5x cheaper on GLM 5.3 Flash.
  • Output is every token the model generates, reasoning included. Generating is slower than reading, so output costs more: 4x the input price on DeepSeek V4.1 Flash.

The formula

cost = (uncached input x input price
      + cached input x cached price
      + output x output price) / 1,000,000

The API response gives every count you need. In the Chat Completions format, usage.prompt_tokens is all input, usage.prompt_tokens_details.cached_tokens is the cached part, and usage.completion_tokens is output. Uncached input is the first minus the second. In the Anthropic Messages format, cached tokens arrive as cache_read_input_tokens.

A worked example

A coding agent session with 300 requests. Each request sends about 50,000 tokens of context and gets about 800 tokens back. Because the agent resends the same conversation each turn, 90% of the input is cached.

The session on DeepSeek V4.1 Flash
BucketTokensPrice / 1MCost
Uncached input1,500,000$0.06$0.09
Cached input13,500,000$0.003$0.0405
Output240,000$0.24$0.0576
Total15,240,000$0.1881

The same session with no caching would cost $0.9576. Input is 98% of the tokens, so for agents the input and cached input prices matter far more than the output price.

List price and the price you pay

A list price is the reference rate before any discount. OpenScale shows its list price struck through next to the price it bills. DeepSeek V4.1 Flash lists at $0.12 input, $0.006 cached input and $0.48 output per 1M tokens and bills 50% less. To compare two APIs, price the same workload on both, with your own cache hit rate. The price comparison does that for one agent workload.

Questions

Why is output more expensive than input?

The model reads all input tokens in one parallel pass, but it writes output one token at a time, so each output token takes more compute.

Are reasoning tokens billed?

Yes, as output tokens. They appear in usage.completion_tokens_details.reasoning_tokens.

What does "per 1M tokens" mean?

The price for one million tokens. A request with 2,000 input tokens at $0.10 per 1M costs $0.0002 for its input.

Sources

NextDeepSeek V4.1 Flash price comparisonThe effective price per 1M tokens on an agent workload, with caching counted in.