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.

Listen to this post · 8 min

Accessibility: the whole post is read aloud — Space plays or pauses, ← → skip 10 seconds, and you can change the speed. It keeps playing with your screen locked.

Share this post

In short

  • 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

EngineBest forEngine page
vLLMHigh throughput on NVIDIA GPUs, many usersvLLM page
SGLangThroughput plus structured generationSGLang
Hugging Face TGIProduction serving of HF modelsTGI
AphroditevLLM-based, popular for roleplay modelsAphrodite
OllamaThe easiest start; GGUF modelsOllama
llama.cppGGUF on any hardware, CPU or GPUllama.cpp
LM StudioA desktop app with a serverLM Studio
MLXApple siliconMLX
KoboldCppSingle-file GGUF server, story writingKoboldCpp
text-generation-webuiMany loaders, lots of knobstext-generation-webui

Jan and GPT4All are supported as well. If you're torn between the two big ones, our vLLM vs Ollama comparison and vLLM install guide go deep.

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**: 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.

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 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, at £0.
  • Share it with a team or customer as a rental.
  • Earn by listing models on the marketplace at your prices.

Which engine should you run?

You haveStart with
One NVIDIA GPU, just youOllama or LM Studio
NVIDIA GPU, many users or batch jobsvLLM or SGLang
A MacMLX or LM Studio (MLX models)
CPU only or odd hardwarellama.cpp
A RAG index to buildInfinity or TEI for embeddings
A voice appSpeaches, or Piper on small boards

Not supported: image generation, fine-tuning and training. Every engine page has setup notes and the settings the connector reads.

Questions people ask

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.

Models in this post — live on Inpherio

Have a GPU, a Mac or a spare PC?

Let it earn while you sleep.

Run open models for people who need them. You set the price and keep everything but the 15% fee.

Become a host

Building with AI?

Every open model, one API.

OpenAI-compatible. Priced by the people who run the hardware.

Start free See the marketplace

Read “Serve local models as an API: every engine, from vLLM to Piper and whisper.cpp” at https://inpherio.co.uk/blog/serve-local-models-as-an-api-every-engine