Sub topic 13
Hosted or self-hosted: weighing the trade-offs
This chapter assumes you have read the earlier chapters on hosted APIs, open-weight models, token pricing, memory estimates, latency, and privacy. It combines them into one decision. You should be comfortable reading short Python programs and the basic terms prompt, token, and context.
The decision in one sentence
Hosted means you pay a provider per token and they run the model. Self-hosted means you run an open-weight model on hardware you control, so you pay for the machines, whether they are busy or idle. Every trade-off below comes from that difference in who owns the operational work and how the cost scales.
The five dimensions
Compare the options on the same five dimensions each time. Otherwise the discussion drifts toward whichever one the loudest person on the team cares about.
| Dimension | Hosted API | Self-hosted open-weight |
|---|---|---|
| Cost shape | Variable. Scales with tokens used. | Mostly fixed. Scales with hardware time. |
| Control | Provider picks versions, limits, and retirement dates. | You pick the model, version, and settings. |
| Privacy | Data leaves your environment. Contract terms matter. | Data can stay inside your network. |
| Operations | Provider handles scaling, patching, and uptime. | Your team handles all of it. |
| Capability ceiling | Often the strongest models available. | Often a step behind the best hosted models, though the gap varies by task. |
Treat the capability row with care. It is a general tendency, not a rule. For a narrow task such as extracting invoice numbers, a small open-weight model can match a large hosted one. Your own evaluation, covered in an earlier chapter, settles it.
Cost: where the lines cross
Hosted cost is roughly linear. Double the traffic and you roughly double the bill. Self-hosted cost is a step function. You pay for a GPU server whether it handles one request per hour or one hundred per second. When it fills up, you buy another.
This produces a break-even volume. Below it, hosted is cheaper because you pay only for what you use. Above it, self-hosted can be cheaper because each extra request costs almost nothing.
The following program computes that break-even point. It reuses the token cost formula from the pricing chapter. All prices are placeholders, so substitute real quotes.
def request_cost(input_tokens: int, output_tokens: int,
price_in_per_million: float, price_out_per_million: float) -> float:
return (input_tokens / 1_000_000) * price_in_per_million + \
(output_tokens / 1_000_000) * price_out_per_million
def break_even_requests(monthly_fixed_cost: float, hosted_cost_per_request: float,
self_hosted_marginal_per_request: float = 0.0) -> float:
"""Monthly request count above which self-hosting costs less."""
saving_per_request = hosted_cost_per_request - self_hosted_marginal_per_request
if saving_per_request <= 0:
return float("inf") # self-hosting never wins on cost alone
return monthly_fixed_cost / saving_per_request
hosted = request_cost(2_000, 300, 1.00, 4.00) # made-up prices
# Made-up self-hosting bill: one GPU server plus a share of an engineer's time
fixed = 2_500.00 + 3_000.00
print(f"hosted per request: ${hosted:.4f}")
print(f"break-even: {break_even_requests(fixed, hosted):,.0f} requests per month")
# hosted per request: $0.0032
# break-even: 1,718,750 requests per monthTwo details in this calculation change real decisions:
- Staff time is a cost. The 3,000 dollars above stands for the share of engineer time spent on deployment, monitoring, upgrades, and on-call duty. Teams that leave it out often conclude that self-hosting is cheap when it is not.
- Utilization matters. The fixed cost buys capacity, not work. If the server is busy 10% of the time, your effective cost per request is ten times what a full server would give you. Hosted pricing never charges you for idle time.
Keep in mind that the break-even figure assumes the self-hosted model is good enough for the task. If you need a larger open-weight model, the hardware line rises. Use the memory estimate from the earlier chapter to size the server first.
Control and stability
A hosted provider can change what you depend on. Models get new versions, older versions get retired, rate limits change, and prices move. Some providers let you pin a dated version, which helps, but pinned versions still have retirement dates. A behavior that your prompts relied on can shift when you are forced to migrate.
With open-weight models, the file you downloaded does not change. You decide when to upgrade. You can also fine-tune it, change sampling settings freely, and inspect internals. The price is that you now own every failure. A crashed inference server at 3 a.m. is your problem.
Privacy and compliance
If regulations or contracts forbid sending certain data to a third party, this dimension can decide the whole question before cost is considered. Self-hosting inside your own network is the simplest way to satisfy such a rule.
Hosted does not automatically mean unsafe. Many providers offer contractual terms such as no training on your data, limited retention, data residency in a chosen region, and compliance attestations. Check the actual terms for the plan you would use, because consumer plans and enterprise plans often differ. Also check retention. Some providers store requests for a period for abuse monitoring even when they do not train on them.
Operational effort
A hosted API gives you an HTTP endpoint. Self-hosting gives you a list of jobs:
- Choose and test a serving tool such as Ollama or vLLM.
- Provision GPUs and keep drivers and libraries compatible.
- Scale for traffic peaks and handle queueing.
- Monitor latency, errors, and memory use.
- Track new model releases and security fixes.
- Check licenses for each model you adopt.
Small teams often underestimate this list. If nobody on the team has run GPU workloads before, add learning time to the estimate.
Latency and throughput
Hosted providers run large fleets, so they usually handle bursts well, but you share capacity and can hit rate limits. Self-hosting gives predictable performance for your own traffic and avoids network distance if the server sits next to your application. It can also queue badly when a burst exceeds capacity. Recall that latency is the time for one request, while throughput is how many requests finish per second. Check both against your requirement under realistic load, not with a single test call.
Common mistakes
- Comparing list prices only. The hosted price per token is visible. The self-hosted costs for staff, idle time, and monitoring are not. Compare total monthly cost.
- Deciding at prototype volume. At 100 requests a day, hosted almost always wins. Decide using projected volume, and plan to revisit.
- Treating the choice as permanent. A model that is swappable behind a small interface lets you start hosted and move later. The portability chapter shows how.
- Ignoring the license. An open-weight model may restrict commercial use or large deployments. Read it before you build on it.
- Choosing a bigger model than needed. Both options get cheaper when the task is handled by a smaller model.
A practical default
For most new projects, start with a hosted API. It has the lowest setup cost, lets you validate the product, and gives you real token counts and traffic data. Move to self-hosting when one of these becomes true:
- A privacy or compliance rule blocks the hosted option.
- Measured volume is well past the break-even point with high expected utilization.
- You need control the provider does not offer, such as fine-tuning or a frozen model version.
- Latency or availability requirements cannot be met through the provider.
A hybrid is also common. Sensitive requests go to a self-hosted model, and general requests go to a hosted one. This relies on the routing idea covered later in the tutorial.
Exercise
A team handles 300,000 requests a month. A hosted API costs $0.0032 per request. A self-hosted setup costs $2,500 a month for hardware plus about $3,000 a month in engineering time, and its marginal cost per request is close to zero. Using the break-even formula from this chapter, which option is cheaper on cost alone? Name one non-cost reason that could still change the answer.
Show answer
The break-even point is 5,500 / 0.0032, which is about 1,718,750 requests per month. At 300,000 requests, the team is far below it. Hosted costs about $960 a month (300,000 × $0.0032), while self-hosting costs $5,500 a month, so hosted is cheaper. A privacy or compliance rule that forbids sending the data to a third party, or a need for a frozen model version, could still force self-hosting despite the higher cost.
Exercise
Why can a self-hosted setup that looks cheaper on paper turn out more expensive in practice? Give two reasons from this chapter.
Show answer
First, staff time for deployment, monitoring, upgrades, and on-call work is a real cost that is often left out. Second, low utilization means you pay for idle capacity, so the effective cost per request is higher than the full-capacity figure. Other valid reasons are needing a larger model than planned, which raises hardware cost, and a burst of traffic that requires extra machines.