LLM API vs. Subscription Plans: Calculating the True Cost per Task

    This article explains why per-token prices alone cannot determine LLM cost and how to compare metered API billing with subscription plans on a per-task basis. It covers input/output pricing, cache-hit effective input rates, a per-task cost formula, subscription quota conversion, overage rules, a comparison checklist, and a sample Python script for calculating both options from task samples.

    1. Unit Price Does Not Equal Cost

    A recent LLM release raised API prices for input tokens, output tokens, and cache-hit tokens. Many developers immediately conclude that the model has become more expensive. But unit price is only one variable in the cost equation. To judge whether a model is expensive, you need to look at cost per task: how much it actually costs to complete a specific piece of work.

    Two common billing paths are metered API billing and subscription plans. They convert to cost in different ways, and the conclusion can even reverse. A model with a higher unit price may cost less in practice if each task produces short output and has a high cache-hit rate. A model with a lower unit price may produce a higher final bill if tasks require repeated retries or long outputs.

    This article first breaks down the three variables in metered billing, then explains how to convert subscription quotas into comparable amounts, and finally provides a checklist and a sample script.

    Pricing and quota rules may change by vendor and version. Before running any estimate, use the official price list and your own actual bills as the source of truth. All numbers in this article are example values for calculation purposes and do not represent any vendor’s real prices.

    2. Which Three Variables Should You Break Down First in Metered Billing?

    2.1 Input and Output Are Billed Separately

    Most APIs price input tokens and output tokens separately. For some vendors, the output price is several times the input price. The exact multiplier depends on the vendor and version, so use the official price list.

    Output is usually more expensive for roughly three reasons. First, output tokens are generated autoregressively one by one, requiring a computation at each step, which consumes more compute and latency. Second, vendors invest and optimize differently in the decoding stage, and the unit price reflects that cost. Third, output length is usually positively correlated with task complexity. For the same task, the longer the model output, the more it costs.

    Therefore, comparing output unit prices alone is not enough. You also need to estimate how many output tokens each task will roughly produce.

    In long-context scenarios such as whole-repository code understanding and long-document analysis, input tokens often account for most of the cost. Do not conclude this from experience alone. Context length and the proportion of repeated content vary greatly across tasks. You need to sample a batch of real tasks and count their input tokens to know the actual share of input in total cost.

    2.2 How Cache Hits Translate into an Effective Input Price

    Many platforms provide caching for repeated input prefixes. Tokens that hit the cache are billed at a lower hit price, while tokens that miss are billed at the standard miss price.

    The effective input price is calculated as follows:

    Effective input price = hit rate × hit price + (1 − hit rate) × miss price

    The hit rate must be calculated from your own task logs:

    Hit rate = input tokens with cache hits ÷ total input tokens

    Do not simply use a vendor’s advertised hit rate. In scenarios such as fixed system prompts, multi-turn conversations, and batch document processing, the hit rate may be high. In scenarios with a single question or a different context each time, the hit rate may be close to zero.

    2.3 Per-Task Cost Formula

    To calculate the cost of a single task, use the following formula:

    Cost per task = input tokens × hit price + input tokens × (1 − hit rate) × (miss price − hit price) + output tokens × output price

    The first two terms together represent the input cost calculated at the effective input price. The second term is the increment caused by cache misses. The parameter values are defined as follows:

    • Input tokens and output tokens: use the average over multiple runs of the task, or the median after grouping by task type.
    • Hit price, miss price, and output price: use the numbers in the official price list for the model version you use. Note that the unit is currency units per million tokens, so convert before calculating.
    • Hit rate: use the weighted average for the same batch of tasks, that is, the sum of hit tokens across all tasks divided by the sum of input tokens across all tasks.

    Here is an example calculation. Assume a task has 50,000 input tokens and 2,000 output tokens, with a hit price of 0.5 currency units per million tokens, a miss price of 2 currency units per million tokens, an output price of 8 currency units per million tokens, and a hit rate of 60%.

    • Base input cost: 50,000 × 0.5 ÷ 1,000,000 = 0.025 currency units
    • Miss increment: 50,000 × 0.4 × (2 − 0.5) ÷ 1,000,000 = 0.030 currency units
    • Output cost: 2,000 × 8 ÷ 1,000,000 = 0.016 currency units
    • Total: 0.071 currency units

    Check with the effective input price: effective input price = 0.6 × 0.5 + 0.4 × 2 = 1.1 currency units per million tokens. Input cost = 50,000 × 1.1 ÷ 1,000,000 = 0.055 currency units. Adding the output cost of 0.016 currency units gives the same total of 0.071 currency units. Both approaches produce the same result.

    3. How Do You Convert Subscription Quota into a Comparable Amount?

    A subscription plan has a fixed fee but limited quota. To compare it with metered billing, first convert the monthly fee into an equivalent unit price.

    Equivalent unit price = monthly fee ÷ available quota in the month

    For example, if the monthly fee is 200 currency units and the available quota is 400 million tokens, the equivalent unit price is 0.5 currency units per million tokens. If the quota is calculated on a weighted basis, meaning input and output consumption have different weights, first convert them into a unified basis by weight, then divide.

    Overage is usually billed separately at an overage price. After monthly consumption exceeds the quota, the actual cost is:

    Monthly total cost = monthly fee + max(0, monthly consumption − monthly quota) × overage price

    Divide the monthly total cost by the number of tasks completed that month to get the per-task cost under the subscription plan. This number must be compared with the metered per-task cost on the same basis.

    The comparison table below helps you confirm what data the estimate requires.

    Dimension API metered billing Subscription plan
    Billing unit Input, output, and cache-hit tokens Monthly fee, quota unit (tokens, calls, or credits)
    Overage rules Pay for what you use Billed at an overage price after quota is exceeded, or rate-limited or suspended
    Best fit Highly variable usage, low usage, need to switch models flexibly Stable usage, frequent calls, predictable usage
    Data needed for calculation Input, output, and cache-hit token counts per task Monthly fee, monthly quota, overage price, monthly consumption, task count

    Subscription Plan Checklist

    Before signing up, verify the following items one by one:

    • Whether the monthly fee and actual available quota match, and whether free credits have been deducted
    • Whether the quota unit is tokens, call counts, or credits, and whether input and output are weighted
    • Whether cache-hit tokens count toward quota, and at what proportion
    • What the overage price is, and whether overage is automatically billed or service is paused
    • Whether validity is monthly, quarterly, or yearly, and whether unused quota is cleared
    • What the rate limits are, such as requests per minute and tokens per minute, and whether requests queue during peak periods
    • Which models the plan covers, and whether it includes the specific version you need
    • Whether the contract has a price adjustment clause, and whether you can cancel or renegotiate if prices change

    4. Use a Sample Script to Compare the Two Options

    The script below reads a task sample file and calculates the total cost and per-task cost for metered billing and a subscription plan separately. The price parameters are example values; replace them with the numbers in the official price list before use.

    1. import csv
    2. # Unit: currency units per million tokens. Example values; replace with official price list numbers.
    3. PRICE = {
    4. "input_miss": 2.0,
    5. "input_hit": 0.5,
    6. "output": 8.0,
    7. }
    8. # Subscription plan parameters. Quota unit is million tokens and must match the actual metering basis.
    9. SUBSCRIPTION = {
    10. "monthly_fee": 200.0,
    11. "quota_m_tokens": 400.0,
    12. "overage_price": 0.8,
    13. }
    14. def api_cost_per_task(input_tokens, output_tokens, hit_rate):
    15. """Metered billing: return the cost of a single task in currency units."""
    16. hit_tokens = input_tokens * hit_rate
    17. miss_tokens = input_tokens - hit_tokens
    18. input_cost = (
    19. hit_tokens * PRICE["input_hit"] + miss_tokens * PRICE["input_miss"]
    20. ) / 1_000_000
    21. output_cost = output_tokens * PRICE["output"] / 1_000_000
    22. return input_cost + output_cost
    23. def subscription_monthly_cost(month_tokens_m):
    24. """Subscription plan: return total monthly cost in currency units. month_tokens_m is in million tokens."""
    25. excess = max(0.0, month_tokens_m - SUBSCRIPTION["quota_m_tokens"])
    26. return SUBSCRIPTION["monthly_fee"] + excess * SUBSCRIPTION["overage_price"]
    27. def main(path):
    28. with open(path, encoding="utf-8") as f:
    29. rows = list(csv.DictReader(f)) # Columns: input_tokens, output_tokens, cache_hit_tokens
    30. api_total = 0.0
    31. total_tokens = 0.0
    32. for row in rows:
    33. inp = float(row["input_tokens"])
    34. out = float(row["output_tokens"])
    35. hit = float(row["cache_hit_tokens"])
    36. hit_rate = hit / inp if inp > 0 else 0.0
    37. api_total += api_cost_per_task(inp, out, hit_rate)
    38. total_tokens += inp + out
    39. n = len(rows)
    40. sub_total = subscription_monthly_cost(total_tokens / 1_000_000)
    41. print(f"Task count: {n}")
    42. print(f"Metered API total cost: {api_total:.2f} currency units, per task {api_total / n:.4f} currency units")
    43. print(f"Subscription total cost: {sub_total:.2f} currency units, per task {sub_total / n:.4f} currency units")
    44. if __name__ == "__main__":
    45. main("task_samples.csv")

    Before running it, make sure the sample file covers a complete billing cycle, such as one month of real task records. With too few samples, both the average and the hit rate are unstable. The script assumes the subscription quota uses the same basis as actual token counts. If the plan weights input and output, you need to apply weighting at total_tokens before comparison.

    In the results, if the metered API total is clearly lower than the subscription total, your usage is relatively low and metered billing is more cost-effective. Conversely, if the subscription per-task cost is lower, your usage is stable and relatively high, making the subscription more suitable. When the difference is small, also consider rate limits, model coverage, and future price adjustment risk rather than looking at cost alone.