New Tool Radar

Local AI

How to Serve a Local Model as an OpenAI-Compatible API with llama-server

Start llama-server with a GGUF model from Hugging Face, then call its OpenAI-compatible endpoints with curl so your own app can use the local model.

Schematic diagram with three boxes: the command llama serve with a GGUF model from Hugging Face, the local server on port 8080, and a curl chat request returning a reply.

If your app already talks to the OpenAI API, you do not have to rewrite it to use a local model. llama.cpp is a dependency-free C/C++ engine for running LLMs, and its server exposes OpenAI-compatible chat completions routes: point your client’s base URL at it and most code just works. The server is the part to run when you want an app, not a chat window, to use the model.

Start the server

Install llama.cpp — on macOS or Linux the quick route is curl -LsSf https://llama.app/install.sh | sh — then start the server with a model pulled straight from Hugging Face. The -hf flag downloads a GGUF model directly, and the quant defaults to Q4_K_M:

llama serve -hf ggml-org/Qwen3.5-0.8B-GGUF --port 8080 --alias qwen3.5-0.8b

The guide says the server listens on 127.0.0.1:9931 by default; this command sets --port 8080 explicitly, so the addresses below always match. The built-in web UI is served at the same address, so you can open http://localhost:8080 in a browser to test the model before writing any code.

Check it is ready, then ask it something

Check readiness with the health endpoint. It returns 503 while the model is loading and {"status": "ok"} once it is ready:

curl http://localhost:8080/health
curl http://localhost:8080/v1/models

GET /v1/models returns the loaded model. By default the model id is the path to the model file; --alias sets a friendlier one, which is why the request below uses qwen3.5-0.8b:

curl http://localhost:8080/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer " \
  -d '{
    "model": "qwen3.5-0.8b",
    "messages": [
      {"role": "user", "content": "Write a limerick about python exceptions"}
    ]
  }'

No key is needed unless you started the server with --api-key — the Bearer <redacted> line is the guide’s placeholder for one.

Check What you should see If you do not see it
Health {"status": "ok"} The model is still loading — wait, then try again
Model list /v1/models lists the model as qwen3.5-0.8b The alias was not set — use the model id the list actually shows
Chat reply A limerick about Python exceptions in the response Check the request body and that the server is still running

Expected result. We checked the llama.cpp server guide and the server README for the start command, the endpoints, and the alias behaviour. We did not run llama-server or send a request.

Limits

The server README is careful to say it makes no strong claims of full OpenAI spec compatibility, but in the project’s experience it is enough for many apps — so an unusual OpenAI parameter may be ignored rather than rejected. The 0.8B example model is fast and good for wiring things up, but much weaker than larger models, so swap in a larger GGUF once your plumbing works. The start command and endpoint details above come from a third-party guide and a copy of the server README, not from the project’s live docs, so confirm the flags with the server’s own help on your installed build. By default the server listens only on your own computer; do not bind it to a wider address unless you mean to. We did not run llama-server, so no reply here is a recorded result.

Sources

See all