Skip to content

AssertionError: openai package is not installed or the API key is not set #122

@mhaugestad

Description

@mhaugestad

I am running into an error: AssertionError: openai package is not installed or the API key is not set.

I am certain that both the openai package is installed and I have the API set as environment variable OPENAI_API_KEY.

openai version 1.11.1
chatarena version 0.1.18

When I run the following code in the same environment 'is_openai_available' resolves to True.

try:
import openai
except ImportError:
is_openai_available = False
# logging.warning("openai package is not installed")
else:
try:
client = openai.OpenAI(api_key=os.environ.get("OPENAI_API_KEY"))
is_openai_available = True
except openai.OpenAIError:
# logging.warning("OpenAI API key is not set. Please set the environment variable OPENAI_API_KEY")
is_openai_available = False

Any ideas what could be causing this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions