{"error":{"message":"model 'gpt-4o' not found","type":"not_found_error",...}} with HTTP 404 is Ollama's OpenAI-compatible endpoint saying it has no model by the name your client sent. The base URL is right; the model field is not. Set it to a model that ollama list shows, such as qwen2.5:0.5b.

If the client's model name cannot be changed, ollama cp qwen2.5:0.5b gpt-4o on the Ollama server gives a local model that name; the same request was then answered with HTTP 200.

The error

{"model":"gpt-4o","messages":[{"role":"user","content":"Say hi"}]}
PS> curl.exe -s -w "\nHTTP %{http_code}\n" http://127.0.0.1:15190/v1/chat/completions -H "Content-Type: application/json" -d "@v1-gpt.json"
{"error":{"message":"model 'gpt-4o' not found","type":"not_found_error","param":null,"code":null}}

HTTP 404

Why it happens

Code written for OpenAI's API carries an OpenAI model name, and pointing its base URL at Ollama changes the server, not the name. The test server had no model called gpt-4o, and it answered in the OpenAI error shape: an error object with message, type not_found_error, param and code. The body was that error object and nothing else, and it came from the test server on port 15190. The quoted name in message is the exact string the client sent, so compare it with ollama list letter by letter.

The body is what tells this 404 apart: here it is a JSON error object that names the model, so the path /v1/chat/completions was right and only the model was missing.

The fix

{"model":"qwen2.5:0.5b","messages":[{"role":"user","content":"Say hi"}]}
PS> curl.exe -s -w "\nHTTP %{http_code}\n" http://127.0.0.1:15190/v1/chat/completions -H "Content-Type: application/json" -d "@v1-ok.json"
{"id":"chatcmpl-149","object":"chat.completion","created":1794548326,"model":"qwen2.5:0.5b","system_fingerprint":"fp_ollama","choices":[{"index":0,"message":{"role":"assistant","content":"Hello! It's nice to meet you. How can I help you today?"},"finish_reason":"stop"}],"usage":{"prompt_tokens":31,"prompt_tokens_details":{"cached_tokens":30},"completion_tokens":17,"total_tokens":48}}

HTTP 200

The second way keeps the client unchanged and renames on the server side:

PS> ollama cp qwen2.5:0.5b gpt-4o
copied 'qwen2.5:0.5b' to 'gpt-4o'
success
PS> curl.exe -s -w "\nHTTP %{http_code}\n" http://127.0.0.1:15190/v1/chat/completions -H "Content-Type: application/json" -d "@v1-gpt.json"
{"id":"chatcmpl-146","object":"chat.completion","created":1794548326,"model":"gpt-4o",...

HTTP 200

The answer then says "model":"gpt-4o" although a small local model wrote it, which can mislead anyone reading logs later. Prefer changing the name in the client's configuration; use the copy for a client that hard-codes its model. ollama rm gpt-4o removed the copy afterwards.

How it was reproduced

On Windows 11 in Windows PowerShell 5.1 with curl 8.22.0 and Ollama 0.40.16, against a separate test server on 127.0.0.1:15190 with its own models folder. The bodies were written with [IO.File]::WriteAllText and posted to /v1/chat/completions: first with gpt-4o, then with qwen2.5:0.5b, then with gpt-4o again after ollama cp; the copy was removed at the end.

Frequently asked

Why does Ollama say model 'gpt-4o' not found?
The OpenAI-style request named gpt-4o, and the Ollama server has no model by that name. Set the model field to a model listed by ollama list.
Can I use an OpenAI model name with Ollama?
As a local copy under that name. In the test ollama cp qwen2.5:0.5b gpt-4o made the copy, and the same request was answered with HTTP 200 by the small local model.
What does not_found_error mean from Ollama's /v1 endpoint?
It is the type field of the OpenAI-style error object Ollama returned with HTTP 404 when the model in the request was not on the server.

More decoded errors in the Fixes category. For a 404 whose body is 404 page not found, see the base URL post.