A Practical Guide to LLM API Cost Accounting and Subscription Plan Optimization
Evaluating the cost of Large Language Model (LLM) APIs requires distinguishing between list prices and actual usage costs. This guide explores how to unify measurement units, analyze pay-as-you-go billing versus credit-based subscription plans, and understand the impact of utilization and stability on effective task costs. By establishing a robust cost governance process, developers can make data-driven decisions to optimize API expenditure while maintaining quality and stability.
I. Defining the Problem: List Price vs. Actual Usage Cost
In scenarios like intelligent programming, document processing, and batch content analysis, developers often encounter two payment models: one bills based on the actual number of tokens processed, while the other requires purchasing a subscription plan first, which is then consumed via credits or other quota units.
Both models can seemingly be converted into “cost per million tokens,” but this figure is only meaningful for comparison when the statistical criteria align. Factors such as separate pricing for input and output, independent accounting for cache hits, fees for failed requests, and whether plan quotas can be fully utilized will all alter the final result.
Therefore, cost evaluation must be distinguished across three layers:
The first layer is the nominal price, which is the price listed in the billing documentation.
The second layer is the actual unit usage cost, calculated by dividing the actual expenditure by the corresponding processing volume within a clear statistical period.
The third layer is the effective task cost, meaning how much it actually costs to complete a business task that meets quality standards.
For developers, the second layer is suitable for analyzing resource consumption, while the third layer is closer to the actual basis for model selection. A cheap API call that requires repeated retries may not be more economical than a slightly more expensive call that reliably returns results in a single attempt.
II. Unifying Measurement Units to Avoid Distorted Conclusions
1. Token Count Does Not Equal Word Count
A token is the basic unit of measurement for text processing in a model, and its segmentation is influenced by tokenization methods, language, code structure, and text content. Chinese characters, foreign words, punctuation, and code snippets cannot be simply converted into tokens at a fixed ratio.
Therefore, during accounting, priority should be given to using actual usage from call logs or bills, rather than estimating based solely on text length.
Different processing pipelines may also append system instructions, historical dialogues, and tool descriptions in the background. These contents may not all appear in the user interface but may still count toward the processing volume. Counting only the user-submitted text will likely underestimate the true input scale.
2. At Least Distinguish Input, Output, and Cache Usage
Common billing models can be abstracted as:
Total Cost = Standard Input Cost + Output Cost + Cache-Related Cost + Other Applicable Fees.
Whether these items exist and how they are priced must be based on actual billing rules. You cannot assume all services use the same structure, nor can you assume cache hits are always free.
If all tokens are merged for calculation, you can obtain a blended unit price that is easy to observe:
Cost per Million Tokens = (Actual Cost / Total Token Count) × 1,000,000.
This metric reflects the average expenditure under a specific business workload, not a fixed price that can be directly applied to all scenarios. Tasks with a high input ratio and short outputs may yield a different blended unit price than long-text generation tasks, even when using the same billing method.
3. The Statistical Scope Must Be Consistent
If the cost includes multiple capability tiers, but the token count only tracks one of them, the calculation will be distorted. Conversely, dividing a single-tier cost by total call volume will underestimate the actual cost.
It is recommended to maintain separate ledgers by task type, capability tier, and billing method. Only after completing the accounting for each group should you aggregate the overall average.
III. Converting Pay-as-you-go Billing: A Sample Bill Analysis
Take a historical usage sample where the expenditure is 31.53 CNY and the cumulative processing volume is 296 million tokens. This is used solely as a calculation demonstration and should not be considered the current pricing of any specific service.
Since 296 million tokens equals 296 “million tokens,” the calculation is:
Cost per Million Tokens = 31.53 / 296 ≈ 0.1065 CNY.
This result indicates that under the billing conditions and workload structure corresponding to this sample, the average expenditure per million tokens processed is about 0.107 CNY.
However, you cannot directly infer that other workloads will have the same cost. During further review, the following questions need to be answered:
- Do the expenditure and usage cover the exact same time range?
- Are there discounts, complimentary quotas, or delayed billing?
- Does it include only a single capability tier?
- What are the proportions of input, output, and cache usage?
- Are retry requests and failed requests included in the statistics?
Special attention must be paid to time boundaries. If usage is recorded by request completion time, but fees are billed by a slightly later settlement time, significant deviations may appear in short cycles. In practice, try to use fully settled cycles and retain original records for verification.
IV. Converting Credit Plans: Allocated Cost vs. Actual Cost
Another sample contains the following data:
- Subscription plan payment amount: 118 CNY;
- Weekly quota: 10,000 credits;
- Credits consumed in one observation: 964 credits;
- Corresponding processing volume: 24.26 million tokens.
For demonstration purposes, assume an accounting cycle contains exactly four complete weekly quotas, making the nominal quota 40,000 credits. Allocated evenly based on the nominal total quota:
Allocated Cost per Credit = 118 / 40,000 = 0.00295 CNY.
The allocated cost for this observation is:
964 × 0.00295 = 2.8438 CNY.
Further converted:
Allocated Cost per Million Tokens = 2.8438 / 24.26 ≈ 0.1172 CNY.
It must be emphasized that this value is a result of “allocation based on the nominal total quota” and does not prove that the user’s final actual cost is exactly at this level.
1. Four Weeks Cannot Directly Replace All Actual Billing Cycles
If a plan is settled by natural month or fixed days, but the quota refreshes weekly, how many quotas can actually be obtained and how the start and end cycles are handled depend on specific rules. You cannot assume that every payment cycle includes exactly four weekly quotas just because a week has a fixed number of credits.
The 40,000 credits above is merely an illustrative accounting assumption and does not represent a universal billing rule.
2. Unused Quota Raises Actual Cost
If 118 CNY is paid, but only 20,000 credits are consumed during the entire cycle and the remaining quota expires, the actual average cost borne by the used credits becomes:
118 / 20,000 = 0.0059 CNY/credit.
Assuming the conversion ratio between credits and processing volume remains unchanged, the unit token cost will also rise accordingly.
Therefore, subscription plans should track two metrics simultaneously:
- Nominal Allocated Cost: Calculated based on the total obtainable quota, suitable for estimating cost-effectiveness when fully utilized.
- Cycle Actual Cost: Calculated based on the actual payment amount and actual processing volume, suitable for evaluating true expenditure.
For non-refundable subscription fees, short-term usage decisions regarding remaining quota also involve marginal cost. However, you should not record the overall plan cost as zero, as this would obscure whether long-term purchasing is actually worthwhile.
V. How to Understand the ~10% Difference in Samples
According to the above formulas, the unit costs for the two samples are approximately 0.1065 CNY and 0.1172 CNY, respectively, with the latter being about 10% higher.
This difference can only describe the samples and cannot form a stable pricing ranking. The reason is that the observation duration, task composition, cache situation, and quota usage assumptions of the two data sets may not be consistent.
In particular, high-intensity calls over a short period may coincide with a large amount of repeated input, concentrated short-answer generation, or other special workloads. Extrapolating one hour of data directly to a whole month will easily overestimate plan utilization and may also underestimate the cost changes brought by output growth.
A more reliable method is to collect samples covering normal business rhythms, including workdays and non-workdays, off-peak and peak periods, and different task types. The observation period should be long enough to include actual settlement and quota refresh processes, rather than just selecting the best-performing time window.
VI. Stability Needs Metric Verification, Not Just Intuition
Stability affects cost, but “feeling slow occasionally” or “having a high failure rate once” is not enough to form a reliable conclusion.
It is recommended to record at least the following metrics:
- Request Success Rate: Whether the request completes normally and what the error types are.
- End-to-End Latency: The time elapsed from initiating the task to obtaining the complete result.
- High-Percentile Latency: The impact of a few slow requests on interaction and batch processing progress.
- Retry Count: How many additional calls a task requires on average.
- Result Qualification Rate: Whether the output meets structural, factual, and business constraints.
- Manual Correction Cost: How much manual processing is required before result delivery.
The business-side metric can be defined as:
Effective Task Cost = Total Spend Attributed to This Task Type / Number of Quality-Qualified Tasks.
If a task requires manual correction, a manual cost item can be added separately. However, the pricing method for manual hours should be clear to avoid packaging subjective estimates as precise conclusions.
Whether failed requests are charged and whether retries are billed repeatedly should be confirmed based on actual records. Even if failed requests themselves are not charged, waiting time and business interruption can still cause losses.
VII. Whether High-Tier Plans Are More Cost-Effective Depends on Utilization and Constraints
Higher-tier plans may offer more quota, but you cannot judge cost-effectiveness solely based on “larger total quota.”
During evaluation, check item by item:
First, whether the purchase cost per unit of credit actually decreases. You need to divide the actual payment amount by the available quota, rather than just looking at the promotional conversion descriptions.
Second, whether the business can stably consume the quota. If task demand has obvious off-peak and peak seasons, over-purchasing may cause idle resources.
Third, whether there are weekly quotas, concurrency, or rate limits. Even if the total quota is sufficient, the inability to use it in a short time may affect delivery.
Fourth, what the quota expiration and carry-over rules are. Non-carry-over periodic quotas usually require more cautious demand matching.
Fifth, whether credit consumption varies with task structure. You cannot assume that all tasks have a fixed “number of tokens per credit.”
Therefore, a reasonable strategy is to forecast the usage distribution first, and then choose the payment scale, rather than buying a larger plan first and then looking for additional tasks to consume the quota.
VIII. Establishing an Executable Cost Governance Process
1. Form a Minimum Viable Ledger
Each call record should contain at least time, task category, capability tier, input usage, output usage, cache usage, credit consumption, cost, request status, latency, and retry flag.
For situations where per-request costs are not available, costs can be allocated according to reasonable rules after settlement, but it must be marked as an estimated value and not confused with actual billed amounts.
Logs should record metadata such as usage and status as much as possible. If you need to save request content, you should comply with business data protection requirements and control access permissions and retention periods.
2. Fix the Test Set to Maintain Fair Comparisons
Prepare a set of tasks representing real business, covering actual needs such as short Q&A, long documents, code generation, and structured extraction. When comparing, try to keep the input, output limits, concurrency conditions, and acceptance criteria consistent.
If certain generation settings cannot completely correspond, the differences should be recorded, and you should not forcefully claim that the test conditions are exactly the same.
3. Prioritize Reducing Invalid Consumption
Common measures include removing duplicate historical context, avoiding carrying irrelevant documents, controlling unnecessary long outputs, reasonably caching reusable content, and setting limits on retry counts.
Caching needs to focus on content updates, permission isolation, and invalidation mechanisms. Retries should distinguish between temporary errors and deterministic errors to avoid continuously sending repeated requests for issues that cannot be automatically recovered.
4. Use Periodic Reviews Instead of One-off Conclusions
After each complete billing cycle, check the actual payment, effective task volume, idle quota, abnormal retries, and quality changes. If the cost suddenly drops, you should also investigate whether it is due to a decrease in tasks or a drop in output quality, rather than a genuine improvement in efficiency.
IX. Conclusion: Moving Cost Comparison from Unit Price Calculation to Business Accounting
Cost per million tokens is a useful basic metric, but it describes resource expenditure under specific workloads and billing conditions and cannot independently represent service value.
Pay-as-you-go billing should focus on checking whether the cost and usage have the same scope; credit plans should focus on checking quota refresh, cycle utilization, and actual consumption relationships; both should ultimately return to the cost of quality-qualified tasks.
True sustainable cost optimization is not about pursuing the lowest number in a single observation, but about continuously reducing the total expenditure for completing business tasks with verifiable data, under acceptable quality, stability, and latency constraints.
