@@ -272,6 +272,8 @@ def chat_completion(
272272 extra_body : Body | None = None ,
273273 timeout : float | httpx .Timeout | None | NotGiven = NOT_GIVEN ,
274274 ) -> ChatCompletionResponse | Stream [ChatCompletionResponseStreamChunk ]:
275+ if stream :
276+ extra_headers = {"Accept" : "text/event-stream" , ** (extra_headers or {})}
275277 return self ._post (
276278 "/v1/inference/chat-completion" ,
277279 body = maybe_transform (
@@ -451,6 +453,8 @@ def completion(
451453 extra_body : Body | None = None ,
452454 timeout : float | httpx .Timeout | None | NotGiven = NOT_GIVEN ,
453455 ) -> CompletionResponse | Stream [CompletionResponse ]:
456+ if stream :
457+ extra_headers = {"Accept" : "text/event-stream" , ** (extra_headers or {})}
454458 return self ._post (
455459 "/v1/inference/completion" ,
456460 body = maybe_transform (
@@ -751,6 +755,8 @@ async def chat_completion(
751755 extra_body : Body | None = None ,
752756 timeout : float | httpx .Timeout | None | NotGiven = NOT_GIVEN ,
753757 ) -> ChatCompletionResponse | AsyncStream [ChatCompletionResponseStreamChunk ]:
758+ if stream :
759+ extra_headers = {"Accept" : "text/event-stream" , ** (extra_headers or {})}
754760 return await self ._post (
755761 "/v1/inference/chat-completion" ,
756762 body = await async_maybe_transform (
@@ -930,6 +936,8 @@ async def completion(
930936 extra_body : Body | None = None ,
931937 timeout : float | httpx .Timeout | None | NotGiven = NOT_GIVEN ,
932938 ) -> CompletionResponse | AsyncStream [CompletionResponse ]:
939+ if stream :
940+ extra_headers = {"Accept" : "text/event-stream" , ** (extra_headers or {})}
933941 return await self ._post (
934942 "/v1/inference/completion" ,
935943 body = await async_maybe_transform (
0 commit comments