llama-server from llama.cpp 1.0: Setup and API

Vladimir Lomtev•
llama-server from llama.cpp 1.0: Setup and API

llama-server is the HTTP server from the llama.cpp project that runs a model in GGUF format and exposes an OpenAI-compatible API: /v1/chat/completions, /v1/embeddings, /v1/responses and more. It runs on CPUs, NVIDIA, AMD, and Apple GPUs, does not require Python, and is a good fit for a server hosting one or two models and a small number of users. Below you will find installation, first run, API testing, concurrency, security, and monitoring.

This guide was prepared by Vladimir Lomtev's AI Studio on November 16, 2026, based on the llama-server README and the llama.cpp v1.0.0 release notes from November 13, 2026. The commands were checked for syntax, but we did not run them on specific hardware. Flags and defaults change between builds, so check llama-server --help for your version.

Contents

How llama-server differs from Ollama and vLLM

llama-server Ollama vLLM
Foundation Direct llama.cpp llama.cpp and a custom management layer Custom engine built on PyTorch
Model format GGUF GGUF through a custom registry Hugging Face weights, AWQ, GPTQ, FP8
Hardware CPU, CUDA, ROCm, Metal, Vulkan, and more CPU, CUDA, ROCm, Metal Primarily NVIDIA and AMD GPUs
Management Command-line flags Commands ollama pull/run, Modelfile Flags and configuration
Typical use case One server, fine-tuned configuration Quick start on a workstation Many users on a GPU

llama-server gives direct access to all llama.cpp parameters without an intermediate layer: KV cache type, number of layers on the GPU, slots, and chat templates. Ollama is more convenient for a quick start, while vLLM is better for high GPU concurrency. A detailed comparison is available in the article “vLLM, Ollama, llama.cpp, or SGLang”.

What changed in llama.cpp 1.0.0

Version 1.0.0 established a stable public API and semantic versioning, as explained in the ggml-org post about version 1.0. For llama-server users, the key changes are:

  • removed the --defrag-thold flag and 35 deprecated C API functions;
  • added KV cache in FP8 (-ctk/-ctv f8_e4m3);
  • fixed handling of --cors-origins, protection against DNS rebinding and SSRF through the CORS proxy and media-by-URL requests;
  • MCP tool calls are canceled when the client disconnects;
  • added the OpenAI-compatible endpoint /v1/audio/speech;
  • the built-in web UI was redesigned.

If your launch script uses --defrag-thold, remove the flag before upgrading: the argument is no longer supported.

Installation

There are three options: a prebuilt release archive from the Releases page, a Docker image, or building from source. For NVIDIA GPUs, building from source according to the llama.cpp build guide looks like this:

git clone https://github.com/ggml-org/llama.cpp
cd llama.cpp
cmake -B build -DGGML_CUDA=ON
cmake --build build --config Release -j
./build/bin/llama-server --version

Docker images are published at ghcr.io/ggml-org/llama.cpp. The CUDA example from the README:

docker run -p 8080:8080 -v /srv/models:/models --gpus all \
  ghcr.io/ggml-org/llama.cpp:server-cuda \
  -m /models/model-Q4_K_M.gguf -c 8192 \
  --host 0.0.0.0 --port 8080 --n-gpu-layers 99

Inside the container, the server listens on all interfaces, so restrict access at the Docker and network level, for example by publishing the port only on 127.0.0.1:8080:8080.

First run

You can specify the model as a local file with -m or download it from Hugging Face with -hf. According to the README, when using -hf you do not need to specify quantization: by default it uses Q4_K_M, and if that is not available, the first file in the repository.

llama-server \
  -hf ggml-org/gemma-3-4b-it-GGUF:Q4_K_M \
  --host 127.0.0.1 --port 8080 \
  -c 16384 -np 4 \
  -ngl auto -fa auto \
  --api-key-file /etc/llama/keys.txt \
  --metrics

