Cost Per Token: The Core Metric for AI Factory TCO Accounting
This article explains why cost per token has become the central metric for evaluating AI infrastructure, breaking down its numerator (total inference investment) and denominator (effective tokens delivered). It outlines a three-layer measurement framework spanning resource, service, and economic efficiency, then presents practical optimization paths and common pitfalls to avoid. Readers will learn how to build an output-oriented TCO accounting system for inference.
1. Why the Yardstick for AI Infrastructure Has Changed
When evaluating an AI infrastructure stack, the most common questions used to be “How much compute do we have?” or “What is the peak performance per card?” These are essentially input-side metrics. Compute cost describes what an organization pays for infrastructure, whether rented or self-built, while cost per dollar of FLOPS describes how much raw floating-point capability each dollar buys. They are easy to measure and convenient for procurement comparisons, but they share a fundamental flaw: raw compute is not the same as the tokens actually usable in the real world.
As projects move from pilots to production, the business no longer asks “How much compute did we buy?” but “How much does it cost to serve a single user request?” The focus therefore shifts to cost per token: the total cost of generating and delivering each token, usually expressed as cost per million tokens. It is the key metric for defining the total cost of ownership (TCO) of inference.
This shift brings an important change in thinking: the token becomes the economic unit that connects power, compute, model serving, and application value. Chips, power, and the software stack are inputs; tokens are outputs; and cost per token is the only bridge between the two. Price adjustments seen across the industry are, in essence, a redistribution of cost and value along this chain rather than pure marketing moves.
2. Breaking Down the Cost Per Token
Before optimizing a metric, you need to be able to decompose it. Cost per token can be abstracted as a ratio:
cost per token = total inference investment / total effective tokens delivered
The numerator (total investment) typically includes:
- Compute cost: depreciation of self-built servers and accelerators, data center space, power and cooling, or the fees for renting inference resources from a cloud provider;
- Storage and data service cost: object and block storage overhead for model weights, vector indexes, session context, and log data;
- Network and transfer cost: cross-availability-zone traffic, load balancers, gateways, and middleware such as message queues;
- Platform and operations cost: container platforms, orchestration and scheduling, monitoring and alerting, logging services, and the necessary human effort;
- Software stack cost: the inference runtime, model licenses, and security and compliance components.
The denominator (total effective tokens) is often overlooked, yet it is usually where the biggest differences come from. Only tokens actually delivered to the business and counted as valid output count as output. Failed requests, timeout retries, and requests blocked by safety policies consume resources but produce no value.
This leads to a key conclusion: cost per token is a composite metric shaped jointly by hardware performance, software optimization, ecosystem support, and actual utilization. It also explains why, with identical hardware specifications, cost per token can differ by several times between teams.
3. From Input Metrics to Output Metrics: Three Layers of Measurement
Organizations should build a layered measurement system rather than letting a single number hide problems.
The first layer is resource efficiency: throughput per accelerator (tokens/second), memory usage, batch size, and request queue latency. It answers “Is the hardware fully utilized?”
The second layer is service efficiency: the concurrency and total throughput the system can sustain under given latency constraints (such as upper limits on time to first token and time per output token). Talking about throughput without latency constraints is meaningless, because a production system must deliver within its SLA.
The third layer is economic efficiency: cost per million tokens, cost per request, and cost attribution sliced by business line or tenant. It answers “Does this business make sense?”
These three layers are linked: improvements in batching and concurrency scheduling raise the first layer, which affects the second and ultimately dilutes the third. Meanwhile, low utilization (for example, off-peak nighttime traffic) directly raises the third layer, even when the first two look good.
4. Actionable Optimization Paths
1. Improve effective utilization. Use elastic scaling to match resource supply to the traffic curve and scale-down policies to handle troughs; pool latency-insensitive offline tasks (batch summarization, data labeling, index building) separately from online requests to avoid contention.
2. Optimize the inference software stack. Widely used techniques such as continuous batching, paged memory management, prefix cache reuse, quantization, and operator fusion can significantly increase output per card without replacing hardware. The following is an illustrative serving configuration logic:
# Illustration: derive sustainable concurrency from throughput and memory constraintsdef estimate_capacity(token_per_sec_per_gpu, gpu_count,avg_output_tokens, sla_seconds):total_throughput = token_per_sec_per_gpu * gpu_countconcurrent_requests = total_throughput * sla_seconds / avg_output_tokensreturn int(concurrent_requests)capacity = estimate_capacity(2000, 8, 400, 2.0)print("Estimated concurrency:", capacity)
3. Govern the denominator. Trimming prompts and context length, capping output length, caching results for high-frequency requests, and bringing retries and timeouts into cost observability all directly lower cost per token, because they reduce invalid tokens.
4. Tier models and tasks. Routing requests to models of different sizes by difficulty, with simple tasks going to smaller models and complex tasks to larger ones, is one of the most direct ways to compress average cost.
5. Improve observability and attribution. Use monitoring, alerting, and logging services to build a “request–resource–cost” correlation view and tag by business line, so you can pinpoint whether a cost anomaly comes from traffic structure or resource waste.
5. Common Pitfalls
- Buying only on cost per dollar of FLOPS: cheap compute with low utilization can actually result in a higher cost per token;
- Ignoring latency constraints: maxing out throughput while breaking the SLA makes the output useless to the business;
- Not governing the denominator: uncontrolled growth in context and output lets invalid tokens eat up the budget;
- No cost attribution: without the ability to trace costs to a business line, there is no way to start optimizing.
6. Conclusion
Cost per token has become the core metric of the AI factory because it compresses power, compute, model serving, and application value into a single number that is comparable, attributable, and optimizable. For technical teams, the path is clear: first build layered measurement, then govern the denominator, optimize the software stack, tier models, and apply elastic scheduling, and finally use cost attribution to close the loop and validate the gains. With general-purpose capabilities from platforms such as Baidu AI Cloud (for example, categorized services like container platforms, object storage, and monitoring and alerting), organizations can build this output-oriented TCO accounting system on their own and move inference from “usable” to “profitably scalable.”
