Same Price, Different Bill: Breaking Down LLM API Monthly Costs

    Many teams assume that choosing an LLM provider doesn't matter if the unit price for pay-as-you-go usage is identical. In reality, the final monthly bill can differ significantly due to multiple overlapping billing rules. This article explores the various billing components—such as input and output tokens, caching, batch processing, subscription plans, off-peak discounts, and regional pricing—that contribute to total LLM API costs. It provides actionable insights into optimizing expenses through cache management, task routing, subscription evaluation, and building a reusable cost estimation model.

    1. Same Price, Different Bill

    Many teams assume that choosing an LLM provider doesn’t matter if the unit price for pay-as-you-go usage is the same. In reality, the final bill can differ by up to 50%. This is because the bill is a combination of multiple billing rules, where unit price is just one factor. Batch discounts, cache billing, subscription plans, off-peak discounts, free tiers, and regional pricing all alter the final cost for the same volume of usage.

    Therefore, when evaluating costs, it’s crucial to distinguish between two concepts: the unit price is the list price, while the bill is the result of multiplying the usage of each billing item by its respective unit price, then applying discounts and plan rules. Comparing only unit prices means looking at just one multiplier of the total bill.

    2. Breaking Down Billing Items

    An LLM API bill typically includes the following types of billing items:

    • Input Tokens: Prompts, system instructions, context, and conversation history.
    • Output Tokens: Content generated by the model, usually priced higher than input.
    • Cache Hit Tokens: Billed when a repeated prefix is reused, with a unit price significantly lower than standard input.
    • Cache Write Fees: Fees incurred when writing to the cache for the first time. Some platforms tier pricing based on cache TTL (Time to Live).
    • Multimodal and Tool Calls: Image, audio, or external tool calls billed separately according to their own rules.

    Different platforms enable different billing items. Before selecting a provider, verify whether and how each platform charges for these items, rather than estimating based solely on input and output.

    3. Three Details of Cache Billing

    Caching can significantly reduce the cost of repeated context, but its cost structure requires attention.

    First, caching usually applies to request prefixes. System prompts, fixed documents, and long conversation histories should be placed at the beginning of the request, with variable content placed at the end. If a timestamp or random ID is placed at the beginning, the prefix changes with every request, and the cache will not hit.

    Second, the TTL determines the hit window. Short-TTL writes cost less, but if not reused before expiration, the cache becomes invalid. Long-TTL writes have a higher unit price, suitable for low-frequency but long-term reused context.

    Third, writes and hits are priced separately. If a prefix is only used once, the write cost may exceed the saved input cost, meaning caching actually increases the expense.

    The following function estimates the net savings for a single prefix. The parameters are illustrative; please refer to the official pricing pages of each platform:

    1. def cache_saving(prefix_tokens, reuse_count, input_price, hit_price, write_price):
    2. """Estimate net savings from caching. Prices are in USD per million tokens, parameters are illustrative.
    3. reuse_count represents the total number of requests using this prefix. The first request is a write, the rest are hits.
    4. """
    5. no_cache = prefix_tokens * reuse_count * input_price / 1_000_000
    6. with_cache = (
    7. prefix_tokens * write_price
    8. + prefix_tokens * (reuse_count - 1) * hit_price
    9. ) / 1_000_000
    10. return no_cache - with_cache
    11. # Example: 100,000 prefix tokens, input $10, hit $1, write $12.5
    12. print(cache_saving(100_000, 20, 10, 1, 12.5)) # Reused 20 times, saves about $16.85
    13. print(cache_saving(100_000, 1, 10, 1, 12.5)) # Reused 1 time, loses $0.25

    The example results show that the reuse count determines whether caching is worthwhile. Before going live, analyze the reuse count of each prefix from real logs to decide which context requires caching.

    4. Splitting Batch Processing and Real-time Calls

    Batch APIs typically accept asynchronous task submissions and return results within a specified time window, generally offering a lower unit price than real-time calls. These interfaces are ideal for data labeling, offline summarization, batch evaluation, and overnight report generation. Conversations where users are waiting or customer service scenarios requiring second-level responses must use real-time calls.

    The key to routing is categorizing tasks by latency requirements:

    1. Keep real-time tasks on the user-facing request path.
    2. Write offline tasks to a task queue, and have a scheduler submit them in batches according to time windows.
    3. Set timeout and retry rules for offline results to prevent tasks from hanging indefinitely.

    After routing, the proportion of batch tasks determines the overall savings. If a platform offers a 40% discount for batch processing and 40% of usage can be processed offline, the total cost saving is roughly 40% multiplied by the 40% discount ratio, or about 16%. This figure should be recalculated using actual task proportions.

    5. Subscription Plans and Overage Billing

    Subscription plans typically charge a fixed monthly fee that includes a certain quota, with pay-as-you-go billing for overages. The core of evaluating whether a plan is worthwhile is comparing the fixed fee with the monthly usage distribution.

    Let the monthly pay-as-you-go spend be U, the plan’s monthly fee be F, and the equivalent pay-as-you-go value of the included quota be Q. The monthly costs for the two methods are as follows:

    • Pay-as-you-go: U
    • Subscription plan: F + max(0, U − Q)

    This yields the following rules:

    • If U exceeds Q and F is less than Q, the plan is always cheaper.
    • If U does not exceed Q, the plan cost is fixed at F; it is only worthwhile if F is less than U.

    When evaluating practically, confirm the quota’s restrictions, including available models, whether the time window resets monthly, and whether the quota can be applied across models. If the quota terms do not match the business’s usage patterns, the nominal discount of the plan cannot be realized.

    6. Off-peak and Time-window Rules

    Some platforms offer discounts for calls made during specific time windows because the computing load is lower during these periods. For latency-insensitive tasks, scheduling calls during discount windows can directly reduce costs.

    Three things to note regarding these rules:
    First, clarify which time zone the window boundaries follow; this should be explicitly stated on the pricing page.
    Second, off-peak discounts may only apply to certain models or interfaces.
    Third, if the business operates across regions, use Coordinated Universal Time (UTC) uniformly in the scheduling layer to avoid time zone conversion errors.

    When estimating returns, use the formula: Overall Savings = Migratable Usage Ratio × Off-peak Discount Rate. This formula assumes stable unit pricing after migration; actual execution should be confirmed by observing data over a period.

    7. Regions and Access Points

    Pricing and compliance requirements may vary across different regions of the same platform. Unit prices in overseas regions are often higher than in domestic regions, and cross-border access increases network latency. If users are primarily located domestically, prioritize accessing the nearest region.

    When selecting a region, consider three factors simultaneously: user location determines latency, data export regulations determine available regions, and existing business deployment locations determine migration costs. Focusing only on unit price can lead to greater costs in latency or compliance.

    Additionally, free tiers for new models or interfaces are usually time-limited. When calculating long-term costs, base estimates on the post-free-tier unit price, rather than treating the free tier as a long-term rate.

    8. Building a Cost Estimation Model

    You can build a reusable estimation model in four steps:

    1. Collect Usage Logs: Record input tokens, output tokens, cache hits, request time, and latency requirements for each request.
    2. Categorize Tasks: Divide requests into real-time and offline categories, and annotate the prefix reuse status for each.
    3. Apply Platform Rules: For each candidate platform, sequentially apply list prices, cache rules, batch discounts, plan rules, and off-peak rules.
    4. Compare and Alert: Output monthly estimates for each platform and set up alerts for abnormal cost trends.