LLM API or Self-Hosted Inference Cluster? Five Cost Calculations to Run First
When a managed model service degrades, every upstream application built on it feels the impact. This article breaks down the build-vs-buy decision for LLM inference into five cost calculations: compute quota, scale and utilization, financial treatment, technology lock-in, and failure/operations ownership. It includes a simplified capacity-cost model and shows why a unified inference gateway with multi-model redundancy often beats an either/or choice between external APIs and self-hosted clusters.
LLM API or Self-Hosted Inference Cluster? Five Cost Calculations to Run First
When a model service becomes unstable, every application that depends on its inference capacity gets dragged down with it: request timeouts, failed tasks, degraded user experience, and in the worst cases, compensation or refunds. This leads many teams to an intuitive conclusion: since inference frameworks are open source and hardware can be purchased, why not just build a self-hosted inference cluster? On the surface, self-hosting eliminates per-call API fees and gives you full control of the stack. But teams that actually do the capacity planning and financial modeling usually reach a different conclusion: it’s not that you can’t deploy it — it’s that the math doesn’t work.
“Doing the math” here doesn’t mean comparing “price per million tokens” against “price per GPU.” It means comparing total cost of ownership, business continuity, and organizational complexity. Here are five calculations that define the boundary between buying API access and building your own cluster.
Calculation 1: The Compute Quota — Budget Can Be Approved, but GPUs and Racks May Not Exist
Being a large enterprise doesn’t mean having unlimited high-end accelerators. An inference cluster needs more than GPUs: it needs racks, power, cooling, high-speed networking, storage, and spare parts. High-end compute is typically reserved for core in-house models and core business workloads, leaving limited room for new capital expenditure. Building a self-hosted cluster to serve external models is, in essence, competing internally for compute quota.
The more practical problem is procurement lead time. Even after budget approval, accelerator delivery, data center expansion, network cabling, and acceptance testing all take time. Business traffic, meanwhile, fluctuates constantly. With a managed model service, capacity is absorbed by the provider’s multi-tenant resource pool. With self-hosting, capacity must be provisioned ahead of peak demand. And once you size for a conservative peak, idle costs show up during off-peak hours.
So the first question is: can you actually obtain the peak compute required for self-hosting within an acceptable timeframe, without impacting core business? If the answer is no, external APIs are the more realistic elasticity option.
Calculation 2: Scale and Utilization — Open-Source Frameworks Cut Costs, but Only If Machines Stay Busy
Open-source inference frameworks genuinely reduce software licensing and engineering optimization costs, but they don’t eliminate fixed costs. Cost amortization in an inference cluster depends on high utilization: traffic peaks during the day and drops at night, so machines sized for peak will burn electricity and depreciation while idle at night. Ideally, a cluster should sustain high throughput around the clock; in reality, business traffic usually has pronounced peaks and valleys.
A simplified capacity-cost model can help with the judgment call:
def compare_cost(peak_qps, avg_qps, node_capacity_qps,node_month_cost, api_price_per_token,avg_tokens_per_request, safety_factor=1.3):# Self-hosted: provision fixed nodes based on peak load and safety factornodes = ceil(peak_qps * safety_factor / node_capacity_qps)self_fixed_cost = nodes * node_month_cost# Effective request volume is estimated from average traffic;# idle capacity cost is absorbed by the fixed poolmonthly_requests = avg_qps * 30 * 24 * 3600self_unit_cost = self_fixed_cost / max(monthly_requests, 1)# External API: cost scales with actual usage, plus retry and redundancy overheadapi_cost = monthly_requests * avg_tokens_per_request * api_price_per_tokenapi_cost_with_retry = api_cost * 1.15return nodes, self_unit_cost, api_cost_with_retry
The point of this model isn’t the specific numbers — it’s a reminder that self-hosted cost is driven by peak capacity, while API cost is driven by actual usage. When average utilization is low, the per-request cost of self-hosting rises quickly. Open-source frameworks optimize per-node throughput, but they can’t turn idle machines at 3 a.m. into revenue.
Calculation 3: The Accounting Treatment — Self-Hosting Is a Heavy Asset; APIs Are a Monthly Expense
A self-hosted inference cluster is a classic capital-intensive investment: hardware procurement, facility modifications, network equipment, spare parts, and operations headcount are depreciated over the asset’s useful life. What you get is not “pay for what you use this month,” but long-term fixed costs and asset impairment risk. External model services behave more like operating expenses — billed by usage or subscription, incurred and recognized in the same month, with far better capacity elasticity.
During periods of cash flow pressure or strict budget review, finance teams generally prefer predictable, business-adjustable operating expenses over heavy assets that lock in years of depreciation. Self-hosting also has to answer the ROI question: if model generations evolve quickly, a hardware cluster optimized for today’s model may need re-tuning tomorrow because of changes in model architecture, quantization methods, or inference engines.
So the third calculation isn’t “is self-hosting cheaper per unit,” but: given uncertain business growth and rapid model iteration, are you willing to lock a short-term technology choice into long-term fixed assets?
Calculation 4: Technology Evolution — APIs Can Be Switched; Self-Hosting Tends to Lock You In
The model service market moves fast. A model that fits your quality and price requirements today may be displaced tomorrow by a cheaper, better-suited one. In the external API model, teams can do model routing, canary switches, and fallbacks through a unified gateway — migration is a configuration or adapter-layer change. A self-hosted cluster is different: hardware selection, inference engine, quantization strategy, compilation optimizations, and monitoring are often tied to a specific model generation. When the model changes, earlier optimizations may partially fail and hardware utilization drops.
“Self-hosting means more autonomy” is a common misconception. Real autonomy comes from replaceability, observability, and engineering abstraction — not from owning a few rows of machines. If you self-host and then can’t switch models because migration costs are too high, you’re locked into your own hardware and engineering stack instead. A safer approach is to keep a unified model access layer that decouples business logic from any specific model:
Business services -> Unified inference gateway -> Model A / Model B / Self-hosted cluster-> Rate limiting, circuit breaking, caching, fallback, auditing
A unified gateway lets external APIs and self-hosting coexist: stable core load goes to the self-hosted cluster, burst traffic goes to external APIs, and a backup model takes over when the primary fails. This preserves elasticity while avoiding lock-in to a single path.
Calculation 5: Failures and Operations — Self-Hosting Doesn’t Eliminate Failures; It Just Moves the Failure Domain
Using external model services doesn’t mean zero failures, and self-hosting doesn’t equal high availability. A self-hosted inference cluster requires 24/7 operations: capacity monitoring, request queuing, timeout retries, driver and firmware compatibility, network troubleshooting, security and compliance, model updates, failure drills, and spare-parts management. Miss any one of these, and your failure domain may end up larger than with external APIs. External services shift some infrastructure operations to the provider, but the business side still needs circuit breaking, rate limiting, caching, asynchronous tasks, and degradation strategies.
When a model service degrades, what actually determines your losses is business continuity design, not who owns the machines. If upstream applications lack timeout controls, retry backoff, and fallback paths, a self-hosted cluster will still get overwhelmed by traffic. With a unified gateway and multi-model redundancy, external APIs can stay available too. The fifth calculation is: does the team have the organizational capability to operate an inference cluster long-term, and is the business willing to take on greater failure responsibility for self-hosting?
When Does Self-Hosting Make Sense?
Self-hosting isn’t wrong, but the conditions for it are fairly specific: long-term stable and predictable load, a small gap between peak and average traffic, strict data compliance requirements, deep model customization, a mature operations team, and long-term capacity planning. For teams with highly variable traffic, rapidly evolving model choices, and sensitivity around cash flow and budget approval, external APIs combined with a unified gateway, multi-model redundancy, and hybrid routing are usually the better deal.
The final decision shouldn’t stop at “API unit price vs. machine unit price.” It should compare total cost of ownership: compute quota, utilization, accounting treatment, technology replaceability, and failure/operations cost. Only after running all five calculations can you tell whether self-hosting is a cost-reduction measure — or just converting variable costs into fixed risk that’s harder to digest.
