I tried this too… Ran curl to generate the otter image and then ran it to edit the image. Both completed without error, but the otter in the edited image had no hat.
@echo off
curl https://api.openai.com/v1/images/edits ^
-H "Authorization: Bearer MYAPIKEY" ^
-F image="@sea_otter_rgba.png" ^
-F prompt="Add a hat to the otter" ^
-F n=2 ^
-F size="1024x1024" > output.json
No error messages were returned, which suggests correct syntax was used. So, something else is going on. Since these commands come from the API reference, I was hoping the simple starter examples would work. Once these curl examples are working, plan to do the same in Python.
I don’t think I ever got it working with curl and ended up using the library… It has something to do with the filetype being created, though, IIRC - the alpha channel?
The image edits endpoint allows you to edit and extend an image by uploading a mask. The transparent areas of the mask indicate where the image should be edited, and the prompt should describe the full new image, not just the erased area . This endpoint can enable experiences like the editor in our DALL·E preview app.
Thanks Paul, I think i’ll drop Curl, and try using another language… The code you pasted looks like PHP? Is that worth a try? I was thinking to try Python.
I started this thread and I neglected to mark my solution - I had to adjust the format
That said…
Pedantically curl is not a language, it is a programme
My advice is to use curl to prototype using the API. There is a small amount of command syntax to learn, about five things in total. There is nothing to get in your way.
If you cannot get an API call working with curl then you have a misunderstanding.
Stick with curl on the command line and switch out to programming when you thoroughly understand how it works.
Thanks. How did you adjust the format ? Here’s the curl command I’m using:
@echo off
:: Scriptname: openai_curl_image_edit.bat
set PROMPT_TEXT=“A white siamese cat wearing a red hat”
echo %PROMPT_TEXT%
curl https://api.openai.com/v1/images/edits ^
-H “Authorization: Bearer ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■g8piZeCX” ^
-F image=“@white_cat_rgba.png” ^
-F prompt=%PROMPT_TEXT% ^
-F n=2 ^
-F size=“1024x1024” > output.json
type output.json
After changing format of the input file to RGBA, no error messages were generated but the Siamese cat doesn’t get a hat. Maybe need to add a mask file but need to figure out how to make those.