비디오 다운로드
curl --request GET \
--url https://api.gravitex.ai/v1/video/generations/download \
--header 'Authorization: <authorization>'import requests
url = "https://api.gravitex.ai/v1/video/generations/download"
headers = {"Authorization": "<authorization>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: '<authorization>'}};
fetch('https://api.gravitex.ai/v1/video/generations/download', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.gravitex.ai/v1/video/generations/download",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.gravitex.ai/v1/video/generations/download"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "<authorization>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.gravitex.ai/v1/video/generations/download")
.header("Authorization", "<authorization>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.gravitex.ai/v1/video/generations/download")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = '<authorization>'
response = http.request(request)
puts response.read_body비디오 다운로드
GET
/
v1
/
video
/
generations
/
download
비디오 다운로드
curl --request GET \
--url https://api.gravitex.ai/v1/video/generations/download \
--header 'Authorization: <authorization>'import requests
url = "https://api.gravitex.ai/v1/video/generations/download"
headers = {"Authorization": "<authorization>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: '<authorization>'}};
fetch('https://api.gravitex.ai/v1/video/generations/download', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.gravitex.ai/v1/video/generations/download",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.gravitex.ai/v1/video/generations/download"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "<authorization>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.gravitex.ai/v1/video/generations/download")
.header("Authorization", "<authorization>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.gravitex.ai/v1/video/generations/download")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = '<authorization>'
response = http.request(request)
puts response.read_body소개
비디오 다운로드 API는 완료된 비디오 파일 데이터를 가져오는 데 사용됩니다. 참고: 이 API는 Sora 2 모델에서만 지원됩니다. 다른 모델(Veo, Ali Wanxiang, Doubao Seedance)은 작업이 성공한 후 조회 작업 API 응답에 비디오 URL이 직접 포함되므로 별도의 다운로드 단계가 필요하지 않습니다.인증
string
必填
Bearer Token, 예:
Bearer sk-xxxxxxxxxx쿼리 매개변수
string
必填
비디오 ID, 조회 작업 API에서 반환된
task_id사용 예제
curl -X GET "https://api.gravitex.ai/v1/video/generations/download?id=video_69095b4ce0048190893a01510c0c98b0" \
-H "Authorization: Bearer sk-xxxxxxxxxx"
응답 예제
{
"success": true,
"generation_id": "video_69095b4ce0048190893a01510c0c98b0",
"task_id": "video_69095b4ce0048190893a01510c0c98b0",
"format": "mp4",
"size": 15728640,
"base64": "AAAAIGZ0eXBpc29tAAACAGlzb21pc28yYXZjMW1wNDEAAAAIZnJlZQAAB...",
"data_url": "data:video/mp4;base64,AAAAIGZ0eXBpc29tAAACAGlzb21pc28yYXZjMW1wNDEAAAAIZnJlZQAAB..."
}
응답 필드 설명
| 필드 | 타입 | 설명 |
|---|---|---|
success | boolean | 성공 여부 |
generation_id | string | 생성 ID (videoId와 동일) |
task_id | string | 작업 ID |
format | string | 비디오 형식 ("mp4" 고정) |
size | number | 비디오 파일 크기(바이트) |
base64 | string | Base64로 인코딩된 비디오 데이터 |
data_url | string | Data URL 형식의 비디오 데이터, 프론트엔드 <video> 태그에서 바로 사용 가능 |
사용 안내
data_url을 사용한 프론트엔드 사용
data_url 필드는 HTML <video> 태그에서 바로 사용할 수 있습니다:
<video src="data:video/mp4;base64,AAAAIGZ0eXBpc29tAAACAGlzb21pc28yYXZjMW1wNDEAAAAIZnJlZQAAB..." controls></video>
파일 다운로드 및 저장
base64 필드를 사용하여 비디오를 파일로 저장합니다:
JavaScript 예제
// 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 예제
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
전체 워크플로 예제 (Sora 2)
-
비디오 생성 작업 제출
응답:
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" } -
작업 상태 조회 (성공할 때까지 폴링)
curl -X GET "https://api.gravitex.ai/v1/video/generations/video_69095b4ce0048190893a01510c0c98b0" \ -H "Authorization: Bearer sk-xxxxxxxxxx"status가succeeded이면 다음 단계로 진행합니다. -
비디오 파일 다운로드
curl -X GET "https://api.gravitex.ai/v1/video/generations/download?id=video_69095b4ce0048190893a01510c0c98b0" \ -H "Authorization: Bearer sk-xxxxxxxxxx"
관련 API
비디오 작업 제출
비디오 생성 작업 제출
비디오 작업 조회
비디오 생성 작업 상태 및 결과 조회
⌘I
