From Tiered Quotas to Self-Hosted Inference: A Cost Breakdown for LLM Services
This article explains the cost structure behind large language model (LLM) services, starting from why providers tier usage quotas and moving into the unit-cost model for inference, the key engineering steps of self-hosted deployment, and how to implement tiered quotas in practice. It covers token cost formulas, hardware selection, inference engine optimizations, metering and rate limiting, capacity estimation, common pitfalls, and actionable recommendations for deciding between building your own inference stack and purchasing managed services.
1. The Nature of Quota Tiers
LLM services typically divide available quotas into multiple tiers. The same model may come with different call limits, concurrency caps, and prices under each tier. Behind these tier differences lie three driving factors: per-unit inference cost, peak concurrency pressure, and differences in usage intensity across users. Providers must balance all three to keep the service sustainable while remaining attractive to users.
Once you understand this, discussions about any specific tier adjustment can move away from speculation and toward verifiable cost and technical logic.
2. The Unit Cost Model
Inference cost can be described with a simple formula:
Cost per token = hourly cost per accelerator ÷ effective tokens produced per hour per accelerator
Here, “effective output” is not the theoretical peak. It is affected by the following factors:
- Batch size: Larger batches generally improve memory and compute utilization, but they also increase per-request latency.
- Context length: Long contexts consume more KV cache, reducing the number of requests that can be served concurrently.
- Quantization: Lower-precision weights reduce memory footprint, but you must evaluate whether output quality remains acceptable.
- Load fluctuation: When actual utilization falls below expectations, fixed costs are spread across fewer tokens, raising the unit price.
A calculation example:
def cost_per_million_tokens(hourly_cost, tokens_per_hour, utilization):effective = tokens_per_hour * utilizationreturn hourly_cost / effective * 1_000_000
These parameters must be replaced with benchmark data from your own environment. Do not directly apply figures published by others.
3. Key Stages of Self-Hosted Inference Deployment
3.1 Model and License
Before deployment, confirm whether the model license permits commercial use, redistribution, and fine-tuning. License terms often directly determine whether you can offer the model as a service.
3.2 Hardware Selection
- Memory capacity: It must hold both model weights and the KV cache. This determines how large a model you can run and how long a context you can support.
- Memory bandwidth: It affects token-by-token generation speed during decoding, which is especially critical for interactive scenarios.
- Software stack compatibility: The maturity of drivers, operator libraries, and inference engines for a given accelerator directly determines your time to launch. The software ecosystems for domestic accelerators are continuously improving, but each model still requires individual verification of operator coverage and output accuracy consistency.
3.3 Inference Engine and Scheduling
Common optimization techniques fall into three categories:
- Continuous batching: New requests can be dynamically inserted into an existing batch, reducing device idle time.
- Prefix caching: Intermediate computation results for identical system prompts are reused, cutting redundant work.
- Prefill/decode separation: This prevents the prefill stage of long inputs from slowing down the generation of short responses.
3.4 Serving and Observability
At a minimum, you need health checks, request timeout controls, queue length monitoring, and token usage statistics broken down by model and by user. Without these metrics, any judgment about cost lacks a factual basis.
4. Engineering Implementation of Tiered Quotas
The core of tiered quotas comes down to two things: accurate metering and reliable rate limiting.
The metering layer records input and output tokens for each request, writes them asynchronously to an aggregate store, and summarizes them by user and time window. The rate limiting layer typically uses token bucket or sliding window algorithms, with independent rate and concurrency limits for each tier.
An illustrative configuration follows. The values are structural examples only and must be set according to your own capacity:
TIERS = {"basic": {"rpm": 20, "tpm": 40_000, "concurrency": 2},"standard": {"rpm": 60, "tpm": 150_000, "concurrency": 4},"pro": {"rpm": 200, "tpm": 600_000, "concurrency": 8},}
When a request arrives, the system first checks the concurrency counter and deducts from the token bucket; after the request completes, settlement is made based on the actual token count. The difference between the pre-deducted quota and actual consumption must be refunded promptly, otherwise long-running operation will cause quota to be wrongly deducted.
5. Capacity Estimation Example
Suppose a team has N accelerators, each producing T effective tokens per hour, with an average utilization of U. Daily output is then approximately N × T × 24 × U. Dividing this by the average daily request volume lets you work backward to the quota each user can be allocated.
The following demonstration uses variables only and does not represent any measured data:
- Let the hourly cost per accelerator be C, effective output be T, and utilization be U;
- Unit cost is C ÷ (T × U);
- If utilization rises from 50% to 80%, the unit cost drops to 0.5 ÷ 0.8 = 62.5% of its original value.
This shows that utilization usually has a greater impact on cost than the unit price of hardware.
6. Common Pitfalls
- Treating peak throughput as daily capacity: Real workloads fluctuate significantly across time periods; it is average utilization that determines cost levels.
- Looking only at hardware unit price: Electricity, facilities, operations, and labor all count toward total cost.
- Ignoring quality regression: After changing the quantization method or inference engine, output quality must be re-verified against a fixed evaluation set.
- Judging profitability based on rumors: Revenue figures circulating publicly usually lack any explanation of statistical methodology and cannot serve as a basis for decisions.
7. Practical Recommendations
- Start with small-scale real traffic to establish a baseline, recording token usage and latency distributions.
- Divide tiers by business priority and set rate and concurrency limits for each.
- Review utilization and unit cost monthly, and use the results to decide whether to scale up or down.
- When comparing self-hosting versus purchasing a managed service, evaluate both consistently on per-token cost and service availability—avoid comparing on a single metric alone.
