Генерация видео
Создание видео с помощью Sora
Создание видео по текстовому описанию.
POST
/v1/videos/generations
Python
import requests
response = requests.post(
"https://api.nixai.ru/v1/videos/generations",
headers={"Authorization": "Bearer YOUR_API_KEY"},
json={
"model": "sora-2",
"prompt": "Красивый закат над морем",
"aspect_ratio": "16:9",
"duration": "15"
}
)
task_id = response.json()["task_id"]
print(f"Task ID: {task_id}")
Node.js
const response = await fetch('https://api.nixai.ru/v1/videos/generations', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
model: 'sora-2',
prompt: 'Красивый закат над морем',
aspect_ratio: '16:9',
duration: '15'
})
});
const data = await response.json();
console.log(`Task ID: ${data.task_id}`);
cURL
curl -X POST "https://api.nixai.ru/v1/videos/generations" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "sora-2",
"prompt": "Красивый закат над морем",
"aspect_ratio": "16:9",
"duration": "15"
}'
Проверка статуса
Используйте полученный task_id для проверки статуса генерации.
POST
/v1/videos/fetch
Python
response = requests.post(
"https://api.nixai.ru/v1/videos/fetch",
headers={"Authorization": "Bearer YOUR_API_KEY"},
json={
"model": "sora-2",
"id": "video_db242923-11eb-44dc-bddf-d71a02ab5174"
}
)
result = response.json()
print(f"Status: {result['status']}")
if result['status'] == 'SUCCESS':
print(f"Video URL: {result['data']['output']}")
Node.js
const response = await fetch('https://api.nixai.ru/v1/videos/fetch', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
model: 'sora-2',
id: 'video_db242923-11eb-44dc-bddf-d71a02ab5174'
})
});
const result = await response.json();
console.log(`Status: ${result.status}`);
if (result.status === 'SUCCESS') {
console.log(`Video URL: ${result.data.output}`);
}
cURL
curl -X POST "https://api.nixai.ru/v1/videos/fetch" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "sora-2",
"id": "video_db242923-11eb-44dc-bddf-d71a02ab5174"
}'
Статусы выполнения
- NOT_START - Не запущено
- IN_PROGRESS - Выполняется
- SUCCESS - Выполнение завершено
- FAILURE - Не удалось