Confirm this is an issue with the Python library and not an underlying OpenAI API
Describe the bug
In v2.34.0, AsyncOpenAI(api_key="") now raises OpenAIError: Missing credentials. In v2.33.0 and earlier, passing an empty string was silently accepted.
This is a breaking change for anyone using the OpenAI Python SDK to talk to OpenAI-compatible local servers (llama.cpp, llamafile, LM Studio, vLLM, etc.) that do not require authentication. These wrappers intentionally pass api_key="" because no credentials are needed for a local HTTP server.
The root cause appears to be the new credential validation logic in _client.py around line 700, which now checks not self.api_key (falsy for ""), along with the new workload_identity and admin_api_key checks added in 2.34.0.
Previous behavior (v2.33.0): AsyncOpenAI(api_key="", base_url="http://localhost:8080/v1") succeeded and produced a usable client.
New behavior (v2.34.0): The same call raises:
openai.OpenAIError: Missing credentials. Please pass an `api_key`, `workload_identity`,
`admin_api_key`, or set the `OPENAI_API_KEY` or `OPENAI_ADMIN_KEY` environment variable.
The workaround is to pass a non-empty placeholder string (e.g., api_key="not-needed"), but this is surprising since api_key="" worked in all prior versions.
To Reproduce
- Install
openai==2.34.0
- Run the code below
- Observe
OpenAIError raised
Code snippets
from openai import AsyncOpenAI
# Works in 2.33.0, fails in 2.34.0
client = AsyncOpenAI(
api_key="",
base_url="http://localhost:8080/v1",
)
OS
Linux and macOS (all platforms)
Python version
Python 3.11, 3.12, 3.13
Library version
openai v2.34.0
Confirm this is an issue with the Python library and not an underlying OpenAI API
Describe the bug
In
v2.34.0,AsyncOpenAI(api_key="")now raisesOpenAIError: Missing credentials. Inv2.33.0and earlier, passing an empty string was silently accepted.This is a breaking change for anyone using the OpenAI Python SDK to talk to OpenAI-compatible local servers (llama.cpp, llamafile, LM Studio, vLLM, etc.) that do not require authentication. These wrappers intentionally pass
api_key=""because no credentials are needed for a local HTTP server.The root cause appears to be the new credential validation logic in
_client.pyaround line 700, which now checksnot self.api_key(falsy for""), along with the newworkload_identityandadmin_api_keychecks added in 2.34.0.Previous behavior (
v2.33.0):AsyncOpenAI(api_key="", base_url="http://localhost:8080/v1")succeeded and produced a usable client.New behavior (
v2.34.0): The same call raises:The workaround is to pass a non-empty placeholder string (e.g.,
api_key="not-needed"), but this is surprising sinceapi_key=""worked in all prior versions.To Reproduce
openai==2.34.0OpenAIErrorraisedCode snippets
OS
Linux and macOS (all platforms)
Python version
Python 3.11, 3.12, 3.13
Library version
openai v2.34.0