# Serve local models as an API: every engine, from vLLM to Piper and whisper.cpp

Every local inference engine has its own server, port and API quirks. Here's how to serve local models as an API whatever engine you run, which engines suit which jobs, and how to put any of them behind one OpenAI-compatible endpoint with a key.

Published 2026-11-27 · https://inpherio.co.uk/blog/serve-local-models-as-an-api-every-engine

Key points:
- For throughput on NVIDIA GPUs, vLLM and SGLang lead; for ease and GGUF models, Ollama, llama.cpp and LM Studio.
- For embeddings, Infinity and Hugging Face TEI are built for batching; Ollama and vLLM also serve them.
- For speech, Speaches wraps Whisper and Kokoro, Piper is tiny and fast, Coqui XTTS and AllTalk do expressive voices.
- The connector finds whichever engines run on the machine, reads their real context windows and benchmarks each model.
- Whatever the engine, callers see one OpenAI-compatible API, and your own requests through self-serve are free.

There are more good inference engines than ever, and each has its own server: vLLM on port 8000, Ollama on 11434, LM Studio on 1234, KoboldCpp on 5001, TEI and Infinity with their own routes, and speech servers with theirs. Here's how to serve local models as an API whichever engine you choose, and how to put them all behind one endpoint.

## Text and chat engines

| Engine | Best for | Engine page |
|---|---|---|
| vLLM | High throughput on NVIDIA GPUs, many users | vLLM page |
| SGLang | Throughput plus structured generation | SGLang |
| Hugging Face TGI | Production serving of HF models | TGI |
| Aphrodite | vLLM-based, popular for roleplay models | Aphrodite |
| Ollama | The easiest start; GGUF models | Ollama |
| llama.cpp | GGUF on any hardware, CPU or GPU | llama.cpp |
| LM Studio | A desktop app with a server | LM Studio |
| MLX | Apple silicon | MLX |
| KoboldCpp | Single-file GGUF server, story writing | KoboldCpp |
| text-generation-webui | Many loaders, lots of knobs | text-generation-webui |

Jan and GPT4All are supported as well. If you're torn between the two big ones, our [vLLM vs Ollama comparison](/blog/vllm-vs-ollama-which-inference-engine-should-you-actually-run) and [vLLM install guide](/blog/how-to-install-vllm-pip-docker-or-wsl2-and-a-vllm-serve-that-works) go deep.

