Part of AI in CanadaAI in Canada · Self-hosting

Ollama, vLLM or llama.cpp server: running your own LLM API.

All three serve an open model behind an OpenAI-compatible API. llama.cpp’s llama-server runs GGUF models on processors, GPUs or both, from a single binary. Ollama wraps a model library and a local API around the same GGML foundations, and is the easiest to start with. vLLM is built for GPU servers that answer many requests at once. Pick by your hardware and how many requests you need to serve in parallel.

Facts checked

The three side by side

llama.cpp (`llama-server`)OllamavLLM
What it is † † † †LLM inference in C/C++ built on the ggml library; MIT licenceAn app that downloads and runs models with a local API; MIT licence. It relied on llama.cpp, and since 2025 also has its own engine built on GGMLA library for LLM inference and serving, started at UC Berkeley’s Sky Computing Lab
Hardware † † † † †Processors (x86, Arm) and GPUs: CUDA, Metal, HIP, Vulkan, SYCL and more; part of a model can sit on the GPU and the rest on the processorProcessors and GPUs, including Apple siliconMainly NVIDIA and AMD GPUs; CUDA needs Linux and compute capability 7.5 or higher. Basic support for x86 and Arm processors
Model format † † † †GGUF files, usually quantisedModels pulled by name, such as gpt-oss:20bHugging Face weights; FP8, INT8, INT4, GPTQ and AWQ quantisation. GGUF is “highly experimental and under-optimized”
OpenAI-compatible API † † †/v1/chat/completions, /v1/embeddings, /v1/models, /v1/responseshttp://localhost:11434/v1: chat, completions, embeddings, models, responses/v1/chat/completions, /v1/completions, /v1/embeddings, /v1/responses; examples use port 8000
Serving several requests † † †Parallel slots (-np) with continuous batchingOne request at a time by default (OLLAMA_NUM_PARALLEL), up to 512 queuedContinuous batching and PagedAttention, its core design
Authentication † † †--api-keyThe local API ignores the key--api-key protects some endpoints only; the docs say not to rely on it alone

† Competitor details come from each vendor’s own published pages on the dates shown; prices and plans change, so check the vendor before you decide. What it is (2026-11-23) · What it is (2026-11-23) · What it is (2026-11-23) · What it is (2026-11-23) · Hardware (2026-11-23) · Hardware (2026-11-23) · Hardware (2026-11-23) · Hardware (2026-11-23) · Hardware (2026-11-23) · Model format (2026-11-23) · Model format (2026-11-23) · Model format (2026-11-23) · Model format (2026-11-23) · OpenAI-compatible API (2026-11-23) · OpenAI-compatible API (2026-11-23) · OpenAI-compatible API (2026-11-23) · Serving several requests (2026-11-23) · Serving several requests (2026-11-23) · Serving several requests (2026-11-23) · Authentication (2026-11-23) · Authentication (2026-11-23) · Authentication (2026-11-23)

llama.cpp’s server, tested

llama-server is one program that loads a GGUF file and serves it. We ran the commands below with a llama.cpp build from November 2026 (build b12651) and the official openai package for Node.js. Both calls returned the expected answers.

  • `-ngl` is the number of model layers kept in GPU memory. 0 runs on processors only; leave it at its default to put as much as fits on the GPU.
  • `-c` and `-np`: with -c 8192 -np 2, the server log showed each of the 2 slots getting 4,096 tokens of context. More slots serve more people at once, each with a shorter context.
  • `--reasoning off`: without it, Granite 4.2 thought first and put the thinking in reasoning_content. With a small max_tokens, the thinking used the whole budget and the answer came back empty.
  • `--alias`: without it, /v1/models lists the file path. The server answers with the loaded model whatever name you send, so the alias is for your own clarity.
  • `--host 127.0.0.1` and `--api-key`: a wrong key got 401 Invalid API Key. Pass --port explicitly; this build’s default was 9931.
# A 3B chat model quantised to 4 bits, on processors only (-ngl 0)
llama-server -m ./models/granite-4.2-3b-Q4_K_M.gguf --alias granite \
  -c 8192 -np 2 -ngl 0 --reasoning off \
  --host 127.0.0.1 --port 8123 --api-key "$LLAMA_API_KEY"

Call it with the OpenAI SDK

Any OpenAI SDK works once baseURL points at the server. response_format with a JSON schema also worked against this server, which helps for extraction.

import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "http://127.0.0.1:8123/v1",
  apiKey: process.env.LLAMA_API_KEY,   // the --api-key given to llama-server
});

const r = await client.chat.completions.create({
  model: "granite",                     // the --alias
  messages: [{ role: "user", content: "Name three Canadian provinces, comma-separated." }],
});
console.log(r.choices[0].message.content);

Embeddings from the same server software

--embeddings restricts a server to embedding requests, so run your embedding model as a second process on its own port, or one after the other as we did. With bge-m3 quantised to 8 bits, the server returned 1,024-dimension vectors of length 1, and an English and a French sentence with the same meaning came out close together.

# An embedding model gets its own server
llama-server -m ./models/bge-m3-Q8_0.gguf --alias bge-m3 --embeddings \
  -ngl 0 --host 127.0.0.1 --port 8123 --api-key "$LLAMA_API_KEY"

# then, with the same client:
#   await client.embeddings.create({ model: "bge-m3", input: ["Le loyer est dû le premier du mois."] })

Ollama: the easiest start

