Download Video
curl --request GET \
--url https://api.gravitex.ai/v1/video/generations/download \
--header 'Authorization: <authorization>'Download Video
GET
/
v1
/
video
/
generations
/
download
Download Video
curl --request GET \
--url https://api.gravitex.ai/v1/video/generations/download \
--header 'Authorization: <authorization>'Documentation Index
Fetch the complete documentation index at: https://docs.gravitex.ai/llms.txt
Use this file to discover all available pages before exploring further.
Introduction
The download video API is used to retrieve completed video file data. Note: This API is only supported for Sora 2 models. For other models (Veo, Ali Wanxiang, Doubao Seedance), the video URL is directly included in the query task API response after the task succeeds, and no additional download step is required.Authentication
Bearer Token, e.g.
Bearer sk-xxxxxxxxxxQuery Parameters
Video ID, which is the
task_id returned by the query task APIUsage Example
curl -X GET "https://api.gravitex.ai/v1/video/generations/download?id=video_69095b4ce0048190893a01510c0c98b0" \
-H "Authorization: Bearer sk-xxxxxxxxxx"
Response Example
{
"success": true,
"generation_id": "video_69095b4ce0048190893a01510c0c98b0",
"task_id": "video_69095b4ce0048190893a01510c0c98b0",
"format": "mp4",
"size": 15728640,
"base64": "AAAAIGZ0eXBpc29tAAACAGlzb21pc28yYXZjMW1wNDEAAAAIZnJlZQAAB...",
"data_url": "data:video/mp4;base64,AAAAIGZ0eXBpc29tAAACAGlzb21pc28yYXZjMW1wNDEAAAAIZnJlZQAAB..."
}
Response Field Description
| Field | Type | Description |
|---|---|---|
success | boolean | Success status |
generation_id | string | Generation ID (same as videoId) |
task_id | string | Task ID |
format | string | Video format (fixed as "mp4") |
size | number | Video file size (bytes) |
base64 | string | Base64 encoded video data |
data_url | string | Data URL format video data, can be used directly in frontend <video> tags |
Usage Instructions
Frontend Usage with data_url
Thedata_url field can be used directly in HTML <video> tags:
<video src="data:video/mp4;base64,AAAAIGZ0eXBpc29tAAACAGlzb21pc28yYXZjMW1wNDEAAAAIZnJlZQAAB..." controls></video>
Download and Save File
Use thebase64 field to save the video as a file:
JavaScript Example
// Get base64 data from response
const response = await fetch('https://api.gravitex.ai/v1/video/generations/download?id=video_xxx', {
headers: {
'Authorization': 'Bearer sk-xxxxxxxxxx'
}
});
const data = await response.json();
// Convert base64 to Blob
const binaryString = atob(data.base64);
const bytes = new Uint8Array(binaryString.length);
for (let i = 0; i < binaryString.length; i++) {
bytes[i] = binaryString.charCodeAt(i);
}
const blob = new Blob([bytes], { type: 'video/mp4' });
// Create download link
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = 'video.mp4';
a.click();
URL.revokeObjectURL(url);
Python Example
import requests
import base64
def download_video(video_id, api_key):
"""Download video and save as file"""
url = f"https://api.gravitex.ai/v1/video/generations/download?id={video_id}"
headers = {"Authorization": f"Bearer {api_key}"}
response = requests.get(url, headers=headers)
data = response.json()
if data.get("success"):
# Decode base64 data
video_data = base64.b64decode(data["base64"])
# Save as file
with open("video.mp4", "wb") as f:
f.write(video_data)
print(f"✅ Video saved: video.mp4 (size: {data['size']} bytes)")
return True
else:
print("❌ Download failed")
return False
Complete Workflow Example (Sora 2)
-
Submit Video Generation Task
Response:
curl -X POST "https://api.gravitex.ai/v1/video/generations" \ -H "Authorization: Bearer sk-xxxxxxxxxx" \ -H "Content-Type: application/json" \ -d '{ "model": "sora-2", "prompt": "A cute little cat playing in the garden", "seconds": "4", "size": "720x1280" }'{ "task_id": "video_69095b4ce0048190893a01510c0c98b0", "status": "submitted", "format": "mp4" } -
Query Task Status (poll until success)
When status is
curl -X GET "https://api.gravitex.ai/v1/video/generations/video_69095b4ce0048190893a01510c0c98b0" \ -H "Authorization: Bearer sk-xxxxxxxxxx"succeeded, proceed to next step. -
Download Video File
curl -X GET "https://api.gravitex.ai/v1/video/generations/download?id=video_69095b4ce0048190893a01510c0c98b0" \ -H "Authorization: Bearer sk-xxxxxxxxxx"
Related APIs
Submit Video Task
Submit video generation task
Query Video Task
Query video generation task status and results
⌘I