Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support of empty api_key #1594

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/openai/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}"}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is we set api_key to None?
It should also handle situation in which API key is not set through argument of env variable.

return headers

@property
@override
Expand Down Expand Up @@ -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}"}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

return headers

@property
@override
Expand Down
Loading