LLM API Costs Explained: Cache Hit Rates, Token Pricing, and Subscription Economics

    The real cost of an LLM API depends on more than its advertised token price. This article examines how cached inputs, output volume, peak-hour pricing, and subscription allowances affect spending, with illustrative comparisons and practical guidance for monitoring and optimizing enterprise workloads.

    As large language models become part of production applications, API costs are becoming a significant concern for developers and businesses. Yet many teams still evaluate providers primarily by their published per-token prices, overlooking variables such as cache utilization, input-to-output ratios, and peak versus off-peak pricing.

    A useful cost assessment must account for how an application actually consumes tokens. Taking a vendor-neutral approach, this article examines the factors behind effective LLM API costs and the economics of subscription plans.

    All prices below are expressed in Chinese yuan (CNY) and are retained as illustrative figures from the original comparison, not as current pricing offers.

    1. Cache Utilization: A Hidden Lever in LLM API Costs

    A common LLM API billing structure separates token usage into three categories:

    • Cached input tokens
    • Uncached input tokens
    • Output tokens

    Cached input tokens typically cost substantially less than uncached input tokens. Applications that reuse eligible context can therefore reduce their effective costs considerably.

    For prices quoted per million tokens, the basic calculation is:

    Total cost = (cached input tokens × cached input price + uncached input tokens × uncached input price + output tokens × output price) / 1,000,000

    Consider two illustrative models. Model A charges CNY 0.115 per million cached input tokens, while Model B charges CNY 0.05 per million cached input tokens during off-peak hours. Judged by cached input pricing alone, Model B appears to cost less than half as much.

    However, a single price does not determine the total bill.

    Scenario 1: 98% Cached Tokens

    Suppose an application processes 100 million tokens, with the following distribution:

    • 98% cached input
    • 1.5% uncached input
    • 0.5% output

    Under the pricing assumptions used in the comparison, Model A costs CNY 12.57, while Model B costs CNY 9.40.

    In this scenario, Model B’s low off-peak cached input price translates into a lower total cost.

    Scenario 2: 95% Cached Tokens

    Now suppose the workload becomes less repetitive and its token distribution changes:

    • 95% cached input
    • 3% uncached input
    • 2% output

    For the same 100 million tokens, the illustrative total rises to CNY 14.92 for Model A and CNY 18.25 for Model B. Model A is now the less expensive option.

    These totals depend on the full pricing assumptions, including uncached input and output rates, which are not provided in the example. They illustrate a cost reversal rather than a fully reproducible price comparison.

    There is also an important distinction in terminology: the percentages above describe cached tokens as a share of all processed tokens, including output. A provider’s reported cache hit rate may instead measure cached tokens as a share of input tokens. Cost models must use consistent definitions.

    The central lesson remains the same: API prices cannot be evaluated independently of workload characteristics. Differences in uncached input and output prices can outweigh an apparent advantage in cached input pricing.

    Before choosing a model, teams should measure how much context their applications actually reuse and how that reuse affects billable token categories.

    2. How Input-to-Output Ratios Affect the Bill

    Cache utilization is only part of the calculation. The balance between input and output tokens also has a substantial impact on spending.

    The first scenario allocates 1.5% of total tokens to uncached input and 0.5% to output. This represents a context-heavy workload with relatively short responses, such as some code-completion or short-answer tasks.

    Agent workflows and long-form processing can have very different distributions. Output tokens often cost several times as much as input tokens. Applications that generate long documents, perform extensive code refactoring, or involve repeated reasoning and generation may therefore spend a larger share of their budget on output.

    For these workloads, output pricing can become the deciding factor in model selection.

    Rather than applying one token ratio to an entire application, developers should build workload profiles for individual functions, such as:

    • Conversational interactions
    • Retrieval-based workflows
    • Content or code generation

    Modeling token distributions separately for each function produces a more realistic estimate of overall costs.

    3. Subscription Plans: Balancing Predictability and Utilization

    Alongside pay-as-you-go APIs, some providers offer developer subscriptions, including plans designed for AI-assisted coding. These typically combine a monthly fee with usage allowances that vary by tier.

    One illustrative coding subscription offers the following monthly prices:

    Plan Monthly price
    Lite CNY 118
    Pro CNY 538
    Max CNY 1,078

    An important detail is how the service defines peak hours. In this example, peak usage runs from 14:00 to 18:00, Monday through Friday, according to the provider’s applicable time zone.

    This four-hour weekday window leaves a substantial amount of non-peak time available for work. Its practical value, however, depends on whether those hours align with the user’s working schedule and workload.

    Under an assumed 98% cached-token share, the example converts the provider’s stated allowances into the following figures:

    Plan Weekly non-peak token allowance Stated equivalent at standard API pricing
    Lite 317 million tokens CNY 160
    Pro 1.900 billion tokens CNY 955
    Max 4.433 billion tokens CNY 2,229

    The original comparison characterizes subscription unit costs as approximately 50%–70% of pay-as-you-go API costs. However, monthly subscription fees and weekly allowances must be normalized to the same period before that estimate can be validated. Actual savings also depend on how much of the allowance is used and whether the assumed token distribution matches the workload.

    For developers or businesses with steady demand—and the flexibility to schedule substantial processing outside peak hours—subscriptions can offer lower effective costs and more predictable monthly spending.

    The trade-off is utilization risk. Unused allowances may expire without a refund, while usage beyond the included quota may incur additional charges, subject to the plan’s terms. Subscription plans are therefore generally better suited to relatively stable workloads than highly irregular demand.

    4. Practical Cost Optimization for Enterprise LLM Applications

    Complex billing rules call for a systematic approach to optimization. Cloud infrastructure can support that process through scheduling, context management, and observability.

    1. Schedule Deferrable Work Outside Peak Hours

    Container platforms and message queues can support a scheduling layer that smooths demand and delays non-real-time work until lower-cost periods.

    Tasks such as overnight data cleaning and batch embedding generation may be suitable for deferred execution. Scheduling them during off-peak hours can help teams use discounted API rates or subscription allowances more effectively, where those tasks are eligible under the relevant pricing terms.

    The objective is to separate workloads that need immediate responses from those that can wait.

    2. Engineer Context Reuse

    Object storage and caching services can help applications manage frequently reused material, including:

    • System prompts
    • Long-document summaries
    • Codebase context

    Organizing and reusing this content can make more input eligible for provider-side context caching.

    However, application-side caching does not automatically create a billable cache hit at the model provider. Savings depend on the provider’s caching mechanism and eligibility rules. Teams should verify the cached input recorded in API usage data rather than assume that locally stored context receives discounted pricing.

    The goal is to reduce repeated processing of uncached input while preserving the context the application needs.

    3. Monitor Token Usage and Cost Drivers

    Cost optimization requires observability. Monitoring, logging, and alerting services from established cloud platforms, including Baidu AI Cloud where available, can support detailed tracking of LLM API usage.

    Teams should tag and aggregate usage by application or business function, monitoring:

    • Cached input tokens
    • Uncached input tokens
    • Output tokens
    • Cache utilization
    • Input-to-output ratios

    If a component’s cache utilization falls below an expected threshold—for example, 95% under the team’s chosen definition—an alert can trigger an investigation into context reuse and application behavior.

    This makes it easier to identify changes that would otherwise appear only as a larger bill at the end of the month.

    Conclusion

    The real cost of an LLM API is not captured by a single per-token price. It depends on cached and uncached input, output volume, context structure, time-based pricing, and the billing model.

    A reliable assessment starts with measured workload data, consistent token definitions, and comparisons made over the same billing period. From there, teams can improve context reuse, schedule flexible workloads during lower-cost periods, and choose between subscriptions and pay-as-you-go pricing based on actual utilization.

    That combination of financial modeling and engineering discipline helps keep LLM applications both technically useful and economically sustainable.