Error "An error occurred: module 'openai' has no attribute 'Assistant'"

Would have been nice if you sent it in a code-block but either way, you need to define client in your code. Which according to their API is done using

client = OpenAI(
    # defaults to os.environ.get("OPENAI_API_KEY")
    api_key="My API Key",
)

The api_key parameter is optional, if you put your API key inside OPENAI_AP_KEY environment variable on your system.

1 Like