LLM API Pricing vs. Subscription Quotas: How to Calculate Your True Costs

    This article explores the gap between list prices and actual costs when using Large Language Model (LLM) APIs. It examines the variables that impact your total expenditure across pay-as-you-go and subscription models, provides a formula to calculate effective unit prices, and outlines a practical framework for cost accounting and optimization.

    1. List Price Is Not Actual Cost

    LLM services are typically offered in two ways. One is pay-as-you-go, where you pay for exactly what you use, with separate pricing for input tokens, output tokens, and cache hit tokens. The other is a subscription plan, where users pay a recurring fee to use the model within specified quota limits.

    The API list price can be seen as the suggested retail price and serves as the basis for pay-as-you-go billing. Subscription quotas, however, are set independently by providers based on compute supply, concurrency load, and cost structure. There is no direct conversion between quota limits and list prices. As a result, the effective unit price for the same model can vary significantly between these two channels, and looking solely at the list price does not reflect actual expenses.

    2. Four Variables Affecting Actual Cost

    1. Billing Units. Most services bill by token, but the unit prices for input, output, and cache hits differ significantly. For scenarios with long contexts or highly repeated prefixes, the cache hit rate will directly impact the total cost.

    2. Quota Structure. Subscription quotas might be calculated by time window, number of requests, or total token volume. Different quota structures convert into inconsistent per-token costs.

    3. Quota Pool Partitioning. Under a single account, conversational features and coding assistance features might use independent quota pools. If you calculate the usage of both pools combined, you may overestimate or underestimate the actual available quota.

    4. Reset Mechanisms. Periodic resets change the temporal distribution of usage. Quotas left unused before a reset are wasted, while concentrated usage after a reset might deplete the quota prematurely.

    3. Calculating the Effective Unit Price

    The effective unit price for a subscription user can be estimated using the following relationship:

    Effective Unit Price = Subscription Fee ÷ Actual Tokens Consumed in the Cycle

    The key to this formula is the denominator. If the quota is sufficient and usage is high, the effective unit price may be much lower than the list price. If a large amount of quota sits idle, the effective unit price will rise quickly. Once the quota is exhausted, if you switch to pay-as-you-go, the cost returns to the list price level. Therefore, when accounting for subscription costs, you must consider three scenarios simultaneously: quota limits, fallback upon exhaustion, and idle waste.

    4. Building a Cost Accounting Framework

    It is recommended to establish an accounting process following these steps:

    1. Analyze business scenarios and distinguish between high-frequency, low-complexity tasks and low-frequency, high-value tasks.
    2. Collect the distribution of input, output, and cache hit tokens for each scenario.
    3. Calculate the pay-as-you-go cost based on list prices as a baseline.
    4. Calculate the effective subscription cost according to plan rules, computing the in-quota and out-of-quota portions separately.
    5. Incorporate non-price factors such as quality, response speed, and stability to form a comprehensive judgment.

    Here is an example code. The prices used are demonstration parameters, not real prices for any service, and should be replaced with official data from the respective service in actual use.

    1. from dataclasses import dataclass
    2. @dataclass
    3. class Pricing:
    4. input_per_m: float # Price per million input tokens
    5. output_per_m: float # Price per million output tokens
    6. cache_hit_per_m: float # Price per million cache hit tokens
    7. def pay_as_you_go_cost(p: Pricing, input_tokens: int,
    8. output_tokens: int, cached_tokens: int) -> float:
    9. """Total cost for pay-as-you-go billing."""
    10. return (input_tokens * p.input_per_m
    11. + output_tokens * p.output_per_m
    12. + cached_tokens * p.cache_hit_per_m) / 1_000_000
    13. def subscription_unit_cost(monthly_fee: float, used_tokens: int) -> float:
    14. """Effective cost per million tokens for a subscription plan.
    15. used_tokens should be the actual tokens consumed during the cycle, not the total quota."""
    16. if used_tokens <= 0:
    17. raise ValueError("used_tokens must be greater than 0")
    18. return monthly_fee / used_tokens * 1_000_000

    When using this, note that used_tokens should reflect actual consumption. If the plan quota is not fully utilized, it should be calculated based on actual consumption, and the idle portion should not be included in the denominator.

    5. Common Misconceptions

    Misconception 1: Comparing only list prices. List prices reflect pay-as-you-go costs and do not directly correspond to the actual expenditure of subscription users.

    Misconception 2: Assuming quotas are always sufficient. Under high-intensity usage, quotas may deplete prematurely. Costs after exhaustion must be calculated separately and cannot follow the subscription unit price.

    Misconception 3: Ignoring the cache hit rate. If the stable, unchanging parts of a prompt can be cached, the total cost will drop significantly. Ignoring this will lead to overestimated costs.

    Misconception 4: Ignoring the independence of quota pools. If quotas for different features are mutually independent, calculating them together will distort the assessment of available quotas.

    6. Engineering Practice Recommendations

    Tiered Model Selection. For low-complexity tasks like formatting, classification, and summarization, you can use lower-cost models. For critical tasks requiring high reasoning capabilities, use more capable models.

    Record Usage. Record the number of input, output, and cache hit tokens for each request, and aggregate them by model, feature, and user dimensions. Enterprise scenarios can leverage logging services and monitoring alerts to set thresholds for anomalous usage.

    Design Cache-Friendly Prompt Structures. Place fixed system instructions and examples at the beginning of the prompt, and variable content at the end to increase the cache hit rate.

    Track Quota Utilization. Set usage progress reminders within the cycle for subscription quotas, and schedule high-value tasks before the reset to minimize quota waste.

    Regularly Review the Cost Model. Service pricing and plan rules may change. The accounting model should be updated regularly with the latest data to avoid making decisions based on outdated parameters.