LLM API Pricing Changes: Cost Evaluation and Model Selection Methods

    As LLM API prices change across input, output, and cache-related billing items, model selection based only on a previously remembered per-token price can become unreliable. This article explains the key billing dimensions, shows how to build a monthly cost estimation model that incorporates cache hit ratios, and describes a task-tier routing approach that assigns primary, mid-tier, and lightweight models according to business value and precision requirements.

    1. Why Price Changes Can Alter Model Selection Conclusions

    LLM API prices are usually adjusted by providers through announcements, and the scope and size of those adjustments vary. Some changes affect the input unit price, some affect the output unit price, and others affect only the cache-hit portion. If developers rely only on the per-million-token price remembered from a particular point in time, the original model selection conclusion may become invalid after a price change.

    Model selection therefore needs to move from “checking unit prices” to “building a model.” By incorporating task call volume, context structure, and output length into the calculation, teams can determine how much a price change actually affects their own costs.

    2. Key Elements of the Billing Structure

    Billing for mainstream LLM APIs generally includes the following dimensions:

    • Input tokens: content that enters the model, such as user prompts, conversation history, and retrieved documents.
    • Output tokens: the response generated by the model. For most services, the output unit price is higher than the input unit price.
    • Cache-hit tokens: when the same prefix is reused, some services charge a lower unit price for this portion.
    • Cache-miss tokens: the input portion that needs to be recalculated and is charged at the standard input unit price.
    • Other billing items: for example, per-request billing, concurrency tiers, and tiered pricing for long context.

    Specific unit prices and rules are subject to each provider’s official page. When estimating costs, use the values from the current announcement and record the effective date of those values.

    The cache-hit item has the greatest impact on agentic tasks and multi-turn conversations. These tasks carry a large amount of repeated content in each round, such as system prompts, tool definitions, and history. If the cache-hit unit price increases, the share of total cost represented by the same call volume will change significantly. Conversely, if the price advantage of cache hits is substantial, the cost of long-context tasks can be kept very low.

    3. Building a Cost Estimation Model

    Before estimating costs, three metrics need to be collected: average daily requests, average input tokens per request (including the cache ratio), and average output tokens per request. With these data points, monthly cost can be calculated.

    Illustrative code:

    1. def estimate_monthly_cost(
    2. requests_per_day: int,
    3. input_tokens_per_req: int,
    4. output_tokens_per_req: int,
    5. cache_hit_ratio: float,
    6. price_input_miss: float,
    7. price_input_hit: float,
    8. price_output: float,
    9. days: int = 30,
    10. ) -> float:
    11. """
    12. Price unit: currency units per million tokens. cache_hit_ratio is in [0, 1].
    13. Return unit: currency units.
    14. """
    15. if not 0 <= cache_hit_ratio <= 1:
    16. raise ValueError("cache_hit_ratio must be between 0 and 1")
    17. total_input = requests_per_day * input_tokens_per_req * days
    18. total_output = requests_per_day * output_tokens_per_req * days
    19. hit_tokens = total_input * cache_hit_ratio
    20. miss_tokens = total_input - hit_tokens
    21. cost = (
    22. miss_tokens * price_input_miss
    23. + hit_tokens * price_input_hit
    24. + total_output * price_output
    25. )
    26. return cost / 1_000_000

    When using the model, substitute the unit prices of different services into the same business scenario and compare the results. To observe sensitivity to price changes, keep other parameters fixed and adjust only one unit price to see how much total cost changes. This helps teams determine which billing item is most worth optimizing.

    In addition to the monthly total, two unit metrics should be calculated: the average cost per business task and the monthly average cost per active user. These two metrics can be directly compared with product pricing and budget limits.

    4. Selecting Models by Task Tier

    Different tasks have very different requirements for model capability, so there is no need to use the same model for everything. A common approach is to tier by complexity:

    1. High-value tasks: architecture design, complex reasoning, and critical code generation. These tasks are sensitive to result quality and are suitable for a more capable primary model.
    2. Routine tasks: general Q&A, format conversion, and text summarization. These tasks can be handled by a mid-tier model with a better cost-performance balance.
    3. Auxiliary tasks: exploratory work such as file retrieval, log filtering, and code location. These tasks are called frequently, and the cost of a single incorrect result is relatively low, making them suitable for low-cost lightweight models.

    The core of tiered routing is to let low-cost models handle a large volume of calls that do not require high precision, while the primary model processes only the steps that affect conclusions. Routing logic can be implemented as follows:

    1. def route_model(task_type: str) -> str:
    2. routing_table = {
    3. "architecture_design": "primary-model",
    4. "code_generation": "primary-model",
    5. "summarization": "mid-tier-model",
    6. "file_search": "light-model",
    7. "log_filter": "light-model",
    8. }
    9. # Unregistered task types fall back to the mid-tier model to avoid using a low-cost model for critical work.