Skip to content

Connect llama.cpp to Open WebUI (2026): llama-server Setup, Docker and Router Mode

7–10 minutes
Woman in a sunny cafe holding a tablet with a LLAMA.CPP + OPEN WEBUI card, hook plug in llama-server

llama.cpp is the engine underneath many local AI apps, and running it directly with llama-server gives you the newest models, quantizations and speed tricks first.

What it lacks is a friendly chat app with users, history and document chat. Open WebUI fills that gap. Since llama-server speaks the OpenAI API, connecting the two takes one URL, and Open WebUI’s llama.cpp provider setting unlocks extras such as a loaded-model indicator, an Eject button and a model management panel.

This guide covers starting llama-server for Open WebUI, the connection settings for native and Docker installs, router mode for many models, model management from Open WebUI, reasoning models, embeddings for RAG, and fixes. It follows the Open WebUI and llama.cpp documentation as of December 2026.

TL;DR

  • Start: llama-server -hf ggml-org/gemma-3-4b-it-GGUF --port 10000
  • Connect: Admin Settings > Connections > Manage OpenAI API Connections, +.
  • URL: http://127.0.0.1:10000/v1, or http://host.docker.internal:10000/v1 when Open WebUI runs in Docker. Keep the /v1.
  • Auth: None (or Bearer with your --api-key).
  • Provider: under Advanced, choose llama.cpp for Loaded markers, Eject and the Manage panel.
  • Many models: start llama-server with no model (router mode) and --models-dir.

Why Connect llama.cpp to Open WebUI?

Ollama llama-server
Setup One installer, model library One binary, any GGUF from Hugging Face
New features Arrive after llama.cpp First, straight from the project
Control Modelfile parameters Every flag: offload, MoE, speculative decoding, KV cache
Open WebUI connection Ollama API, detected automatically OpenAI API with the llama.cpp provider

If you only want the simplest path, our Open WebUI with Ollama guide is quicker. Pick llama.cpp when you want the latest models or fine control. New to it? Install it first with our llama.cpp install guide.

Step 1: Start llama-server

  1. Get llama-server from the prebuilt releases or build it. Check it runs with llama-server --version.
  2. Pick a model. The easiest way is -hf, which downloads a GGUF from Hugging Face into the cache. The quant defaults to Q4_K_M, and a vision projector is fetched automatically when the repo has one.
  3. Start the server on a known port:
llama-server -hf ggml-org/gemma-3-4b-it-GGUF --port 10000

# or a GGUF you already have
llama-server -m /models/Qwen3-8B-Q4_K_M.gguf --port 10000 -c 16384 -ngl all
  • -c sets the context size. The default 0 loads it from the model.
  • -ngl sets how many layers go to the GPU: a number, auto (default) or all.
  • --host defaults to 127.0.0.1. Use --host 0.0.0.0 only if another machine or a container must reach it.
  • --api-key requires a key on every request. Use it whenever the server is reachable beyond your own PC.

Always pass --port so you know where it listens. Open http://127.0.0.1:10000 in a browser and llama.cpp’s own web UI appears, which confirms the server works. Every flag is explained in our llama-server guide.

Step 2: Add the Connection in Open WebUI

  1. Open admin settings: Admin Panel > Settings > Connections.
  2. Under Manage OpenAI API Connections, click +.
  3. URL: http://127.0.0.1:10000/v1. The /v1 at the end matters.
  4. Auth: None for a keyless server. With Bearer and an empty key, Open WebUI sends no Authorization header, which is the same as None. If you started llama-server with --api-key, choose Bearer and paste that key.
  5. Provider: expand Advanced and pick llama.cpp from the Provider dropdown.
  6. Save, open a new chat and pick the model from the dropdown.

Why set Provider? Open WebUI cannot tell a llama.cpp server from any other OpenAI-compatible server by looking at /v1/chat/completions, so the dropdown tells it.

With llama.cpp selected you get the green Loaded marker in the model selector, the admin Eject button, extra model details, the management panel, and stored reasoning replayed to the server as reasoning_content.

Docker Networking

Inside a container, 127.0.0.1 means the container itself, not your PC. This is the most common reason the connection fails.

Setup URL to use
Both installed natively http://127.0.0.1:10000/v1
Open WebUI in Docker, llama-server on the host (Windows, Mac) http://host.docker.internal:10000/v1
Same, on Linux Add --add-host=host.docker.internal:host-gateway to the Open WebUI container, and start llama-server with --host 0.0.0.0
Both in one Docker Compose file http://llama:8080/v1 (service name and internal port)

llama.cpp publishes server images. A Compose service with CUDA looks like this, based on the README’s Docker example:

services:
  llama:
    image: ghcr.io/ggml-org/llama.cpp:server-cuda
    command: -m /models/Qwen3-8B-Q4_K_M.gguf -c 16384 --host 0.0.0.0 --port 8080 --n-gpu-layers 99
    volumes:
      - ./models:/models
    deploy:
      resources:
        reservations:
          devices:
            - driver: nvidia
              count: all
              capabilities: [gpu]
  open-webui:
    image: ghcr.io/open-webui/open-webui:main
    ports:
      - "3000:8080"
    volumes:
      - open-webui:/app/backend/data
volumes:
  open-webui:

Then add http://llama:8080/v1 as the connection. More Docker fixes are in our Open WebUI connection error guide.

