Skip to content

AsyncOpenAI(api_key="") raises OpenAIError in v2.34.0, breaking OpenAI-compatible local servers #3224

@tbille

Description

@tbille

Confirm this is an issue with the Python library and not an underlying OpenAI API

  • This is an issue with the Python library

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

  1. Install openai==2.34.0
  2. Run the code below
  3. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions