What Is a Token? A Guide to LLM Usage-Based Pricing

    This article explains what tokens are, why large language models charge based on token usage, and how input, output, and cache pricing work. It walks through a realistic cost calculation, the key factors that drive token consumption, and practical strategies for managing and reducing LLM costs in production.

    What Is a Token? A Guide to LLM Usage-Based Pricing

    1. What Is a Token?

    Large language models do not understand natural language directly. Instead, text is first split into “tokens” before being processed. A token is the smallest unit of text the model handles: it may be a complete word, a Chinese word, a single character, or a word fragment that includes spaces. During encoding, a tokenizer maps the raw string into a token sequence, which is then converted into vectors and fed into the network. During generation, the process reverses: tokens are decoded one by one back into human-readable text.

    Tokenization efficiency varies significantly across languages. In English, a word usually corresponds to one or a few tokens, whereas in Chinese, a single character may map to one or more tokens depending on the tokenizer design and vocabulary size. As a result, the same “500 characters” of Chinese and English content can consume very different numbers of tokens—potentially several times apart—which directly affects cost.

    2. Why LLM Providers Charge by Token

    Inference on large models requires GPU compute, and the amount of computation scales roughly linearly with context length and generation length. Token-based pricing offers several advantages:

    1. Quantifiable costs: The compute consumed by each request can be mapped precisely to a token count, making billing transparent.
    2. Separate input and output pricing: Prompt (input) and completion (output) have different computational profiles. Input only needs a single forward encoding pass, while output must be generated autoregressively step by step, which is why output is usually priced higher. Separate pricing reflects this difference.
    3. Cache support: Many requests repeat the same system prompts or similar questions. Providers offer caching mechanisms, where tokens that hit the cache are billed at a heavily discounted rate, reducing costs for high-volume use cases.

    3. Pricing Rules and a Sample Cost Calculation

    A typical pricing structure (check the official documentation for actual prices from each provider) includes:

    • Input token price (cache miss)
    • Input token price (cache hit, typically an order of magnitude cheaper)
    • Output token price

    Example Calculation

    Suppose you ask a model a question in Chinese of about 500 characters, and the model responds with about 1,000 characters. Using a common ratio for Chinese of roughly 1–2 tokens per character, take 1.5 as an estimate:

    • Input: 500 × 1.5 ≈ 750 tokens
    • Output: 1,000 × 1.5 ≈ 1,500 tokens

    Assume an illustrative input price of about 2 per million tokens and an output price of about 8 per million tokens (CNY; these are representative magnitudes only and do not reflect any specific provider):

    1. Input cost = 750 / 1,000,000 × 2 = 0.0015
    2. Output cost = 1500 / 1,000,000 × 8 = 0.012
    3. Total ≈ 0.0135

    So a single medium-length Q&A exchange costs on the order of one to two cents. That may seem trivial, but when daily volume reaches hundreds of thousands or millions of calls, or when system prompts are long, the expense scales up quickly. This is why token budget management is essential in engineering practice.

    4. Key Factors That Affect Token Consumption

    1. System prompt length: A long system prompt is billed again on every request, even though its content never changes. Keep it concise or leverage caching.
    2. Context carried over: In multi-turn conversations, passing the entire history as context causes tokens to accumulate. Apply truncation, summarization, or keep only the key turns.
    3. Output length control: Asking the model to “answer concisely” and setting a maximum output token limit can significantly reduce output-side costs.
    4. Language and format: Structured output such as JSON carries many punctuation marks and field names, making it more token-expensive than natural language.
    5. Cache hit rate: When repeated prompt prefixes hit the cache, costs can drop to roughly one-tenth of the original. This yields major savings for high-concurrency, homogeneous requests.

    5. Practical Recommendations: How to Control Costs

    • Establish monitoring: Log the input/output token counts and cache-hit status for every request, and build a cost dashboard.
    • Optimize prompts: Compress system prompts and remove redundant examples. Place fixed long text at the beginning of the prompt to improve cache hits.
    • Use tiered models: Route simple tasks to lightweight models and reserve stronger models for complex tasks. Avoid over-provisioning.
    • Set hard limits: Configure maximum output tokens and timeouts in API parameters to prevent runaway generation from spiraling costs out of control.
    • Cache at the application layer: For high-frequency Q&A scenarios, cache complete responses in your application to reduce call volume further.

    6. Conclusion

    Tokens are the fundamental unit underlying both LLM capability boundaries and usage-based billing. Understanding that character count is not the same as token count, that input and output are priced separately, and that cache discounts exist is the key to moving from “being able to call the API” to “using it affordably and well”. Build token budgets into your architecture design from the start: streamline prompts, control context, leverage caching, and monitor consumption so that AI capabilities can support your business reliably and cost-effectively.