[GH-ISSUE #2861] use the /api/chat API,always response empty content #27506

Closed
opened 2026-04-22 04:53:53 -05:00 by GiteaMirror · 6 comments
Owner

Originally created by @NullpointerW on GitHub (Mar 1, 2024).
Original GitHub issue: https://github.com/ollama/ollama/issues/2861

request:

curl --location 'http://localhost:11434/api/chat' \
--header 'Content-Type: application/json' \
--data '{
    "model": "gemma:7b-instruct-fp16",
    "message": [
        {
            "role": "user",
            "content": "why is the skyw blue?"
        }
    ]
}'

always return:

{
    "model": "gemma:7b-instruct-fp16",
    "created_at": "2024-03-01T11:17:53.3907871Z",
    "message": {
        "role": "assistant",
        "content": ""
    },
    "done": true
}
Originally created by @NullpointerW on GitHub (Mar 1, 2024). Original GitHub issue: https://github.com/ollama/ollama/issues/2861 request: ``` curl curl --location 'http://localhost:11434/api/chat' \ --header 'Content-Type: application/json' \ --data '{ "model": "gemma:7b-instruct-fp16", "message": [ { "role": "user", "content": "why is the skyw blue?" } ] }' ``` always return: ``` json { "model": "gemma:7b-instruct-fp16", "created_at": "2024-03-01T11:17:53.3907871Z", "message": { "role": "assistant", "content": "" }, "done": true } ```
Author
Owner

@pdevine commented on GitHub (Mar 1, 2024):

What type of system do you have? Also can you post the server logs? That particular model is pretty sizeable so requires a beefy system. Also check to make certain you're running Ollama 0.1.26 or later as gemma requires a newer version.

<!-- gh-comment-id:1973634296 --> @pdevine commented on GitHub (Mar 1, 2024): What type of system do you have? Also can you post the server logs? That particular model is pretty sizeable so requires a beefy system. Also check to make certain you're running Ollama 0.1.26 or later as gemma requires a newer version.
Author
Owner

@pdevine commented on GitHub (Mar 1, 2024):

I just realized it was because you used message vs. messages. Try:

% curl --location 'http://localhost:11434/api/chat' \
--header 'Content-Type: application/json' \
--data '{
    "model": "gemma:7b-instruct-fp16",
    "messages": [
        {
            "role": "user",
            "content": "why is the skyw blue?"
        }
    ]
}'
<!-- gh-comment-id:1973645454 --> @pdevine commented on GitHub (Mar 1, 2024): I just realized it was because you used `message` vs. `messages`. Try: ``` % curl --location 'http://localhost:11434/api/chat' \ --header 'Content-Type: application/json' \ --data '{ "model": "gemma:7b-instruct-fp16", "messages": [ { "role": "user", "content": "why is the skyw blue?" } ] }' ```
Author
Owner

@pdevine commented on GitHub (Mar 1, 2024):

I'm going to go ahead and close the issue. Hope this helps though!

<!-- gh-comment-id:1973650825 --> @pdevine commented on GitHub (Mar 1, 2024): I'm going to go ahead and close the issue. Hope this helps though!
Author
Owner

@NullpointerW commented on GitHub (Mar 1, 2024):

I'm going to go ahead and close the issue. Hope this helps though!

You are right,thanks a lot.

<!-- gh-comment-id:1973709616 --> @NullpointerW commented on GitHub (Mar 1, 2024): > I'm going to go ahead and close the issue. Hope this helps though! You are right,thanks a lot.
Author
Owner

@zamzx commented on GitHub (Apr 9, 2024):

I just realized it was because you used message vs. messages. Try:

% curl --location 'http://localhost:11434/api/chat' \
--header 'Content-Type: application/json' \
--data '{
    "model": "gemma:7b-instruct-fp16",
    "messages": [
        {
            "role": "user",
            "content": "why is the skyw blue?"
        }
    ]
}'

Yay! message vs messages got me! Now my first ollama scripting adventure is well underway.
Thank you internet stranger! ^_^

<!-- gh-comment-id:2044063050 --> @zamzx commented on GitHub (Apr 9, 2024): > I just realized it was because you used `message` vs. `messages`. Try: > > ``` > % curl --location 'http://localhost:11434/api/chat' \ > --header 'Content-Type: application/json' \ > --data '{ > "model": "gemma:7b-instruct-fp16", > "messages": [ > { > "role": "user", > "content": "why is the skyw blue?" > } > ] > }' > ``` Yay! message vs messages got me! Now my first ollama scripting adventure is well underway. Thank you internet stranger! ^_^
Author
Owner

@danydin commented on GitHub (Jun 30, 2024):

I just realized it was because you used message vs. messages. Try:

% curl --location 'http://localhost:11434/api/chat' \
--header 'Content-Type: application/json' \
--data '{
    "model": "gemma:7b-instruct-fp16",
    "messages": [
        {
            "role": "user",
            "content": "why is the skyw blue?"
        }
    ]
}'

haha gosh i had the same typo.. programming can be so annoying sometimes without even any error messages which makes it seems like it all went fine, why there was no error coming from requesting non existing key though..?

<!-- gh-comment-id:2198460958 --> @danydin commented on GitHub (Jun 30, 2024): > I just realized it was because you used `message` vs. `messages`. Try: > > ``` > % curl --location 'http://localhost:11434/api/chat' \ > --header 'Content-Type: application/json' \ > --data '{ > "model": "gemma:7b-instruct-fp16", > "messages": [ > { > "role": "user", > "content": "why is the skyw blue?" > } > ] > }' > ``` haha gosh i had the same typo.. programming can be so annoying sometimes without even any error messages which makes it seems like it all went fine, why there was no error coming from requesting non existing key though..?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#27506