← All guides
Guides · 8 min read

Input, Output, and Cached Tokens: What You're Actually Billed For

How input tokens are calculated, what cached input really costs, and the billing categories that surprise first-time API users.

Updated Aug 14, 2026 · Reviewed by PromptCostLab
A server room with rows of blue and green network cabling
Three token categories, three prices: knowing which is which is most of the bill. Image: Helpameout / Wikimedia Commons

Token and pricing information changes frequently. Use this guide for planning and verify model-specific limits and prices with the provider before production billing.

Three prices on every invoice

LLM APIs bill in up to three token categories, each with its own rate. Input tokens are what you send. Output tokens are what the model generates — usually the most expensive category. Cached input tokens are reused prompt prefixes the provider processed recently, billed at a fraction of the fresh-input price.

The surprises for new API users come from two directions: input is much larger than the visible prompt (history, tools, and retrieved text all count), and output is often the dominant cost even though prompts look bigger.

How input tokens are calculated

When your request reaches the provider, the entire payload is tokenized with the model's tokenizer. That includes the system prompt, every message in the conversation so far, retrieved documents, tool schemas, and structural formatting the SDK inserts (role labels, message boundaries). Each piece becomes a token ID, and the provider counts the total.

For planning, tokenize the assembled request — not the text box. A chat application on its fifth turn re-sends the four earlier turns as input every time, which is why conversation apps see input grow linearly per turn while each answer stays short. English prose runs about 4 characters per token; code and non-Latin scripts run denser.

Output tokens: the expensive side

Output rates typically run 3–6x input rates: Claude Sonnet 5 is $2 in / $10 out; GPT-5.6 Terra is $2 / $12; Gemini 3.6 Flash is $0.75 / $3.75. On models that always think — like Claude Fable 5 — the model's internal reasoning tokens are billed as output too, at $50 per million.

Budget output deliberately: set max-output limits that match the task, ask for structured concision, and stop generation when required fields are complete. A single runaway response can cost more than a thousand normal ones.

Cached input: the discount you should be using

Most providers now cache repeated prompt prefixes automatically or on request. The discounts are substantial: Anthropic, OpenAI, and Kimi bill reads at about 10% of input price; DeepSeek's disk cache hits cost roughly 1/120th of fresh input ($0.003625 vs $0.435 per million on V4 Pro); Mistral discounts 90%. Some providers also bill the first write: Anthropic and OpenAI charge 1.25x input for a 5-minute cache write (Anthropic's 1-hour write is 2x).

The pattern that pays off is a stable prefix: fixed system instructions and shared documents first, variable user content last. One changed character near the top can invalidate everything after it, so keep timestamps and random IDs out of the cached region.

A worked example

Consider a support assistant on Claude Sonnet 5 with an 8,000-token system prompt plus 2,000 tokens of retrieved help articles and an average 600-token answer. Uncached, each request costs about $0.022 in input plus $0.006 in output. With a 90% cache-hit rate on the stable 8K prefix, input drops to roughly $0.0058 — cutting the total bill by more than half. At 50,000 requests a month, that is real money from one structural decision.

The PromptCostLab caching calculator runs exactly this math across providers, including write costs and hit-rate assumptions you control.

Reading the usage fields

After each request, provider usage responses report the authoritative counts: input tokens, cached tokens (sometimes split into read and creation), output tokens, and reasoning tokens where applicable. Log these. They are the ground truth your estimates should be calibrated against, and they catch silent growth — a retrieval layer that quietly added 30% more context, or a model upgrade that changed tokenizers.

Frequently asked questions
What are input tokens?

Input tokens are everything you send to the model in a request: system instructions, the user's message, conversation history, retrieved documents, tool definitions, and file or image content after tokenization. Providers price input separately from output, usually cheaper per token.

How are input tokens calculated?

Your full request payload is tokenized — split into vocabulary pieces by the model's tokenizer — and every resulting token counts, including chat-role labels and formatting the SDK adds. A 10,000-character English system prompt is roughly 2,500 input tokens; tools and images add more through provider-specific rules.

What is a cache read?

A cache read happens when a provider reuses a previously processed prompt prefix instead of recomputing it. Reads are billed at a steep discount — typically 10% of the input price (Anthropic, OpenAI, Kimi) or less (DeepSeek's hits cost about 1/120th of fresh input).

Sources & further reading

Prices, token behavior, and model limits change. These primary provider docs are the right place to verify the details before shipping.

Put this into practice.Paste your own prompt into the calculator and see its context and cost tradeoffs.Open PromptCostLab calculator →