Error using gpt-image-1 api with 'quality' parameter in image edit request and difference in playground

I’m experiencing an error in setting a ‘quality’ parameter with the new ‘gpt-image-1’ api for image edit request.

result = client.images.edit(
        image=open(image_path, "rb"),
        prompt=prompt,
        model="gpt-image-1",
        n=1,
        quality="low",
        size="1024x1536",
    )

The error message says :

 result = client.images.edit(
             ^^^^^^^^^^^^^^^^^^^
TypeError: Images.edit() got an unexpected keyword argument 'quality'

Does anyone else encounter this error as well? In the api document, it said that you can use ‘quality’ for image edit but it doesn’t seem working for me: https://platform.openai.com/docs/api-reference/images/createEdit. I can get the result without setting the ‘quality’ but couldn’t set the ‘quality’,

Also in the playground, I was able to create image edit request with reference image and quality setting to ‘low’, but when I check out the code from playground, it was using client.images.edits instead of client.images.edit as specified in the api document (see screenshot below). Is there different ways of creating request? :face_with_monocle:

1 Like

The Python library is blocking the previously unknown parameter from being sent.

You can update with pip install --upgrade openai

You can also ask a smart AI model how to use the “httpx” library to send multipart/form-data in the files parameter, using that for both the binary file and the “form” fields of parameters like prompt and quality.

I have this exact problem as well…

Hey,
Even after adding and upgrading the openai sdk.
Getting this error if sending quality as low
response = self.openai_client.images.edit(
model=“gpt-image-1”,
image=image_file_obj,
prompt=prompt,
n=1,
size=size,
user=userId,
quality=“low”,
)

"Failed to generate image from image: 500: {‘message’: ‘An unexpected error has occurred. We are working on it.’, ‘description’: "OpenAI API error: Images.edit() got an unexpected keyword argument ‘quality’", ‘canRetry’: True}

Pls help