Dall-e API load jpg from url to instagram

This is for private use only.

I currently run a python script on a Raspberry Pi to generate a Dall-e URL. That works nicely. Now I want to upload the generated picture to my private instagram account. This works well already for pictures on a https:// site if the url ends with “.jpg”. The Dall-e endpoint however does not have this ending, and just appending “.jpg” does not work.

Anyone have an idea how I can solve this? I can save the Dall-e picture to my local desktop as a .jpg, but then the instagram POST does not work, as it needs a https:// address for the POST.

Thanks.

I would get the response as B64 and save it yourself locally. Lot cleaner that way. Good luck.

1 Like

Thanks. As I wrote, saving locally works already. However to post to insta I need a https:// address with .jpg ending. Any proposal?

(What puzzles me is that I tried with postman 2 days ago with just the Dall-e URL, and there it worked.)

You do know the URL supplied only lasts an hour or so, correct?

What’s your upload code look like?

1 Like

Yes. Creating a Dall-e picture and posting is in one python script. So should only take a couple of seconds.

I use the post as described here: Media - Instagram Platform - Documentation - Meta for Developers

This successfully works for jpg files already, however not for the Dall-e URL

Just upload it to an image host after you get it from DALL-E, use the Imgur link in your script.

Alternatively you might be able to just rename the file and add a .png to the end of it.

If the script only works with .jpg files (might be a Instagram limitation) then a simple convert will be enough.

https://docs.wand-py.org/en/0.6.11/guide/write.html#convert-images-to-jpeg

Hi, thanks for your proposals. In the meantime I found the issue: it is the “%2B” in the Dall-e URL that generates the problem:
When I want to upload to Instagram with “requests.post(url)”, then Instagram somehow thinks this part of the URL is a “+” sign, converts and replaces it, and the upload fails.

Any proposal how to solve this? I am searching in the web since several days now, but everything I tried so far does not work.

Thanks.

Problem with %2B in Dall-e URL - API - OpenAI Developer Forum

Solution from Foxabilo works. See other thread.