The Economics of Self-Hosted GPU Inference for Large Language Models

    This article breaks down the cost of running large language model inference on self-deployed GPU clusters instead of public APIs. Using a real case where a platform moved roughly 44% of its inference traffic (about 16 trillion tokens) in-house within three months, it walks through capacity sizing, the throughput math, short-term GPU rental pricing, and the utilization trap that can double effective cost per token. It also compares gross margins under usage-based billing versus low-price subscriptions, offers a decision checklist for self-hosting versus public APIs, and outlines the engineering risks to plan for.

    1. The Shift: Inference Traffic Moving Back from Public APIs

    A notable trend is emerging in the industry: one AI coding tool platform has migrated roughly 44% of its model inference traffic from third-party APIs to self-deployed GPU resources, amounting to about 16 trillion tokens. Completing the compute channel setup, independent model hosting, and traffic cutover within three months is itself telling—once inference volume crosses a certain threshold, “self-hosting” flips from a cost burden into a cost advantage.

    The approach is not technically mysterious. It packages stateless inference services into an elastically scalable cluster, replaces long-term capital expenditure with short-term compute rental, and uses a gateway layer for traffic routing. Let’s break the whole chain down and run the numbers.

    2. Capacity Sizing: What Kind of Cluster Handles 16 Trillion Tokens

    Start with an order-of-magnitude check. If 16 trillion tokens are consumed within one month, the average throughput requirement is:

    1. 16e12 / (30 * 24 * 3600) ≈ 6.17e6 token/s

    That is about 6.17 million tokens per second. The fact that three racks (roughly 216 high-end GPUs) can carry this depends on three conditions:

    1. High-concurrency batching (continuous batching) pushes GPU utilization high;
    2. Coding requests have long inputs and short outputs, so per-request GPU memory residency time is short;
    3. High prefix cache reuse means large amounts of repeated code context do not need to be recomputed.

    Conversely, a general-purpose chat workload with long outputs and highly varied context would require significantly more GPUs for the same throughput. The first principle of capacity planning: do not extrapolate full traffic from peak-scenario measurements.

    3. Cost Structure: Rent, Unit Cost, and the Utilization Trap

    Based on publicly visible short-term rental ranges (about $9–10 per hour for high-end models, about $6–7 for the next tier), the monthly rent for 216 GPUs lands roughly in the $1.4M–$1.56M range. Under ideal full load, the compute cost per token can be pushed down to about $0.0029–0.0032 per million tokens.

    But here lies the easiest part to miscalculate—utilization. The formula above assumes 24/7 full load, while real business day-to-night peaks and troughs often differ by 2–3x:

    1. effective unit cost = nominal unit cost / average utilization
    2. If average utilization is only 50%, cost immediately doubles to about $0.006/million tokens

    So the economics of self-hosting do not depend on the sticker price, but on whether batch queues and low-priority offline jobs can fill the troughs.

    4. Gross Margin Under Two Business Models

    • Usage-based billing: If the external price is significantly above the cost level of a few tenths of a cent per million tokens, a 50%–70% gross margin is reasonable; this is also the scenario where self-hosting becomes profitable first.
    • Low-price subscription: For a plan at around $10 per month, if per-user monthly consumption reaches a few trillionths of the total, rent is almost entirely eaten up, margins are razor-thin or even negative, and it must rely on a “most users are light users” distribution to break even.

    The right way to judge profitability is to build a tiered model:

    1. def margin(users, arpu, avg_tokens_per_user, price_per_mtok, cost_per_mtok, util):
    2. revenue = users * arpu
    3. cost = users * avg_tokens_per_user * (cost_per_mtok / util)
    4. return (revenue - cost) / revenue

    Treating the share of heavy users as a sensitivity variable reveals where the safety boundary of the subscription model lies.

    5. Self-Hosted vs. Public API: A Decision Checklist

    Prefer self-hosting: traffic is stable and predictable, per-request context has high redundancy, data must stay within a specific boundary, and mature inference gateway and scheduling capabilities already exist.

    Prefer public APIs: traffic fluctuates sharply, models iterate frequently, and GPU operations and failover capabilities are lacking. In this case, you can rely on the cloud provider’s container platform, object storage, logging service, and monitoring and alerting capabilities to quickly stand up an elastic inference layer, converting capital expenditure into operating expenditure.

    The pragmatic path is hybrid routing: use the self-hosted cluster for baseline traffic, overflow peaks and long-tail traffic to APIs, and use a unified gateway for weighted canary and fallback.

    6. Risks and Engineering Essentials

    Short-term contracts mean renewal price volatility risk; single-rack failures require cross-availability-zone redundancy; model version upgrades require blue-green deployment and fast rollback; and token metering must be instrumented uniformly at the gateway side, otherwise cost attribution is impossible. Only when these are built into the infrastructure does self-hosting become truly sustainable.