The Ollama API listens on http://127.0.0.1:11434 as soon as the app or ollama serve is running, with no key and no password. Its own routes live under /api/ (chat, generate, models) and its OpenAI-compatible layer under /v1/, so most OpenAI clients work by changing the base URL and the model name.
We did not stop at reading the code. On 6 November 2026 we started the official Ollama v0.40.15 binary for Linux inside a container with no network at all, on the processor only, with a tiny 135-million-parameter model (smollm2:135m), and threw requests at it: native routes, OpenAI routes, a made-up key, foreign origins, routes that want to reach ollama.com. Then we did the same reading for LM Studio, llama.cpp, vLLM and MLX, so you know what each local API opens and to whom.
OllamaRuntime sheet
LM StudioRuntime sheet
How to call the Ollama API: address, port and a first request
Out of the box the server listens on 127.0.0.1, port 11434: only programs on your own computer can reach it. The quickest check is curl http://127.0.0.1:11434/api/version, which in our test answered {"version":"0.40.15"}. A first chat with the native API looks like this:
curl http://127.0.0.1:11434/api/chat -d '{
"model": "qwen3:8b",
"messages": [{"role": "user", "content": "Why is the sky blue?"}],
"stream": false
}'
Mind the "stream": false. In the native API, streaming is on unless you switch it off: our /api/generate without that field came back as one JSON line per chunk, each with "done": false. With it, you get a single JSON plus timings in nanoseconds; the answer sits in message.content for /api/chat, as above, and in response for /api/generate. In our test the 135M model loaded in 0.52 seconds and wrote 16 tokens. The model has to be downloaded first (ollama pull qwen3:8b); if it is not, the API answers with a 404. On the command line, ollama list tells you which models are downloaded; that command and the rest, with their real output, are in our Ollama commands cheat sheet.
In this video the request goes to http://localhost:11434/api/generate from Visual Studio Code, with the REST Client extension instead of curl, and with "stream": false so the answer arrives in one piece, the same switch we explain above.
Opens on YouTube (no cookies) only when you press play.

