Skip to content
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
4 changes: 4 additions & 0 deletions src/openai/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ def __init__(

self.workload_identity = workload_identity if provider_runtime is None else None

_api_key_provided = api_key is not None
if provider_runtime is not None:
self.api_key = ""
self._api_key_provider = None
Expand Down Expand Up @@ -224,6 +225,7 @@ def __init__(
provider_runtime is None
and _enforce_credentials
and not self.api_key
and not _api_key_provided

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Permit requests when an explicit empty API key is supplied

For OpenAI(api_key="", base_url=...) and the mirrored async path, construction now succeeds, but a standard generated request still fails before reaching the local server: _bearer_auth returns no header for the empty key, and _validate_headers then raises TypeError because Authorization is absent. Preserve the explicit-empty-key state through request-time validation, or automatically treat Authorization as intentionally omitted, so this change restores actual local-server calls rather than only client construction.

Useful? React with 👍 / 👎.

and self._api_key_provider is None
and workload_identity is None
and self.admin_api_key is None
Expand Down Expand Up @@ -803,6 +805,7 @@ def __init__(

self.workload_identity = workload_identity if provider_runtime is None else None

_api_key_provided = api_key is not None
if provider_runtime is not None:
self.api_key = ""
self._api_key_provider = None
Expand Down Expand Up @@ -830,6 +833,7 @@ def __init__(
provider_runtime is None
and _enforce_credentials
and not self.api_key
and not _api_key_provided
and self._api_key_provider is None
and workload_identity is None
and self.admin_api_key is None
Expand Down