LLM API Pricing Explained: Token Costs, Context Caching, and How to Choose the Right Plan

    This article breaks down how LLM API costs actually work: why unit price alone doesn't reflect true cost, how official and third-party channels differ in price, context length, and throughput, how context caching reduces effective spend, and how to compare subscriptions against pay-as-you-go billing. It ends with a four-step framework and a pre-launch checklist for evaluating model providers.

    1. Unit Price Is Not Total Cost: Where Inference Costs Come From

    The floor of API pricing is typically set by compute, electricity, and server depreciation, while the ceiling depends on market supply and demand. How low a provider can push its prices also depends on inference engine optimization, cluster scheduling efficiency, and hardware utilization.

    Some vendors have claimed high theoretical margins in technical blog posts, but the original posts did not disclose their calculation methodology and the figures cannot be verified, so this article does not cite specific numbers. What can be said with confidence is that providers with more efficient inference have lower marginal cost per call, which gives them room to adopt low-price strategies and amortize fixed costs across high call volumes.

    This approach is commonly known as penetration pricing. A provider does not necessarily earn large profits on each call; instead, it aims to build a developer ecosystem through scale. For developers, the official first-party price is usually closest to the model’s true inference cost and works well as a comparison baseline. However, a low price alone cannot tell you whether a provider is operating at a loss or can sustain its pricing long term — that requires financial information.

    2. Same Model, Different Channels: Official vs. Third-Party Providers

    On aggregation platforms, the same open-source model is often offered by multiple providers at once, with large differences in price and parameters. The table below uses a set of data from the source material purely to illustrate the comparison method:

    Metric Official First-Party Channel Third-Party Reseller Relative Difference
    Input price (USD per million tokens) 1.74 4.45 ~2.6× the official price
    Output price (USD per million tokens) 3.48 5.50 ~1.6× the official price
    Context window 1M 800K ~80% of official
    Max output tokens 384K 131K ~34% of official
    Throughput (tokens/s) Not given in source Reported as 4 in source Test conditions unknown

    The third-party channel’s input price is about 2.6× the official price, while its output price is about 1.6×. Because the two multipliers differ, the overall gap cannot be summarized with a single number. The context window and maximum output length are also significantly reduced — roughly 80% and 34% of the official figures, respectively.

    One possible explanation for the performance gap is hardware. Third-party resellers often rent generic GPU resources and are constrained by interconnect bandwidth and VRAM capacity, making it hard to fully accommodate the memory required by long sequences. To keep the service usable, they may compress the KV cache (the space where the model stores intermediate computation results) or cap sequence lengths. First-party providers can tailor inference kernels to their own hardware and use dynamic batching to improve GPU utilization. These explanations are consistent with engineering common sense, but the source material provides no measured evidence, so readers should verify them independently.

    Throughput directly affects waiting time. At 4 tokens/s, generating 1,000 tokens takes about 250 seconds. In multi-turn conversations or long-document processing, that level of latency is hard for users to accept. When evaluating a service, check at least these four metrics:

    • Input/output unit price: Reflects direct monetary cost, but must be calculated against your actual usage.
    • Context window length: Determines how much material a single request can hold and how much history a multi-turn conversation can retain.
    • Max output tokens: Caps the length of a single response, which matters greatly for code generation and long-form writing.
    • Throughput: Determines response speed. If throughput is too low, even a cheap unit price is unusable in production.

    3. How Cache Hits Reduce Real Costs

    Context caching means that when the prefix of a request’s prompt matches a previous request, the server reuses the already-computed KV cache instead of recomputing that portion. This reduces both latency and compute, and is usually reflected in a lower billed rate.

    The figures given in the source material are: uncached input at roughly 1 RMB per million tokens, dropping to about 20% of the original price on a cache hit. These numbers may not apply to all platforms; always check the official pricing page.

    The effective input cost can be calculated as:

    Effective price = uncached price × (1 − hit rate) + cached price × hit rate

    Using the numbers above — uncached at 1 RMB per million tokens and cached at 0.2 RMB — an 80% hit rate yields an effective price of 1 × 0.2 + 0.2 × 0.8 = 0.36 RMB per million tokens. At a 0% hit rate, the effective price stays at 1 RMB. That is a difference of roughly 2.8×. The higher the hit rate, the more the real cost drops.

    Cache benefits vary significantly by scenario:

    • Multi-turn conversation: The conversation state built in earlier turns can be reused in later requests.
    • Code completion: When a user repeatedly edits the same file, the unchanged file header can hit the cache multiple times.
    • Knowledge-base Q&A: A fixed system prompt and repeated retrieved document chunks both generate cache savings.

    To improve hit rates, place the unchanging system prompt and static documents at the front of the prompt, and put the user input that changes each time at the end. Also confirm in the SDK or the returned usage field whether cached token counts are observable. If they are not, you cannot verify the hit rate, and your cost estimates have no solid basis.

    4. Subscription vs. Pay-as-You-Go

    Many subscription plans offer compute allowances that, when converted at API prices, far exceed the subscription fee. The source material mentions that in some heavy-usage scenarios, actual compute consumption can reach 20 to 30 times the subscription fee. However, that figure came without assumptions about usage frequency, model, or call volume, so it cannot be verified and is not adopted here.

    Providers may offer subscriptions for several reasons: collecting real interaction data for model iteration, increasing user retention, and leveraging sunk-cost psychology to encourage continued use. These are common business logics, but their impact on any specific provider requires financial and user-behavior data to assess.

    For developers, the most direct approach is to compute a ratio using your own call volume:

    Subscription value = total pay-as-you-go cost for the same usage ÷ subscription fee

    A ratio greater than 1 means the subscription is more cost-effective. For example, if a month’s usage would cost 300 RMB on pay-as-you-go and the subscription costs 100 RMB, the ratio is 3 and the subscription wins. If the ratio is below 1, pay-as-you-go saves more.

    The two models suit different scenarios:

    • Low-frequency or occasional tasks: Pay-as-you-go is usually more flexible and avoids paying for idle quota.
    • High-frequency code explanation and refactoring: If the ratio is clearly above 1, a subscription is likely more economical.
    • High-concurrency production services: These need stable latency and predictable costs, and pay-as-you-go makes budgets easier to control. Subscription plans typically come with usage limits and terms of service, so confirm those conditions before wiring one into a production pipeline.

    5. Building Your Own Cost Evaluation Framework

    Putting everything together, you can evaluate an LLM service in four steps:

    1. Baseline comparison: Use the official first-party price as the reference. If a third-party channel charges more while offering a shorter context window or output limit, choose cautiously.
    2. Effective cost calculation: Provided the context and output lengths meet your business needs, compute the actual spend per million tokens. At the same time, run load tests with your own real request samples and record time to first token and average throughput.
    3. Cache-friendliness assessment: Check whether the API offers cache control options, whether cached token counts are observable, and estimate the prompt reuse rate in your own workload.
    4. Channel tiering: For latency-sensitive online services that require stable output, prefer the first-party API. For latency-insensitive tasks like offline batch processing or data cleaning, you can test third-party channels — but verify output quality and stability first.

    Before going live, prepare a checklist and confirm each item:

    • Are unit prices and multipliers taken from official pricing pages, with the query date noted?
    • Do the context window and max output length cover the longest samples in your workload?
    • Do throughput test results state the concurrency level, input length, and output length?
    • Are cache hit rate and cached-token billing observable?