Once a generation job is successful, the API returns a list of assetIds (or a single assetId in the job metadata). To get the actual file URL (e.g., to download the image or video), you must query the specific asset endpoint.
Endpoint: GET https://api.cloud.scenario.com/v1/assets/{assetId}
Python Example
This script assumes you already have the asset_id from the previous step (e.g., from the job.metadata.assetIds list).
import requests
import base64
# Configuration
API_KEY = "YOUR_API_KEY"
API_SECRET = "YOUR_API_SECRET"
ASSET_ID = "asset_1gHMbHjSjWYLyAnd7ZxzPkcQ" # Replace with your actual Asset ID
# Authentication
auth_str = f"{API_KEY}:{API_SECRET}"
b64_auth = base64.b64encode(auth_str.encode()).decode()
headers = {
"Authorization": f"Basic {b64_auth}",
"Accept": "application/json"
}
def get_asset_url(asset_id):
url = f"https://api.cloud.scenario.com/v1/assets/{asset_id}"
try:
response = requests.get(url, headers=headers)
response.raise_for_status()
data = response.json()
asset_url = data['asset']['url']
print(f"Successfully retrieved Asset URL:")
print(asset_url)
return asset_url
except requests.exceptions.RequestException as e:
print(f"Error retrieving asset: {e}")
# Run the function
get_asset_url(ASSET_ID)
JSON Response Structure
When you call this endpoint, the API returns the asset details, including the direct url.
{
"asset": {
"id": "asset_1gHMbHjSjWYLyAnd7ZxzPkcQ",
"url": "https://cdn.scenario.com/assets/asset_1gHMbHjSjWYLyAnd7ZxzPkcQ.png",
"type": "image",
"createdAt": "2024-03-20T10:00:00Z",
"metadata": {
"prompt": "A futuristic city..."
}
}
}
📘 For more details: Check the full reference in the Scenario Documentation.
Was this helpful?