What the parameters do:

  • --host — defaults to 127.0.0.1, meaning the server is accessible only from this machine;
  • --port — set this explicitly: in the current README the default is 9931, while many instructions use 8080;
  • -c — context size in tokens; 0 means use the value from the model;
  • -np — number of slots, meaning the number of concurrent requests handled;
  • -ngl — how many layers to keep in video memory: a number, auto or all;
  • -fa — Flash Attention: on, off or auto;
  • --api-key-file — a file with access keys, one per line;
  • --metrics — enables the Prometheus endpoint.

The chat template is processed by the Jinja engine; according to the README, it is enabled by default (--jinja).

API checks

GET /health does not require a key and returns 503 while the model is loading, and 200 when the server is ready:

curl -s http://127.0.0.1:8080/health
curl -s http://127.0.0.1:8080/v1/models -H "Authorization: Bearer $LLAMA_KEY"
curl -s http://127.0.0.1:8080/v1/chat/completions \
  -H "Authorization: Bearer $LLAMA_KEY" -H "Content-Type: application/json" \
  -d '{"model":"default","messages":[{"role":"user","content":"Briefly: what is the KV cache?"}],"max_tokens":200}'

From Python, the standard OpenAI client works:

import os
from openai import OpenAI

client = OpenAI(base_url="http://127.0.0.1:8080/v1", api_key=os.environ["LLAMA_KEY"])
reply = client.chat.completions.create(
    model="default",
    messages=[{"role": "user", "content": "Create a five-point plan for testing an LLM server"}],
    max_tokens=300,
)
print(reply.choices[0].message.content)

In single-model mode, the server does not choose the model based on the model field, and the name it shows in /v1/models can be set with --alias. In multi-model mode, this field is used to select the model, as described below.

Concurrency, context, and the KV cache

Each concurrent request takes one slot. The -np flag sets the number of slots, with the default being -1 — automatic. The --kv-unified flag enables a unified KV buffer shared across all sequences; according to the README, it is enabled by default when the number of slots is selected automatically. If you set the slots manually without a shared buffer, the context -c is effectively divided among them, and each request gets less.

You can reduce KV cache memory usage with -ctk and -ctv. Available f16 (default), bf16, q8_0, q4_0, the new f8_e4m3 and others. How this affects capacity and quality is covered in the article “KV cache in FP8”, and how to calculate VRAM for weights and context is covered in the article “How Much VRAM Does an LLM Need”.

The flag --cache-reuse N lets you reuse prompt fragments from the cache by shifting the KV cache, if they are at least N tokens long. This is useful for chats where the history grows but the beginning stays the same.

Multiple models in one server

If you start llama-server without a model, it runs in router mode: the main process launches a separate instance for each model and routes requests based on the model field in JSON. By default, a model loads on first request; --no-models-autoload disables this. --models-max limits the number of simultaneously loaded models, evicting the least recently used ones, and --models-memory-margin N unloads models until the new one fits, leaving N MiB free on each device.

For a server where one model is needed during the day and another at night, there is --sleep-idle-seconds: after the specified idle time, the model and its KV cache are unloaded from memory, and the next request loads them again. Requests to /health, /props, /models and /metrics do not wake the server.

Security

  • Keys. --api-key or --api-key-file. The /health endpoint is public by design.
  • Address. Keep 127.0.0.1 and expose the server externally through a reverse proxy with TLS and access logging. For direct TLS, use --ssl-key-file and --ssl-cert-file.
  • CORS. According to the README, the server reflects any Origin header by default with credentials allowed. For a local network, set --cors-origins to the address of your interface; for the same machine, use localhost.
  • Tools. The --tools flag enables file read and write access through the API. The README marks it as experimental and does not recommend it in an untrusted environment; if you need it, use --tools-runtime with a separate container.
  • Updates. Version 1.0.0 fixed issues with CORS, DNS rebinding, and SSRF — a server exposed to the network should be updated.