Every Ollama API endpoint, native and OpenAI-compatible
We counted them on 6 November 2026 in server/routes.go of v0.40.15 (lines 2383 to 2452): 37 routes, 24 under /api/, 12 under /v1/ and the root /, which only says “Ollama is running”. These are the ones you will use, and the last column says whether the request leaves your computer:
| Route | What it does | Leaves your computer? |
|---|---|---|
/api/chat, /api/generate |
Chat with messages, or complete a single prompt | Only with a cloud model |
/api/embed |
Embeddings (/api/embeddings is the older form) |
Only with a cloud model |
/api/tags, /api/ps, /api/show, /v1/models |
Downloaded models, models in memory, details of one | No (/api/show, only with a cloud model) |
/api/pull, /api/push, /api/create, /api/copy, /api/delete |
Manage models | Pull and push talk to the model registry, and so does create when it starts from a model you do not have |
/api/balance, /api/usage, /api/me |
Your ollama.com account | Always |
/api/experimental/web_search, /api/experimental/web_fetch |
Web search and page fetching for tools | Always |
/v1/chat/completions, /v1/completions, /v1/responses, /v1/embeddings |
OpenAI compatibility | Only with a cloud model |
/v1/messages |
Anthropic compatibility | Only with a cloud model |
The rest: housekeeping (/api/version, /api/status, the blobs behind ollama create, sign-out), the catalogue of recommended models (/api/experimental/model-recommendations), the details of one model in OpenAI style (/v1/models/ plus its name), /v1/responses/compact, /v1/systemone, 3 audio routes under /v1/audio/ and a passthrough for the Codex desktop app under /api/codex/. Which API to pick? The native one gives you Ollama’s own knobs in one place: options (num_ctx, temperature), keep_alive and the timings. The /v1/ one exists so the code you already wrote for OpenAI, or a tool that only speaks OpenAI, works without touching anything else. Both answer from the same models.
Ollama’s OpenAI-compatible API, from Python
Point the official OpenAI client at your machine and give it any key: it insists on one, Ollama ignores it. Ollama’s own documentation writes api_key='ollama' with the comment “required but ignored”. This is the code we ran with the official openai 3.46.0 package for Python, with qwen3:8b in place of our test model and without our max_tokens=12 limit:
from openai import OpenAI
client = OpenAI(base_url="http://127.0.0.1:11434/v1", api_key="ollama")
r = client.chat.completions.create(
model="qwen3:8b",
messages=[{"role": "user", "content": "Name one planet."}],
)
print(r.choices[0].message.content)
With our test model it answered in 0.16 seconds, client.models.list() returned the models downloaded on the server and stream=True sent the answer in pieces. The same works with curl: send the request to /v1/chat/completions with -H "Content-Type: application/json" and an OpenAI-style body. 2 things change from OpenAI’s servers. The model name is Ollama’s tag (qwen3:8b), and /v1/models tells you which ones you have; an unknown name gets a 404 with not_found_error, exactly as an OpenAI client expects. The context is still Ollama’s, chosen by your graphics memory, and in the /v1/ API you do not get num_ctx: set it on the server with OLLAMA_CONTEXT_LENGTH. As a bonus, a /v1/messages route speaks Anthropic’s format, and it answered our test as well.
Opens on YouTube (no cookies) only when you press play. More videos on its sheet →
Halfway through this tutorial, from about minute 7 to minute 11, Tim shows the HTTP API at work: ollama serve on port 11434, a Python script with requests calling /api/chat and printing the answer as it streams in, and then the ollama package for Python, which hides the HTTP part. The rest of the video covers installing, the command line and Modelfiles.
Which Ollama endpoints call ollama.com, and how OLLAMA_NO_CLOUD stops them
A local API that phones out deserves its own section. In v0.40.15 there are 2 kinds. Some routes always go to ollama.com: /api/balance and /api/usage forward to https://ollama.com:443, throw away the caller’s Authorization header and sign the request with your computer’s key (~/.ollama/id_ed25519), and the experimental web search and fetch do the same job for tools. The others only leave when the model name ends in :cloud or -cloud (gpt-oss:120b-cloud, for instance): the request goes to the same route on ollama.com instead of to your graphics card. That covers the 6 inference routes under /v1/ (chat/completions, completions, embeddings, responses, messages and systemone) and /v1/models/ followed by a model name, and in the native API /api/chat, /api/generate, /api/embed (with its older form) and /api/show.
We checked it in the container with no network. Without any setting, /api/balance, /api/usage and 2 chats with cloud models (gpt-oss:20b-cloud through /v1/chat/completions, gpt-oss:120b-cloud through /api/chat) came back with a 502 and an error that spells out the address they were trying to reach, https://ollama.com:443 followed by the same route. At start-up the server also tried 2 calls of its own: the catalogue of recommended models and a list of cloud models. With OLLAMA_NO_CLOUD=1, the same 4 requests got a 403 without even trying (“ollama cloud is disabled: balance is unavailable”, “… remote model is unavailable”), the log printed Ollama cloud disabled: true and the 2 start-up calls disappeared. The one it does not cover is /api/me, the account check the desktop app makes when it opens.

OLLAMA_HOST, OLLAMA_ORIGINS and keep_alive
OLLAMA_HOST sets where the server listens (default 127.0.0.1:11434, envconfig/config.go). OLLAMA_HOST=127.0.0.1:11435 moves it to another port; OLLAMA_HOST=0.0.0.0:11434 opens it to every network interface, still without a password, and then the server also stops checking the Host header. While it listens on 127.0.0.1, that check turns away names it does not know: our request with a made-up Host (atacante.example) got a 403, the same request with localhost:11434 a 200. It accepts local and private addresses, localhost, the computer’s own name and names ending in .localhost, .local or .internal. Client programs read OLLAMA_HOST too, so use the same value on both sides. Inside Docker the image sets 0.0.0.0 and the Host check switches off: what changes in a container.
OLLAMA_ORIGINS is CORS, the list of web pages your browser may let in. By default it includes localhost, 127.0.0.1 and 0.0.0.0 on any port, plus app://, file://, tauri:// and the VS Code schemes. In our test, http://localhost:3000 and file:// got through; an unrelated site (https://ejemplo.com in our test), a chrome-extension:// and the null origin got a 403. Your variable adds to that list, it does not replace it: OLLAMA_ORIGINS=chrome-extension://* ollama serve lets Chrome extensions in and keeps the rest.
keep_alive decides how long a model stays in memory after answering. In v0.40.15 the default is 5 minutes (KeepAlive() in envconfig/config.go, and Ollama’s own help says "5m"), and we saw it happen: an answer at 07:43:05 UTC and /api/ps showing expires_at at 07:48:05. It accepts a duration ("10m", "1h"), a number of seconds, a negative number to keep the model loaded for good, or 0 to unload it straight away: {"model": "smollm2:135m", "keep_alive": 0} came back with "done_reason": "unload" and /api/ps was empty. In the request it beats OLLAMA_KEEP_ALIVE on the server, and /v1/chat/completions takes it too, as an extra field of Ollama’s own: in the OpenAI client for Python, extra_body={"keep_alive": "30m"}. A large model that unloads every 5 minutes makes the next question wait for it to load again: if your app makes one request every 10 minutes, ask for "keep_alive": "30m".
The LM Studio API and server: port 1234, tokens and CORS
LM Studio is closed source, so everything in this section comes from its official documentation, read on 6 November 2026 for 0.4.28, the stable version that day. The server starts from the Developer tab or with lms server start, and listens on localhost:1234. Among the dialects it speaks: OpenAI under /v1/ (/v1/chat/completions, /v1/responses, /v1/embeddings, /v1/completions, /v1/models), Anthropic at /v1/messages and its own REST API under /api/v1/, which can also load, unload and download models. So the Python above works by changing 2 things: base_url="http://localhost:1234/v1" and the model name, the identifier LM Studio shows.

