Book a free call

LLM Deployment: API vs Self-Hosting — Which Fits?

Deploying an LLM through an API is fast and pay-as-you-go, while self-hosting gives you control over data, models and cost at scale. Here is how to choose.

Hertiv engineering teamReviewed by a senior engineer
6 min read
LLM Deployment: API vs Self-Hosting — Which Fits?
On this page

Short answer

LLM deployment through an API means calling a hosted model over the internet and paying per use, while self-hosting means running the model on your own servers or cloud machines. The API route is faster to start and cheaper at low volume; self-hosting gives you more control over data, latency and long-run cost. The right choice depends on volume, data rules, latency needs and how much engineering time you have.

What is LLM deployment?

LLM deployment is how a large language model is made available for real use, so that an application can send it text and get answers back. The two main routes are calling a hosted model through an API and running the model yourself on machines you control.

An API route means a provider runs the model and you pay for each call. Self-hosting means you run an open-weight model on your own servers or rented cloud machines, and you pay for the machines whether or not anyone is using them. Both routes can power the same product, but they differ in cost, control and effort.

Route How it works Best for Watch out for
Hosted API Send text to a provider, get an answer back Fast starts, low volume Per-use fees, data leaves your systems
Self-hosting Run the model on your own machines High volume, strict data rules Machine costs, ops work
Hybrid API for most work, self-hosted for sensitive work Mixed data rules Two systems to maintain

Most teams start with an API because it needs no infrastructure. Self-hosting becomes attractive when volume grows, data rules tighten, or the model must run close to the user. The rest of this guide compares the two routes in detail.

How does API deployment work?

API deployment works by sending a request to a provider over the internet and receiving the model's answer back, usually within a second or two. Your application holds an API key, formats the prompt, and handles the response.

The provider manages the model, the machines and the scaling. When traffic rises, the provider adds capacity; when it falls, you stop paying for use. Pricing is usually per token — a small unit of text — so costs track volume directly. Check the provider's own pricing page for current rates, or write "see vendor site" in your budget rather than guessing.

The trade-off is control. Your prompts and data pass through the provider's systems, so the provider's data rules and uptime become part of your product. Some providers offer data residency options or zero-retention modes, but you must read the terms and confirm they fit your obligations. For teams building with LLM development partners, the API route is the usual starting point.

How does self-hosting work?

Self-hosting works by running an open-weight model on machines you control, either in your own data centre or on rented cloud machines with GPUs. Your application talks to the model over your own network, and no prompt leaves your systems unless you choose to send it.

You pick the model, the machine size and the serving software. Smaller models run on one machine; larger ones need several machines working together. You also take on the ops work: updating the model, watching GPU use, handling failures and keeping the service fast under load.

The main benefit is control. You decide where data lives, which model version runs, and how requests are logged. That matters for regulated work and for products where latency must stay low. The cost is engineering time: someone must own the deployment, and that person is on call when it breaks.

API vs self-hosting: the trade-offs

The trade-offs between API and self-hosting come down to cost shape, control, latency, data, scaling and maintenance. Neither route wins on every point, so the right choice depends on your product, not on the technology.

Factor Hosted API Self-hosting
Cost Pay per use; cheap at low volume Fixed machine cost; cheaper at high volume
Control Provider picks the model version You pick the model and version
Latency Depends on network and provider load Low when the model sits near users
Data Data passes through the provider Data stays in your systems
Scaling Automatic, within provider limits You add machines yourself
Maintenance Provider handles updates Your team handles updates and failures

Cost is the point most teams get wrong. An API looks cheap at first because there is no machine bill, but per-use fees grow with every request. Self-hosting looks expensive because of the machine bill, but that bill stays flat while volume grows. The break-even point is where the two lines cross, and it moves with model size and request volume.

How to choose in 5 steps

You choose between an API and self-hosting by testing the decision against volume, data rules, latency and team capacity. The five steps below turn the trade-offs into a clear answer.

  1. Estimate real volume. Count requests per day and tokens per request from a real pilot, not from a guess.
  2. Check the data rules. If prompts contain personal or regulated data, confirm where the data may travel and how long it is kept.
  3. Set a latency target. Decide how fast an answer must arrive, and test both routes against that target.
  4. Price both routes for a year. Compare the API bill at your volume with the machine bill plus engineer time for self-hosting.
  5. Test the harder route first. If self-hosting might win, run a small self-hosted pilot before committing to the API.

