LLM Token Pricing Conversion and Cost Accounting Practices
Understanding LLM token pricing is crucial for accurate cost estimation and preventing budget overruns. This article explores token fundamentals, unit conversions (per 1k vs. per 1M), and the differences between input and output pricing. It provides a practical framework for building cost accounting models, comparing subscription versus pay-as-you-go plans, and identifying key factors that impact actual costs, such as context repetition and output length. Additionally, it covers usage monitoring, model selection criteria, and engineering optimization strategies to help teams manage LLM expenses effectively.
1. Why Re-evaluate Token Pricing
LLM services typically bill by the token. Many teams focus solely on the price per million tokens during selection without understanding the actual consumption it represents. This often leads to underestimating costs and facing unexpectedly high bills post-launch, or misjudging cost-efficiency by mistaking a low unit price for a low total cost.
To make accurate cost judgments, you must understand three things: what a token is, how to convert pricing units, and how to compare different billing models.
1.1 What is a Token?
Tokens are the smallest unit of measurement for model text processing. Before input, the model uses a tokenizer to split text into tokens, and during output, it generates tokens one by one. A token might be a complete word, a fragment of a word, a single character, or a group of punctuation marks or spaces.
Therefore, the same text length can produce vastly different token counts depending on the language and tokenizer. There is no fixed ratio between Chinese text characters and token counts; it depends on the specific model’s tokenization method. When estimating, rely on the usage fields returned by the server rather than directly calculating from character counts.
1.2 Unit Conversion: CNY per Million Tokens vs. CNY per Thousand Tokens
Different providers use inconsistent pricing units; some charge per thousand tokens, others per million tokens. Converting between them requires attention to scale:
- Multiply the price per thousand tokens by 1,000 to get the price per million tokens.
- Divide the price per million tokens by 1,000 to get the price per thousand tokens.
The conversion itself is simple, but unit confusion is a common pitfall. For instance, treating a price per thousand tokens as per million tokens underestimates costs by nearly 1,000x. It is recommended to standardize on “CNY per million tokens” for team comparisons and note the original unit in spreadsheets.
1.3 Separate Pricing for Input and Output
Most LLM services price input and output tokens separately, with output typically costing more. Input includes system prompts, conversation history, retrieved document chunks, and user queries. Output includes the model’s generated response, including internal tokens generated during reasoning (if billed by the service).
This means two operations with the same total token count can have very different costs. A Q&A scenario with long context and short answers incurs primary costs in input; a writing scenario with short input and long generation incurs primary costs in output. These must be tracked separately during accounting.
2. Building a Basic Cost Accounting Model
The basic cost accounting formula is as follows:
Cost per request = (Input token count * Input unit price + Output token count * Output unit price) / 1,000,000Monthly cost = Σ Cost per request
Here, unit prices refer to CNY per million tokens. While the formula seems simple, note the following in practice.
2.1 Splitting Request Types by Scenario
A single application typically handles various requests, such as intent recognition, summarization, long document Q&A, and code generation. The average input and output lengths vary significantly across these. It is recommended to track them by scenario before aggregating.
Below is a schematic accounting process to illustrate the approach. Actual implementation should adapt to business log structures:
Define scenario list = [Intent recognition, Summarization, Long document Q&A, Code generation]For each scenario:Read request logs from the last 30 daysCalculate average input tokens, average output tokens, and request countMonthly cost for scenario = Request count * (Avg input tokens * Input price + Avg output tokens * Output price) / 1,000,000Total monthly cost = Sum of monthly costs for all scenarios
2.2 Using Percentiles Instead of Averages
Averages can mask long-tail issues. A small number of ultra-long context requests can consume the majority of tokens. In addition to averages, review P90 and P99 input/output lengths and estimate the costs of these long-tail requests separately.
2.3 Reserving Margin for Retries and Exceptions
Network timeouts, format validation failures, and tool-calling loops can cause repeated requests. Empirically, it is reasonable to reserve a proportional margin on top of the calculated result, with the specific percentage based on production error rates. If error rate data is unavailable, start with a conservative estimate and adjust post-launch.
3. Subscription vs. Pay-As-You-Go
Some services offer fixed monthly subscription plans, allowing usage consumption within a quota. The unit cost calculation for these plans differs from pay-as-you-go; you cannot directly compare subscription prices with pay-as-you-go unit prices.
3.1 Calculating Effective Unit Cost
The effective unit cost for a subscription can be calculated as:
Effective unit cost = Monthly subscription fee / Monthly actual consumed token count * 1,000,000
For example, if a subscription plan costs 1,000 CNY/month and the team consumes 200 million tokens in that month:
Effective unit cost = 1000 / 200,000,000 * 1,000,000 = 5 CNY per million tokens
The same consumption under a pay-as-you-go unit price might cost more or less, depending on the pricing level. Before comparing, clarify: whether the consumption is real, whether it includes both input and output, and whether failed requests are accounted for.
3.2 Hidden Conditions of Subscriptions
When calculating effective unit cost, it is easy to overlook these limitations:
- Rate limits: Caps on requests per minute or tokens per minute may force businesses to queue or degrade during peak times.
- Usage caps: What happens when the quota is exceeded—degradation, rate limiting, or additional fees?
- Terms of use: Whether specific use cases are allowed, if it suits batch production calls, or if automated program calls are permitted.
- Idle costs: Unused monthly quotas usually do not roll over, effectively increasing the actual unit cost.
Subscription plans suit stable, predictable, interaction-heavy scenarios. For production workloads requiring high concurrency, auditability, and shared quotas across services, pay-as-you-go is generally easier to manage.
3.3 Principle of Same-Criteria Comparison
When comparing different plans, standardize the following criteria:
- Price input and output separately, then combine for total cost.
- Include consumption from retries and failed requests.
- Include costs for both cache hits and misses.
- Standardize conversions to CNY per million tokens.
Only with consistent criteria will the comparison be meaningful.
4. Key Factors Affecting Actual Costs
Beyond the accounting model, several factors can significantly alter actual costs and should be considered during the design phase.
4.1 Context Repeat Billing
In multi-turn conversations, each turn resends the history as input. Without trimming, input tokens grow linearly with conversation turns, accumulating costs.
Mitigation methods include:
- Keep only the most recent turns and summarize earlier content.
- Separate stable system prompts from variable user content to leverage server-side caching (if supported).
- In RAG scenarios, control the number and length of document chunks injected, keeping only content relevant to the query.
4.2 Output Length Control
Output tokens usually carry a higher unit price. If the prompt doesn’t constrain answer length, the model may generate verbose content. Control this by:
- Explicitly defining the answer structure and word count range in the prompt.
- Setting the maximum output token parameter to prevent abnormal generation.
- Using fixed field formats for structured output tasks to reduce irrelevant text.
4.3 Extra Consumption in Reasoning Tasks
Some models perform internal reasoning before answering, and these tokens may be billed as output. Enabling deep reasoning for simple tasks significantly increases costs. It is recommended to enable reasoning capabilities based on task difficulty rather than defaulting to always-on.
4.4 Batch vs. Real-time Differences
Real-time interactions are latency-sensitive, while batch offline tasks are not. They can use different service tiers and calling strategies. Offline tasks can be queued, request-batched, and executed during off-peak hours, typically making costs easier to control.
5. Usage Monitoring and Estimation Methods
Accounting is pre-estimation; monitoring is post-calibration. Combining both ensures controllable costs.
5.1 Logging Usage at the Request Layer
Every call should log input tokens, output tokens, model name, business scenario ID, latency, and result status. This data is used for billing reconciliation and anomaly detection.
Schematic code:
Function CallModel(request_content, scenario_id):start_time = CurrentTime()response = SendRequestToModelService(request_content)latency = CurrentTime() - start_timeLog({scenario: scenario_id,input_tokens: response.usage.input_tokens,output_tokens: response.usage.output_tokens,latency_ms: latency,status: response.status})Return response.content
5.2 Setting Budget Alerts
Compare daily, weekly, and monthly token consumption against budget thresholds, and notify owners via monitoring alert channels when exceeded. Alerts should be tiered: 70% of budget issues a reminder, 90% requires manual confirmation, and 100% can trigger rate limiting or degradation.
5.3 Regular Regression Accounting
Business scale, prompt versions, and model versions change, altering accounting results. It is recommended to review monthly: compare estimated costs with actual bills, analyze variance causes, and update accounting parameters. If variance exceeds a certain threshold, prioritize investigating repeated requests, context bloat, or abnormal loops.
6. Selection Evaluation Framework
Unit price is only one dimension of selection. A low-priced but unstable solution may inflate total costs due to rework and manual review. Evaluate comprehensively across these six dimensions.
| Dimension | Key Questions | Common Metrics |
|---|---|---|
| Quality | Does the output meet task requirements? | Manual scoring, automated evaluation pass rate |
| Cost | Total spend per unit task | CNY per million tokens, cost per task |
| Latency | Are first-token response and overall latency acceptable? | P50, P95 latency |
| Stability | Error rate, rate limit frequency, availability | Error rate, retry count |
| Compliance | Do data handling methods match business requirements? | Data retention policy, deployment method |
| Replaceability | Difficulty of switching to another service | Coupling degree of the interface adapter layer |
6.1 Tiered Selection by Task
Different tasks have different quality requirements. Business tasks can be divided into three tiers:
- High-value complex tasks, such as key decision support or complex code modifications, suit higher-capability models where cost is acceptable.
- Medium tasks, like standard Q&A or content rewriting, can use models with better cost-efficiency.
- Simple batch tasks, like classification, extraction, or format conversion, suit lightweight models or rule-based methods.
Tiering typically reduces overall costs significantly without compromising the quality of critical tasks.
6.2 Designing Evaluation Datasets
Before selection, prepare a representative batch of real samples, including normal and edge cases, and define clear scoring criteria. Evaluations should cover how different models perform on the same batch, recording quality, latency, and cost. Judging solely by unit price or a single demo effect rarely yields reliable decisions.
7. Engineering Implementation Optimization Strategies
After finalizing a plan, you can further reduce costs and improve stability at the engineering level.
7.1 Model Routing
Set routing rules at the application layer to decide which model to call based on task type or input length. Routing logic can start simple, such as splitting by scenario ID, and gradually introduce dynamic strategies based on historical quality data.
Function SelectModel(task_type, input_length):If task_type in [Key decision, Complex generation]:Return High_capability_modelIf input_length > Long_text_threshold:Return Long_context_modelReturn Economy_model
Routing rules must align with evaluation results; do not adjust them based solely on experience.
7.2 Cache and Reuse
For high-repetition requests, such as fixed system instructions or standard answers to FAQs, cache results at the application layer. Caches need expiration times and should be invalidated promptly when prompts or business rules change.
7.3 Prompt Compression
Redundant descriptions in prompts continuously consume input tokens. Regularly review prompts, remove repetitive instructions, and rewrite lengthy rules into structured items. This often reduces input costs without sacrificing effectiveness. After compression, re-run the evaluation set to confirm no quality degradation.
7.4 Degradation and Circuit Breaking
During service rate limiting or anomalies, the system should have a fallback plan, such as switching to a backup model, returning cached results, or prompting users to retry later. Degradation strategies ensure availability and prevent retry storms during outages from amplifying costs.
8. Accounting Considerations in Cloud Environments
If your business is deployed in specific cloud environments, such as LLM services provided by Baidu AI Cloud, accounting should be based on that platform’s official billing documentation and usage details. The billing units, free quotas, resource package rules, and regional differences of different services must be verified item by item. Maintaining the standardized criteria mentioned earlier makes data comparable across different platforms.
9. Pre-Launch Checklist
Before going live, confirm the following items:
- Have billing units been standardized, and original unit price sources noted?
- Have input and output tokens been accounted for separately?
- Have statistics been split by scenario, including long-tail requests?
- Have retries, failed requests, and cache variances been included?
- Are usage logs recorded for every call?
- Are tiered budget alerts set up?
- Is an evaluation dataset prepared, and multi-plan comparisons completed?
- Are routing, degradation, and rollback strategies defined?
Following this checklist enables teams to obtain reliable cost estimates during the selection phase and continuously calibrate during operation, avoiding billing runaway or selection errors.