Serve Many Models With Router Mode

One llama-server per model gets messy. Start llama-server without a model and it runs as a router that loads and unloads models on demand, forwarding each request by its model field.

# models from the Hugging Face cache
llama-server --port 10000

# or a folder of GGUF files
llama-server --models-dir ./models --port 10000 -c 16384
  • Put multi-file models (vision projectors, split shards) in their own subfolder. Projector files must start with mmproj.
  • Arguments you pass to the router, such as -c, become defaults for every model.
  • --models-max caps how many models stay loaded at once (default 4, least recently used unloaded first).
  • For per-model settings, use a preset file: --models-preset ./my-models.ini.
  • Models load automatically on first request unless you add --no-models-autoload.

Open WebUI lists every model the router exposes, so one connection covers your whole library. Before router mode, people used a separate swapper; our llama-swap guide covers that approach.

Manage Models From Open WebUI

With Provider set to llama.cpp, admins get a model management panel: Admin Panel > Settings > Models, the ⋯ menu, then Manage.

Action llama.cpp
List the server’s models Yes
Download a model by ref Yes
Load or unload a model Yes
Delete a cached model Yes
  • Download from the selector: type a model ref into the model selector’s search box and Open WebUI offers a Download row for each connected target.
  • Eject: a loaded model shows a green Loaded marker and admins see Eject, which calls llama.cpp’s unload endpoint without restarting the server. On a connection left at the Default provider, Eject returns an error.
  • The actions are proxied to llama-server, so files on disk are handled by the server. Open WebUI strips a trailing /v1 before calling the management API, so the chat URL works unchanged.

Reasoning, Context and Speed Settings

Reasoning models

llama-server’s --reasoning-format deepseek puts the model’s thoughts in reasoning_content, which Open WebUI shows as a collapsible thinking block. --reasoning-budget N caps thinking tokens (-1 unlimited, 0 no thinking), and --reasoning-effort passes a level such as low or high to templates that support it. The Jinja chat template engine is on by default.

Context size

The context is fixed by the server’s -c, so a chat longer than that fails. Size it to your VRAM, and remember that -np (parallel slots) shares the context between slots. Our Open WebUI context length guide covers long chats.

Speed

  • Keep the whole model on the GPU with -ngl all if it fits.
  • For big MoE models that do not fit, offload experts to the CPU; see our MoE offload guide.
  • Flash attention defaults to auto.
  • Try a draft model for faster replies with our speculative decoding guide.
  • Measure changes with llama-bench.

Tool calling

Open WebUI’s native function calling works with models whose chat template supports tools. Details in our llama.cpp function calling guide.

Use llama.cpp for RAG Embeddings

A llama-server instance with /v1/embeddings can also serve embeddings for document chat. Run a second instance with an embedding model and the --embedding flag, which restricts it to embeddings only:

llama-server -m /models/nomic-embed-text-v1.5.Q8_0.gguf --embedding --port 10001

In Admin Panel > Settings > Documents, set the embedding engine to OpenAI, the URL to http://127.0.0.1:10001/v1, and the model name. Re-index existing knowledge after changing embedding models. See our Open WebUI RAG guide.

Troubleshooting

“Network problem” or no models listed

Check the URL ends in /v1, then open http://127.0.0.1:10000/v1/models in a browser. In Docker, use host.docker.internal instead of 127.0.0.1.

Open WebUI freezes after saving a bad URL

The model list request is waiting on an unreachable server. Start llama-server, or raise AIOHTTP_CLIENT_TIMEOUT_MODEL_LIST (default 10 seconds) for slow starts.

401 Unauthorized

llama-server was started with --api-key. Set Auth to Bearer with the same key.

Eject returns an error

Set the connection’s Provider to llama.cpp. The Default provider cannot unload models.

Thinking text shows inside the answer

Start the server with --reasoning-format deepseek so thoughts arrive in reasoning_content.

Replies cut off in long chats

The conversation exceeded -c. Raise it, lower -np, or start a new chat.

Model list goes stale

With the base model list cache on, Open WebUI keeps the old list. Click refresh next to the cache toggle in Connections.

FAQ

Does Open WebUI support llama.cpp?

Yes, through llama-server’s OpenAI-compatible API, with a dedicated llama.cpp provider option for model management.

What URL do I use for llama.cpp in Open WebUI?

http://127.0.0.1:PORT/v1, or http://host.docker.internal:PORT/v1 when Open WebUI runs in Docker.

Do I need an API key?

No, unless you started llama-server with --api-key. Set Auth to None.

Can I switch models without restarting llama-server?

Yes, in router mode. Start it without a model and Open WebUI can load, unload and download models.

Is llama.cpp faster than Ollama in Open WebUI?

Often similar, since Ollama builds on llama.cpp, but llama-server gets new optimizations first and exposes every tuning flag.

Can I use LM Studio the same way?

Yes. Set Provider to LM Studio for the same panel, minus deleting models and the Eject button.

Sources

Free weekly email

Get new AI guides every week

One short weekly email with our newest local AI, ComfyUI and AI tool guides. No spam, no pop-ups, just the good stuff.

Free. Unsubscribe anytime in one click. We only use your email to send this newsletter. See our privacy policy.

Woman in a sunny cafe holding a tablet with a LLAMA.CPP + OPEN WEBUI card, hook plug in llama-server