404 on /api/chat #13

Closed
opened 2026-02-15 16:27:27 -05:00 by yindo · 1 comment
Owner

Originally created by @leolivier on GitHub (Jan 28, 2024).

Hi,
I started ollama serve w/o issue
Then I tried ollama.list() which returned the 3 models I have pulled with a 200 code on /api/tags. One of these models is 'mistral:latest'
Then I tried ollama.show('mistral') and it returned an object with a license, a modelfile, ... and a code 200 on /api/show
Up to now, everything fine...
Then I tried the chat example code:

response = ollama.chat(model='mistral', messages=[
  {
    'role': 'user',
    'content': 'Why is the sky blue?',
  },
])
print(response['message']['content'])

and here I get a 404 code on /api/chat

$ python ollama-test.py
Traceback (most recent call last):
  File "/home/olivi/devt/ollama/ollama-test.py", line 9, in <module>
    response = ollama.chat(model='mistral', messages=[
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/olivi/miniconda3/envs/ollama/lib/python3.11/site-packages/ollama/_client.py", line 158, in chat
    return self._request_stream(
           ^^^^^^^^^^^^^^^^^^^^^
  File "/home/olivi/miniconda3/envs/ollama/lib/python3.11/site-packages/ollama/_client.py", line 81, in _request_stream
    return self._stream(*args, **kwargs) if stream else self._request(*args, **kwargs).json()
                                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/olivi/miniconda3/envs/ollama/lib/python3.11/site-packages/ollama/_client.py", line 57, in _request
    raise ResponseError(e.response.text, e.response.status_code) from None
ollama._types.ResponseError: 404 page not found

In the ollama server terminal:

[GIN] 2024/01/28 - 09:49:50 | 200 |       281.8µs |       127.0.0.1 | GET      "/api/tags"
[GIN] 2024/01/28 - 09:49:50 | 200 |         405µs |       127.0.0.1 | POST     "/api/show"
[GIN] 2024/01/28 - 09:56:49 | 404 |        24.4µs |       127.0.0.1 | POST     "/api/chat"

Than I tried:

response = generate('mistral', 'Why is the sky blue?')
print(response['response'])

which worked fine (code 200 on /api/generate')

So why a 404 on /api/chat? Is it because of an error in the lib or because mistral does provide a chat API?

Originally created by @leolivier on GitHub (Jan 28, 2024). Hi, I started ollama serve w/o issue Then I tried `ollama.list()` which returned the 3 models I have pulled with a 200 code on /api/tags. One of these models is 'mistral:latest' Then I tried `ollama.show('mistral')` and it returned an object with a license, a modelfile, ... and a code 200 on /api/show Up to now, everything fine... Then I tried the chat example code: ``` response = ollama.chat(model='mistral', messages=[ { 'role': 'user', 'content': 'Why is the sky blue?', }, ]) print(response['message']['content']) ``` and here I get a 404 code on /api/chat ``` $ python ollama-test.py Traceback (most recent call last): File "/home/olivi/devt/ollama/ollama-test.py", line 9, in <module> response = ollama.chat(model='mistral', messages=[ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/olivi/miniconda3/envs/ollama/lib/python3.11/site-packages/ollama/_client.py", line 158, in chat return self._request_stream( ^^^^^^^^^^^^^^^^^^^^^ File "/home/olivi/miniconda3/envs/ollama/lib/python3.11/site-packages/ollama/_client.py", line 81, in _request_stream return self._stream(*args, **kwargs) if stream else self._request(*args, **kwargs).json() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/olivi/miniconda3/envs/ollama/lib/python3.11/site-packages/ollama/_client.py", line 57, in _request raise ResponseError(e.response.text, e.response.status_code) from None ollama._types.ResponseError: 404 page not found ``` In the ollama server terminal: ``` [GIN] 2024/01/28 - 09:49:50 | 200 | 281.8µs | 127.0.0.1 | GET "/api/tags" [GIN] 2024/01/28 - 09:49:50 | 200 | 405µs | 127.0.0.1 | POST "/api/show" [GIN] 2024/01/28 - 09:56:49 | 404 | 24.4µs | 127.0.0.1 | POST "/api/chat" ``` Than I tried: ``` response = generate('mistral', 'Why is the sky blue?') print(response['response']) ``` which worked fine (code 200 on /api/generate') So why a 404 on /api/chat? Is it because of an error in the lib or because mistral does provide a chat API?
yindo closed this issue 2026-02-15 16:27:27 -05:00
Author
Owner

@leolivier commented on GitHub (Jan 28, 2024):

Update: I was running ollama 0.1.9. After updating to 0.1.22, it started working...

@leolivier commented on GitHub (Jan 28, 2024): Update: I was running ollama 0.1.9. After updating to 0.1.22, it started working...
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: ollama/ollama-python#13