Skip to content

Throw exception if API key ENV vars are empty #2092

Open
@iloveitaly

Description

@iloveitaly

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

If you use an ENV var for setting the API key, and the ENV happens to be empty, no exception is thrown until a call is made and the exception is ambiguous (i.e., not clear that the token is empty).

To Reproduce

export OPENAI_API_KEY=""

and use the completions API

Code snippets

OS

15.3

Python version

v3.13.1

Library version

1.61.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions