Self-Hosting LLMs Doesn't Mean Free Tokens: A Cost Breakdown

    Self-hosting a large language model is often mistaken for eliminating inference costs. This article explains why local deployment shifts costs rather than removing them, breaks down the cost per million tokens using a formula where utilization is the key variable, and includes reference calculations for electricity and hardware depreciation. It also covers how to compare self-hosting against API pricing at the same model capability tier, when self-hosting is genuinely cost-effective, and engineering methods to improve utilization.

    1. The Bottom Line: Self-Hosting Isn’t Free, It Shifts the Cost Structure

    Many people assume that downloading a model and running it on their own machine makes inference costs disappear. Since there are no external API calls, generating more content costs nothing extra, so “token freedom” is achieved and the only remaining question is whether the hardware is powerful enough.

    This reasoning doesn’t hold up under accounting. Local deployment doesn’t make tokens zero-cost. It replaces usage-based operating expenses with a one-time hardware investment, ongoing electricity bills, and your own time. After the purchase, the marginal cost of generating one more token is indeed close to zero, but cost-effectiveness is never measured by marginal cost. It’s measured by average cost: the higher the share of time the machine spends producing at full capacity each day, the lower the fixed cost allocated to each token. Conversely, if the machine sits idle most of the time, the effective per-token price may be higher than calling an API of the same tier.

    The second misconception is that “enough VRAM means you can get work done.” VRAM determines whether you can load the model and how long a context window you can open. Whether you can actually get work done depends on the task type, output quality requirements, concurrency scale, and latency tolerance. Loading a model and running it at a usable level are two different things.

    2. Write the Cost as a Formula: The Denominator Is the Key Variable

    Any discussion of self-hosted inference feasibility should return to a reproducible equation:

    1. Cost per million tokens = (hardware depreciation + electricity + labor time cost) / actual tokens produced (millions)

    Among the three terms in the numerator, hardware depreciation is usually the largest, electricity comes second, and labor time is the easiest to overlook yet often the most expensive. Environment setup, quantization conversion, inference framework tuning, and troubleshooting are all real expenses that come with no invoice. The denominator is utilization, which is affected by both concurrency and daily runtime and can easily vary by a factor of ten to twenty.

    Reference Calculation (data from a publicly shared setup of a used server plus consumer-grade accelerator cards)

    Assume this setup has roughly 256 GB of aggregate VRAM, about 60 tokens/s for a single request, about 450 tokens/s combined across 16 concurrent requests, and daily power consumption of about 11 kWh. At a residential electricity rate of 0.55 CNY per kWh, the daily electricity cost is about 6 CNY.

    Electricity only:

    • Low-utilization scenario: 4 hours of actual generation per day with a single request, producing about 60 × 3600 × 4 ≈ 860,000 tokens, or about 7 CNY per million tokens in electricity.
    • High-utilization scenario: 16 concurrent requests running at full capacity all day, producing about 450 × 86400 ≈ 39 million tokens. Power consumption is significantly higher than under mixed daily loads, so estimating electricity at two to three times gives only 0.3 to 0.5 CNY per million tokens.

    The same machine shows a ten- to twenty-fold difference in unit price, and the difference lies almost entirely in the denominator.

    Recalculate With Depreciation

    Using straight-line depreciation over 3 years, take two hardware investment levels of 20,000 CNY and 80,000 CNY (80,000 CNY roughly corresponds to the top configuration of a high-end all-in-one machine or a combination of two small desktop inference devices; throughput may not match the setup above, but the same throughput figures are used here only to observe the effect of hardware price):

    Hardware investment Daily depreciation 4 hours, single stream (CNY/million tokens) 24 hours, full concurrency (CNY/million tokens)
    20,000 CNY ~18 CNY depreciation ~21 + electricity ~7 ≈ 28 depreciation plus electricity ~1
    80,000 CNY ~73 CNY depreciation around 90 a bit over 2

    At low utilization, the self-hosted unit price is on the order of tens of CNY; at high utilization, it can be pushed down to around 1 CNY. Depreciation is the multiplier that widens the gap.

    3. Comparing Prices: Don’t Compare a Local Small Model With a Flagship API

    Self-hosted setups can usually only run lightweight open-source models, and the API tier corresponding to such models is priced at roughly a few CNY per million output tokens. More capable models reach a dozen CNY or more (prices keep changing; only the order of magnitude is given here). Comparing the actual cost of running a lightweight model locally against a flagship model’s price is a mismatch of baselines, and the conclusion is bound to be distorted.

    The correct comparison aligns three tiers: task requirements → acceptable model capability tier → API price and self-hosted amortized cost at that tier. Only within the same capability tier are self-hosting and API calls comparable.

    4. When Self-Hosting Is Genuinely Cost-Effective

    • Stable, continuous load: fixed batch jobs, offline data processing, or long-running high-concurrency online services where utilization stays high over the long term.
    • Data must stay local: compliance or confidentiality requirements make data leaving the premises unacceptable, so API price isn’t the only variable.
    • Deep customization is needed: fine-tuning, private operators, special decoding strategies, or a fixed latency budget are hard to fully control on a managed API.
    • Idle compute is already available: the hardware depreciation has already occurred, so the incremental cost is mainly electricity.

    Conversely, for an individual with intermittent usage, occasional daytime Q&A, and near-idle nights, nearly all the fixed cost is wasted on a low-output denominator. Calling an API is more economical and less hassle in most scenarios.

    5. Raising Utilization: Actionable Engineering Methods

    • Batching and continuous batching: combining multiple requests into a batch is the most direct way to increase throughput.
    • Quantization and VRAM planning: reduce weight bit-width within an acceptable precision range to free up space for larger batches and longer contexts.
    • Request queuing and prioritization: separate interactive from offline tasks to prevent long jobs from blocking short requests.
    • Metrics monitoring: at minimum, collect throughput, time to first token, VRAM usage, average daily utilization, and power consumption, and use data to drive scaling decisions.
    • Elastic fallback: have the self-hosted cluster handle baseline load and spill peak overflow to general-purpose cloud compute or managed inference services, balancing cost and availability.

    6. Decision Checklist

    1. Estimate actual daily generation time and concurrency to calculate utilization, rather than looking only at peak throughput.
    2. Plug your local electricity rate and depreciation period into the formula above to get the amortized cost per million tokens.
    3. Find the API price at the same capability tier and compare on the same basis.
    4. Convert labor time into a cost and include it in the numerator; most people change their conclusion here.
    5. Start with a small-scale validation, test quality and throughput with real task samples, then decide whether to purchase.

    The real value of local deployment lies in control, customization, and data boundaries, not in a unit price that is necessarily lower. Evaluate it as an infrastructure investment that requires operations, measure it clearly with the two rulers of utilization and depreciation, and you can avoid the common trap of “discovering it’s more expensive than calling an API only after buying.”