Skip to content
AgenticAIWiki
  1. Learn
  2. Part 5
  3. 30. Local inference
  4. 30.7

Lesson 30.7 · 7 of 8 · 6 min read · Reviewed 24 Nov 2026

Desktop runners: Ollama, LM Studio and llama.cpp

By the end, you can

  • Compare Ollama, LM Studio and llama.cpp by how you use them.
  • Call a desktop runner's local server from your own code.

Lesson 30.3 split tools into desktop runtimes and production servers. This lesson zooms in on the desktop side, where three names cover most setups: llama.cpp, Ollama and LM Studio. They overlap a lot, so it helps to see them as layers.

Three layers, three tools

llama.cpp Ollama LM Studio
What it is The C/C++ inference engine A runner with a CLI and a background server A desktop app with a graphical interface
How you start Build or download binaries, then run llama-cli or llama-server ollama run <model> Search for a model in the app, click to load
Model files GGUF files you download yourself Pulled from its library by name and tag Downloaded through the app’s model browser
Best for Full control, scripting, unusual hardware Developers who want one command People who prefer a window to a terminal

Ollama and LM Studio have both built on llama.cpp, and LM Studio can also use Apple’s MLX engine on Macs. So the speed you get often comes from the same engine underneath. The difference is mostly convenience, model management and defaults.

Calling a local server from code

All three can run a small HTTP server on your machine. Ollama listens on port 11434 by default, llama-server on 8080 and LM Studio’s server on 1234, though you can change each. Many of these servers also offer an endpoint shaped like a common chat API, so existing client code needs only a new base URL.

import json, urllib.request

body = {"model": "small-model:8b-q4", "messages": [{"role": "user", "content": "Summarise: ..."}]}
req = urllib.request.Request(
    "http://localhost:11434/api/chat",
    data=json.dumps({**body, "stream": False}).encode(),
    headers={"Content-Type": "application/json"},
)
reply = json.load(urllib.request.urlopen(req))
print(reply["message"]["content"])

The model nameModel id: The exact string that names a model in an API request, such as a specific model version. here is an example. Use the exact name and tag your runner lists. Keep the URL in configuration, so the same code can point at a local runner or a cloud model (30.5).

A worked choice

A small team builds a meeting-notes summariser that must run offline.

  • The developers use Ollama: one command to pull the model, and a server their tests can call.
  • The designer uses LM Studio to try prompts in a chat window without a terminal.
  • The release build embeds llama.cpp directly, so there is no separate app to install, and the GGUF file ships with the product.

They agree on one GGUF file at one quantizationQuantization: Storing model weights with fewer bits, such as 4 or 8 instead of 16, to cut memory and speed up inference. level and write its name into the repo, so everyone is testing the same weights.

Common mistakes

  • Assuming one name means one file. Tags change, and a short name may point to a default quantization. Record the full tag or the file hash.
  • Forgetting the context setting. Runners often default to a modest context length. Long documents get cut unless you raise it, which also raises memory use.
  • Exposing the server. Bind it to localhost unless you mean to share it, and put any keys in environment variables, never in code.
  • Comparing runners on different settings. Match the file, context length and samplingSampling: Choosing the next token from the model’s probability distribution, rather than always taking the most likely one. settings before you compare speed or quality.

Key points

  • llama.cpp is the inference engine; Ollama and LM Studio are friendlier runners, and both have built on llama.cpp.
  • Ollama is command-line first and runs a background server; LM Studio is a desktop app with a model browser and a built-in server.
  • All three can expose a local HTTP API, so your app calls localhost instead of a cloud endpoint.
  • Pin the exact model file and settings, because the same model name can mean different quantizations.
Hands-on labOn your own machine

Run one model in two desktop runners

Load the same GGUF file in two desktop runners and compare them fairly.

You will have: A short comparison note: file, settings, speed and your verdict for each runner.

Steps

  1. Choose one GGUF file at one quantization level and record its exact name.
  2. Load it in two runners, for example LM Studio and llama.cpp, or Ollama with an imported GGUF.
  3. Set the same context length and sampling settings in both.
  4. Ask the same three prompts in each and note tokens per second and any differences in output.
  5. Turn on each runner's local server and call it once from a script, using an environment variable for the URL.

Done when

  • Both runs use the same file and settings, written down.
  • Each runner answers a request from your script on localhost.
  • Your note says which runner you would use for development and which for a demo, and why.

Docs: Ollama documentation · LM Studio documentation · llama.cpp (GitHub)

Quick checkA teammate's app works with a local model on their laptop, but gives worse answers on yours with the same model name. What is the most likely cause?
How sure are you?
Pick an answer and how sure you are