Problem with Public access to DALLE-generated URLs

Hi All - can somebody just please explain what the status is with the URLs returned by the DALLE API “response_format”:“url” when generating an image and why they’re not accessible?

I have good reasons for not wanting to use the b64_json option (which someone else has posted here that this was their workaround for the issue), not least because of the overhead of handling and decoding 4mb strings over the wire. I just want to use the URL and inject it into an img tag on the page and there are many examples of people having successfully done this.

However, it seems that any URL generated is not accessible either when pasted into the address bar or immediately used within an img tag as the error occurs

Has the security status changed for these URLs since people have posted about using them in their img tags and if so what is the solution? Is there any way to use the API key to somehow authenticate with the generated URL or am I just missing something daft?!

Thank you.

1 Like

The URLs expire (timeout). The last time I checked a few weeks ago, the timeout was around 2 hours, so if you try to use the URLS after that time, they are “gone”.

What I do is to immediately save the image to disk (in a public folder accessible via the web) after I generate an image and then I use “my URL” to the image and not the OpenAI URL.

Note sure if this helps or now.

Hope it does.

:slight_smile:

Hi and thanks a lot for taking the time reply! I was aware of the 2 hour window but to be honest that’s fine for our purposes - we just want to give our website users a bit of inspiration as opposed to making the images downloadable for them. Plus the server overhead of handling potentially 100s of 4mb files is too much currently, so we just wanted to show the image as a “one-off” using the OpenAI-hosted URLs. Other people seem to be able to embed these inside IMG tags and it works fine eg How to Generate Images using React and the Dall-E 2 API – React and OpenAI API Tutorial

Thanks again.

It is easy to set a crontab function or job to periodically delete the local images, BTW.

So, it’s really not a problem.

It’s not the storage which is the issue but the drain on resources downloading 4mb files. I just need to understand why other people are able to use the OpenAI-hosted URLs even if only temporarily. Thanks.

1 Like

It is hard to know why code works or not without seeing the code.

However, if you open your browser web dev console, you should be able to easily see any errors causing this to fail.

It’s not a coding issue as the URL is successfully generated…I just need to know why I can’t use it within an IMG tag as other people have done The error on the console is as above - “Server Failed to Authenticate the Request. Make sure the value of Authorization header is formed correctly including the signature” and what the workaround is if any.

Thanks.

I am not talking about API coding.

I’m taking about your HTML code which you use to embed the temporary Dall-E URL on your web site.

It’s literally just < img src=" < DALLEURL > " > < /img > !

Yes, and the browser dev console will generally show you the exact error of why it is broken.

:slight_smile:

Anyway, best of luck.

In all my apps, I found it best to immediately download the image and to not depend on the OpenAPI provided URL for anything at all.

Maybe someone else can help you better than me; since we use different approaches.

Thanks a lot. So just assuming that nobody can help with this and I need to download the image…I’ve just thought that actually how do you do that without needing to pass the API token? As presumably the REST call will only return either b64_json or url so you then need to get the URL via another call - so don’t you hit any public access/security issues?

I have a similar issue. I’m trying to post the image to Instagram but the image cannot be fetched from the URL. Having to download them would add a lot of overhead because I would have to download the image the upload it somewhere to create a public URL and then use that to post to IG.

This thread might be helpful for you?

Good luck.

I am having this same issue, urls are immediately giving an AuthenticationFailed error. Did you happen to find a solution?