Notice: MAI Image 2.7 launch limited-time 20% off, covering the full text-to-image and image editing lineup, try it now
Notice: Black Friday 2026 × Cyber Monday: Get up to 30% extra on top-ups, DeepSeek free to use · View the promotion
Blog

Tutorial

HiAPI Output URL Expired? Download Within 7 Days or Keep It Persistent

Why task output links stop working, what expireAt means, and two fixes: download right away, or keep files on HiAPI with persistent storage.

Jun 28, 2026 5
HiAPI Output URL Expired? Download Within 7 Days or Keep It Persistent
Temp links last
About 7 days
Persistent
$0.05 / GB·month
Downloads
Free
On this page

TL;DR

  • Output links from POST /v1/tasks are temporary: they're deleted about 7 days after the task finishes. expireAt on each output tells you exactly when, in Unix seconds.
  • If a link has already expired, it can't be revived. Querying the task again returns the same link, and re-running the task bills you again.
  • Two fixes: download the file as soon as the task succeeds, or keep it on HiAPI with "storage": "persistent" ($0.05 per GB per month). You can also promote a temporary output to persistent any time before it expires.

What a finished task looks like

This is a real task detail from GET https://api.hiapi.ai/v1/tasks/{taskId}:

{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "tk-hiapi-01M59F0HVM9QSCYPDT4BHABD3K",
    "model": "grok-imagine/text-to-image",
    "status": "success",
    "created": 1792392841,
    "completed": 1792392863,
    "storage": "temp",
    "output": [
      {
        "type": "image",
        "url": "https://temp.hiapi.ai/.../01M59F0HVM9QSCYPDT4BHABD3K-0.png",
        "expireAt": 1792997663
      }
    ]
  }
}
  • storage: "temp" is the default tier.
  • expireAt minus completed is 604,800 seconds, exactly 7 days. We checked four tasks, two images and two videos, and all four had the same 7-day window.
  • status moves through queued, handling and archiving before ending at success or fail. Only those last two are final.
  1. The link was saved instead of the file. A database row, a CMS field or a Notion page holds the temp.hiapi.ai URL. It works for a week, then breaks for everyone.
  2. The file was fetched late. A queue picks up the result days later, after expireAt.
  3. A batch job skipped the upload step. The logs look fine, and the files are gone a week later.
  4. An output was passed to the next task as an input. It works today but fails if the second task is re-run after the link expires.

Fix 1: download in the same code path

# pip install requests; export HIAPI_KEY=your-key first
import os, time, requests

API = "https://api.hiapi.ai/v1/tasks"
H = {"Authorization": f"Bearer {os.environ['HIAPI_KEY']}"}

def run_and_save(model, inp, path, timeout_s=600):
    r = requests.post(API, json={"model": model, "input": inp}, headers=H, timeout=30).json()
    if r.get("code") != 200:
        raise RuntimeError(r)
    task_id = r["data"]["taskId"]          # store this before polling
    deadline = time.time() + timeout_s
    while time.time() < deadline:
        d = requests.get(f"{API}/{task_id}", headers=H, timeout=30).json()["data"]
        if d["status"] == "success":
            out = d["output"][0]
            with open(path, "wb") as f:      # or upload to S3 / R2 here
                f.write(requests.get(out["url"], timeout=120).content)
            return task_id, out["expireAt"]
        if d["status"] == "fail":
            raise RuntimeError(d.get("error"))
        time.sleep(3)
    raise TimeoutError(task_id)

run_and_save("z-image", {"prompt": "a red ceramic teapot on a wooden table", "aspect_ratio": "1:1"},
             "teapot.png")

Save your own storage URL in the database, not the HiAPI link. If the process crashes after submitting, poll the stored taskId again instead of creating a new task; within the 7 days the file is still there.

Fix 2: keep the output on HiAPI

If you'd rather not run your own storage, ask HiAPI to keep the file:

curl -s -X POST https://api.hiapi.ai/v1/tasks \
  -H "Authorization: Bearer $HIAPI_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "z-image",
    "storage": "persistent",
    "input": {"prompt": "a red ceramic teapot on a wooden table", "aspect_ratio": "1:1"}
  }'

storage goes at the top level, next to model, not inside input. Check data.storage on the task detail: if your balance is too low or you're over your storage cap, the output quietly falls back to temp and the task still succeeds.

Already have temporary outputs you want to keep? Promote them before they expire. Get their ids from GET /v1/storages, then:

curl -s -X POST https://api.hiapi.ai/v1/storages/promote \
  -H "Authorization: Bearer $HIAPI_KEY" \
  -H "Content-Type: application/json" \
  -d '["90216", "90215"]'

Up to 50 ids per call. The response lists accepted and rejected ids, with a reason for each rejection, such as cap_exceeded. Promotion runs in the background; the file keeps its path and moves to the persistent domain. You can also promote from Dashboard → Storage.

temp (default) persistent
Kept for About 7 days Until you delete it
Cost Free $0.05 per GB per month, billed daily
Downloads Free Free
Size cap None 100 GB per account by default

What it costs: 5 GB stored for a month is $0.25; 50 GB is $2.50. Delete a file with POST /v1/storages/delete and the charge stops from the next day. There's no way to move a persistent file back to temporary.

If your balance can't cover storage for 3 days in a row, persistent files enter a 7-day grace period and you get an email. Top up and they stay; if the grace period runs out, they're deleted.

Which fix to use

  • You already have S3, R2 or a CDN: Fix 1. Download once and serve from your own storage.
  • You want links to keep working with no storage of your own: Fix 2 with "storage": "persistent".
  • You only need a few results kept: leave everything on temp and promote the ones you want.

FAQ

About 7 days after the task finishes. The exact time is in expireAt (Unix seconds) on each output.

No. GET /v1/tasks/{taskId} returns the same link. After it expires, the file is gone unless you promoted it.

Will re-running the task cost money?

Yes. A new task is billed again, which is why saving the file the first time is the cheap option.

Yes. Anyone with the URL can download the file, but the path is random and can't be guessed. Signed or private links aren't offered today.

Does persistent storage count videos too?

Yes. Every image, video and audio file you keep counts toward the stored size.

The full reference is in the Output Storage docs and the task detail docs.

Related articles

View all articles →

Start building with persistent AI artifacts

Get your API key and call image, video and audio models through one task-based API.

Read the API docs