Saving an AI image to your website or project: why you should download it

All in One AIAI Images·· 8 views· 3 min read

In short: when the image is ready, you get links to the files in outputs. Those links are not permanent. If you put them straight into your website, the image may disappear one day. Download the file and keep your own copy, on the website or in the project.

Where the links are

Through the API, call GET /v1/media/generations/{id} until the status is completed. The links are in the outputs list and the real cost in credits_charged. The full request, from start to end, is in creating AI images through the API.

Downloading with curl

Replace the text in quotes with the link from outputs. -o gives the file its name and -L follows a redirect, if there is one:

curl -L -o hero.jpg "<link from outputs>"

The file format depends on the model. In the example in our documentation, the output_format field chooses jpeg (the default) or png: give the file the right extension.

Downloading in your program

In Python, right after the check that returned completed (job is that generation):

import requests

url = job["outputs"][0]
with open("hero.jpg", "wb") as f:
f.write(requests.get(url, timeout=60).content)

With aio and with the MCP server

The aio command downloads on its own to the --out folder. If the generation did not finish within the waiting time, download it later with aio status:

aio generate image "a bakery shop window at dawn" --opt size=1024x1024 --out images/
aio status <id> --download --out images/

In a coding agent with the MCP server, ask it to save the file in the project, for example: "Generate a square image of a modern office with plants and morning light, and save it to public/img/hero.png."

Before you put the image on your website

1 Optimise the file, so the page does not get heavy: see image optimisation and WebP.
2 Give it a clear name and alt text: see alt text and file names for images.
3 If the image sits further down the page, use lazy loading: see what to defer and what never to.
4 Check what the image shows before you publish: see what to check before you publish.
Also keep the prompt (the text you wrote) and the model id next to the file. They help you make more images in the same style.

Need more images? Choose the model and see the price in All in One AI.

See All in One AI

SEE ALSO

Image optimisation and WebP

Alt text and file names for images: what to write, and what to avoid

Making images with AI for your website: what to check before you publish

Creating AI images through the API: the request, the status and saving the file

All in One AI

RECOMMENDED PRODUCT

Web hosting with cPanel

Domain and SSL included, daily backups and the panel you already know. from $5.36/mo (3-year plan, with coupon)

See plans
Was this answer helpful? Your answer helps us improve this article.