i appreciate the help, because you’re clarifying things i was unsure about. after diving back in, i’ve concluded that i don’t think this is my root issue (sadly)… i’m pretty sure sending an API request with the ‘image’ paramater as data from an open ai API response is triggering a CORS issue. my guess is that my api key would be exposed in the image data, thus visible to the front end(??)
it’s a bummer because i was hoping to use js to programmatically create story books. a cover image would be created first, then several others created through the images/edits endpoint, using the cover image as a ‘home base’. but i don’t think i can do it without creating a db to store the image, or a backend API to call open ai as a third party API, or something along those lines(??)
hopefully open AI can do something in the future to make this use case easier to achieve, and if it’s already possible (which i’m sure is likely the case) that the docs be refreshed for future development
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' }
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
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.
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