A Practical Guide to Cutting LLM Inference Costs: Context Caching and Reasoning Effort Selection

    Large language model inference costs can spiral in long, multi-step agentic tasks, where the same context is read over and over and billed every time. This guide explains two levers for reducing those costs: context caching (prompt caching), which makes repeated reads of a stable prefix an order of magnitude cheaper, and reasoning effort tiers, which let you balance quality, latency, and cost per task. It covers how caching matches on stable prefixes, why agentic workloads benefit the most, how to model real savings from cache hit rates rather than surface unit prices, and a practical framework for choosing reasoning tiers. A closing checklist turns the strategy into a measurable optimization loop.

    1. Why Cost Is a Core Constraint in LLM Engineering

    When you move large language models into real production workloads, one thing becomes clear quickly: the per-call token cost looks small in isolation, but it multiplies across long-running, multi-step tasks. This is especially true for the agentic workloads that are now common—where a model reads a code repository, calls tools repeatedly, and shares the same context across many steps. Every “re-read” is billed again. If the billing model has no optimization for repeated reads, the cost of a long task grows roughly linearly with the number of steps, or even faster.

    This makes two things critical to understand: first, how caching reduces the cost of repeated input; and second, how the reasoning effort level (how deeply the model “thinks”) affects both quality and cost. This article covers both dimensions and lays out a practical framework for selection and optimization.

    2. Context Caching: Making “Repeated Reads” Cheaper

    2.1 What a Cache Read Really Is

    LLM billing is typically priced separately for input tokens and output tokens. Without caching, even if you send nearly identical prefixes (system prompt, tool definitions, conversation history, long documents) across consecutive requests, the model recomputes that prefix every time, so that input is effectively billed repeatedly.

    The idea behind context caching (commonly called prompt caching or context caching) is to temporarily store the “processed result” of a repeatedly used prefix. When a later request hits the cache, that prefix is billed at a very low rate instead of being recomputed at the normal input price. In one sentence: cache reads make “having the model re-read input it has already processed” an order of magnitude cheaper.

    2.2 Why Agentic Workloads Benefit the Most

    Agentic workloads are characterized by “the same context being read repeatedly”:

    • The system prompt and tool schema stay constant throughout a session;
    • Across multiple tool-call turns, the history keeps growing, but the earlier portion is a stable prefix;
    • Scenarios like code analysis and long-document Q&A often ask multiple follow-up questions about the same large context.

    The common thread is a highly stable prefix with a very high reuse rate, so cache hit rates are naturally high and the savings far exceed those of a one-off Q&A exchange.

    2.3 Cache Hit Conditions and Engineering Considerations

    Whether caching works depends on a few engineering details:

    1. The prefix must be stable and ordered. Caching usually matches on the “longest common prefix,” so any change early in the sequence invalidates everything after it. Put stable content (system prompt, tool definitions) first and volatile content (timestamps, random IDs, the user’s latest input) as late as possible.
    2. It usually requires an explicit write. Most solutions require you to mark “cache this prefix” on the first request, then reuse it within its validity window; caches typically have a time-to-live (TTL), and expired entries must be rewritten.
    3. Hit rate needs monitoring. Caching is not free—the write itself has a cost, and if a prefix is used only once or twice before being discarded, caching can cost more than it saves.

    A simple layout principle:

    1. [Stable prefix: system prompt + tool schema + long document] ← cache this
    2. [Semi-stable: multi-turn conversation history]
    3. [Volatile: user's latest question + random parameters] ← do not cache

    3. Cost Modeling: Where the Savings Actually Come From

    A common misconception is worth clearing up: a “price cut announcement” does not always lower the base unit price. Often the base input/output unit price stays unchanged, and the entire cost reduction comes from a drop in the cache read price.

    A hypothetical example (numbers are only to illustrate the calculation, not any real product pricing): suppose a model charges 10 units per million input tokens and 50 units per million output tokens, and the cache read price drops from 1 unit to 0.25 units per million tokens.

    • If, in a request, the stable prefix (which makes up most of the input) fully hits the cache, the cost of that input drops to one-quarter of the original;
    • Because cache-hit input makes up a high share of agentic workloads, the overall blended cost can be significantly lower than the surface unit price suggests.

    This explains estimates like “typical workloads see cost reductions of about one quarter, and agentic workloads up to nearly one half”—the reduction is driven almost entirely by the cache hit rate, not by a lower unit price.

    Practical advice: don’t look only at the price table. Run a weighted estimate based on your own workload’s “cache hit rate” and “input/output ratio.” A high-reuse, long-context agent and a short Q&A application can differ several-fold in actual savings.

    4. Multiple Reasoning Effort Tiers: The Quality/Latency/Cost Triangle

    4.1 What Reasoning Effort Is

    Modern reasoning models commonly offer an adjustable “reasoning depth/effort” level, usually split into tiers from low to high (e.g., low / medium / high and above). Higher tiers mean more internal “thinking” before the model answers, which often brings stronger complex-reasoning ability but also more output tokens, higher latency, and higher cost. Notably, these models usually do not offer an option to “turn reasoning off completely”—reasoning is part of the model’s capability, and what you can adjust is the depth, not the presence.

    4.2 Suitable Scenarios for Each Tier

    • Low: suited to “fast and accurate” tasks such as intent classification, formatted extraction, simple rewriting, and routing decisions. These tasks are latency-sensitive and need little deep reasoning, so a high tier is pure waste.
    • Medium: suited to routine code generation, structured summarization, and standard Q&A—the cost-effective range for most everyday tasks.
    • High and above: suited to complex debugging, multi-step planning, difficult algorithm derivations, and agent decisions that need long-chain logical consistency. Here the extra reasoning tokens buy correctness and less rework, and may actually be cheaper overall.

    4.3 Selection Framework

    An actionable decision approach:

    1. First bucket tasks by difficulty and label each stage with “does this need deep reasoning.”
    2. Start at the low tier by default and measure accuracy on an offline evaluation set. If it meets the bar, don’t raise it; if not, increase tier by tier until the quality threshold is met.
    3. Factor “retry cost” into the total. Occasional errors at a low tier that trigger retries or human intervention often cost more than using a high tier from the start.
    4. Layer the agent pipeline. Use higher tiers at critical nodes like planning/decision-making and lower tiers at mechanical execution nodes, avoiding a one-size-fits-all approach across the whole chain.

    Example pseudocode:

    1. def pick_effort(task):
    2. if task.kind in ("classify", "extract", "format"):
    3. return "low"
    4. if task.requires_multi_step_planning:
    5. return "high"
    6. return "medium"

    5. Combining Both: Holistic Optimization for Long Tasks

    Caching and reasoning effort are not either/or; they are two knobs that stack:

    • Caching reduces the repeated-read cost on the input side and pays off most for long tasks with large stable prefixes;
    • Reasoning effort controls the investment on the output/thinking side and determines per-step quality and cost.

    For a typical agentic long task, the best combination is often: bring all stable context into the cache to raise the hit rate, while dynamically allocating reasoning effort by node difficulty, opening the high tier only where deep thinking is genuinely needed. Combining the two is what lets you push per-task cost to the minimum without sacrificing quality.

    6. Conclusion and Deployment Checklist

    • Use a stable prefix + cache reads to cut repeated-input cost by an order of magnitude;
    • Run weighted estimates based on your own cache hit rate and input/output ratio, not just the price table;
    • Select reasoning effort by task difficulty, starting low by default and raising as needed;
    • Set effort tiers by layer across the agent pipeline, avoiding a one-size-fits-all approach;
    • Continuously monitor cache hit rate and retry rate to turn optimization into a measurable engineering loop.

    If your team is already using LLM services on a public cloud platform (such as Baidu AI Cloud), you can combine these strategies with the platform’s general product categories—caching capabilities, monitoring and alerting, and logging services—to build a sustainable optimization system with observable hit rates, gradual effort rollout, and attributable costs.