How to Calculate the Cost of Local LLM Inference: CapEx vs. Cloud OpEx

    This article breaks down the real economics of running large language models locally instead of relying on cloud APIs. It explains why memory capacity and bandwidth—not raw compute—are the primary constraints, offers a reproducible cost model covering electricity, depreciation, utilization, and operations, and shows how to estimate payback periods. It also outlines a practical optimization order and a hybrid routing architecture, helping teams decide when local, cloud, or hybrid inference makes financial and technical sense.

    1. The Starting Point: In the Agent Era, Tokens Shift from a Consumable to a Cost Center

    The cost structure of LLM applications has changed fundamentally over the past two years. Traditional question-and-answer usage is a one-shot exchange, and the token volume per request stays largely predictable. Under the agent paradigm, a single task often runs multiple loops of planning, tool calls, result reflection, and re-planning. It is not unusual for one task to consume several times the tokens of a simple Q&A request. The industry vividly calls this amplification effect the “token black hole.”

    At the same time, prices on the supply side are not falling monotonically. When leading model vendors adjust pricing collectively and some tiers see clear increases, demand-side amplification and supply-side price hikes stack up, and the billing curve turns steep.

    The Jevons paradox in economics states that gains in usage efficiency can drive total consumption up rather than down. The same pattern is repeating in token consumption: context windows have expanded from a few thousand tokens to the million-token range, models are more capable and can fit more material into a single call, so people naturally stuff in more documents, longer histories, and more tool outputs. Total consumption rises instead of falling.

    So the core question emerges: can “compute” be converted from an operating expense (OpEx) that erodes profit every month into a capital expense (CapEx)—a one-time investment amortized over the long run? This article answers with a reproducible model and offers criteria for the decision.

    2. The Real Bottleneck for Local Inference: The Memory Wall, Not the Compute Wall

    Much of the discussion focuses on how many TOPS a chip delivers, but the first-order constraint for running LLMs locally is memory capacity and memory bandwidth.

    The reason is straightforward: during autoregressive decoding, every token generated requires reading the full set of model weights. This stage is memory-access intensive rather than compute intensive. Therefore:

    • Memory capacity determines “whether it fits”: a model that does not fit cannot run, and quantization can only compress so far;
    • Memory bandwidth determines “how fast it generates”: decoding throughput is roughly proportional to bandwidth;
    • Peak compute mainly affects the prefill stage, meaning the speed of processing long inputs.

    This is where unified memory architecture adds value: the CPU, GPU, and NPU share the same address space, avoiding repeated copies between dedicated VRAM and system memory, so the capacity ceiling is no longer capped by “only 8GB/16GB of VRAM.” Unified memory at the 128GB level means a 30B-class model, or even a larger quantized model, can be loaded in full, instead of being forced back to a 7B-class small model.

    A dose of cold water is needed here: capacity solves “runnable,” but it does not mean “fast enough.” In public tests, this class of platform running a distilled 32B-class model at 8-bit quantization often generates at only single-digit tokens/s. Whether that is acceptable depends on the latency tolerance of the business.

    3. Making the Cost Clear: A Reproducible Model

    Assume a certain high-memory unified-memory device with a one-time investment of about CNY 21,500, a full-load power draw of 140W, running 7×24, and a commercial electricity price of CNY 1 per kWh.

    1. Daily energy = 0.14 kW × 24 h = 3.36 kWh
    2. Daily electricity cost = 3.36 × 1 = CNY 3.36
    3. Daily output = 10 tokens/s × 86400 s = 864,000 tokens
    4. Electricity cost per 10K tokens = 3.36 / 86.4 ≈ CNY 0.038

    Compared with cloud quotes of several to a dozen-plus CNY per 10K tokens, the electricity cost differs by two orders of magnitude. But counting only electricity is cheating; three overlooked costs must be added:

    1. Depreciation. Using straight-line depreciation over 3 years (about 1,095 days), CNY 21,500 / 1,095 ≈ CNY 19.6/day, or about CNY 0.23 per 10K tokens.
    2. Utilization. Real workloads rarely run at full load. At an average utilization of 30%, daily output drops to about 260,000 tokens, and unit cost multiplies by 3.3×, to about CNY 0.75 per 10K tokens.
    3. Operations and labor. Model updates, quantization, monitoring, and failure handling are all hidden costs, and in small-scale deployments they are often the largest item.

    Conclusion: the economics of local inference do not come from “cheap electricity,” but from “reusing idle capacity” and “keeping data within its domain.” If utilization stays below 20% over the long term, the pure cost case does not hold.

    4. How to Estimate the Payback Period: Don’t Divide the Bill by Peak Throughput

    The original text gives a 5.6-day payback, with the implicit assumption that local inference replaces hundreds of CNY per day in cloud spending and runs at full load. This calculation holds under the premise of “an existing stable, high-frequency load,” but it lacks generality. A more rigorous approach is to write the payback period as a function:

    1. Payback days = Device investment / (Daily cloud cost - Daily local cost)
    2. Daily local cost = electricity + depreciation + operations allocation

    This yields three decision rules:

    • Stable and large load (e.g., tens of millions of tokens per day on average) → local/self-hosted is more cost-effective, with payback measured in weeks;
    • Highly variable load with concentrated peaks → pay-as-you-go is easier, and self-hosting creates a lot of idle capacity;
    • Load involving sensitive data or requiring deep customization → localization still has compliance value even if the cost is slightly higher.

    5. The Correct Order for Performance Optimization

    If you decide to self-host, the optimization payoff from high to low is roughly:

    1. Quantization and model selection. Prioritize the smallest model that “fits in memory and is good enough”; 4-bit/8-bit weight quantization usually cuts memory usage significantly; note that quantization loses precision and must be validated on an evaluation set.
    2. Batching and concurrency. Decoding throughput is bandwidth-bound, and moderate batching can raise total throughput but pushes up single-request latency, requiring a tradeoff against the SLA.
    3. Context governance. This is the most underrated step: trimming history, replacing full injection with retrieval, and summarizing results can reduce both cost and latency.
    4. Inference runtime tuning. Common techniques such as KV Cache reuse, paged cache management, operator fusion, and speculative decoding have corresponding capabilities in most mainstream inference frameworks.
    5. Separated prefill and decode deployment. At larger scale, splitting long-input processing from token-by-token generation into different resource pools can significantly improve responsiveness for long-document scenarios.

    A schematic service wrapper:

    1. # Pseudocode: the general shape of a local inference service
    2. def handle(request):
    3. ctx = build_context(
    4. history=trim(request.history, max_turns=6),
    5. retrieved=retrieve(request.query, top_k=5), # retrieval instead of full injection
    6. )
    7. return local_engine.generate(
    8. prompt=render(ctx),
    9. max_tokens=1024,
    10. temperature=0.2,
    11. )

    6. Hybrid Architecture: The Final Answer for Most Teams

    The more common and more robust form in production is tiered routing, not an either/or choice between “all cloud” and “all local”:

    • Tier 1: a local small model handles high-frequency, simple, privacy-sensitive tasks (classification, extraction, formatting, intent recognition);
    • Tier 2: a local mid-size model handles routine generation and tool calls;
    • Tier 3: a cloud large model serves as a fallback for complex reasoning and long-tail tasks;
    • Side path: a unified logging service, monitoring and alerting, and cost accounting, tagged by tenant/business line, so the true unit cost becomes visible.

    In platform practices such as Baidu AI Cloud, the common approach is also to combine general capabilities like container platforms, object storage, message queues, and logging and monitoring to carry this tiering, rather than relying on a single inference device.

    7. Conclusion

    Local inference is not “cheaper cloud”; it is a swap of cost structures: trading CapEx for OpEx, and operational complexity for data sovereignty and controllable marginal cost. Whether it is worth doing comes down to three numbers: stable load intensity, acceptable latency, and full per-token cost (including depreciation and labor). Calculate these three clearly, then decide between local, cloud, or hybrid, and you will not keep oscillating between bills and idle capacity.