(Live on Inpherio: https://inpherio.co.uk/models/qwen3:14b)

## Embedding engines

- **Infinity**: fast, batching embedding server for sentence-transformer models.
- **TEI** (Text Embeddings Inference): Hugging Face's production embedding server.
- **Ollama and vLLM** also serve embedding models alongside chat.

Embedding servers shine when you batch: send lists of passages, not one at a time.

## Speech engines

- **[Speaches](/engines/speaches)**: an OpenAI-compatible server for Whisper transcription and Kokoro or Piper speech in one place.
- **Piper**: tiny, fast text-to-speech that runs on a Raspberry Pi.
- **Coqui XTTS** and **AllTalk**: expressive voices and voice cloning.
- **whisper.cpp**: Whisper transcription in C++, quick on CPUs and Apple silicon.

Any other OpenAI-compatible speech server works too.

(Live on Inpherio: https://inpherio.co.uk/models/Systran/faster-whisper-large-v3)

## Engine settings that matter for serving

Whichever engine you run, a few settings decide how well it serves:

- **Context length.** Ollama defaults to a short context unless you raise `num_ctx`; vLLM uses `--max-model-len`. The context you serve is what callers get, so set it deliberately: longer contexts cost memory.
- **Keep-alive.** Ollama unloads idle models after a few minutes by default. Raise `OLLAMA_KEEP_ALIVE` if you want models to stay warm for callers.
- **Parallelism.** vLLM and SGLang batch concurrent requests automatically. Ollama serves a small number in parallel (`OLLAMA_NUM_PARALLEL`); llama.cpp's server has `--parallel`.
- **GPU memory share.** vLLM reserves a set fraction of VRAM at start-up (its GPU memory setting); leave headroom if other things use the card.
- **Quantisation.** GGUF Q4_K_M is the usual balance for Ollama and llama.cpp; vLLM prefers AWQ, GPTQ or FP8 builds.

The connector reads the context window each engine really serves, so listings show what callers actually get rather than the model's theoretical maximum.

## Running more than one engine on a machine

It's common to run two engines side by side: vLLM for a big chat model and Infinity or Ollama for embeddings, or Ollama for chat and Speaches for voice. That works as long as they don't fight over GPU memory. Give the big engine a fixed share, put small models on the CPU where they're fast enough, and avoid loading the same model twice in two engines. The connector reads every engine it finds on localhost, so callers see all of their models in one list.

## Picking a model format per engine

GGUF files work with Ollama, llama.cpp, LM Studio and KoboldCpp. vLLM, SGLang, TGI and Aphrodite load Hugging Face model folders, often in AWQ, GPTQ or FP8 form. MLX uses its own converted weights on Apple silicon. When you download a model, pick the format your engine wants first; converting later is slow and easy to get wrong.

## Keeping engines up to date

Engines move fast: vLLM, llama.cpp and Ollama ship new versions every few weeks, often with speed-ups for new models. Update on a quiet day, re-run a quick test, and keep the previous version handy in case a model breaks. The connector re-reads your engines and models when it starts, and benchmarks new models before they serve anything, so an upgrade never puts an untested model in front of callers.

## The common problem: many servers, many APIs

Run two or three of these and you have a handful of ports, different request shapes (OpenAI, Ollama, KoboldCpp's own), no keys, and nothing that works from outside your network. Every client needs to know which engine has which model.

## One OpenAI-compatible endpoint in front of all of them

The [connector](/connector) solves that on the machine itself. On start it scans localhost for running engines, reads which models each one has and their real context windows, and benchmarks every model on your hardware (cold load, time to first token and tokens per second; generation speed for speech). Callers then use one endpoint:

- `/v1/chat/completions`, `/v1/messages` (Anthropic format) and `/api/chat` (Ollama format) for text;
- `/v1/embeddings` for embeddings;
- `/v1/audio/speech` and `/v1/audio/transcriptions` for speech.

Requests are translated to each engine's own format and the replies translated back. Nothing listens on your machine: the connector dials out, and only talks to engines on localhost.

What you can do with that endpoint:

- **Use it yourself** from anywhere with [self-serve](/self-serve), at £0.
- **Share it** with a team or customer as a [rental](/rentals).
- **Earn** by listing models on the [marketplace](/marketplace) at your prices.

## Which engine should you run?

| You have | Start with |
|---|---|
| One NVIDIA GPU, just you | Ollama or LM Studio |
| NVIDIA GPU, many users or batch jobs | vLLM or SGLang |
| A Mac | MLX or LM Studio (MLX models) |
| CPU only or odd hardware | llama.cpp |
| A RAG index to build | Infinity or TEI for embeddings |
| A voice app | Speaches, or Piper on small boards |

Not supported: image generation, fine-tuning and training. Every [engine page](/engines) has setup notes and the settings the connector reads.

## FAQ

**Which engine should I use to serve an LLM?** vLLM or SGLang for high throughput on NVIDIA GPUs, Ollama or LM Studio for simplicity, llama.cpp for GGUF on any hardware, MLX on Apple silicon.
**Can I serve embeddings and speech too?** Yes. Infinity, TEI, Ollama and vLLM serve embeddings; Speaches, Piper, Coqui XTTS and AllTalk serve text-to-speech; Speaches and whisper.cpp serve transcription.
**Do I have to change my engine to use the connector?** No. It finds engines already running on the machine and uses them as they are. If there's none, the installer can add Ollama and a small model.
**Are image generation or fine-tuning supported?** No. The supported workloads are text, embeddings, text-to-speech and transcription.
