Skip to content

TypeError: object ImagesResponse can't be used in 'await' expression #723

@Showdown76py

Description

@Showdown76py

With AsyncOpenAI, openai.images.generate does not work correctly when it is used with await, but it works without await. This seems to work perfectly in NodeJS, but not here in Python.

Example code:

response = await openai.images.generate(
    model="dall-e-3",
    prompt=prompt,
    n=1,
    quality="hd",
    response_format="b64_json",
    size=("792x1024"
)

And here is the traceback:

Traceback (most recent call last):
  File "app.py", line 83, in dall_e
    response = await openai.images.generate(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: object ImagesResponse can't be used in 'await' expression

By removing await, it works correctly, but it is obviously not running asynchronously.

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