LLM API Billing Explained: Input, Output, Cache Reads and Writes, and Long Context

What one API call is charged for — uncached input, cache reads and writes, output and reasoning tokens — and how service tiers and long-context rules change the prices. With estimation tips, common billing questions and how to reconcile.

4 min read

Everyone knows LLM APIs bill by the token. Yet when the bill arrives, many people still can't say why a particular call was expensive. The reason is that tokens in one call don't share a single price: input, cache and output are each priced separately, and service tiers and context length can switch to a different set of prices. This post ties the rules together.

First, tokens

A token is the smallest unit a model processes, cut by its tokenizer. In English a token is roughly part of a common word; in Chinese a single character often maps to one or more tokens, depending on the tokenizer. Images and files are converted to input tokens too.

So the most accurate way to estimate usage is to let the API count for you:

  • Anthropic: POST /v1/messages/count_tokens counts input tokens in the official format — no generation, no charge.
  • OpenAI: each response's usage.input_tokens reports the input tokens actually counted for that call.

Five billable items in one call

ItemWhat it isPrice
Uncached inputInput sent this time that didn't hit the cacheBase input price
Cache readsInput that hit an earlier cache writeUsually far below the base input price
Cache writesInput written to the cache for later reuseDepends on lifetime; above base input on Anthropic
OutputEverything the model generatesUsually several times the input price
of which reasoningA reasoning model's thinkingCounted as output, billed at the output price

The charge is each item's tokens times its price, summed:

charge = uncached input × input price
       + cache reads    × cache-read price
       + cache writes   × cache-write price (by lifetime)
       + output         × output price
(prices are per million tokens)

Why output is priced highest — and reasoning deserves attention

Every output token requires a full forward pass of the model, while input is processed in parallel, so output prices are typically several times the input price.

Reasoning models amplify this: the thinking before the answer is billed as output too. The visible answer may be a few hundred words while usage shows ten times as many output tokens. Check completion_tokens_details.reasoning_tokens (Chat Completions) or output_tokens_details.reasoning_tokens (Responses) to see how much was thinking. How to manage it: Choosing reasoning effort.

Three rules that change the whole price set

Service tiers

Standard, Fast, Flex and Ultrafast each have their own prices for the same model. Fast is quicker and pricier, Flex is cheaper and slower. The tier you request — and the one the request is actually processed at — decides which prices apply. See Choosing a service tier.

Long context

For some models, once input exceeds a threshold, every billable item of the whole request uses long-context prices, not just the part above the threshold. GPT-6 models use 272K: a request with 300K total input has its input, cache and output all billed at long-context prices. See Making 1M-token context pay off.

Region

On Claude models that support inference_geo, requests with inference_geo: "us" (US-only inference) are billed at 1.1× for every item.

The three most common billing questions

One action, several requests? A coding agent's single action usually involves several model calls: reading files, planning, calling tools, reasoning again. Each one is a real call.

Are failed requests charged? That depends on the service. On UnioAPI, requests rejected before execution (400, 401, 402, 404, 429 …) are free, requests that fail before producing output are free, and an interrupted stream is billed for the output already delivered.

Same prompt, different charges? Different output length, different reasoning depth or a cache hit versus a miss all change the charge.

How UnioAPI bills

  • Sale price = official price × the model's discount. Official prices come from OpenAI's and Anthropic's public price lists; each model's official price, sale price and discount are on the model pages.
  • Billed at the price in effect when the request was made; later price changes don't affect past requests.
  • Charged per call from a US-dollar balance, by actual token usage, with no minimum spend.
  • One record per call: Request logs in the console list the model, tokens, tier and charge of every call.

To check a charge, follow Usage & billing records: find the record from the response's X-Request-ID, then recompute it from usage and the model page prices. The full rules are in Billing & usage.

Keep reading