404 page not found from Ollama's OpenAI-compatible API means the path in the
URL is not one the server serves. The working address is
http://127.0.0.1:11434/v1/chat/completions (one /v1, plural
completions); a missing /v1, a doubled /v1/v1 or an
/api prefix all give the same plain-text 404.
Fix the URL the request actually goes to. If your client takes a base URL, set it to
http://127.0.0.1:11434/v1 and check the full URL it sends against the one
above. A 404 with a JSON body that names a model is a different problem: the path is right
and the model name is wrong.
The error
Four wrong paths, sent to a test server on port 15191, gave the same answer:
PS> curl.exe -s -i -H "Content-Type: application/json" -d "@chat.json" http://127.0.0.1:15191/chat/completions
HTTP/1.1 404 Not Found
Content-Type: text/plain
...
Content-Length: 18
404 page not found
The same 18-byte text/plain body came back for
/v1/v1/chat/completions, /api/chat/completions and
/v1/chat/completion (singular).
Why it happens
The plain 404 page not found answer carries no JSON and no model name, so it
says nothing about your model or your request body: the server found no route for the
path. In the test, a path without /v1, with it twice, with
/api in front, or with one letter missing, were all refused this way, with
the same valid body file that the correct path accepted.
Once the path is right, a wrong model name gives a 404 too, but it looks different: the
content type is application/json and the body says which model was not found.
Here the name had a hyphen where the tag needs a colon:
PS> curl.exe -s -i -H "Content-Type: application/json" -d "@chatbad.json" http://127.0.0.1:15191/v1/chat/completions
HTTP/1.1 404 Not Found
Content-Type: application/json
...
Content-Length: 105
{"error":{"message":"model 'qwen2.5-0.5b' not found","type":"not_found_error","param":null,"code":null}}
The fix
PS> curl.exe -s -i -H "Content-Type: application/json" -d "@chat.json" http://127.0.0.1:15191/v1/chat/completions
HTTP/1.1 200 OK
Content-Type: application/json
...
{"id":"chatcmpl-230","object":"chat.completion","created":1794280799,"model":"qwen2.5:0.5b","system_fingerprint":"fp_ollama","choices":[{"index":0,"message":{"role":"assistant","content":"Hello, how are you?"},"finish_reason":"stop"}],"usage":{"prompt_tokens":35,"prompt_tokens_details":{"cached_tokens":0},"completion_tokens":7,"total_tokens":42}}
The body file chat.json held
{"model":"qwen2.5:0.5b","messages":[{"role":"user","content":"Say hello in three words."}]}.
To see which model names the /v1 routes accept, ask the same server for its
list; the id values are the names to send:
PS> curl.exe -s http://127.0.0.1:15191/v1/models
{"object":"list","data":[{"id":"qwen3:0.6b","object":"model",...},...,{"id":"qwen2.5:0.5b","object":"model","created":1793949287,"owned_by":"library"},{"id":"all-minilm:latest","object":"model","created":1793949263,"owned_by":"library"}]}
A quick way to tell the two 404s apart is the -i flag: text/plain
with 18 bytes is a wrong path, application/json with an error object is a
wrong model.
How it was reproduced
Ollama 0.40.14 (ollama --version) on Windows 11, run as a separate
ollama serve with OLLAMA_HOST=127.0.0.1:15191 and its own models
folder holding qwen2.5:0.5b, so the test server's port is 15191 rather than
the default 11434. Requests were sent with curl.exe from Windows PowerShell
5.1, with the JSON in an ASCII body file. The five failing requests and the working one
were sent within two seconds of each other against the same server.
Frequently asked
- What is the OpenAI base URL for Ollama?
- Use http://127.0.0.1:11434/v1 as the base URL, so that chat requests reach /v1/chat/completions. In the test, /chat/completions without v1, /v1/v1/chat/completions and /api/chat/completions all returned 404 page not found.
- Why does Ollama return 404 page not found?
- The path of the request is not one the server serves. The body is 18 bytes of text/plain and says nothing about the model, so check the URL first: one /v1 and the plural completions.
- How do I tell a wrong model name from a wrong URL in Ollama?
- Send the request with curl -i. A wrong URL gives text/plain 404 page not found; a wrong model on the right path gives application/json with an error message such as model 'qwen2.5-0.5b' not found.
More decoded errors in the Fixes category. For every Ollama endpoint with curl and .NET, see the Ollama API guide.