[GH-ISSUE #7277] Error occurred: Error code: 400 - {'error': {'message': 'unexpected EOF', 'type': 'invalid_request_error', 'param': None, 'code': None}} #66679

Closed
opened 2026-05-04 07:47:13 -05:00 by GiteaMirror · 8 comments
Owner

Originally created by @ghost on GitHub (Oct 20, 2024).
Original GitHub issue: https://github.com/ollama/ollama/issues/7277

What is the issue?

using local computer can run :from openai import OpenAI
client = OpenAI(
base_url='http://.........:8000/v1/',
api_key='ollama', # required but ignored
)
chat_completion = client.chat.completions.create(
messages=[
{
'role': 'user',
'content': 'Say this is a test',
}
],
model='qwen2.5:72b',
)
print(chat_completion)but at the other computer :Error occurred: Error code: 400 - {'error': {'message': 'unexpected EOF', 'type': 'invalid_request_error', 'param': None, 'code': None}}

OS

Linux, Windows

GPU

No response

CPU

No response

Ollama version

0.3.13

Originally created by @ghost on GitHub (Oct 20, 2024). Original GitHub issue: https://github.com/ollama/ollama/issues/7277 ### What is the issue? using local computer can run :from openai import OpenAI client = OpenAI( base_url='http://.........:8000/v1/', api_key='ollama', # required but ignored ) chat_completion = client.chat.completions.create( messages=[ { 'role': 'user', 'content': 'Say this is a test', } ], model='qwen2.5:72b', ) print(chat_completion)but at the other computer :Error occurred: Error code: 400 - {'error': {'message': 'unexpected EOF', 'type': 'invalid_request_error', 'param': None, 'code': None}} ### OS Linux, Windows ### GPU _No response_ ### CPU _No response_ ### Ollama version 0.3.13
GiteaMirror added the bugapi labels 2026-05-04 07:47:14 -05:00
Author
Owner

@rick-github commented on GitHub (Oct 20, 2024):

Default port for ollama is 11434, your script is using 8000. Did you configure the ollama server to use port 8000?

<!-- gh-comment-id:2424961153 --> @rick-github commented on GitHub (Oct 20, 2024): Default port for ollama is 11434, your script is using 8000. Did you configure the ollama server to use port 8000?
Author
Owner

@ghost commented on GitHub (Oct 22, 2024):

Default port for ollama is 11434, your script is using 8000. Did you configure the ollama server to use port 8000?

yes,and I can curl this

<!-- gh-comment-id:2428814282 --> @ghost commented on GitHub (Oct 22, 2024): > Default port for ollama is 11434, your script is using 8000. Did you configure the ollama server to use port 8000? yes,and I can curl this
Author
Owner

@rick-github commented on GitHub (Oct 22, 2024):

What's the output of that curl?

<!-- gh-comment-id:2428824444 --> @rick-github commented on GitHub (Oct 22, 2024): What's the output of that curl?
Author
Owner

@ghost commented on GitHub (Oct 22, 2024):

What's the output of that curl?
curl http://:8000/api/ps

StatusCode : 200
StatusDescription : OK
Content : {"models":[{"name":"qwen2.5:72b","model":"qwen2.5:72b","size":54438088704,"digest":"424bad2cc13f72f5
bcd8085de63f48e7ef2ae5bf50a30be4b3ade7d3258f5796","details":{"parent_model":"","format":"gguf","fami
...
RawContent : HTTP/1.1 200 OK
Content-Length: 361
Content-Type: application/json; charset=utf-8
Date: Sun, 20 Oct 2024 12:44:14 GMT

            {"models":[{"name":"qwen2.5:72b","model":"qwen2.5:72b","size":54438088704,"d...

Forms : {}
Headers : {[Content-Length, 361], [Content-Type, application/json; charset=utf-8], [Date, Sun, 20 Oct 2024 12:
44:14 GMT]}
Images : {}
InputFields : {}
Links : {}
ParsedHtml : mshtml.HTMLDocumentClass
RawContentLength : 361

<!-- gh-comment-id:2428837457 --> @ghost commented on GitHub (Oct 22, 2024): > What's the output of that curl? curl http://:8000/api/ps StatusCode : 200 StatusDescription : OK Content : {"models":[{"name":"qwen2.5:72b","model":"qwen2.5:72b","size":54438088704,"digest":"424bad2cc13f72f5 bcd8085de63f48e7ef2ae5bf50a30be4b3ade7d3258f5796","details":{"parent_model":"","format":"gguf","fami ... RawContent : HTTP/1.1 200 OK Content-Length: 361 Content-Type: application/json; charset=utf-8 Date: Sun, 20 Oct 2024 12:44:14 GMT {"models":[{"name":"qwen2.5:72b","model":"qwen2.5:72b","size":54438088704,"d... Forms : {} Headers : {[Content-Length, 361], [Content-Type, application/json; charset=utf-8], [Date, Sun, 20 Oct 2024 12: 44:14 GMT]} Images : {} InputFields : {} Links : {} ParsedHtml : mshtml.HTMLDocumentClass RawContentLength : 361
Author
Owner

@ghost commented on GitHub (Oct 22, 2024):

What's the output of that curl?

$response = Invoke-WebRequest -Uri http://:8000/api/generate -Method POST -Body '{"model": "qwen2.5:72b", "prompt": "为什么草是绿的?"}' -ContentType 'application/json'
PS D:\test>
PS D:\test> $rawContent = $response.RawContent
PS D:\test> $lines = $rawContent -split "`n" #
PS D:\test> foreach ($line in $lines) {

try {
    $json = $line | ConvertFrom-Json
    $json
} catch {
    Write-Host "无法解析的行:$line"
}

}
无法解析的行:HTTP/1.1 200 OK
无法解析的行:Transfer-Encoding: chunked
无法解析的行:Content-Type: application/x-ndjson
无法解析的行:Date: Sun, 20 Oct 2024 13:26:24 GMT

model created_at response done


qwen2.5:72b 2024-10-20T13:26:24.488869105Z ?????? False
qwen2.5:72b 2024-10-20T13:26:24.565323044Z ??? False
qwen2.5:72b 2024-10-20T13:26:24.642167784Z ????????? False
qwen2.5:72b 2024-10-20T13:26:24.710467701Z ?????? False
qwen2.5:72b 2024-10-20T13:26:24.777325371Z ?????? False
qwen2.5:72b 2024-10-20T13:26:24.844375228Z ?????? False
qwen2.5:72b 2024-10-20T13:26:24.906853638Z ?????? False
qwen2.5:72b 2024-10-20T13:26:24.967298989Z ?????? False
qwen2.5:72b 2024-10-20T13:26:25.027440419Z ?????? False
qwen2.5:72b 2024-10-20T13:26:25.087232675Z ??? False
qwen2.5:72b 2024-10-20T13:26:25.144918405Z ????????? False
qwen2.5:72b 2024-10-20T13:26:25.200894836Z ????????? False
qwen2.5:72b 2024-10-20T13:26:25.255961725Z ?????? False
qwen2.5:72b 2024-10-20T13:26:25.309884705Z ??? False
qwen2.5:72b 2024-10-20T13:26:25.363755727Z ?????? False
qwen2.5:72b 2024-10-20T13:26:25.417717815Z ?????? False
qwen2.5:72b 2024-10-20T13:26:25.470564486Z ??? False
qwen2.5:72b 2024-10-20T13:26:25.523020636Z ?????? False
qwen2.5:72b 2024-10-20T13:26:25.575704171Z ?????? False
qwen2.5:72b 2024-10-20T13:26:25.628040761Z ????????? False
qwen2.5:72b 2024-10-20T13:26:25.680473446Z ??? False
qwen2.5:72b 2024-10-20T13:26:25.732600809Z ???? False
qwen2.5:72b 2024-10-20T13:26:25.785217302Z True

<!-- gh-comment-id:2428841304 --> @ghost commented on GitHub (Oct 22, 2024): > What's the output of that curl? $response = Invoke-WebRequest -Uri http://:8000/api/generate -Method POST -Body '{"model": "qwen2.5:72b", "prompt": "为什么草是绿的?"}' -ContentType 'application/json' PS D:\test> PS D:\test> $rawContent = $response.RawContent PS D:\test> $lines = $rawContent -split "`n" # PS D:\test> foreach ($line in $lines) { >> try { >> $json = $line | ConvertFrom-Json >> $json >> } catch { >> Write-Host "无法解析的行:$line" >> } >> } 无法解析的行:HTTP/1.1 200 OK 无法解析的行:Transfer-Encoding: chunked 无法解析的行:Content-Type: application/x-ndjson 无法解析的行:Date: Sun, 20 Oct 2024 13:26:24 GMT model created_at response done ----- ---------- -------- ---- qwen2.5:72b 2024-10-20T13:26:24.488869105Z ?????? False qwen2.5:72b 2024-10-20T13:26:24.565323044Z ??? False qwen2.5:72b 2024-10-20T13:26:24.642167784Z ????????? False qwen2.5:72b 2024-10-20T13:26:24.710467701Z ?????? False qwen2.5:72b 2024-10-20T13:26:24.777325371Z ?????? False qwen2.5:72b 2024-10-20T13:26:24.844375228Z ?????? False qwen2.5:72b 2024-10-20T13:26:24.906853638Z ?????? False qwen2.5:72b 2024-10-20T13:26:24.967298989Z ?????? False qwen2.5:72b 2024-10-20T13:26:25.027440419Z ?????? False qwen2.5:72b 2024-10-20T13:26:25.087232675Z ??? False qwen2.5:72b 2024-10-20T13:26:25.144918405Z ????????? False qwen2.5:72b 2024-10-20T13:26:25.200894836Z ????????? False qwen2.5:72b 2024-10-20T13:26:25.255961725Z ?????? False qwen2.5:72b 2024-10-20T13:26:25.309884705Z ??? False qwen2.5:72b 2024-10-20T13:26:25.363755727Z ?????? False qwen2.5:72b 2024-10-20T13:26:25.417717815Z ?????? False qwen2.5:72b 2024-10-20T13:26:25.470564486Z ??? False qwen2.5:72b 2024-10-20T13:26:25.523020636Z ?????? False qwen2.5:72b 2024-10-20T13:26:25.575704171Z ?????? False qwen2.5:72b 2024-10-20T13:26:25.628040761Z ????????? False qwen2.5:72b 2024-10-20T13:26:25.680473446Z ??? False qwen2.5:72b 2024-10-20T13:26:25.732600809Z ???? False qwen2.5:72b 2024-10-20T13:26:25.785217302Z True
Author
Owner

@rick-github commented on GitHub (Oct 22, 2024):

Are you really using http://:8000/ in the curl request? Also, you can add "stream":false to the body so you don't need to write a for loop to process the output.

<!-- gh-comment-id:2428857316 --> @rick-github commented on GitHub (Oct 22, 2024): Are you really using `http://:8000/` in the curl request? Also, you can add `"stream":false` to the body so you don't need to write a for loop to process the output.
Author
Owner

@ghost commented on GitHub (Oct 22, 2024):

Are you really using http://:8000/ in the curl request? Also, you can add "stream":false to the body so you don't need to write a for loop to process the output.

Yes, I just hid the IP when I sent it. When I use this on my local machine, it’s not question marks but a normal text.

<!-- gh-comment-id:2428879523 --> @ghost commented on GitHub (Oct 22, 2024): > Are you really using `http://:8000/` in the curl request? Also, you can add `"stream":false` to the body so you don't need to write a for loop to process the output. Yes, I just hid the IP when I sent it. When I use this on my local machine, it’s not question marks but a normal text.
Author
Owner

@rick-github commented on GitHub (Oct 22, 2024):

Is your server on the same LAN as your local machine or is it a cloud server? Do you have any proxies or captive portals?

<!-- gh-comment-id:2429013040 --> @rick-github commented on GitHub (Oct 22, 2024): Is your server on the same LAN as your local machine or is it a cloud server? Do you have any proxies or captive portals?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#66679