LLM Cost Analysis: Caching, Time-Based Pricing, and Subscription Plans

    Calculate the true cost of large language model services by separating cached input, uncached input, and output tokens. This article explains how to evaluate cache hit rates, time-based pricing, subscription utilization, and cost per accepted task, then build a cost model that can be reconciled with actual bills.

    1. Why a Low Token Price Does Not Always Mean a Low Total Cost

    Discussions about large language model pricing often begin with the price per million tokens. Yet a single price describes only one billing category. It does not directly represent the cost of a task, a set of conversations, or an entire production system.

    One API call may include cached input, uncached input, and generated output. These categories often have different prices, and their proportions vary by workload. Usage-based pricing may also vary by time of day, while subscription plans may impose limits on quotas, concurrency, billing periods, and eligible use cases.

    A useful cost analysis therefore starts with three questions:

    1. Are the same billing categories being compared?
    2. Do the usage figures represent the same workload?
    3. Do the costs correspond to accepted tasks that meet the same quality requirements?

    Without consistent assumptions, even mathematically correct calculations may be unsuitable for purchasing or architecture decisions.

    2. Build a Consistent Token Cost Model

    Track Input and Output Separately

    Divide token usage within a reporting period into three categories:

    • H: Cached input tokens.
    • U: Uncached input tokens.
    • O: Output tokens.

    Let their respective prices per million tokens be Ph, Pu, and Po. The base API cost is:

    1. C = (H × Ph + U × Pu + O × Po) / 1,000,000

    Cached and uncached input must be mutually exclusive. Tokens counted in H must not also be counted in U.

    If a service separately charges for cache writes, cache storage, or other items, add those charges explicitly. Do not assume this formula covers the entire bill. The applicable billing rules determine which additional items need to be included.

    Distinguish Between Two Definitions of Cache Hit Rate

    The term “cache hit rate” can refer to metrics with different denominators.

    The first is the input cache hit rate:

    1. h = H / (H + U)

    The second is the share of all billable tokens represented by cached input:

    1. r = H / (H + U + O)

    These are not interchangeable. When output tokens are present, the second ratio is generally lower than the first.

    For example, suppose cached input represents 98% of all billable tokens, uncached input represents 1.5%, and output represents 0.5%. The input cache hit rate is actually:

    1. 98% / 99.5% ≈ 98.49%

    A cost report should therefore say more than “98% cache hit rate.” It should specify the denominator, reporting period, and whether the metric is weighted by requests or tokens.

    Prefer Token-Weighted Metrics

    A request-level cache hit rate cannot directly replace a token-level metric.

    If most short requests hit the cache while long requests frequently miss, the request-level hit rate may look strong without producing a comparable reduction in cost. For billing analysis, dividing total cached input tokens by total input tokens is usually more reliable than taking a simple average of per-request hit rates.

    3. Understand the Cost Structure with Hypothetical Prices

    The following prices are illustrative only. They do not represent any actual service, current quote, or purchasing recommendation. All amounts are in Chinese yuan (CNY).

    Assume a service charges:

    Billing category Price per million tokens
    Cached input CNY 0.10
    Uncached input CNY 1.00
    Output CNY 2.00

    During one reporting period, total billable usage is 100 million tokens:

    • Cached input: 98%.
    • Uncached input: 1.5%.
    • Output: 0.5%.

    The total cost is:

    1. C = 98 × 0.10 + 1.5 × 1.00 + 0.5 × 2.00
    2. = CNY 12.30

    Now suppose the cached-input share falls to 95%, while the output share remains at 0.5%. The uncached-input share consequently rises to 4.5%.

    The cost becomes:

    1. C = 95 × 0.10 + 4.5 × 1.00 + 0.5 × 2.00
    2. = CNY 15.00

    A three-percentage-point decline in the cached-input share increases cost by approximately 22%. The reason is that lower-priced cached tokens have been replaced by higher-priced uncached input.

    This example shows why neither the cached-input price nor total token volume is sufficient on its own. The bill depends on the weighted combination of usage and prices across all billing categories.

    4. Calculate Cost Break-Even Conditions

    Fix Input Volume and the Output-to-Input Ratio

    Let total input volume be I, the input cache hit rate be h, and the output-to-input ratio be q:

    1. O = q × I

    The base cost can then be written as:

    1. C = I / 1,000,000 × [h × Ph + (1 − h) × Pu + q × Po]

    This expression highlights three major cost drivers:

    • As h increases, input cost generally moves closer to the cached-input price.
    • As q increases, output pricing has a greater effect on total cost.
    • The larger the gap between Pu and Ph, the more sensitive cost becomes to changes in cache hit rate.

    Different tasks therefore require different parameters. Long-context question answering, short-text classification, and long-form generation should not share a single fixed usage profile.

    Break-Even Points Apply Only to Specific Workloads

    To compare two pricing structures, substitute their respective prices into the cost formulas, set the formulas equal, and solve for the break-even cache hit rate or output-to-input ratio.

    That threshold is not a permanent purchasing conclusion. It assumes consistent input volume, output ratio, applicable pricing periods, and quality requirements. Changing any of these conditions may invalidate the comparison.

    A more practical approach is to build a cost sensitivity table. Test low, typical, and high cache hit rates while also varying the output ratio. This reveals how sensitive each option is to workload changes, rather than identifying only the lowest price under ideal conditions.

    5. Weight Time-Based Pricing by Actual Usage

    When prices vary by time period, do not multiply all usage by the lowest available rate.

    For time period t, let cached input, uncached input, and output volumes be Ht, Ut, and Ot, with corresponding prices Pht, Put, and Pot. Total cost is:

    1. C = Σ [Ht × Pht + Ut × Put + Ot × Pot] / 1,000,000

    In particular, avoid estimating the share of spending from the number of hours covered by a discounted rate. Workloads are rarely distributed evenly throughout the day. Interactive traffic may cluster during business hours, while offline batch processing may offer more scheduling flexibility.

    Deferrable tasks can be moved to a different execution window if delivery deadlines still permit it. Real-time services should prioritize response time and availability rather than introduce substantial delays solely to obtain a lower price.

    Do not assume cache hit rates remain unchanged across time periods, either. Cache expiration, request spacing, and content changes can all affect reuse. After rescheduling a workload, validate its billing behavior again.

    6. Evaluate Subscriptions by Usable Allowance, Not Advertised Allowance

    Confirm How the Allowance Is Measured

    A subscription may limit usage by request count, periodic quota, or another rule. An allowance does not automatically correspond to a fixed number of tokens.

    Without an explicit conversion rule, avoid presenting a plan as providing a specific monthly token volume. If an estimate is possible, state the assumptions, including average input length, average output length, cache hit rate, and applicable pricing periods.

    Also confirm that the plan supports the intended access method. Benefits intended for interactive use should not be assumed to cover automated batch API calls.

    Calculate the Actual Replacement Value

    Let S be the monthly subscription fee. Let A be the usage-based cost of the workload actually covered by that subscription.

    Define:

    1. Subscription cost ratio = S / A

    A ratio below 1 means only that the subscription costs less than equivalent usage-based billing for the workload being evaluated. It does not mean the subscription is cheaper in every scenario.

    If much of the allowance goes unused, even a substantial advertised discount may produce no real savings. Conversely, high utilization does not guarantee value if concurrency or reset-period limits prevent tasks from finishing. Additional usage charges and waiting costs may still need to be included.

    Do Not Treat Weekly and Monthly Allowances as Equivalent

    Weekly quotas, monthly subscription cycles, and calendar months do not align exactly. Multiplying a weekly allowance by a fixed number of weeks produces only a rough estimate.

    Accurate budgeting also requires checking:

    • When the allowance resets.
    • Whether unused allowance rolls over.
    • When the subscription takes effect.
    • How overages are handled.

    For enterprise accounting, a daily usage model tied to the actual billing period is preferable.

    7. Move from Token Cost to Cost per Accepted Task

    Low token costs do not necessarily mean low delivery costs. A more useful metric is:

    1. Cost per accepted task =
    2. Total cost during the reporting period / Number of tasks that pass acceptance criteria

    Depending on the business, total cost may include more than the API bill:

    • Charges for failed calls and duplicate requests.
    • Regeneration costs when results fail quality checks.
    • Human review and editing.
    • Context assembly, retrieval, and data processing.
    • Integration, monitoring, and ongoing maintenance.

    For example, a low-cost generation that regularly requires several rounds of correction may cost more to deliver than a task completed successfully on the first attempt. Cost evaluations should therefore report acceptance rate, average number of attempts, and response time alongside token prices.

    Multi-turn tasks also require attention to context growth. Conversation history, documents, and execution results accumulate, increasing subsequent input volume. Partial cache reuse does not make unlimited context growth harmless: unnecessary information can still add cost, latency, and quality risks.

    8. Establish an Auditable Cost Management Process

    Turn cost analysis into a repeatable process.

    1. Build a Representative Sample

    Include short requests, long-context requests, multi-turn tasks, and long-output tasks. Apply explicit acceptance criteria.

    Do not extrapolate to the entire business using only samples that easily achieve high cache hit rates.

    2. Record Billing-Relevant Data

    At a minimum, retain:

    • Request timestamp.
    • Input token count.
    • Cached input token count.
    • Output token count.
    • Retry count.
    • Task type.
    • Acceptance result.

    For sensitive workloads, prioritize the metadata needed for analysis. Avoid retaining complete business content solely for cost tracking.

    3. Run Sensitivity Analyses

    Test scenarios such as declining cache hit rates, longer outputs, concentrated usage, and underutilized subscriptions.

    Use the results to establish a reasonable budget range rather than a single estimate without clear assumptions.

    4. Reconcile Estimates with Bills

    Compare internal estimates with actual billing line items. Check that reporting periods, failed requests, additional charges, and time-period assignments are consistent.

    5. Optimize Within Quality Constraints

    Potential improvements include reducing repeated context, keeping reusable prefixes stable, limiting unnecessarily verbose output, and capping retries.

    However, do not retain outdated information merely to increase cache hits, or remove context essential to completing a task just to reduce token usage.

    Conclusion

    Effective LLM cost analysis is not about finding the lowest individual unit price. It is about building a model that reflects real workloads, explains actual bills, and predicts cost variation.

    Start with consistent token categories and cache hit rate definitions. Then account for output proportions, usage timing, subscription utilization, and task acceptance results.

    For developers and enterprises, the most valuable long-term metric is the total cost of completing an accepted task under defined quality, latency, and reliability constraints.