Ollama pulls a model by name and serves it on http://localhost:11434, bound to 127.0.0.1 by default. Point an OpenAI client at http://localhost:11434/v1/ with any API key; the client needs one, and Ollama ignores it.

  • Context defaults to 4,096 tokens. Raise it with OLLAMA_CONTEXT_LENGTH or the num_ctx parameter if your prompts are longer, or they will be cut.
  • One request at a time by default on most backends. OLLAMA_NUM_PARALLEL raises it; up to 512 requests wait in the queue, and up to 3 models stay loaded on a processor-only machine.
  • No key check. To expose it beyond the machine (OLLAMA_HOST), put it behind a private network or an authenticating proxy.

vLLM: GPU servers with many users

vLLM is the one to use when a GPU server must answer many requests at once. PagedAttention manages the memory that holds each request’s context, and continuous batching adds new requests to the batch already running instead of waiting for it to finish. vllm serve <model> starts an OpenAI-compatible server.

  • Linux and a recent GPU: CUDA support needs Linux (no native Windows; use WSL) and a GPU of compute capability 7.5 or higher, such as a T4, L4, A100 or H100.
  • Processors are a side path: x86 and Arm processors get basic inference and serving; AVX-512 is recommended on x86.
  • GGUF is not its format. Use the model’s Hugging Face weights, or an FP8, AWQ or GPTQ build of them.
  • Security: --api-key (or VLLM_API_KEY) leaves some endpoints unauthenticated. Keep vLLM on a private network.

GGUF and quantisation

GGUF is the single-file model format llama.cpp and Ollama load. Quantisation stores weights with fewer bits, which shrinks the model and can speed it up, at some cost in accuracy (measured as perplexity or KL divergence). Re-quantising an already quantised file loses more quality than quantising from the 16-bit original. Q4_K_M is the type llama.cpp’s own quantisation guide uses as its example.

Llama 3.1 8B asBits per weightFile size
F16 (original precision) †16.014.96 GiB
Q8_0 †8.507.95 GiB
Q5_K_M †5.705.33 GiB
Q4_K_M †4.894.58 GiB

† Competitor details come from each vendor’s own published pages on the dates shown; prices and plans change, so check the vendor before you decide. F16 (original precision) (2026-11-23) · Q8_0 (2026-11-23) · Q5_K_M (2026-11-23) · Q4_K_M (2026-11-23)

What hardware each needs

  • Memory first: the quantised weights must fit, plus the context of every request being served. A 70B model at Q4_K_M is about 43 GB before any context, per llama.cpp’s own table.
  • On a GPU, everything fast happens in GPU memory. vLLM and a fully offloaded llama-server need the whole model there; llama-server can split a model that doesn’t fit between GPU and processor, more slowly.
  • On processors, llama-server and Ollama run models in ordinary RAM. That works for small and mid-size models when answers can take seconds, and it is how Canner runs its endpoints.
  • Many users at once is where vLLM on a GPU pulls ahead: batching serves many requests together, which processors can’t do at the same scale.

When self-hosting is worth it

  • Worth it: high, steady volume that keeps a GPU busy; a model or fine-tune no API offers; text that may not leave your network; a team that already runs servers.
  • Not worth it: occasional or uneven use, where a GPU sits idle most of the day; no one to patch and watch the server; you need frontier-model quality, which open models don’t match.
  • Middle ground: a hosted API for open models. You keep the OpenAI-compatible code above and hand off the server.

Canner’s endpoints run llama.cpp’s server

Canner’s AI endpoints run llama.cpp’s server on processors on Canner’s own server in Montréal, behind a gateway that adds keys, per-endpoint limits and a content policy. The client code is the same as above; only the base URL, key and model name change. We ran this against the live service.

  • Models: gemma-4-26b-a4b, granite-4.2-3b, and bge-m3 for embeddings.
  • Speed: processors, one request at a time across the service. A long answer from Gemma takes tens of seconds, so run it in the background (background jobs) and stream to the screen.
  • Data: prompts and answers are processed in memory and never stored. Usage is measured in model time with a monthly allowance per plan; see AI endpoints for current allowances.
import OpenAI from "openai";

// Same code against Canner: OPENAI_BASE_URL and OPENAI_API_KEY come from the
// environment (set automatically in a project with an attached AI endpoint).
const client = new OpenAI();

const r = await client.chat.completions.create({
  model: "granite-4.2-3b",
  messages: [{ role: "user", content: "Name three Canadian provinces, comma-separated." }],
});
console.log(r.choices[0].message.content);

Questions

Is Ollama built on llama.cpp?

It started that way: Ollama relied on llama.cpp for model support. In May 2025 it introduced its own engine, built directly on the GGML library that also underlies llama.cpp, starting with multimodal models. Its README still lists llama.cpp as a supported backend.

Does vLLM run on a CPU?

Yes, with basic inference and serving on x86 and Arm processors under Linux. vLLM is designed around GPUs, though; for processor-only machines, llama.cpp’s server or Ollama are the usual choice.

Is llama-server OpenAI-compatible?

Yes. It serves /v1/chat/completions, /v1/embeddings, /v1/models and /v1/responses, and works with the official OpenAI SDKs by setting the base URL. JSON-schema structured output also works.

Can vLLM load GGUF files?

Only experimentally. vLLM’s documentation calls its GGUF support highly experimental and under-optimized, now provided by a plugin. Use the model’s original weights or an FP8, AWQ or GPTQ version with vLLM.

How much memory does a self-hosted LLM need?

At 4-bit quantisation (Q4_K_M), about 4.9 GB for an 8B model and 43 GB for a 70B model, plus memory for the context of each request served at once.

llama.cpp’s server, run for you in Montréal.

Keep your OpenAI-compatible code and hand off the server. See AI endpoints.