From a7c4fd039453508b8b0492efb172b28fb0da518f Mon Sep 17 00:00:00 2001 From: Stainless Bot <107565488+stainless-bot@users.noreply.github.com> Date: Fri, 16 Feb 2024 19:00:54 -0500 Subject: [PATCH] chore(client): use correct accept headers for binary data (#1161) --- src/openai/resources/audio/speech.py | 2 ++ src/openai/resources/files.py | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/openai/resources/audio/speech.py b/src/openai/resources/audio/speech.py index 4e94d4aaef..fbdc1ecff1 100644 --- a/src/openai/resources/audio/speech.py +++ b/src/openai/resources/audio/speech.py @@ -78,6 +78,7 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ + extra_headers = {"Accept": "application/octet-stream", **(extra_headers or {})} return self._post( "/audio/speech", body=maybe_transform( @@ -149,6 +150,7 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ + extra_headers = {"Accept": "application/octet-stream", **(extra_headers or {})} return await self._post( "/audio/speech", body=maybe_transform( diff --git a/src/openai/resources/files.py b/src/openai/resources/files.py index 58a2a217c7..8b2bc4f181 100644 --- a/src/openai/resources/files.py +++ b/src/openai/resources/files.py @@ -238,6 +238,7 @@ def content( """ if not file_id: raise ValueError(f"Expected a non-empty value for `file_id` but received {file_id!r}") + extra_headers = {"Accept": "application/binary", **(extra_headers or {})} return self._get( f"/files/{file_id}/content", options=make_request_options( @@ -272,7 +273,6 @@ def retrieve_content( """ if not file_id: raise ValueError(f"Expected a non-empty value for `file_id` but received {file_id!r}") - extra_headers = {"Accept": "application/json", **(extra_headers or {})} return self._get( f"/files/{file_id}/content", options=make_request_options( @@ -511,6 +511,7 @@ async def content( """ if not file_id: raise ValueError(f"Expected a non-empty value for `file_id` but received {file_id!r}") + extra_headers = {"Accept": "application/binary", **(extra_headers or {})} return await self._get( f"/files/{file_id}/content", options=make_request_options( @@ -545,7 +546,6 @@ async def retrieve_content( """ if not file_id: raise ValueError(f"Expected a non-empty value for `file_id` but received {file_id!r}") - extra_headers = {"Accept": "application/json", **(extra_headers or {})} return await self._get( f"/files/{file_id}/content", options=make_request_options(