Pricing and Cost Optimization Strategies for LLM Inference Services

    As large language model (LLM) inference services shift from trial phases to usage-based billing, balancing user demand for performance and quotas with provider compute costs is crucial for sustainable operations. This article explores the cost modeling of LLM inference, from individual requests to per-token metrics, and examines key user experience indicators such as Time to First Token (TTFT) and generation speed. It also analyzes common pricing models, explains why price reductions alone do not guarantee growth, and shares practical engineering strategies for multi-backend routing, circuit breaking, and operational quota design.

    1. Background: Why Quota Pricing is in Focus

    LLM coding assistants and various inference services are transitioning from trial phases to pay-as-you-go models. Users care about how much quota they can use per month, response speed, and service stability. Service providers care about whether the unit compute cost is covered by the price. The gap between the two determines whether a service can operate sustainably.

    Industry discussions generally focus on three areas:

    First is the cyclical change in compute supply. When new acceleration hardware enters mass production and ramps up, the rental and resale prices of previous-generation devices typically drop. As a result, the procurement or leasing costs for service providers decrease, changing the margin available for pricing.

    Second is inference engine optimization. Implementing operator fusion, dynamic batching, memory management, and request scheduling for specific model architectures can significantly reduce the actual cost per million tokens. On the same hardware, the throughput difference between different inference implementations can be substantial.

    Third is the pricing strategy itself. Service providers sometimes use high quotas with low unit prices to acquire users, or tiered quotas to observe actual demand. Whether subsidized pricing is sustainable depends on having clear cost limits and stop-loss mechanisms.

    It is important to note that price changes by a single service provider or model do not directly represent broader market trends. To determine whether a pricing strategy is reasonable, one should return to the cost model itself and verify it using quantifiable metrics.

    2. Cost Model: From Single Request to Per-Token Cost

    The core issue of inference cost is: how much hardware resource is consumed to generate each token? The inference process is typically divided into two phases:

    • Prefill phase: Processes the input prompt. It is compute-intensive, meaning longer inputs take more time.
    • Decode phase: Generates output tokens sequentially. It is memory-intensive and is significantly affected by memory bandwidth and batch size.

    Therefore, input length, output length, concurrency, and batching strategy directly impact the unit cost. Long-context scenarios also consume a large amount of KV cache, reducing the number of concurrent requests a single GPU can handle.

    Unit cost can be estimated using the following formula:

    1. Unit cost (Currency/Million tokens) = Cost per GPU hour / (Effective tokens per GPU hour) * 1,000,000
    2. Effective tokens per GPU hour = Theoretical peak throughput (tokens/second) * Average utilization * 3600

    A code example is shown below (all parameters are hypothetical and for illustrative purposes only):

    1. def cost_per_million_tokens(gpu_hour_cost, peak_tps, utilization):
    2. # gpu_hour_cost: Cost per GPU hour
    3. # peak_tps: Theoretical peak throughput per GPU (tokens/second)
    4. # utilization: Average utilization, ranging from 0 to 1
    5. effective_tps = peak_tps * utilization
    6. tokens_per_hour = effective_tps * 3600
    7. return gpu_hour_cost / tokens_per_hour * 1_000_000
    8. # Assuming a GPU hour cost of 20, peak throughput of 100 tokens/second, and 60% average utilization
    9. print(cost_per_million_tokens(20, 100, 0.6)) # Approximately 92.6 per million tokens

    This model reveals two key conclusions. First, utilization is inversely proportional to unit cost; under low load, fixed costs are spread thinly, causing costs to rise rapidly. Second, doubling throughput roughly halves the unit cost, meaning inference engine optimization has a massive impact on overall cost.

    3. Experience Metrics: TTFT, Generation Speed, and End-to-End Latency

    Cost is only half of pricing; the other half is the actual user experience. There are three commonly used experience metrics:

    • Time To First Token (TTFT): The time from sending a request to receiving the first token. It primarily reflects prefill phase duration and queueing.
    • Tokens Per Second (TPS): The number of tokens generated per second during the output phase, determining the output pace for long texts.
    • End-to-end latency: The total time taken for a complete response.

    End-to-end latency can be approximated as:

    1. End-to-end latency ≈ TTFT + Output token count / TPS

    Example code:

    1. def end_to_end_latency(ttft_seconds, output_tokens, tps):
    2. return ttft_seconds + output_tokens / tps
    3. # Assuming a TTFT of 5 seconds and an output of 1000 tokens
    4. print(end_to_end_latency(5, 1000, 120)) # Approximately 13.3 seconds
    5. print(end_to_end_latency(5, 1000, 70)) # Approximately 19.3 seconds

    With the same quota, a slower service completes fewer tasks. The more time users spend waiting, the lower the actual value of their quota. Therefore, evaluating whether a quota is attractive requires looking beyond nominal numbers to consider how much work users can accomplish within a given unit of time.

    4. Common Quota Pricing Models

    In practice, several common quota pricing models exist:

    1. Pay-as-you-go: Pay for what you use. Revenue is directly tied to cost, presenting the lowest risk, but users have a weaker perception of the price.
    2. Subscription plus quota: Charges a fixed monthly fee with an included usage allowance. This provides users with predictable costs, but providers must control overconsumption by heavy users.
    3. Tiered quota: Different tiers correspond to different quotas and unit prices. This helps providers identify the true demand distribution among users.
    4. Time-limited subsidy: Temporarily increases quotas or lowers unit prices within a specific time window, used for customer acquisition or testing market response.

    Subsidized pricing requires clear prerequisites. Providers should pre-determine the break-even point and set cost limits. The basic break-even relationship is as follows:

    1. Revenue = Unit price * Actual usage
    2. Cost = Unit cost * Actual usage + Fixed cost
    3. Break-even condition: Revenue ≥ Cost

    Example code:

    1. def break_even_check(price_per_m, unit_cost_per_m, usage_m, fixed_cost):
    2. revenue = price_per_m * usage_m
    3. cost = unit_cost_per_m * usage_m + fixed_cost
    4. return revenue - cost # Positive means profit, negative means loss

    There is an easily overlooked point in this formula: the quota limit does not equal actual usage. If the quota is very high but actual user consumption is low, the quota limit has a limited impact on costs; actual usage is what truly determines cost. Therefore, assessing the risk of a high-quota policy requires observing both the quota limit and the actual usage distribution.

    5. Why Price Cuts Don’t Always Bring Growth

    Price is one dimension of user choice, but not the only one. The following four factors are often more important than price:

    First, experience match. TTFT and TPS directly determine fluency during use. If a service’s speed is noticeably lower than similar services, users may switch to alternatives even if there is a price advantage.

    Second, capability boundaries. Whether the model supports multimodal input, whether the context length meets needs, and whether tool calling and structured output are stable all affect the user’s actual work results. When capability boundaries are unclear, a price advantage is difficult to convert into retention.

    Third, switching costs. Users typically interact with multiple models or services simultaneously. When switching costs are low, users will adjust their choices at any time based on speed, stability, and effectiveness. Price is just one factor in their comparison.

    Fourth, trust and stability. Service interruptions disrupt user workflows and leave a lasting impression. The negative impact of a severe outage may outweigh weeks of price advantages.

    From this, we can conclude a basic principle: quotas are the entry point that attracts users, but experience and stability determine whether they stay. Relying solely on high quotas to drive usage volume rarely leads to sustainable growth.

    6. Engineering Practices: Multi-Backend Routing and Fallback

    When dealing with multiple backend services, a common practice is dynamic routing based on health status, latency, and cost. Below is a simplified routing example:

    1. from dataclasses import dataclass
    2. @dataclass
    3. class Backend:
    4. name: str
    5. healthy: bool # Health check result
    6. p50_ttft: float # Median TTFT in seconds
    7. tps: float # Generation speed (tokens/second)
    8. cost_per_m: float # Unit cost per million tokens
    9. def pick_backend(backends, max_ttft=6.0, min_tps=60.0):
    10. # First, filter out backends that are unhealthy or do not meet experience standards
    11. candidates = [
    12. b for b in backends
    13. if b.healthy and b.p50_ttft <= max_ttft and b.tps >= min_tps
    14. ]
    15. if not candidates:
    16. raise RuntimeError("No backends meet the experience standards; need to trigger fallback strategy")
    17. # Assuming experience standards are met, select the backend with the lowest cost
    18. return min(candidates, key=lambda b: b.cost_per_m)

    On this basis, two mechanisms need to be paired:

    • Timeout and retry: Set a timeout for each request. If it times out, switch to a backup backend, and limit the number of retries to prevent cascading failures.
    • Circuit breaker: Temporarily block a backend after consecutive failures reach a threshold, and use a small amount of traffic to probe for recovery after a cooldown period.

    The basic logic of a circuit breaker is as follows:

    1. class CircuitBreaker:
    2. def __init__(self, failure_threshold=5, reset_timeout=30):
    3. self.failure_threshold = failure_threshold # Consecutive failure threshold
    4. self.reset_timeout = reset_timeout # Cooldown time in seconds
    5. self.failures = 0
    6. self.opened_at = None
    7. def allow(self, now):
    8. if self.opened_at is None:
    9. return True
    10. # Allow probe requests after cooldown ends
    11. return now - self.opened_at >= self.reset_timeout
    12. def record(self, success, now):
    13. if success:
    14. self.failures = 0
    15. self.opened_at = None
    16. else:
    17. self.failures += 1
    18. if self.failures >= self.failure_threshold:
    19. self.opened_at = now

    The benefits of a multi-backend approach are clear. When a particular backend fluctuates, traffic can be quickly shifted to other backends, significantly reducing the perceived downtime for users. Meanwhile, the tradeoff between cost and experience can be adjusted via parameters without modifying business code.

    7. Implementation Steps for Quota Design and Operations

    To put the above analysis into actual operation, the following five steps can be taken:

    1. Build a cost model: Measure unit costs by model, by backend, and by time period, and record changes in utilization.
    2. Define experience goals: Set Service Level Objectives (SLOs) for TTFT, TPS, and error rates as constraints for quota design.
    3. Design tiered quotas: Segment tiers based on the real usage distribution of users to avoid sharing a single high quota among all users.
    4. Canary release and monitoring: Trial new quota policies with a small subset of users. Monitor active user counts, per-capita usage, retention rates, error rates, and backend distribution.
    5. Set stop-loss lines: Automatically tighten quotas or restore original prices when the loss ratio exceeds a preset threshold.

    The stop-loss check can be written as a simple rule:

    1. def should_tighten_quota(daily_revenue, daily_cost, threshold=0.2):
    2. if daily_cost <= 0:
    3. return False
    4. loss_ratio = (daily_cost - daily_revenue) / daily_cost
    5. return loss_ratio > threshold