Module 'openai' has no attribute 'Image'

Hello everyone, I received an email telling me that the API could now generate DALL-E images. Very happy, I looked in the documentation how to do it. I simply wanted to copy paste into a test file… I got the following error:

Traceback (most recent call last):
File “test.py”, line 6, in
response = openai.Image.create(
AttributeError: module ‘openai’ has no attribute ‘Image’

Here is my Python code:

import os
import openai

openai.api_key = "myKey"

response = openai.Image.create(
  prompt="a white siamese cat",
  n=1,
  size="1024x1024"
)

image_url = response['data'][0]['url']
print(str(image_url))

Anyone had the same error? I tried to update via PIP the “openai” module but it is not that apparently. Thanks for your help

1 Like

Hey @pougaud please share what version of the package you are using by doing pip list.

1 Like

Answer here.

me too ,openai 0.8.0

Module ‘openai’ has no attribute ‘Image’

pip3 uninstall openai && pip3 install openai will ensure everything gets updated to the latest version of the library and that will solve your problem

1 Like