A common answer is to start with the API and move later. That works if the move is planned: keep prompts and model calls behind one interface in your code, so switching the model behind it does not mean rewriting the product. A MLOps consulting review can help design that interface before the first line of product code.

Example: a support team compares the two routes

Example (hypothetical): a support team handles 20,000 chats a month and wants an LLM to draft replies. Each chat uses about 800 tokens, so monthly use is 20,000 × 800 = 16,000,000 tokens.

On the API route, the team assumes a hypothetical rate of £0.002 per 1,000 tokens. The monthly bill is 16,000 × £0.002 = £32. On the self-hosted route, one GPU machine costs a hypothetical £600 a month, plus about 4 hours of engineer time. At this volume the API route is far cheaper.

Now scale the same team to 2,000,000 chats a month. API use becomes 2,000,000 × 800 = 1,600,000,000 tokens, and the bill is 1,600,000 × £0.002 = £3,200 a month. The self-hosted route needs three machines at £600 each, which is £1,800 a month, plus engineer time. At this volume self-hosting wins on cost, and the team would also gain control over data and model version.

The example uses made-up rates to show the shape of the decision. In a real project, plug in the provider's current rates and your real machine prices, and the break-even point will show itself. A small proof of concept is the cheapest way to measure real token use before choosing.

What are the common mistakes?

The most common LLM deployment mistakes are choosing on price alone, ignoring data rules, and tying the product to one provider's model so tightly that switching becomes a rewrite.

  • Choosing on price alone. The cheapest route at low volume is rarely the cheapest at high volume.
  • Ignoring data rules. Sending regulated data to an API without checking retention and residency terms creates risk.
  • Hard-coding one model. If prompts and calls are scattered through the product, switching models means rewriting it.
  • Skipping latency testing. A model that answers in two seconds in a demo may take eight under real load.
  • Forgetting the ops burden. Self-hosting needs someone on call; if nobody owns it, the first outage stops the product.

If your model needs tuning for your own data, read the guide to how to fine-tune an LLM before choosing a deployment route, since fine-tuned models have their own hosting needs.

Key takeaways

  • API deployment is fast to start and cheap at low volume; self-hosting wins on control and high-volume cost
  • Self-hosting keeps data in your systems but needs GPU machines and someone on call
  • The break-even point depends on request volume, tokens per request and model size
  • Keep model calls behind one interface so you can switch routes without rewriting the product
  • Check data retention, residency and model version rules before committing to either route

Frequently asked questions

Is it cheaper to self-host an LLM or use an API?

It depends on volume. At low volume an API is usually cheaper because you pay per use with no machine bill. At high volume, fixed machine costs can beat per-use fees. Price both routes for a year using your real token counts and current vendor rates.

Can I self-host an LLM without GPUs?

Small models can run on CPUs, but they are slow for real-time use. Most production self-hosting uses GPUs, either on your own machines or rented cloud machines. A small model on one GPU machine is the usual starting point for a pilot.

Does API deployment send my data to the provider?

Yes. Prompts and responses pass through the provider's systems, so you must check the provider's data retention, residency and training-use terms. Some providers offer zero-retention modes; confirm the terms fit your obligations before sending regulated data.

What is an open-weight model?

An open-weight model is one whose trained weights are publicly available, so you can download and run it on your own machines. You still need to follow its licence, which may limit commercial use or require sharing changes.

Can I switch from an API to self-hosting later?

Yes, if your code keeps model calls behind one interface. Then you can swap the API call for a call to your own hosted model without rewriting the product. Plan that interface early, since retrofitting it later is slow work.

How do I keep latency low with an LLM?

Put the model close to your users, keep prompts short, and cache repeated answers where safe. For API routes, test under real load rather than trusting demo speeds. For self-hosted routes, size the machines for peak traffic, not average traffic.

Found this useful? Share it.
Hertiv engineering team

Written from projects we build for clients: AI and agent systems in production. Every post is reviewed by a senior engineer before publishing and updated when practice changes.

About HertivHow we work

Choosing how to deploy your LLM? Talk to Hertiv.

A senior engineer replies within one business day. Or see our LLM Development service.

Book a free call

Keep reading

All posts

Tell us what you want to build

A senior engineer reads every request and replies within one business day with questions, a rough range, or a call link.

  • NDA on request before any details
  • You own all code, models and IP
  • US, UK and EU time-zone overlap

Your email app should open with your message ready to send. If it does not, write to [email protected].

Prefer email? Write to [email protected]
Estimate costBook a call