Skip to main content

Serve an OpenAI-compatible endpoint

Any model whose family provides serve becomes an HTTP endpoint in one command, speaking the OpenAI request and response shapes. Existing OpenAI SDK code connects by changing its base URL; nothing else about the client changes.

Start the server

clika-modelverse meta-llama/Llama-3.2-1B-Instruct serve --host 0.0.0.0 --port 8000
[17:19:07.555] [modelverse] [info] serving on http://0.0.0.0:8000 (model=Llama-3.2-1B-Instruct); open it in a browser for the chat page
[17:19:07.555] [modelverse] [info] endpoints: POST /v1/chat/completions /v1/audio/transcriptions; GET /v1/models /health /props / (web UI) /dashboard

The load flags from prompt apply unchanged (--device, --max-seq, a GGUF weight selector on the source); the operational flags are the server's own:

  • --host and --port: the bind address, 127.0.0.1:8000 by default. Loopback by default is deliberate; expose it with --host 0.0.0.0 when you mean to.
  • --no-web-ui: disable the built-in chat page on /.
  • --cors: answer cross-origin requests, for a browser front end on another origin.
  • --max-active and --max-queue: admission control. Requests past the queue limit are shed and surface as HTTP 503 after retries with backoff, so an overloaded server degrades loudly instead of stalling silently.

The routes

What the server answers depends on the model's family; every serving model carries the common rows.

RouteServesModel families
POST /v1/chat/completionschat, streaming (SSE) and non-streamingtext and multimodal generators
POST /v1/audio/transcriptionsmultipart audio file to transcriptspeech-to-text (Whisper)
POST /v1/audio/speech; POST, GET, DELETE /v1/voicestext in, waveform out, in a voice registered first through the voice registry (Speak text)text-to-speech (Chatterbox, Qwen3-TTS)
POST /v1/embeddingstexts to dense vectorsembedding models
POST /v1/similaritytexts to a cosine matrixembedding models
POST /v1/translationstexts plus a language pairtranslation models
POST /v1/images/generationsprompt to generated imagediffusion models
POST /v1/depthmultipart image to depth artifactsdepth estimators
POST /v1/segmentationsmultipart image to a class-mask documentsegmentation models
POST /v1/detectionsmultipart image to box/score/label rows (an open-vocabulary detector also takes a prompt)detectors
GET /v1/models, GET /propswhat is loaded and how it is configuredall
GET /health, GET /v1/health{"status":"ok"}, the machine probeall
GET /the built-in web chat pageall, unless --no-web-ui
GET /dashboardthe live request dashboardall

Call it

Non-streaming, from anything that can POST JSON:

curl -s http://127.0.0.1:8000/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{"messages": [{"role": "user", "content": "One-line haiku about rain."}]}'

Streaming adds "stream": true and reads server-sent events, one data: line per delta, data: [DONE] last, the shape OpenAI clients already parse. Which means the SDKs work as-is:

from openai import OpenAI

client = OpenAI(base_url="http://127.0.0.1:8000/v1", api_key="unused")
for chunk in client.chat.completions.create(
model="llama",
messages=[{"role": "user", "content": "One-line haiku about rain."}],
stream=True,
):
print(chunk.choices[0].delta.content or "", end="", flush=True)

A multimodal model takes OpenAI-shaped image content parts in the same route; a Whisper model is called with a multipart file upload instead (Transcribe audio shows both of its forms).

Operate it

GET /health is the readiness probe for a load balancer. GET /props reports the loaded model and its effective options, the remote twin of -v's effective-options report. The dashboard on /dashboard shows live requests; /api/requests is its JSON feed. Everything the server logs goes to stderr like the rest of the clika-modelverse executable, so systemd or a container runtime captures it without configuration.

For the same server inside your own process (your engines, your routes, the built-in UI swapped for your page), the 01_serve program in Additional examples is the smallest complete consumer of the library's OpenAiServer.