High severity beginner · Fix: 2-5 min

ExpiredDownloadUrlError

replicate.exceptions.ExpiredDownloadUrlError

What this error means
Replicate's output URL expired error occurs when the temporary download link for model output is accessed after its short validity period.

Stack trace

traceback
replicate.exceptions.ExpiredDownloadUrlError: The output URL has expired and can no longer be used to download the result.
QUICK FIX
Download the output immediately after prediction completes or re-fetch the output URL from the model output object before downloading.

Why it happens

Replicate generates temporary URLs for model outputs that expire quickly (usually within minutes) for security and resource management. Attempting to download the output after this expiration window causes this error.

Detection

Monitor the time elapsed between output creation and download attempt; log and check for ExpiredDownloadUrlError exceptions to catch expired URLs before retrying.

Causes & fixes

1

Downloading output after the replicate output URL's short expiration time (usually a few minutes).

✓ Fix

Download the output immediately after the model run completes or cache the output locally before the URL expires.

2

Storing the output URL and reusing it later instead of fetching a fresh URL from the model output object.

✓ Fix

Always access the output URL directly from the latest model output object instead of reusing old URLs.

3

Network delays or retries causing the download attempt to happen after the URL expiration.

✓ Fix

Implement retry logic that refreshes the output URL by re-fetching the model output or rerunning the prediction if the URL expired.

Code: broken vs fixed

Broken - triggers the error
python
import replicate

client = replicate.Client(api_token=os.environ['REPLICATE_API_TOKEN'])
model = client.models.get('stability-ai/stable-diffusion')
version = model.versions.get('some-version-id')

prediction = client.predictions.create(version=version.id, input={'prompt': 'a cat'})

# Waiting too long before accessing output URL
output_url = prediction.output[0]  # This URL may expire

import requests
response = requests.get(output_url)  # This line triggers ExpiredDownloadUrlError
print(response.content)
Fixed - works correctly
python
import os
import replicate
import requests

client = replicate.Client(api_token=os.environ['REPLICATE_API_TOKEN'])
model = client.models.get('stability-ai/stable-diffusion')
version = model.versions.get('some-version-id')

prediction = client.predictions.create(version=version.id, input={'prompt': 'a cat'})

# Access output URL immediately from prediction object
output_url = prediction.output[0]  # Fresh URL

response = requests.get(output_url)  # Download immediately to avoid expiration
print(response.content)  # Fixed: download done before URL expires
Changed code to download output immediately after prediction to avoid using an expired URL.

Workaround

Catch ExpiredDownloadUrlError, then re-fetch the prediction output object or rerun the prediction to get a fresh output URL before retrying the download.

Prevention

Design your system to download or cache outputs immediately after prediction completes, and avoid storing or reusing output URLs beyond their short expiration window.

Python 3.8+ · replicate >=0.7.0 · tested on 0.8.x
Verified 2026-04
Verify ↗

Community Notes

No notes yetBe the first to share a version-specific fix or tip.