How Cached Input Tokens Are Billed: Step by Step
§1 Step 1: Separate Cached Context From Generated Answers
Cached input tokens are prompt tokens whose previously computed context can be reused. They are not free tokens, and prompt caching is not a stored-answer service. The model still generates a new response, so output tokens remain a separate billing category. Repeated requests do not necessarily produce identical answers. ([developers.openai.com](https://developers.openai.com/api/docs/guides/prompt-caching))
For a practical walkthrough, imagine a support assistant that sends the same product handbook with every customer question. Your goal is to avoid paying the full processing price for that unchanged handbook repeatedly, while keeping each customer's question separate.
§2 Step 2: Identify the Three Input Billing Buckets
Before calculating savings, distinguish ordinary input, cache creation, and cache reuse. Anthropic documents separate usage counters for each category. Its ordinary input counter excludes tokens reported as cache reads or cache creation, so treating that counter as the entire prompt would undercount usage. ([platform.claude.com](https://platform.claude.com/docs/en/build-with-claude/prompt-caching))
- – Ordinary input tokens: Budget for new content billed at the applicable standard input rate.
- – Cache-write tokens: Check whether creating reusable context carries a separate rate or premium.
- – Cache-read tokens: Apply the applicable discounted rate to context actually reused.
Use this calculation after mapping the response fields into nonoverlapping buckets: input cost = ordinary tokens × ordinary rate + write tokens × write rate + read tokens × read rate. Divide by one million when rates are quoted per million tokens. OpenAI's documented calculation likewise separates these categories rather than charging every input token at the standard rate. ([developers.openai.com](https://developers.openai.com/api/docs/guides/prompt-caching))
§3 Step 3: Calculate a Cache Hit Without Double Counting
Consider an illustrative price schedule, not a Fluxio quote: ordinary input costs $2 per million tokens, cache writes cost $2.50, and cache reads cost $0.20. Assume a 10,000-token handbook, a 1,000-token question, and a cache configuration that writes only the handbook.
- – First request: Writing the handbook costs $0.025, and processing the question costs $0.002, totaling $0.027 before output.
- – Later cache hit: Reading the handbook costs $0.002, and processing the new question costs $0.002, totaling $0.004 before output.
- – Without caching: Processing all 11,000 input tokens at the ordinary rate costs $0.022 per request.
Across ten requests with one write and nine hits, input spending becomes $0.063 instead of $0.220, approximately 71% less. The first request costs more, but repeated reuse recovers that premium. Output charges are excluded from both totals.
§4 Step 4: Verify the Model's Actual Cache Rates
Never turn an illustrative discount into a universal assumption. For example, Anthropic lists Claude Haiku 4.5 at $1 per million ordinary input tokens, $1.25 for five-minute cache writes, $2 for one-hour writes, and $0.10 for cache hits. Those are direct-provider rates, not a verified relay quote. ([platform.claude.com](https://platform.claude.com/docs/en/build-with-claude/prompt-caching))
Before deployment, record the rates your actual API route charges. Include the model, cache duration, and any other billing modifiers in your estimate. A useful procurement question is whether the relay exposes cache usage clearly enough to reconcile individual requests with your bill.
§5 Step 5: Preserve the Prefix That Qualifies for Reuse
Prompt caching reuses matching prefixes, so place stable instructions and reference material before changing questions. Check minimum cacheable length and expiration rules rather than assuming every repeated sentence qualifies. Anthropic's default five-minute cache lifetime refreshes when reused, but an expired entry may require another write. ([platform.claude.com](https://platform.claude.com/docs/en/build-with-claude/prompt-caching))
For your test, send two requests with an unchanged handbook and different questions. Then change the handbook and repeat. Compare reported reads, writes, and total cost instead of judging caching from response speed alone.
§6 Step 6: Reconcile Cache Savings in a Streaming Application
Fluxio fits teams wanting a streaming-first, pay-per-token relay with one key across multiple model providers. Its OpenAI SDK compatibility makes it a practical option to evaluate alongside your existing client. Confirm cache-field forwarding and route-specific pricing before forecasting savings; compatibility alone should not be your evidence of a cache discount.
Log ordinary input, cache writes, cache reads, output, and time to first token for each test. Compare cold and warm requests separately. Treat a lower total cost per completed task, rather than a high cache-hit percentage alone, as your success criterion.
Sign up for Fluxio.