diff --git a/src/openai/_client.py b/src/openai/_client.py index 8b404e234d..4cfd2c09b2 100644 --- a/src/openai/_client.py +++ b/src/openai/_client.py @@ -157,7 +157,8 @@ def qs(self) -> Querystring: @override def auth_headers(self) -> dict[str, str]: api_key = self.api_key - return {"Authorization": f"Bearer {api_key}"} + headers = {} if api_key == "" else {"Authorization": f"Bearer {api_key}"} + return headers @property @override @@ -371,7 +372,8 @@ def qs(self) -> Querystring: @override def auth_headers(self) -> dict[str, str]: api_key = self.api_key - return {"Authorization": f"Bearer {api_key}"} + headers = {} if api_key == "" else {"Authorization": f"Bearer {api_key}"} + return headers @property @override