Self-Hosted LLM Inference: Does It Really Mean Free Tokens?
Self-hosting a large language model does not eliminate cost; it shifts pay-as-you-go billing into fixed hardware spending, engineering effort, and ongoing operations. This article breaks down the real cost structure of self-hosted inference, explains how GPU memory capacity and bandwidth set the first practical limit, and covers the performance metrics that shape user experience, including time to first token, generation speed, and tail latency. It also discusses where smaller models fit, why quantization requires regression testing on your own data, and how task routing, RAG pipelines, observability, and fallback paths turn local deployment into a sustainable engineering choice rather than a slogan.
Many teams start with a simple expectation: download a large language model, run it on your own hardware, and API calls become free. Tokens are now unlimited, and the business case takes care of itself. Reality is more complicated. Self-hosting changes how you pay, not whether you pay. It converts usage-based billing into fixed capital spending plus headcount, and it transfers responsibility for stability, performance tuning, and security compliance to your own team. Self-hosted inference only becomes genuinely usable once you account for compute planning, inference engine configuration, model precision tradeoffs, application-side engineering, and long-term operations.
What “Free Tokens” Actually Means: Cost Shifts, It Does Not Disappear
The cost structure of self-hosted inference breaks down into four parts:
- Hardware depreciation and redundancy: GPUs, servers, storage, and networking must be sized for peak load rather than average load, with spare capacity reserved for failures.
- Power and data center space: electricity, cooling, and rack space are ongoing expenses.
- People: deploying inference services, tuning performance, and handling incidents all require dedicated engineering time.
- Opportunity cost: hardware locked to a single model for long periods is hard to scale elastically.
A practical shortcut is to estimate effective throughput instead of theoretical compute:
Cost per token ≈ (hardware depreciation + power + operations labor) / (average daily effective output tokens)Effective output tokens = concurrency × average output length per request × tokens generated per second × average daily hours at full load
The denominator is what matters. If your workload peaks during business hours and sits idle overnight, average daily hours at full load may be only a few, and cost per token climbs quickly. In that situation, “free” only looks good on paper.
Compute and GPU Memory: The First Real Barrier
Memory capacity decides whether a model runs at all; memory bandwidth decides how fast it runs. A rough estimate:
Weight footprint ≈ parameter count × bytes per parameterKV Cache ≈ layers × 2 × sequence length × concurrency × hidden dimension × bytes per element
A model in the billions-of-parameters range can need tens of gigabytes of memory for weights alone at half precision. Add the KV cache for long contexts and you easily exceed the capacity of a single GPU. Common mitigations include weight quantization, tensor parallelism and pipeline parallelism, context length limits, paged KV cache management, and offloading part of the computation to host memory, at the cost of significantly higher latency.
Quantization is not lossless compression. Low-bit quantization degrades most general tasks only slightly, but in long-chain reasoning, code generation, and strict structured output it can raise format error rates and weaken instruction following. You have to validate with regression tests on your own business data, not just public benchmark leaderboards.
Performance: Throughput, Time to First Token, and Stability
Local inference performance usually comes down to three metrics:
- Time to first token (TTFT): driven by input length and prefill computation, especially visible with long documents.
- Generation rate (TPS): mainly driven by memory bandwidth and batching strategy.
- Tail latency (P99): shapes how users perceive the service and often matters more than the average.
The improvements are cumulative: continuous batching raises throughput, prefix caching reuses repeated system prompts and document chunks, speculative decoding lowers per-step cost, and a sensible maximum output length keeps individual requests from stalling the queue. An illustrative configuration:
engine:dtype: bfloat16max_model_len: 8192max_num_seqs: 64enable_prefix_caching: truegpu_memory_utilization: 0.90
You also need a fallback path ready: switch to a smaller backup model or a rule-based response when the primary model is unavailable, so a single point of failure is never exposed directly to end users.
Model Capability Limits: Where Smaller Models Fit and Where They Do Not
Smaller models have clear advantages in latency, deployment density, and cost, and they fit well-defined tasks such as classification, extraction, summarization, intent recognition, and fixed-template generation. They degrade more easily on complex multi-step reasoning, global understanding of long documents, rare languages and domain terminology, and strict structured output. The right engineering answer is task tiering: route requests by difficulty, send simple ones to the small model, and escalate complex ones to a larger model or an external inference service, balancing cost against quality.
Engineering Pipeline: The Model Is One Component
Between raw model output and a usable result sits a long chain: document parsing and chunking, vector retrieval and recall, prompt template management, output validation and retries, result caching, and audit trails. The quality of retrieval-augmented generation usually depends more on chunking strategy, recall quality, and reranking than on swapping in a larger model. You also need input and output content safety filtering, sensitive data masking, role-based access control, and full call-chain tracing so you can tell which stage produced a wrong answer.
Operations and Governance: The Long-Term Burden That Gets Underrated
Self-hosted services bring daily work: driver and runtime version compatibility, memory fragmentation and leaks, batch jobs competing with online traffic, model version canary releases and rollbacks, and setting dashboard metrics and alert thresholds. Build at least four categories of observability metrics: throughput and latency distribution, error and timeout rates, memory and temperature levels, and business-side quality metrics such as structured output compliance rate. An inference service without quality metrics has no acceptance criteria.
Hybrid Architecture: The More Practical Path
Most teams end up with a hybrid setup: self-hosted inference for core paths to keep data in-house and costs predictable, cloud inference services for elastic peaks and long-tail complex requests; data and model files in object storage, asynchronous decoupling through a message queue, elastic resources on a container platform, and unified visibility through log services and monitoring alerts. The general-purpose capabilities Baidu AI Cloud offers in these scenarios, such as object storage, message queues, container platforms, log services, and monitoring alerts, can serve as a reference for filling gaps in a self-hosted stack; check the official documentation for exact specifications and pricing.
Conclusion
Self-hosting is not the finish line. It trades usage-based billing for autonomy plus self-managed operations. Calculate effective throughput and cost per token first, use quantization and parallelism to keep hardware busy, control quality risk with task tiering, and cover stability with observability and fallbacks. That is when token freedom turns from a slogan into a sustainable engineering reality.
