From e4f9069aa618e27c6b48cfb957cd162bf338227e Mon Sep 17 00:00:00 2001 From: Takeshi Yoneda Date: Wed, 23 Oct 2024 10:34:08 -0700 Subject: [PATCH] Correctly set Accept header to text/event-stream for streaming Signed-off-by: Takeshi Yoneda --- src/openai/resources/chat/completions.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/openai/resources/chat/completions.py b/src/openai/resources/chat/completions.py index ceaf3c2fec..2bb2671fbb 100644 --- a/src/openai/resources/chat/completions.py +++ b/src/openai/resources/chat/completions.py @@ -812,6 +812,7 @@ def create( timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> ChatCompletion | Stream[ChatCompletionChunk]: validate_response_format(response_format) + extra_headers = {"Accept": "text/event-stream", **(extra_headers or {})} if stream else extra_headers return self._post( "/chat/completions", body=maybe_transform(