"AttributeError: module 'openai' has no attribute 'Image'"

I’m getting the above error when I run the following code:

import os
import openai
openai.api_key = os.getenv("key")
  prompt="A cute baby sea otter",

The error points to line five, and it kicks out:
AttributeError: module 'openai' has no attribute 'Images'

I installed openai via pip/pip3 in

1 Like

You need to update the package.

pip install -U openai

should solve this issue.


Thank you, I will give it a shot! Does anyone know what version of OpenAI started to have the image attribute?

When I run

pip show openai

I see:

Version: 0.8.0


Ok, so short of the long: I was using an old version of OpenAI. But it would not upgrade, because the latest version of python I had running was Python 3.8.

I upgraded Python, created a virtual environment, and installed openai 0.25.0 using pip.

The old version of Python was preventing openai package from updating past something insanely old like 0.8.0, which did not have the Image functions.

Now we’re off to the races. Thank you @vaibhav.garg !


Thanks for coming back to explain. Hopefully this helps someone in the future! Glad you got it sorted.

1 Like

I tried every thing mentioned above but I still get error
File “C:\Users\DELL\OneDrive\Documents\leet_python\openai.py”, line 5, in
response = openai.Image.create(

AttributeError: partially initialized module ‘openai’ has no attribute ‘Image’ (most likely due to a circular import)
I am using openai version 0.26.5 and python version 3.9.7
Complete program is
import openai
PROMPT = “An eco-friendly computer from the 90s in the style of vaporwave”
openai.api_key = “■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■45rVGzyG”
response = openai.Image().create(

Try renaming your python program:

Causes a circular import; you have named your python program the same name as the module. Rename your program to


The issue is covered here.

1 Like