Cannot import name 'OpenAI' from 'openai'

Try pip install openai==0.28

Worked for me

1 Like

Had the same problem today. I’ using openai 1.3.2 and Python 3.10. This did the trick for me

from openai._client import OpenAI
client = OpenAI(api_key = 'API_KEY')
2 Likes

Since 1.3.2 came out thirteen hours ago, one wonders if you did not actually have the same problem, just the same symptom!

I updated the library (pip install --upgrade openai), and did not need any changes in the import or client code. Python 3.11.5.

This worked for me too, I’m on openai==1.3.6 with Python 3.11.6, thank you!

1 Like

Make sure your python file is not named as openai.py or rename any file with that name in your current folder of execution.

2 Likes

As this topic has a marked solution, closing topic.