Skip to content

Commit 62f3a1b

Browse files
committed
fix: when api_key is None, the request should not contain 'Authorization': f 'Bearer {api_key}'. openai#961
1 parent a8fa0de commit 62f3a1b

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/openai/_client.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,9 @@ def qs(self) -> Querystring:
170170
@override
171171
def auth_headers(self) -> dict[str, str]:
172172
api_key = self.api_key
173-
return {"Authorization": f"Bearer {api_key}"}
173+
if api_key :
174+
return {"Authorization": f"Bearer {api_key}"}
175+
return {}
174176

175177
@property
176178
@override
@@ -401,7 +403,9 @@ def qs(self) -> Querystring:
401403
@override
402404
def auth_headers(self) -> dict[str, str]:
403405
api_key = self.api_key
404-
return {"Authorization": f"Bearer {api_key}"}
406+
if api_key :
407+
return {"Authorization": f"Bearer {api_key}"}
408+
return {}
405409

406410
@property
407411
@override

0 commit comments

Comments
 (0)