How to Buy LLM Tokens: Pricing Rules and Cost Estimation
Learn how token usage is measured, how major purchasing and billing models work, and how to estimate usage costs for LLM applications. This guide covers input and output pricing, budget forecasting, cost-control techniques, common mistakes, and a practical procurement checklist.
1. Understand What a Token Is
A token is the smallest unit of text processed by a large language model (LLM). Models do not calculate usage directly by character or word count. Instead, they first split the input text into tokens and then process those tokens individually. The exact tokenization rules are determined by each model’s tokenizer, so the same text may produce different token counts across different models.
The following are general guidelines. Always use the actual tokenization result for accurate estimates:
- An English word is often close to one token, although longer words may be split into multiple tokens.
- In Chinese text, each character typically consumes about one to two tokens. Punctuation and numbers also contribute to token usage.
- Code, JSON, and other structured content often have a higher token density than ordinary prose.
Pricing is based on token usage rather than character count. Treating the number of characters or words as the token count is one of the most common causes of budget inaccuracies.
2. Common Ways to Purchase Tokens
LLM services generally support several purchasing or billing models. The exact names and rules vary by provider:
- Prepaid account balance: Add funds through the provider’s console, with usage deducted from the balance as requests are made. This is suitable for individual developers and small-scale testing.
- Postpaid billing: Use the service first and pay according to a billing statement issued at the end of a billing period. This is useful for teams with fluctuating usage or established enterprise accounting processes.
- Prepaid resource packages: Purchase a fixed amount of token capacity in advance, usually with an expiration period. This works well for businesses with relatively stable and predictable usage.
- Enterprise procurement: Purchase services through a contract and corporate payment process. This may include invoices, account permissions, and usage reporting.
Deposit limits, credit arrival times, balance expiration, and refund terms are determined by each provider. These rules may also vary by account type or promotional policy. Before placing an order, check the provider’s console and terms of service rather than relying on outdated third-party information.
3. How to Check Prices and Calculate Costs
Most LLM services publish prices per one million tokens and use separate rates for input and output tokens. Output tokens are often more expensive because content generation generally requires more computational resources. Some providers may also offer different prices for cached inputs, model tiers, or different usage periods.
The general cost formula is:
Total cost = Input tokens ÷ 1,000,000 × Input price + Output tokens ÷ 1,000,000 × Output price
The following example demonstrates the calculation. The prices are placeholders for illustration only and must be replaced with the rates published in the provider’s official documentation:
def estimate_cost(input_tokens: int, output_tokens: int,input_price_per_m: float, output_price_per_m: float) -> float:"""Estimate the cost of one request using prices per million tokens."""input_cost = input_tokens / 1_000_000 * input_price_per_moutput_cost = output_tokens / 1_000_000 * output_price_per_mreturn input_cost + output_cost# Placeholder prices for demonstration onlycost = estimate_cost(input_tokens=2000,output_tokens=800,input_price_per_m=1.0,output_price_per_m=4.0,)print(f"Estimated cost per request: {cost:.6f}")
Keep two points in mind when converting prices:
- Make sure the currency and measurement units are consistent. Do not confuse a price per thousand tokens with a price per million tokens.
- Check the provider’s billing granularity and rounding rules. Some platforms bill an entire request, while others calculate actual usage to a specified decimal precision.
4. A Basic Method for Forecasting Usage
A reliable budget estimate can be created in three steps.
Step 1: Sample real requests. During testing or an initial low-traffic phase, record the input and output token count for every request. If the provider offers usage details or a token-counting interface, use that data directly. Otherwise, estimate usage locally with a tokenizer that matches the target model.
Step 2: Calculate the distribution of per-request costs. Do not look only at the average. Pay attention to percentiles as well. The cost of a P50 request may differ significantly from that of a P95 request, particularly when long-document summarization or multi-turn conversations are involved.
Step 3: Multiply by the expected request volume and add a buffer. Multiply the per-request cost by the expected daily or monthly request count, then reserve an additional margin for business growth and occasional long inputs.
The following example estimates a monthly budget:
def monthly_budget(avg_cost_per_call: float, daily_calls: int,buffer_ratio: float = 0.2) -> float:"""Estimate a monthly budget from average request cost and daily volume."""base = avg_cost_per_call * daily_calls * 30return base * (1 + buffer_ratio)
5. Practical Cost-Control Techniques
After setting a budget, use engineering controls to keep actual spending within the expected range.
1. Make prompts more concise. System prompts are generally sent and billed repeatedly. Extract recurring rules into shorter instructions and remove unnecessary examples or background information to reduce input token usage.
2. Limit output length. Most APIs support a maximum output token setting. For classification, extraction, and decision-making tasks, limiting the output to what is necessary can prevent unnecessarily long responses.
3. Select the model tier based on the task. Simple classification or format-conversion tasks often do not require the most capable model. Using different model tiers for different workloads can significantly reduce unit costs while maintaining acceptable quality.
4. Reuse results. For identical inputs, implement result caching at the application layer. For fixed long contexts, if the provider supports cache-based pricing, keep the prefix consistent whenever possible to improve cache hits.
5. Process long text in segments. Sending an entire long document in one request increases both cost and latency. Splitting the document by semantic boundaries and retrieving only relevant sections is often more economical than submitting the full text.
6. Set budget alerts and usage limits. Configure usage alerts and spending limits in the provider’s console. Send request logs to a monitoring system and compare actual daily usage with the planned budget.
6. Common Mistakes
- Comparing unit prices without considering total usage. A lower-priced model may generate longer responses or require more retries, resulting in a higher overall cost. Compare the cost of completing a task rather than the unit price alone.
- Treating character or word count as token count. Chinese text and code have different token densities from English text. Estimating tokens directly from character count can produce significant errors.
- Ignoring retries and failed requests. Timeout retries and repeated calls after format-validation failures can all incur additional charges. Request logs should record the number of retries.
- Overlooking balance expiration and refund policies. If prepaid credits expire, include the expiration period in project planning to avoid unused credits being forfeited.
- Using loose account and key management. When multiple projects share one account, it becomes difficult to attribute costs. Separate accounts or credentials by project or environment, and rotate keys regularly.
7. Procurement Checklist
Before purchasing tokens or committing to an LLM service:
- Confirm the input and output prices for the target model, and check whether cached-input pricing is supported.
- Use real samples to estimate the distribution of per-request costs instead of relying only on example data.
- Clarify payment methods, deposit limits, balance expiration, and refund terms.
- Configure budget alerts, spending limits, and daily usage reports.
- Define model tiers for different business scenarios and record the per-task cost for each tier.
- Verify enterprise requirements such as invoices, corporate payment, and access management.
Overall, buying tokens is not complicated. The key is to understand the unit of measurement, apply the correct cost formula, and continuously monitor usage. A complete estimate based on real request data can usually provide a reliable budget for an LLM project.
