From beba53e3c249bee161f5b7f5e637f09b9da3fdca Mon Sep 17 00:00:00 2001 From: rusdevops Date: Sat, 3 Aug 2024 15:13:41 +0300 Subject: [PATCH] add support of empty api_key --- src/openai/_client.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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