LLM Token Pricing Logic and Model Selection in Practice

    When a major model generation ships a new price list, teams often react with anxiety and then switch providers blindly. This article explains how LLM billing actually works—input tokens, output tokens, and cache-hit tokens, and why output is usually the most expensive tier—then compares subscription plans with pay-per-use APIs, covers capability dimensions such as parameter count, MoE activation, and context window, provides a reusable Python model for estimating monthly token cost, and closes with concrete optimization tactics and a five-step selection framework.

    Introduction: Token Billing Is the Cost Foundation of AI Applications

    When a large language model releases a new generation and its pricing shifts noticeably, many teams first feel anxious, and then often react by switching providers without much analysis. But if you only stare at the number “the unit price went up several times,” it is easy to make a short-sighted decision. The professional approach is to understand the billing logic thoroughly first: where exactly the money goes, which volumes can be optimized, and which capabilities you genuinely have to pay for.

    For individuals and teams whose core work is AI-assisted coding and knowledge processing, the cost structure usually comes from two paths: buying a subscription plan (a fixed monthly fee in exchange for a quota), or going with a pay-per-use API (pay for what you consume). Both can meet the requirement, but “what you actually get inside a plan, how the quota is deducted, and how to keep spending under control with metered billing” are completely different engineering problems. This article works through those questions.

    1. The Billing Unit: Tokens, Not Characters

    The billing basis for large language models is the token, not the word count or character count. A token is the smallest unit the model processes after splitting text, so a passage of Chinese, a block of code, or an image (in natively multimodal models) all get encoded into a number of tokens.

    There is an engineering detail here that is easy to overlook: token accounting is not symmetric between input and output. Content of the same length costs a different amount depending on whether it is sent to the model as a prompt or returned as a completion—the output-side unit price is usually significantly higher than the input side, because autoregressive generation carries a larger compute cost. So when you estimate cost, you cannot simply use “character count × unit price”; you have to measure input volume and output volume separately.

    This matters especially for code scenarios: reading a large chunk of repository context is input, while generating patches, functions, and tests is output. The ratio between the two often differs enormously and directly shapes the structure of your bill.

    2. Three Token Categories: Input, Output, and Cache Hits

    Modern inference services generally split billing into three dimensions. Understanding how they are priced relative to each other is the first step in controlling cost:

    • Input tokens (cache miss): the full prompt is sent through the model, billed at the input rate.
    • Output tokens: the completion generated by the model, usually the most expensive tier.
    • Cache-hit tokens: when multi-turn conversations or repeated prefixes (such as a fixed system prompt or a long document) are reused, the service side can reuse an existing KV cache, and the hit portion is priced clearly below a regular input token. A common industry approach is to charge only a small fraction of the regular input rate for hits, which encourages the efficient pattern of “prefix reuse.”

    The general relationship among the three is: output > input > cache hit. The core of cost optimization for a mature team is getting as much repeated content as possible into the cache-hit tier while compressing unnecessary output volume.

    3. Subscriptions vs. Pay-Per-Use APIs: How the Two Payment Models Really Differ

    Neither model is inherently better; the question is whether it matches your load profile.

    A subscription plan is essentially “prepay to unlock a quota ceiling.” It typically offers several monthly tiers: the lower ones may only expose previous-generation or lightweight models, while the higher ones include the latest flagship capability and a larger context window, along with a credit or quota system. Its advantage is predictable cost—monthly spend is capped, which suits fixed teams with stable, high-frequency usage. The risk is that unused quota is wasted, and exceeding it may get you throttled.

    A pay-per-use API is essentially “pay for what you use.” It fits workloads with heavy variance, prototype validation phases, or batch jobs that are extremely sensitive to per-run cost. The risk is unpredictable cost: once a loop runs out of control, context keeps growing, and failed retries stack up, the bill can inflate quickly.

    A practical decision rule:

    1. if usage is stable and continuously high-frequency:
    2. evaluate subscriptions first (predictable cost, low marginal cost)
    3. elif usage is sparse or highly variable:
    4. use the pay-per-use API first (avoid paying for idle quota)
    5. else:
    6. hybrid model (subscription as primary, overflow via API)

    4. Evaluating Model Capability: Parameters, Context, and Sparse Architecture

    Selection cannot be based on price alone; you also need to check whether the capability covers the requirement. When evaluating a general-purpose LLM, the industry commonly looks at these dimensions:

    • Parameter scale and activation pattern: today’s mainstream flagships generally use a mixture-of-experts (MoE) architecture, meaning the total parameter count is very large but only a subset of experts is activated per inference. Total parameters determine the ceiling of knowledge capacity; activated parameters determine the compute and latency of a single inference. Understanding the “total parameters / activated parameters” pair is what lets you judge whether a model is “large and comprehensive” or “small and fast.”
    • Context window: context capability ranging from hundreds of thousands to millions of tokens directly determines whether you can feed in a whole large repository, a very long document, or many rounds of history at once. But the longer the context, the higher the input cost and latency, so use it as needed rather than maxing it out by default.
    • Scenario focus: some models lean toward long-horizon coding, large-scale repository understanding, and native multimodality; others emphasize strong price-performance and low latency. Start by clarifying the primary scenario, then match the model tier.

    When a platform offers a “flagship + lightweight” combination, the best practice is usually routing by task difficulty: simple completions go to the lightweight tier, while complex refactoring and architecture-level work calls the flagship tier.

    5. Cost Estimation: A Reusable Method

    Rather than judging “expensive or not” by feel, build a quantifiable estimation model. Below is a general example; plug in your real usage to estimate monthly token cost:

    1. def estimate_monthly_cost(
    2. requests_per_day: int,
    3. avg_input_tokens: int,
    4. avg_output_tokens: int,
    5. cache_hit_ratio: float, # cache hit ratio, 0 to 1
    6. input_price: float, # price per 1M input tokens
    7. output_price: float, # price per 1M output tokens
    8. cache_price: float, # price per 1M cache-hit tokens
    9. ):
    10. total_input = requests_per_day * avg_input_tokens * 30
    11. total_output = requests_per_day * avg_output_tokens * 30
    12. cached = total_input * cache_hit_ratio
    13. fresh_input = total_input - cached
    14. cost = (
    15. fresh_input / 1e6 * input_price
    16. + cached / 1e6 * cache_price
    17. + total_output / 1e6 * output_price
    18. )
    19. return round(cost, 2)

    Hook this function into your call logs and backfill the parameters with real data, and you can see the true composition of your cost. In most cases you will find that output volume and cache-missing input volume are the two biggest cost sources—and that is exactly where optimization should focus.

    6. Cost Optimization Practices

    Without changing capability, try these strategies in order:

    1. Maximize cache hits: keep stable system prompts, tool definitions, and long documents at the front of the prompt and leave them unchanged, so repeated requests land in the cache-hit tier. For multi-turn conversations, keeping the prefix identical works better than constantly rewriting it.
    2. Slim down context: do not stuff an entire repository into the context. Retrieve on demand and pass only the relevant fragments—this lowers input cost and also reduces noise, improving quality.
    3. Route across model tiers: use lightweight models for formatting, completion, and simple Q&A, and call the flagship only for complex tasks, forming a cost gradient.
    4. Control output inflation: state output length and format constraints explicitly in the instructions so the model does not become verbose and inflate output tokens.
    5. Guard retries and concurrency: set timeouts, retry limits, and budget circuit breakers on calls so the bill does not spiral out of control in abnormal situations.

    7. Selection Decision Framework

    Bringing it all together, here is a decision sequence you can apply:

    • Step 1, define capability: clarify the context length, modality support, and depth of code or knowledge processing the primary scenario requires.
    • Step 2, measure usage: use logs to estimate daily requests, average input/output tokens, and the cache hit ratio you can realistically achieve.
    • Step 3, compare models of payment: stable and high-frequency points to subscriptions; variable and sparse points to pay-per-use; hybrid scenarios get a primary plan plus overflow.
    • Step 4, optimize: treat cache hits and context slimming as ongoing work, and review periodically with the estimation model.
    • Step 5, leave room: avoid deep lock-in to a single provider or proprietary interface, and preserve portability so you can respond to future changes in price and capability.

    Conclusion

    Faced with the price swings that come with each new model generation, the rational response is not to be led by the numbers, but to return to the billing logic itself: separate input, output, and cache costs, understand where subscriptions and pay-per-use each apply, and keep measuring and optimizing with a quantifiable model. Once you can reduce “unit price” back to “cost structure,” a price change stops being a source of anxiety and becomes an ordinary variable you can manage with engineering means. That is the real selection capability teams need to build in the AI era.