Where it goes further than Ollama is the key. By default it asks for none, like Ollama, but the server settings have a Require Authentication switch, and under Manage Tokens you create tokens with their own permissions; from then on every request carries Authorization: Bearer plus the token (the OpenAI client sends its api_key in that same header, so the token goes there). CORS is off unless you start it with --cors or tick Enable CORS, and the address is 127.0.0.1 unless you use --bind 0.0.0.0 or Serve on Local Network, which its documentation recommends pairing with a token. The LM Studio equivalent of keep_alive is ttl: a model the API loads on demand unloads after 60 minutes of idleness, and one loaded with lms load stays put.

Ollama, LM Studio, llama.cpp, vLLM and MLX: their local APIs side by side
llama.cppRuntime sheet
vLLMRuntime sheet
MLX (mlx-lm)Runtime sheet
All 5 speak OpenAI under /v1/, so a program written for one can be pointed at another by changing the port and the model name. What sets them apart is everything else. Read in the code of each stable version on 6 November 2026 (LM Studio, in its documentation; Ollama, again on 10 November 2026 in v0.40.16; llama.cpp, again on 13 November 2026 in v1.0.0, with the same default port, address and CORS setting):
| Runtime (version) | Port | Listens on | API key | CORS by default | Calls of its own |
|---|---|---|---|---|---|
| Ollama (v0.40.16) | 11434 | 127.0.0.1 | None, a key you send is ignored | localhost, 127.0.0.1, 0.0.0.0 and local apps | Model catalogue every 4 hours, a list of cloud models at start-up and the cloud routes (except /api/me), all off with OLLAMA_NO_CLOUD; the desktop app also checks for updates every hour and asks for your account when it opens, and neither can be switched off |
| LM Studio (0.4.28) | 1234 | 127.0.0.1 | Tokens with permissions, off by default | Off | Update checks and engine auto-updates; no telemetry, by its maker’s word |
| llama.cpp (v1.0.0) | 9931 | 127.0.0.1 | --api-key |
Any origin | None |
| vLLM (0.33.0) | 8000 | 0.0.0.0 | --api-key, which covers only part of the routes |
Closed | Usage statistics on by default, every 10 minutes |
| mlx-lm (0.32.2) | 8080 | 127.0.0.1 | None | Any origin | None; model downloads go through Hugging Face’s library |
3 rows deserve a second look. vLLM is the only one that listens on every network interface out of the box: on a server with a public address and no firewall in front, its port 8000 is open to whoever finds it, and its own security page warns that --api-key only protects some groups of routes. llama.cpp reflects any origin back to the browser, so any web page you visit can talk to a llama-server without a key; with --api-key, everything except /health and its web interface asks for it. And mlx-lm opens CORS to everyone and has no key at all, which is fine on your own Mac and nowhere else.

If Ollama is not installed yet, our guide to running Ollama locally starts from scratch and explains the SSH tunnel for reaching it from another computer without opening it up. If the API answers but the model does not, Ollama not working has the fixes, and if the answers get cut short, context length in Ollama explains num_ctx. For the other 2 servers: run LM Studio locally and llama.cpp not working.