Build with AI

How do you turn a local model into a server your apps can use?

Written as of · Published · By Robert Scales, with AI tools · 4 min read

Short answer

Start a server program such as Ollama, llama-server or vLLM, and it will answer on a local address using the same request format as OpenAI's API, so most apps only need a new base URL. Ollama and llama.cpp suit one person or a small group on any computer, and vLLM suits many simultaneous users on a Linux machine with a graphics card.

A chat window is only the start. Once a model runs on your own hardware, you probably want other programs to use it: a coding agent, a script that summarizes files, an internal tool for your team. To do that, you run the model as a server, a program that waits for requests on a network address and sends answers back.

Nearly all of these servers speak the same language. They copy the request format of OpenAI's API, so software written for a hosted model can usually point at your machine by changing one setting. The comparison of Ollama and LM Studio covers the desktop apps. This article covers the serving side, and how to pick an engine.

Three engines

Ollamallama-server (llama.cpp)vLLM
Best forOne person, quick setupControl on any hardwareMany users at once
Runs onMac, Windows, LinuxMac, Windows, Linux, CPU or GPULinux; Mac through a community plugin; Windows only through WSL
Main model formatIts own library, GGUFGGUFHugging Face models; FP8, AWQ and others
Default address127.0.0.1:11434127.0.0.1, port set by youlocalhost:8000
Parallel requestsDefault 1, set by OLLAMA_NUM_PARALLELSlots, set by --parallelContinuous batching

A worked example: three ways to start

With Ollama, the server is already running in the background once it is installed, and the API answers on port 11434.

With llama.cpp, you name a model and a context size. Here 32,768 tokens are shared by two slots:

llama-server -hf <user>/<model>:<tag> -c 32768 --parallel 2 --port 8080

With vLLM, on a Linux machine with a suitable graphics card:

uv pip install vllm --torch-backend=auto
vllm serve Qwen/Qwen2.5-1.5B-Instruct --host 127.0.0.1 --max-model-len 8192 --gpu-memory-utilization 0.8

Any of them can then be called the same way, here from Python with the standard OpenAI client:

from openai import OpenAI

client = OpenAI(base_url="http://127.0.0.1:8080/v1", api_key="local")
reply = client.chat.completions.create(
    model="local",
    messages=[{"role": "user", "content": "Summarize this note in two lines: ..."}],
)
print(reply.choices[0].message.content)

Change the port to match your engine. On Ollama and vLLM, model must be the name the server lists at /v1/models.

Settings that bite

Memory. vLLM takes 92% of the graphics memory by default so lower --gpu-memory-utilization if anything else shares the card. Its memory guide also recommends limiting --max-model-len when you run short.

Context multiplied by users. In Ollama, required memory scales with the number of parallel requests times the context length. Four parallel requests at 32,000 tokens cost about the same as one at 128,000. A model that fit fine for one person can fail for four, and the memory calculator shows how to plan for this.

Queues. When too many requests arrive, Ollama answers with a 503 error, and OLLAMA_MAX_QUEUE sets how long the line can get. Your app should retry rather than fail.

What batching buys you

A language model can work on several requests at once, reading the same weights for all of them. Continuous batching adds new requests to the batch as old ones finish, so the machine stays busy. llama-server and vLLM both offer it.

LMSYS measured what this means in practice on a DGX Spark, using another server called SGLang. On Llama 3.1 8B, one request at a time produced 20.5 tokens per second. With 32 requests at once, total output reached 368 tokens per second. That is about 18 times more work from the same chip, though each user then sees about 11.5 tokens per second, which is slower than one user alone. Batching is a benefit for a shared service, not for a single chat.

Keeping it private

Local means private only as long as the server stays local. Ollama and llama-server listen only to your own machine by default, and vLLM's guide describes localhost as its default. Name the address explicitly, as in the command above, then check it from another device.

  • Ollama: setting OLLAMA_HOST to 0.0.0.0 exposes it to your network.
  • llama-server: --host changes the address, and --api-key turns on a key. There is no key by default.
  • vLLM: --api-key or the VLLM_API_KEY variable does the same.

If others need access, use a VPN or a reverse proxy with its own login rather than opening the port on your router. Chat logs stay on your disk too, as the cloud or local guide explains.

Try it: Start any of the three engines with a small model, then send it a request with curl and with the Python client above. Send five requests at once from separate terminals and note how the speed per request changes.

Prompt
Here is my setup: [engine, model, graphics memory, number of expected users, typical prompt length]. Suggest values for context length and parallel requests that fit my memory, and show the arithmetic. Then list what I should check to confirm the server is reachable only by the people I intend.

Do you need a server at all if you work alone?

You probably already have one. Ollama and LM Studio both run a local API, so a coding agent or a script can use them without any extra work. There is no reason to install vLLM for a single user on a home computer: the advantage of batching appears only when several requests arrive at the same time.

Move to vLLM when you have a real queue: a team sharing a model, or a program sending many requests in parallel. Before then, the simplest setup that keeps your data on your machine is the right one. If you do grow, your apps will not need to change much, since all three accept the same request format.

Sources

  1. LLaMA.cpp HTTP Server (README) — ggml-org (GitHub)
  2. Quickstart, vLLM documentation — vLLM project
  3. Ollama FAQ — Ollama (documentation)

Sources for the articles linked in the text

Each linked article has its own page, with its sources and its date.

From the Guide to Artificial Intelligence, by Robert Scales, published by Holistic Hybrid Inc. Share and adapt it under CC BY-NC-SA 4.0: credit the guide, link to https://guidetoartificialintelligence.com/en/learn/local-ai-server-vllm-llama-cpp/, no commercial use without permission, and keep the same licence.

Get the free Guide to Artificial Intelligence

Sign up for the newsletter and receive the free guide: what changed in AI, one lesson, one prompt to try. Unsubscribe in one click.

How we handle your address

Back to top

Display

Your choices are saved in this browser only. No data is sent.

Text size
100%
Colours
Reading
More settings
Accessibility statement

Get the app

Add the guide to your home screen. It opens like an app, and the pages you have read stay available offline.

Read without a connection: download the articles

iPhone and iPad (Safari, Chrome, Edge)

  1. Tap the Share button (the square with an arrow). In Chrome and Edge, it is in the address bar or the menu.
  2. Choose “Add to Home Screen”.
  3. Tap “Add”.

Android (Chrome, Edge, Samsung Internet, Firefox)

  1. Open the browser menu (⋮ or ☰).
  2. Choose “Install app” or “Add to Home screen”.
  3. Confirm with “Install”.

Computer (Chrome, Edge)

  1. Click the install icon at the right end of the address bar, or open the browser menu (⋮ or …).
  2. In Chrome, choose “Cast, save and share”, then “Install page as app”. In Edge, choose “Apps”, then “Install this site as an app”.
  3. Click “Install”.

Mac (Safari)

  1. Open the File menu.
  2. Choose “Add to Dock”.
  3. Click “Add”.

Firefox on a computer can’t install a site as an app. Use Chrome, Edge or Safari instead.