Monitoring

With the --metrics flag, the server exposes Prometheus metrics at /metrics. Useful ones to start with:

Metric What it shows
llamacpp:requests_processing How many requests are being processed
llamacpp:requests_deferred How many requests are waiting for a free slot
llamacpp:prompt_tokens_seconds Average prompt processing speed, tokens per second
llamacpp:predicted_tokens_seconds Average generation speed, tokens per second
llamacpp:n_busy_slots_per_decode Average number of busy slots per step

Growth requests_deferred means there are not enough slots: increase -np if memory allows, or set up a queue with limits on the gateway, as described in the article on LLM request queuing. The /slots endpoint shows the state of each slot.

Running as a systemd service

[Unit]
Description=llama-server
After=network-online.target

[Service]
User=llama
ExecStart=/opt/llama.cpp/build/bin/llama-server -m /srv/models/model-Q4_K_M.gguf --host 127.0.0.1 --port 8080 -c 16384 -np 4 -ngl all --api-key-file /etc/llama/keys.txt --metrics
Restart=on-failure

[Install]
WantedBy=multi-user.target

Save the file as /etc/systemd/system/llama-server.service, then run systemctl daemon-reload and systemctl enable --now llama-server. Replace the paths and parameters with your own.

Common issues

  • The server doesn't start after an update — check whether the removed --defrag-thold is still in the command.
  • Responses are slow, GPU is barely utilized — the model is partially on the CPU; check -ngl and the layer placement lines in the startup log.
  • Responses are cut off on long documents — the context per slot is smaller than needed; increase -c or decrease -np.
  • A browser app from the local network gets denied — --cors-origins is not configured.
  • The response is in the wrong format — the model's chat template doesn't match what is expected; check /props and set the template explicitly if needed.

FAQ

Can I replace Ollama with llama-server without changing the app? If the app uses the OpenAI-compatible API, you only need to change the endpoint and key. If it uses Ollama's custom API (/api/chat), some development work will be needed.

How many users can llama-server handle? It depends on the model, hardware, and request length. Use a load test as your guide, not the number of slots; the methodology is in the article on load testing a local LLM.

Do I need a GPU? No, llama-server also runs on CPU, but generation will be noticeably slower. For small models and occasional requests, that may be enough.

Are embeddings and reranking supported? Yes, the README describes /v1/embeddings and /reranking, and they require a suitable model.

How Vladimir Lomtev's AI studio helps launch llama-server

Vladimir Lomtev's AI studio deploys LLMs on company servers, including in isolated environments. For llama-server, that means:

  • choosing the model, quantization, and context settings for the task and available hardware;
  • setting up the server as a service with access keys, a reverse proxy, and monitoring;
  • integrating the API with corporate systems and testing responses on real tasks;
  • running load testing and handing the team an update guide.

The first step is to choose one task for the local model, note which server it will run on, and define what counts as a sufficient result. Discuss the task.

Bottom line: llama-server is direct access to llama.cpp

llama-server is a good fit when you need a lightweight OpenAI-compatible server without Python, with full control over llama.cpp settings and the ability to run on any hardware. Run it on a local address with keys, enable metrics, and update to 1.0.0 for security fixes. When user volume grows and latency starts to rise, evaluate moving to vLLM or SGLang.

Request an audit

Share your contact details and we will follow up.

← All articles

Comments (0)

Loading comments…

Leave a comment
No registration required

Book a strategy call
for agentic operations

Tell us which workflow you want to improve. We will map feasibility, risks, and the fastest MVP path.

By submitting, you agree to our privacy policy

Contacts

Global Operations

Serving U.S. clients remotely
with private cloud and on-prem options

Strategy calls by request

We respond after reviewing your workflow context.

info@agentsunrise.pro

For partnership inquiries

Have a proposal?

Write to us in messengers

© 2026 AgentSunrise