Local Deployment of LLMs ≠ Inference Freedom: Do the Math
This article analyzes the true costs and trade-offs of deploying large language models locally versus using cloud APIs. It covers hidden prerequisites, cost calculation, performance metrics, capability boundaries, and provides a decision checklist to help teams choose between local, cloud, or hybrid deployment strategies.
Conclusion First
Local deployment does free you from rate limits and per-token billing, but it is not “free.” It trades variable costs for one-time CapEx + continuous electricity + human maintenance + capability degradation. Self-hosting is only truly cost-effective if at least two of three conditions are met: high call volume, strict data residency requirements, and latency tolerance. Otherwise, “token freedom” often leads to “idle compute.”
1. Three Hidden Prerequisites of “Token Freedom”
The first prerequisite is that memory capacity must fit the model weights and KV Cache. Take a Q8 quantized 10-billion-parameter model as an example. Weights alone require tens of GB of memory. Add the KV Cache for long contexts and batching overhead, and actual usage is typically 1.3 to 2 times the size of the weights. This means there is a whole hardware tier difference between “it can run” and “it runs comfortably.”
The second prerequisite is that quantization inevitably causes capability degradation. Q8 is a conservative quantization level, and the loss is usually acceptable. However, if you drop to Q4 or lower to fit into smaller memory, the stability of instruction following, long-chain reasoning, and structured output (like strict JSON) will noticeably decline. Many “it runs locally but the results are wrong” issues stem not from the model itself, but from the quantization level and context length.
The third prerequisite is that operations and maintenance are entirely on you. Cloud API 429 errors, rate limits, and latency spikes are indeed annoying, but local deployment requires dealing with driver and runtime version alignment, quantized file verification, VRAM fragmentation, auto-restart after process crashes, and model upgrade regression testing—no vendor is there to cover your back.
2. Treat Cost as a Curve, Not a Number
The core of deciding whether self-hosting is worth it lies in finding the break-even point. You can use a simplified model:
Self-hosting total cost ≈ Hardware depreciation (over 3 years) + Power (kW) × Electricity rate × 24 × 365 + Maintenance laborCloud total cost ≈ Input token price × Input volume + Output token price × Output volumeWhen Self-hosting total cost / Monthly processed tokens < Cloud unit price, self-hosting becomes advantageous
An illustrative calculation (parameters are for demonstration only, replace them with your own): Assuming equipment power consumption is 1.2 kW and the electricity rate is 0.6 CNY/kWh, the full-load electricity cost is about 6,300 CNY/year. If the hardware investment is 80,000 CNY depreciated over 3 years, that is about 27,000 CNY/year. The total fixed expenditure is about 33,000 CNY/year. Dividing this by your actual stable token throughput gives the real unit price. Note that the denominator is actual throughput, not theoretical peak—most individual users’ real utilization stays below 20% long-term, which multiplies the effective unit price several times.
The conclusion is straightforward: For low-frequency, sporadic scenarios demanding top-tier capabilities, the cloud is more economical. For high-frequency, batch, offline-capable, and data-sensitive scenarios, the advantages of self-hosting will only amplify as utilization increases.
3. Look Beyond “Can It Run”: Four Performance Metrics
- TTFT (Time To First Token): Determines interactive feel, most affected by prompt length and prefill compute.
- TPOT (Time Per Output Token): Determines “typewriter” fluency, constrained by memory bandwidth.
- Concurrent throughput: 20 tokens/s at concurrency 1 does not mean 20 tokens/s at concurrency 8; memory bandwidth gets diluted.
- Long context degradation: When context scales from 4K to 32K, KV Cache and attention overhead rise, often causing an order-of-magnitude drop in throughput.
It is recommended to benchmark with a unified script rather than trusting any single marketing number:
import time, json, urllib.requestdef bench(prompt, max_tokens=256, repeat=3):payload = json.dumps({"model": "local-model","messages": [{"role": "user", "content": prompt}],"max_tokens": max_tokens,"stream": True,}).encode()results = []for _ in range(repeat):req = urllib.request.Request("http://127.0.0.1:8000/v1/chat/completions",data=payload, headers={"Content-Type": "application/json"})start, first, n = time.perf_counter(), None, 0with urllib.request.urlopen(req) as resp:for line in resp:if not line.startswith(b"data:") or b"[DONE]" in line:continuen += 1if first is None:first = time.perf_counter()end = time.perf_counter()results.append({"ttft": round(first - start, 3),"tpot": round((end - first) / max(n, 1), 4),"total": round(end - start, 3),})return resultsprint(bench("Explain what KV Cache is in three sentences."))
Increase repeat to 8–16 and observe TPOT changes to get the true concurrency curve on your hardware.
4. Acknowledge Capability Boundaries Early
Medium-sized local models are quite usable for tasks with clear boundaries such as summarization, rewriting, classification, extraction, code completion, and format conversion. However, they still lag significantly behind flagship cloud models in highly demanding tasks like global reasoning over ultra-long documents, complex multi-step Agent orchestration, strict tool calling, fine-grained multimodal understanding, and video generation. Additionally, local generation of video and images requires far more VRAM and cooling than text inference, representing a separate hardware budget line.
A pragmatic approach is tiered routing: assign high-frequency, simple, and sensitive tasks to local models, and overflow low-frequency, high-difficulty tasks requiring peak capabilities to cloud APIs.
Request → Task grading (Rules/small model judgment)├─ Simple & High-frequency & Sensitive → Local inference service└─ Complex & Low-frequency → Cloud general APIResult → Unified evaluation and logging (Monitoring/Alerting + Logging service)
Supporting engineering essentials: add health checks and auto-restarts for local services; use container platforms to solidify the runtime environment; version-control prompts and quantization versions; build a 50–100 case business regression suite to run after every quantization or model change, using data rather than feelings to judge whether capabilities have improved or degraded.
5. Decision Checklist
Choose local deployment if you: have large and stable call volumes, require strict data compliance where data cannot leave the domain, need offline availability, and can tolerate second-level latency.
Choose the cloud if you: demand the strongest capabilities, have highly fluctuating call volumes, lack maintenance personnel, and need multimodal and ultra-long context support.
Choose a hybrid approach if you are the vast majority of teams—this is currently the most mainstream engineering answer.
To summarize: Local deployment buys controllability and determinism, not a free lunch. Calculate utilization and break-even points before chasing “token freedom,” so you do not blow your budget on idle compute.
