News / Learn / Local & open models
How do you serve open models in production?
You'll be able to describe how to serve an open model to real users, and the parts you must get right.
In plain English
Serving an open model means running it on a server so your app can send it requests over the network. A model server loads the weights, takes requests, and returns tokens. You manage the hardware, the scaling, and the uptime yourself.
Why it matters
Hosted APIs hide the server work. Once you run your own model, you own latency, cost per request, data handling, and failures. Knowing the basics lets you choose between self-hosting and a managed provider with clear reasons.
How it works
A model server holds the model in GPU or CPU memory and runs inference for each request. Most servers batch several requests together so the hardware stays busy. This raises throughput, which is how many tokens per second the system produces across all users. It can add a little latency for each single user.
Two numbers matter most in production. Latency is how long one user waits for a response. Throughput is how much work the system finishes per second. Tuning one often hurts the other. Measure both under load that looks like your real traffic.
The server exposes an HTTP API, often compatible with a common chat format, so your app code stays simple. Put the server behind a gateway or reverse proxy. Use it to handle authentication, rate limits, timeouts, and logging. Never expose the raw model port to the public internet.
Memory limits the model you can run. The weights, the context window cache, and the batch size all use memory. Quantization can shrink the weights so a model fits on smaller hardware. Test quality after you quantize, because smaller weights can lose accuracy on hard tasks.
Plan for failure. Requests can time out, the server can run out of memory, and a model update can change behavior. Add health checks, restart rules, request timeouts, and a fallback path. Keep the model version pinned so output does not shift without notice.
A concrete example
A client calls a self-hosted model server that speaks a chat API. The timeout and error handling matter as much as the request.
import requests
URL = "http://model-gateway.internal/v1/chat/completions"
def ask(prompt: str) -> str:
payload = {
"model": "my-open-model",
"messages": [{"role": "user", "content": prompt}],
"max_tokens": 300,
"temperature": 0.2,
}
try:
resp = requests.post(URL, json=payload, timeout=30)
resp.raise_for_status()
return resp.json()["choices"][0]["message"]["content"]
except requests.RequestException:
# Fall back or return a clear error instead of hanging
raise RuntimeError("model server unavailable")A short sketch to show the idea. Check the official docs of the tool you use.
What goes wrong
- Exposing the model port directly Put the server behind a gateway that handles auth, rate limits, and logging.
- No timeouts Set client and server timeouts so slow requests free resources instead of piling up.
- Judging speed on one request Load test with realistic concurrency. Batching changes results a lot under load.
- Unpinned model versions Pin the exact weights and quantization you tested so behavior stays stable.
Going deeper
Learn about continuous batching, KV cache memory, autoscaling GPU workers, and how to run evaluations before and after each model change.
FAQ
Should I self-host or use a hosted API?
Self-host when you need control over data, cost at high volume, or custom weights. Use a hosted API when you want less operational work. Compare total cost, including engineering time, not just compute.
Why does throughput matter more than speed for one user?
Serving many users at once depends on throughput. Batching lets one GPU handle many requests, which lowers cost per token.
Does quantization always reduce quality?
It usually reduces quality a little, and the loss varies by task. Evaluate the quantized model on your own tasks before you ship it.
How do I know my server is healthy?
Expose a health endpoint, track latency and error rates, and alert on memory use and queue length.
Written with AI by CapyLaunch. Spotted a mistake? Email hello@capylaunch.com.