Hi, I’m encountering an issue while using the Assistants API with the gpt-4o model via the OpenAI Python SDK.
I consistently receive the following error: httpx.RemoteProtocolError: peer closed connection without sending complete message body (incomplete chunked read)
Log:
Traceback (most recent call last):
File “/Users/Documents/venv/lib/python3.12/site-packages/httpx/_transports/default.py”, line 101, in map_httpcore_exceptions
yield
File “/Users/Documents/venv/lib/python3.12/site-packages/httpx/_transports/default.py”, line 127, in iter
for part in self._httpcore_stream:
File “/Users/Documents/venv/lib/python3.12/site-packages/httpcore/_sync/connection_pool.py”, line 407, in iter
raise exc from None
File “/Users/Documents/venv/lib/python3.12/site-packages/httpcore/_sync/connection_pool.py”, line 403, in iter
for part in self._stream:
File “/Users/Documents/venv/lib/python3.12/site-packages/httpcore/_sync/http11.py”, line 342, in iter
raise exc
File “/Users/Documents/venv/lib/python3.12/site-packages/httpcore/_sync/http11.py”, line 334, in iter
for chunk in self._connection._receive_response_body(**kwargs):
File “/Users/Documents/venv/lib/python3.12/site-packages/httpcore/_sync/http11.py”, line 203, in _receive_response_body
event = self._receive_event(timeout=timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/Users/Documents/venv/lib/python3.12/site-packages/httpcore/_sync/http11.py”, line 213, in _receive_event
with map_exceptions({h11.RemoteProtocolError: RemoteProtocolError}):
File “/Users/.pyenv/versions/3.12.2/lib/python3.12/contextlib.py”, line 158, in exit
self.gen.throw(value)
File “/Users/Documents/venv/lib/python3.12/site-packages/httpcore/_exceptions.py”, line 14, in map_exceptions
raise to_exc(exc) from exc
httpcore.RemoteProtocolError: peer closed connection without sending complete message body (incomplete chunked read)
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File “/Users/Documents/app/routes/assistant_stream.py”, line 133, in stream_run_events
for event in run:
File “/Users/Documents/venv/lib/python3.12/site-packages/openai/_streaming.py”, line 46, in iter
for item in self._iterator:
File “/Users/Documents/venv/lib/python3.12/site-packages/openai/_streaming.py”, line 58, in stream
for sse in iterator:
File “/Users/Documents/venv/lib/python3.12/site-packages/openai/_streaming.py”, line 50, in _iter_events
yield from self._decoder.iter_bytes(self.response.iter_bytes())
File “/Users/Documents/venv/lib/python3.12/site-packages/openai/_streaming.py”, line 278, in iter_bytes
for chunk in self._iter_chunks(iterator):
File “/Users/Documents/venv/lib/python3.12/site-packages/openai/_streaming.py”, line 289, in _iter_chunks
for chunk in iterator:
File “/Users/Documents/venv/lib/python3.12/site-packages/httpx/_models.py”, line 897, in iter_bytes
for raw_bytes in self.iter_raw():
File “/Users/Documents/venv/lib/python3.12/site-packages/httpx/_models.py”, line 951, in iter_raw
for raw_stream_bytes in self.stream:
File “/Users/Documents/venv/lib/python3.12/site-packages/httpx/_client.py”, line 153, in iter
for chunk in self._stream:
File “/Users/Documents/venv/lib/python3.12/site-packages/httpx/_transports/default.py”, line 126, in iter
with map_httpcore_exceptions():
File “/Users/.pyenv/versions/3.12.2/lib/python3.12/contextlib.py”, line 158, in exit
self.gen.throw(value)
File “/Users/Documents/venv/lib/python3.12/site-packages/httpx/_transports/default.py”, line 118, in map_httpcore_exceptions
raise mapped_exc(message) from exc
httpx.RemoteProtocolError: peer closed connection without sending complete message body (incomplete chunked read)
Environment:
Model: gpt-4o
OpenAI SDK Version: 2.8.1
