
You asked ChatGPT to generate an image, and now you want that file somewhere else — in your app, your docs, your pipeline. Digging through the generation metadata or the network tab, you found a gen_id and went looking for the download endpoint that accepts it. There isn't one. A gen_id is not a file handle, and requests aimed at the app's own image infrastructure fail like this:
HTTP 422
{"detail":[{"type":"missing","loc":["query","p"],"msg":"Field required","input":null},
{"type":"missing","loc":["query","ts"],"msg":"Field required","input":null}]}
HTTP 404
<Error><Code>ResourceNotFound</Code>
<Message>The specified resource does not exist.</Message></Error>
This guide covers what a gen_id actually is, every way that does work to retrieve an image you generated, and the API route to use when you need downloadable image URLs programmatically.
Ordered by how often each one is the real blocker:
gen_id is internal generation metadata, not a file reference. It identifies a generation inside your conversation so that follow-up requests ("edit that one") can point at it. No public endpoint accepts a gen_id and returns an image file — there is nothing to call.chatgpt.com/backend-api/... carry a timestamp and signature in the query string (ts, p, and friends). Paste one somewhere that truncates query params and you get the 422 above, listing the missing fields; let it age past its window and it stops authenticating.404 ResourceNotFound.The pattern behind all four: a consumer chat app's images are served for that app's UI, not for programmatic retrieval. Deep-diving the same failure modes: ChatGPT image gen_id URLs explained.
Work down this checklist:
gen_id. Inside the original conversation, the generation it points to can still be referenced for a follow-up edit or re-render. Outside that conversation, the id resolves to nothing — regenerating is the only path. There is no id-to-file exchange, so treat gen_id values as disposable.backend-api or oaiusercontent links. Those rows will keep breaking one by one. Where the links still load in your own browser, download each image and re-upload it to storage you control; where they've already expired, regenerate. Then store your URL.On hiapi, gpt-image-2 (the model behind ChatGPT-grade image generation) is available through the unified task endpoint — see the gpt-image-2 model page for capabilities, and the live pricing page, which lists gpt-image-2/text-to-image at $0.03 per image.
Create a task with the bare model id — gpt-image-2, no pipeline suffix (suffixed ids are rejected with a 400):
curl -X POST https://api.hiapi.ai/v1/tasks \
-H "Authorization: Bearer $HIAPI_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-image-2",
"input": {"prompt": "a lighthouse at dawn, soft fog", "aspect_ratio": "1:1", "resolution": "1K"}
}'
A succeeding call returns {"code":200,"data":{"taskId":"..."}}. If you get HTTP 401 instead:
{"error":{"code":"permission_denied","message":"This API key cannot use the selected model. Please check permissions or use another key. ...","request_id":"...","type":"hiapi_error"}}
your key is missing, mistyped, or not permitted for the model — check the authentication docs and your key in the dashboard.
Then poll the task and download the output the moment it succeeds:
curl -s https://api.hiapi.ai/v1/tasks/$TASK_ID -H "Authorization: Bearer $HIAPI_KEY"
# when "status":"success": fetch output[0].url before its expireAt
curl -s -o lighthouse.png "<output[0].url>"
Note the symmetry: output[0].url is also a signed link with an explicit expireAt — but unlike a chat app, the API hands you the URL precisely so you can download the file. Pull the bytes immediately, upload them to your own bucket or CDN, and store that URL in your database. That copy is your stable image URL. Full field-by-field reference: Create Task; on handling expiry: hiapi output URL expired: download before it expires.
Is there any endpoint — official or not — that downloads an image by gen_id?
No public endpoint resolves a gen_id to a file. Anything claiming to is guessing at private app internals that can change or break at any time. Retrieval paths that work: the in-app download button, or generating via an API that returns an output file URL.
Can I pass a ChatGPT gen_id to an image API to fetch or edit that image?
No. The id only has meaning inside the conversation that produced it. To edit an image elsewhere, download the file first, then use it as input — for example, image-to-image on hiapi takes public image URLs as input references.
How do I get a permanent URL for an AI-generated image? Host it yourself. Every image service — chat apps and APIs alike — serves generated files through signed, expiring links. Download the bytes while the link is valid, upload to your own storage (R2, S3, anything), and reference your copy.
Where do my hiapi-generated images live after the task finishes?
In the task result: poll GET /v1/tasks/{taskId} until status is success, then read output[0].url. The URL carries an expireAt timestamp — download before then; after expiry, re-run the task.
Why did my saved ChatGPT image link break after a few days when it worked at first?
It was a signed, session-scoped link. The signature in the query string has a validity window, and the file itself can age out — after either, you get the 422 (missing/invalid signature params) or 404 ResourceNotFound responses shown above.