LLM API Cost Optimization: How Cache Billing and Reasoning Effort Affect Your Bill

    This article explains the main components of LLM API billing, including input, output, cache writes, and cache reads. It shows how cache-friendly context design and per-task reasoning effort settings can reduce costs for agentic workloads, using a recent pricing change as a case study.

    1. Starting from a Common Billing Puzzle

    Many teams that adopt LLM APIs run into the same problem. The number of calls does not grow noticeably, yet the bill keeps rising as the application becomes more complex. When teams break down the bill, the largest costs usually come from two sources: repeated billing for input tokens, and hidden consumption from reasoning effort levels. Neither reflects the model getting “smarter.”

    A recent pricing change from one model provider shows this clearly. In a new version, the provider kept the base input and output prices unchanged but cut the price of cache reads by 75%. For a typical workload, this lowers the total cost by about 25%. For agentic workloads, savings can approach 50%. This case is a useful example for understanding what makes up the cost structure of an LLM API.

    2. Four Components of Billing: Input, Output, Cache Writes, and Cache Reads

    LLM APIs typically bill by token across four dimensions:

    1. Input tokens: All the context sent to the model in each request. The unit price is relatively low.
    2. Output tokens: The content the model generates. The unit price is usually several times the input price.
    3. Cache writes: When long context is first written to the cache, the provider typically charges a premium over regular input.
    4. Cache reads: Later requests that hit the cache are billed at a price far below regular input.

    The fourth item matters most. Suppose input costs 10 USD per million tokens, output costs 50 USD per million, and cache reads drop from 1 USD to 0.25 USD per million. The cache read price looks like only one line item, but its effect is multiplicative. Cache reads often account for the large majority of total input tokens, so a price cut there changes the overall bill substantially.

    3. Why Cache Reads Are Critical for Agentic Workloads

    3.1 The Context Pattern of Agentic Workloads

    In a traditional single-turn question-and-answer call, each request carries a new context, so the cache hit rate is naturally low. Agentic applications work differently:

    • An agent repeatedly sends the same system prompt, tool definitions, and codebase summaries across multiple loop iterations.
    • Each tool call result is appended to the end of the context, but most of the content before it stays the same.
    • Long-running tasks can span dozens or hundreds of turns, so the same prefix is read by the model dozens or hundreds of times.

    Because of this, prefix caching has a very high hit rate. A 75% cut in cache read prices reduces the main cost item of a session by three-quarters.

    3.2 A Simplified Cost Estimate

    The following illustrative estimate shows the value of caching for an agent task:

    • Fixed prefix (system prompt, tool definitions, project documentation): about 50K tokens
    • Incremental content appended per turn: about 2K tokens
    • Total turns: 40

    Without caching, each turn pays the full input price for 50K tokens. The total billed input is about 52K × 40 ≈ 2.08 million tokens. With caching, only the first turn’s 50K tokens are billed at the cache write price. The prefix in the other 39 turns is billed at the cache read price, which is assumed to be 10% of the original input price:

    1. Input cost without cache ≈ 2,080,000 × input price
    2. Input cost with cache ≈ 50,000 × cache write price
    3. + (39 × 50,000) × cache read price
    4. + 80,000 × incremental input price

    Working backward from the stated figures, where a typical workload saves about 25% and an agentic workload saves about 45%, the savings get closer to the upper limit as the cache read price falls, the number of agent turns grows, and the prefix gets longer. This explains why the provider made cache reads cheaper. The pricing change encourages high-persistence agentic workloads to move to the platform.

    4. Reasoning Effort Levels: A Dial for Thinking Depth

    Another notable change in the new version is that reasoning capability is split into several effort levels, from low to high. The provider no longer offers an option to turn reasoning off completely.

    4.1 How Effort Levels Affect Cost and Latency

    Reasoning effort controls how large an internal “thinking” budget the model uses before it produces the final answer. In general:

    • Low: Very few thinking tokens. Responses are fast and cheap, which suits deterministic tasks such as classification, extraction, and format conversion.
    • Medium: A balance for routine coding, knowledge questions, and multi-step tool calls. Most agents use this level by default.
    • High and above: The model can run longer internal reasoning. This suits hard problems such as complex debugging, mathematical proofs, and architecture design. The cost is that thinking tokens are billed as output, so latency and cost both rise noticeably.

    A common mistake is to enable a high effort level globally as a “quality safeguard.” In practice, high effort on simple tasks usually adds cost without improving quality. A more practical approach is to route each task to an effort level:

    1. # Pseudocode: route reasoning effort by task complexity
    2. def pick_effort(task):
    3. if task.type in ("classify", "extract", "format"):
    4. return "low"
    5. if task.type in ("code_review", "tool_orchestration"):
    6. return "medium"
    7. return "high" # Reserve for complex reasoning and hard debugging

    4.2 The Economics of Combining Caching and Effort Levels

    Reasoning effort mainly affects the output side, including thinking tokens. Caching affects the input side. These two levers are independent of each other. The recommended order is to implement caching first, since it is highly predictable and does not reduce quality. After that, fine-tune effort levels and use an evaluation set to confirm that a lower level still meets your quality requirements.

    5. Same Model, Different Safeguards

    Another industry trend is worth watching. The same underlying model may be offered in variants with different safeguard levels. The public version targets general use. Controlled-access versions add extra safety alignment for sensitive areas such as cybersecurity and life sciences. For example, they may reduce false positives or limit the model’s ability to generate offensive code.

    For enterprise selection, the takeaway is that equal capability does not mean an identical product. Teams that handle sensitive data should evaluate each version’s content safety policies against their own compliance requirements, in addition to benchmark scores and pricing.

    6. A Practical Checklist for Model Selection and Cost Optimization

    1. Maximize prefix cache hits: Place stable system prompts and tool definitions at the start of the context, and put dynamic content at the end. Avoid inserting timestamps, random IDs, or other content in the middle that breaks prefix stability.
    2. Design the context structure for multi-turn tasks: Append incrementally rather than reordering the context each time, so that cache hits stay continuous.
    3. Route reasoning effort by task: Use a small-scale evaluation to find the lowest effort level that is sufficient for each task.
    4. Monitor cache hit rate: Track it as a core cost metric with alerts. A sudden drop in the hit rate usually means the context structure has changed in a way that causes problems.
    5. Track lifecycle and retirement timelines: Model versions usually follow a defined retirement policy. Build a buffer for migration into your architecture so you are not locked to a single version.
    6. Benchmark with your own workloads: Public benchmarks are only a reference. Use stress tests on your own tasks to determine real cost and quality.

    7. Summary

    This pricing change signals a clear shift. Competition among LLM APIs is moving from the unit price of a single call toward the total cost of ownership for agentic workloads. The large cut in cache read prices and the finer control offered by multiple reasoning levels both aim to lower the barrier for long-running, multi-step agent applications. For developers, understanding the billing structure, designing context to be cache-friendly, and choosing effort levels deliberately will control costs more directly than waiting for price cuts.