Self-Hosting Large Language Models: Calculate the Costs Before You Decide

    This guide helps teams and individuals decide whether to self-host LLM inference or call cloud APIs. It explains why ongoing operations often cost more than deployment, provides a simple monthly total cost of ownership model with a break-even calculation, and covers the VRAM trade-offs of running large models locally. It also describes the three scenarios where self-hosting is justified, the cases where cloud APIs are the better choice, and a decision checklist.

    1. Key Takeaway

    Most teams and individuals do not need to self-host large language model inference services. Only three situations justify serious consideration: data cannot leave the internal network, the business must run in an offline environment, or fixed usage is so large that the cloud bill becomes a significant burden. If none of these apply, calling a cloud API directly is usually simpler and has a lower total cost.

    The analysis below is based on a real self-hosting experience. The author ran models in the 30B and 32B range on a personal server. The author also loaded a 70B-class model in 4-bit quantized form into 128GB of VRAM and exposed it as an API through an inference service. The most direct lesson from this experience is that the deployment itself is not expensive. The real effort goes into keeping the system running after deployment.

    2. Deployment Is the Cheapest Part. Operation Is the Real Cost

    Downloading model weights, installing an inference framework, and starting the service usually takes half a day. Many people conclude from this that self-hosting is cost-effective. That conclusion is a common misconception.

    After deployment, the following tasks keep occurring:

    • Power and cooling: Servers running at full or partial load accumulate electricity charges every month. Cooling for the server room or home also needs to be factored in.
    • Hardware occupation: Models and caches occupy VRAM for long periods. Even when the service is idle, these resources cannot be used for other tasks.
    • Version maintenance: Open-source models and inference frameworks are updated frequently. Security patches and performance improvements require manual evaluation and upgrades.
    • Incident handling: Service crashes, VRAM overflows, driver failures, and full disks tend to happen late at night and require on-call staff to respond.
    • Capacity planning: As concurrency grows, teams need to decide whether to add GPUs and how to adjust batching and scheduling strategies.

    A significant share of cloud API pricing covers exactly this kind of operations and safety-net work. Self-hosting moves that cost from the invoice to the team’s schedule. People whose time is cheap can accept that trade. Teams whose time is expensive will usually find that self-hosting does not pay off.

    3. Estimating Total Cost of Ownership with a Model

    When comparing the two options, use total cost of ownership (TCO) as the basis, not only the cost of a single deployment. The script below provides a simplified monthly cost model. Replace all parameters with actual data.

    1. def monthly_cost_local(
    2. hardware_cost: float, # Total hardware investment (CNY)
    3. amortize_months: int, # Number of months over which hardware is depreciated
    4. power_kw: float, # Average power draw of the whole system (kW)
    5. hours_per_day: float, # Actual running hours per day
    6. electricity_price: float, # Electricity price (CNY per kWh)
    7. ops_hours: float, # Operations labor per month (hours)
    8. ops_hourly_rate: float, # Hourly cost of operations staff (CNY)
    9. ) -> float:
    10. hardware = hardware_cost / amortize_months
    11. power = power_kw * hours_per_day * 30 * electricity_price
    12. ops = ops_hours * ops_hourly_rate
    13. return hardware + power + ops
    14. def monthly_cost_api(
    15. monthly_tokens_million: float, # Monthly usage (millions of tokens)
    16. price_per_million: float, # Cloud API price (CNY per million tokens)
    17. ) -> float:
    18. return monthly_tokens_million * price_per_million

    This model has two points to note.

    First, the marginal cost of local deployment is close to zero, but its fixed costs are rigid. Whether the server processes one token or a million, hardware depreciation, base electricity, and operations hours still accrue. The effective cost per token therefore depends on actual usage:

    Effective unit price = monthly fixed cost / actual monthly token count

    The lower the usage, the higher the unit cost. This is why businesses with volatile usage are often a poor fit for self-hosting.

    Second, operations time is usually underestimated. If one person spends a dozen or more hours a month on upgrades, monitoring, and incidents, the opportunity cost of that time is often far higher than the difference on the cloud bill, especially if the same time could go to product development.

    When deciding whether to self-host, first calculate the break-even point: the monthly token volume at which local fixed costs equal the cloud bill. If actual usage stays consistently below this value, self-hosting loses money.

    4. The Limits of “Token Freedom”

    After self-hosting, there is no longer a per-token bill, but resource constraints do not disappear. They take a different form.

    VRAM determines the model size you can run. Take a 70B-class model quantized to 4 bits as an example. The weights alone take up a large amount of VRAM, and the remaining space must hold the KV cache. Longer contexts and higher concurrency mean larger caches. With the same hardware, you can only trade off among speed, concurrency, and context length. You cannot maximize all three at once.

    To use a larger model or a longer context, you need more VRAM, which means more hardware investment. Local deployment does not eliminate cost. It converts cost from pay-per-use into a one-time investment plus ongoing operations.

    When choosing hardware, consider these dimensions:

    1. The parameter size and quantization method of the target model, which determine the weight memory.
    2. The target concurrency and average context length, which determine the cache memory.
    3. The acceptable time to first token and generation speed, which determine the compute requirements.
    4. The expansion plans for the next one to two years, which determine whether to reserve headroom.

    5. Three Scenarios Where Self-Hosting Is Justified

    1. Data Cannot Leave the Internal Network

    For scenarios involving classified information, customer personal data, or unpublished internal documents, sending content to an external API may directly violate compliance requirements. In these cases, local deployment is one of the few viable options.

    This scenario is driven by compliance, not cost savings. Even if the local option has a higher total cost, it should take priority when compliance requirements are explicit. The compliance team should take part in designing the solution, including access control, log auditing, and policies for storing and backing up model files.

    2. Offline or Low-Latency Operation Is Required

    Field operations, isolated production systems on internal networks, and mobile devices with unstable connectivity may not be able to depend on cloud services. Edge devices have limited compute and can usually run only smaller models. For tasks such as classification, extraction, and keyword detection, however, small models are often sufficient.

    The test for this scenario is whether offline capability is a hard requirement. If it is, local execution is the only solution. If the goal is only to reduce latency somewhat, a cloud node located closer to the users can usually solve the problem without building your own infrastructure.

    When deploying on edge devices, focus on two metrics: prefill speed (how fast the input is processed) and decode speed (how fast tokens are generated one by one). Both depend on the chip’s memory bandwidth and compute capability. Measure actual values on the target device. Spec sheets alone cannot predict performance.

    3. Fixed, High Usage

    When a business consistently consumes millions of tokens every day and the usage is predictable, the amortized cost of local deployment may fall below the cloud bill. The key word here is “fixed.” If usage fluctuates heavily, the idle cost of hardware during low-traffic periods can offset the savings.

    When assessing this, look at the stability of monthly usage rather than peak usage. If the business has clear periodic fluctuations, consider a hybrid approach: local hardware handles the base load, while burst traffic goes to cloud APIs.

    In the following situations, calling a cloud API directly is usually the better choice:

    • Occasional usage: For occasional use, such as a few calls per month, hardware and operations costs cannot be spread over enough usage.
    • Dependence on the latest model capabilities: Cloud models are usually updated faster than local maintenance cycles. If the business relies on new model capabilities, a local setup will tend to fall behind.
    • Lack of operations capacity: Without dedicated staff for monitoring and incident response, interrupted service may not be restored in time. Business losses can then far exceed the API price difference.
    • Unclear requirements: During the validation phase, iterating quickly with a cloud API is more sensible than investing in hardware upfront.

    7. Model Obsolescence

    Locally deployed models become outdated. Open-source models keep changing in capability, security, and support for new languages and tasks. Once a version is chosen and put into production, the team needs a fixed evaluation cadence, including:

    1. Regularly comparing old and new versions on an internal evaluation set.
    2. Tracking known vulnerabilities and security advisories, and assessing upgrade risks.
    3. Keeping a rollback path so the team can switch quickly if a new version causes problems.
    4. Recording every change to the model and inference configuration to make issues traceable.

    If the team cannot sustain this cadence, the model will quickly become a legacy system that requires long-term maintenance but has no owner.

    8. Decision Checklist

    Before making a decision, answer each of the following questions:

    • Is the data allowed to be sent to external networks? If not, self-hosting is mandatory.
    • Is there a hard requirement for offline or ultra-low-latency operation