Serving LLMs: Hosted APIs vs Self-Hosting, Inference Engines, Batching, Quantization and Hardware Planning

LLM Development 60 min min read Updated: Nov 21, 2026 Advanced
Serving LLMs: Hosted APIs vs Self-Hosting, Inference Engines, Batching, Quantization and Hardware Planning
Advanced Topic 1 of 3

Option 1: A Hosted API

You call the provider's servers. There is nothing to run. It is the fastest way to start, and often the best for small teams. You pay per token and follow the provider's terms.

Option 2: Self-Hosting

You run an open model on your own or rented GPUs. You gain control and privacy, and you take on the work of servers, scaling, updates and monitoring.

Tool typeExamplesGood for
High-throughput inference serversvLLM, SGLangMany users on GPU servers
Local and edge runtimesllama.cpp, MLXLaptops, phones, small machines
LibraryHugging Face TransformersExperiments and custom code
Managed endpointsCloud model hosting servicesSelf-host without managing servers
Compatible APIs Many inference servers offer an HTTP API shaped like popular chat APIs, so your app code can often switch between a hosted model and a self-hosted one by changing the base URL and model name.

Batching

A GPU is much more efficient when it handles many requests together. Servers use continuous batching to add new requests into the running batch. This raises total throughput, though each request may wait a little.

Memory Planning

You need memory for the weights and for the KV cache of all active requests. Quantizing weights to fewer bits lowers memory, with some risk of quality loss that you must test.

python def plan(params_b, bits, kv_gb_per_seq, concurrent, overhead_gb=2.0): weights = params_b * bits / 8 # billions of params * bytes per param = GB kv = kv_gb_per_seq * concurrent return round(weights + kv + overhead_gb, 1) for bits in [16, 8, 4]: print(bits, "bit, 8B model, 10 users, 1 GB cache each ->", plan(8, bits, 1.0, 10), "GB total")
Result

16 bit, 8B model, 10 users, 1 GB cache each -> 28.0 GB total | 8 bit, 8B model, 10 users, 1 GB cache each -> 20.0 GB total | 4 bit, 8B model, 10 users, 1 GB cache each -> 16.0 GB total

Lower precision can move a model from needing a big server GPU to fitting on a smaller one. Always compare quality before and after quantizing, using your own test set.

A Simple Decision Guide

  • Starting out or low traffic: hosted API
  • Strict data rules: self-host or a private cloud option
  • Very high steady traffic: compare cost of tokens and of GPUs
  • Offline or on-device use: local runtime with a small quantized model
Hidden work Self-hosting also means security patches, capacity planning, load tests, monitoring and on-call support.

Practice

  1. Change the plan demo to 30 concurrent users
  2. Write whether your project should use API or self-hosting, and why
  3. List three things to monitor on a model server

Conclusion

Pick the simplest serving option that meets privacy, cost and speed needs, and plan memory for weights and caches.

Quick Summary: API vs self-host; engines; batching; memory planning.

Get Newsletter

Subscibe to our newsletter and we will notify you about the newest updates on Edugators