I am using exactly the same demo code here, but got below error:
---------------------------------------------------------------------------
BadRequestError Traceback (most recent call last)
Cell In[6], line 1
----> 1 response = client.images.edit(
2 model="dall-e-2",
3 image=open("sunlit_lounge.png", "rb"),
4 mask=open("mask.png", "rb"),
5 prompt="A sunlit indoor lounge area with a pool containing a flamingo",
6 n=1,
7 size="1024x1024"
8 )
9 image_url = response.data[0].url
10 print(image_url)
File ~/Library/Python/3.9/lib/python/site-packages/openai/resources/images.py:184, in Images.edit(self, image, prompt, mask, model, n, response_format, size, user, extra_headers, extra_query, extra_body, timeout)
179 if files:
180 # It should be noted that the actual Content-Type header that will be
181 # sent to the server will contain a `boundary` parameter, e.g.
182 # multipart/form-data; boundary=---abc--
183 extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})}
--> 184 return self._post(
185 "/images/edits",
186 body=maybe_transform(body, image_edit_params.ImageEditParams),
187 files=files,
188 options=make_request_options(
...
(...)
987 stream_cls=stream_cls,
988 )
BadRequestError: error, status code: 400, message: invalid character '-' in numeric literal
My code:
response = client.images.edit(
model="dall-e-2",
image=open("sunlit_lounge.png", "rb"),
mask=open("mask.png", "rb"),
prompt="A sunlit indoor lounge area with a pool containing a flamingo",
n=1,
size="1024x1024"
)
image_url = response.data[0].url
print(image_url)
Could you take a look?