Using image URL in images/edits request

It’s even easier! You just need to tell it to originally send the binary…

Each image can be returned as either a URL or Base64 data, using the response_format parameter. URLs will expire after an hour.

Note to @logankilpatrick — sent a chat to help about broken link in the API docs… points to localhost rather than the page…

It looks like this is fixed now on this page: OpenAI API

Let me know if it is still an issue on your end @PaulBellow

1 Like

Looks fine here now. Raf responded a while back.

Happy New Year. We’ve been trying to hold down the fort, so to speak. :wink:

1 Like

i’m still encountering issues with this endpoint. i’m now passing my PNGs exactly like the reference in the docs, but i’m getting
error: { code: null, message: "Invalid input image - format must be in ['RGBA', 'LA', 'L'], got 1.", param: null, type: 'invalid_request_error' }

image

Did you try the solution up-thread?

@PaulBellow yes. those return ‘message: ‘Uploaded image must be a PNG and less than 4 MB.’’, which is even further away from the last error i posted

There is another recent post in the community that may relevant. It talks about the file being 24 bit vs 32 bit PNG files.

My understanding is that the file.name setting in my example above is important in Typescript. It helps the AI understand that it is a valid PNG file. I suspect you may need to give your image and mask buffers names, and also cast them as type any

1 Like

didnt mean to tag you in that last reply, sorry raymon. thanks for the help, but it isn’t working for me sadly

1 Like

Do you have your code with the changes made?

Screenshot_1

image

i’m not even getting a useful error message anymore

Can you cast while calling a function?

I would set it up like one of the two examples above…

Also, you’re not setting image.name so it’s certain it’s a PNG… might be the problem?

more of the same. here’s all my code in one spot.


Screenshot_3

Can you upload the image and mask you’re using?

Are they 24bit or 32bit PNGs?

Is the normal generation endpoint working for you?

ETA: Might also try casting and setting up the images within the function?

1 Like

Can you also give us the console.log output for the response object (remove any sensitive info first)

If that is what is in the second image you posted, then response is undefined at the time the log is being called

1 Like

generation works. i’m using a function to save the generation response as a PNG, then using that as my edits image. i’m not sure if it’s 24b or 32b, but i’ll dig into it.

i do have some console logs in my code, but it seems they aren’t even triggering. i’m getting some massive block of data from the API, and the second image is what i can gather as the relevant part of it. i think it’s returning undefined because something is wrong with my request. hopefully it’s the bits thing.

I’m betting that might be something to do with it?

What are you using to save the PNG?

i’m using the npm library ‘image-downloader’

image

I’m starting to think maybe it’s not saving the PNG correctly…or rather, not saving in a form DALLE2 can use…

Can you upload the image and mask you’re using?

Might also try to return it as base64 rather than url…

Can you give us an example of what you get for the url variable?

Is it a url, or is it a string starting with “data:image/gif;base64,R0l” etc…

If it is undefined, can you also get the value for response.data[0][“url”]
Note: this only has one reference to data

I have some ideas - but the answer will help go in the right direction

Finally, can you also give the line where you define the download object in your final bit of code

https://oaidalleapiprodscus.blob.core.windows.net/private/org-iXQ5jPan1aYIFVj3pQgfwLh5/user-gGYciXCncqKJKkTnlOPE8Vpb/img-RA5juSiEiSrYwzvw3VmOz7PL.png?st=2023-01-12T00%3A40%3A55Z&se=2023-01-12T02%3A40%3A55Z&sp=r&sv=2021-08-06&sr=b&rscd=inline&rsct=image/png&skoid=6aaadede-4fb3-4698-a8f6-684d7786b067&sktid=a48cca56-e6da-484e-a814-9c849652bcb3&skt=2023-01-11T23%3A39%3A44Z&ske=2023-01-12T23%3A39%3A44Z&sks=b&skv=2021-08-06&sig=zhtFqp3gdVZWWBFSOqvXDDYQNBYlfjuk56sfhViwNeE%3D

this is a URL returned by my request to image generations. i’ve tried many different ways of converting both URL and b64 data to a valid PNG, but i had no idea what exactly constitutes such a thing. so i eventually ended up on the npm package ‘image-installer’, which is where the download object is from.

import * as download from 'image-downloader'

as for using b64 @PaulBellow, i’m just not certain how exactly to convert it to a valid PNG. i’ve tried several methods but haven’t landed on the right way. i knew absolutely nothing about images before this project, so it’s tough for me to identify where the issues are coming from

i tried logging the url response from edits, but it doesn’t even trigger the log. the call fails and logs a huge object that i’m not familiar with

image