MAGI-2
Проверка статуса
Возвращает состояние задачи по task_id. Опрос возможен только тем
API-ключом, которым задача была создана. Рекомендуемый интервал опроса —
5–10 секунд. Завершающие статусы: completed, rejected, failed.
POST
/
v1
/
videos
/
fetch
Проверка статуса видео
curl --request POST \
--url https://api.nixai.ru/v1/videos/fetch \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "magi-2",
"id": "b22c9ae2-0b55-4398-88df-0191aae664f0"
}
'import requests
url = "https://api.nixai.ru/v1/videos/fetch"
payload = {
"model": "magi-2",
"id": "b22c9ae2-0b55-4398-88df-0191aae664f0"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({model: 'magi-2', id: 'b22c9ae2-0b55-4398-88df-0191aae664f0'})
};
fetch('https://api.nixai.ru/v1/videos/fetch', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));const url = 'https://api.nixai.ru/v1/videos/fetch';
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({model: 'magi-2', id: 'b22c9ae2-0b55-4398-88df-0191aae664f0'})
};
fetch(url, options)
.then(res => res.json())
.then(json => console.log(json))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.nixai.ru/v1/videos/fetch",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model' => 'magi-2',
'id' => 'b22c9ae2-0b55-4398-88df-0191aae664f0'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.nixai.ru/v1/videos/fetch"
payload := strings.NewReader("{\n \"model\": \"magi-2\",\n \"id\": \"b22c9ae2-0b55-4398-88df-0191aae664f0\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.nixai.ru/v1/videos/fetch")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"magi-2\",\n \"id\": \"b22c9ae2-0b55-4398-88df-0191aae664f0\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.nixai.ru/v1/videos/fetch")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"magi-2\",\n \"id\": \"b22c9ae2-0b55-4398-88df-0191aae664f0\"\n}"
response = http.request(request)
puts response.read_body$headers=@{}
$headers.Add("Authorization", "Bearer <token>")
$headers.Add("Content-Type", "application/json")
$response = Invoke-WebRequest -Uri 'https://api.nixai.ru/v1/videos/fetch' -Method POST -Headers $headers -ContentType 'application/json' -Body '{
"model": "magi-2",
"id": "b22c9ae2-0b55-4398-88df-0191aae664f0"
}'import Foundation
let parameters = [
"model": "magi-2",
"id": "b22c9ae2-0b55-4398-88df-0191aae664f0"
] as [String : Any?]
let postData = try JSONSerialization.data(withJSONObject: parameters, options: [])
let url = URL(string: "https://api.nixai.ru/v1/videos/fetch")!
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.timeoutInterval = 10
request.allHTTPHeaderFields = [
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
]
request.httpBody = postData
let (data, _) = try await URLSession.shared.data(for: request)
print(String(decoding: data, as: UTF8.self))using RestSharp;
var options = new RestClientOptions("https://api.nixai.ru/v1/videos/fetch");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddHeader("Authorization", "Bearer <token>");
request.AddJsonBody("{\n \"model\": \"magi-2\",\n \"id\": \"b22c9ae2-0b55-4398-88df-0191aae664f0\"\n}", false);
var response = await client.PostAsync(request);
Console.WriteLine("{0}", response.Content);
using RestSharp;
var options = new RestClientOptions("https://api.nixai.ru/v1/videos/fetch");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddHeader("Authorization", "Bearer <token>");
request.AddJsonBody("{\n \"model\": \"magi-2\",\n \"id\": \"b22c9ae2-0b55-4398-88df-0191aae664f0\"\n}", false);
var response = await client.PostAsync(request);
Console.WriteLine("{0}", response.Content);
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({model: 'magi-2', id: 'b22c9ae2-0b55-4398-88df-0191aae664f0'})
};
fetch('https://api.nixai.ru/v1/videos/fetch', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_WRITEDATA, stdout);
curl_easy_setopt(hnd, CURLOPT_URL, "https://api.nixai.ru/v1/videos/fetch");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Authorization: Bearer <token>");
headers = curl_slist_append(headers, "Content-Type: application/json");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{\n \"model\": \"magi-2\",\n \"id\": \"b22c9ae2-0b55-4398-88df-0191aae664f0\"\n}");
CURLcode ret = curl_easy_perform(hnd);CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_WRITEDATA, stdout);
curl_easy_setopt(hnd, CURLOPT_URL, "https://api.nixai.ru/v1/videos/fetch");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Authorization: Bearer <token>");
headers = curl_slist_append(headers, "Content-Type: application/json");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{\n \"model\": \"magi-2\",\n \"id\": \"b22c9ae2-0b55-4398-88df-0191aae664f0\"\n}");
CURLcode ret = curl_easy_perform(hnd);val client = OkHttpClient()
val mediaType = MediaType.parse("application/json")
val body = RequestBody.create(mediaType, "{\n \"model\": \"magi-2\",\n \"id\": \"b22c9ae2-0b55-4398-88df-0191aae664f0\"\n}")
val request = Request.Builder()
.url("https://api.nixai.ru/v1/videos/fetch")
.post(body)
.addHeader("Authorization", "Bearer <token>")
.addHeader("Content-Type", "application/json")
.build()
val response = client.newCall(request).execute()falsefalse{
"task_id": "b22c9ae2-0b55-4398-88df-0191aae664f0",
"status": "processing"
}Опрашивайте эндпоинт, пока
Если передать
Задача, которую запрашивают чужим API-ключом, не находится: опрашивать её можно только тем ключом, которым она была создана.
Сообщения
Сообщение
status не станет completed, rejected или failed. Рекомендуемый интервал опроса — 5–10 секунд. Генерация обычно занимает несколько минут; длинные ролики могут генерироваться дольше.
Статусы
| Статус | Значение |
|---|---|
processing | Задача выполняется. |
completed | Видео готово, ссылка в video_url. |
rejected | Запрос не прошёл проверку параметров или модерацию. Причина в error и message. Не оплачивается. |
failed | Видео не удалось сгенерировать по внутренней причине, error: "UnknownError". Запрос можно повторить. Не оплачивается. |
output_format: "base64", поле video_url в ответе для завершённой задачи будет содержать строку base64 вместо ссылки.
Ответ: в процессе
{
"task_id": "b22c9ae2-0b55-4398-88df-0191aae664f0",
"status": "processing"
}
Ответ: готово
{
"task_id": "b22c9ae2-0b55-4398-88df-0191aae664f0",
"status": "completed",
"video_url": "https://cdn.nixai.ru/videos/b22c9ae2.mp4"
}
Ответ: отклонено
{
"task_id": "b22c9ae2-0b55-4398-88df-0191aae664f0",
"status": "rejected",
"error": "BadRequest",
"message": "Duration must be between 4s and 30s."
}
Ошибки
Ошибки выполнения задачи возвращаются в ответе/v1/videos/fetch в полях error и message.
error | Статус задачи | Причина |
|---|---|---|
BadRequest | rejected | Параметры запроса не прошли проверку. Повтор без исправления запроса завершится той же ошибкой. |
ContentRejected | rejected | Промпт, материалы или готовое видео отклонены модерацией. |
UnknownError | failed | Видео не удалось сгенерировать по внутренней причине. Запрос можно повторить. |
Сообщения BadRequest
Параметры
message | Что исправить |
|---|---|
Prompt is required. | Передайте непустой prompt. |
Prompt must not exceed 15000 characters. | Сократите prompt до 15 000 символов. |
Only the 1080p resolution is supported. | Уберите size или передайте 1080p. |
Aspect ratio must be one of 21:9, 16:9, 4:3, 1:1, 3:4, 9:16. | Укажите допустимое значение aspect_ratio или не передавайте его. |
Duration must be an integer. | Передайте duration целым числом. |
Duration must be between 4s and 30s. | Укажите duration от 4 до 30. |
generate_audio must be a boolean. | Передайте true или false, а не строку. |
Seed must be an integer between 0 and 2147483647. | Передайте seed целым числом в этом диапазоне или уберите поле. |
Type must be frames or omitted. | Уберите type или передайте frames. Других значений у модели нет. |
Кадры
message | Что исправить |
|---|---|
Type frames takes one or two images: the first frame and, optionally, the last frame. | С type: "frames" передайте в images одно или два изображения. |
Type frames does not take reference videos or audios. | Уберите videos и audios или уберите type: "frames", чтобы генерировать по референсам. |
Type frames does not take aspect_ratio: the video keeps the aspect ratio of the first frame. | Уберите aspect_ratio: соотношение сторон берётся из первого кадра. |
Референсы
message | Что исправить |
|---|---|
images must be a list of URLs. | Передайте массив строк, а не одну строку. То же для videos и audios. |
Up to 10 reference images are allowed. | Сократите число изображений. Для видео и аудио предел — 5. |
Reference video #N must be an MP4 or MOV file. | Перекодируйте видео №N в MP4 или MOV. |
Reference audio #N must be an MP3 or WAV file. | Перекодируйте аудио №N в MP3 или WAV. |
Reference video #N duration must be between 2s and 30s. | Файл №N слишком короткий или слишком длинный. То же для аудио. |
Total duration of reference videos must not exceed 30s. | Сократите суммарную длину входных видео. То же для audios. |
Duration of reference video #N could not be read. | Файл №N повреждён или не является медиафайлом. То же для аудио. |
Reference video #N: expected video, got audio. | В videos передан файл без видеодорожки. |
A reference file could not be read. Check that the URL is publicly accessible and points to a media file. | Ссылка на видео или аудио недоступна либо ведёт не на медиафайл. |
Timed out reading a reference file. Check that the URL is publicly accessible. | Сервер с видео или аудио не ответил вовремя. |
Изображения по ссылке
Относится и к референсам, и к кадрам.message | Что исправить |
|---|---|
Each URL in `images` must be a publicly reachable http(s) link. | Ссылка должна открываться из интернета: адреса внутренней сети и localhost не принимаются. |
A file from `images` could not be downloaded. Check that the link is public and points directly to the file. | Файл не скачался за 30 секунд либо хост вернул ошибку. Проверьте, что ссылка открывается без авторизации и ведёт прямо на файл. |
Each file in `images` must not exceed 20 MB. | Уменьшите изображение до 20 МБ. |
A URL in `images` does not point to a supported image. | По ссылке должен быть сам файл изображения, а не страница с ним. |
Сообщение ContentRejected
message | Что это значит |
|---|---|
The input or the result was rejected by content moderation. | Модерация отклонила промпт, переданные материалы или готовое видео. Измените запрос. |
Примеры
Проверка статуса
curl https://api.nixai.ru/v1/videos/fetch \
-H "Authorization: Bearer $NIXAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "magi-2",
"id": "b22c9ae2-0b55-4398-88df-0191aae664f0"
}'
Python: создание и ожидание результата
import os
import time
import requests
API = "https://api.nixai.ru/v1"
HEADERS = {"Authorization": f"Bearer {os.environ['NIXAI_API_KEY']}"}
task = requests.post(f"{API}/videos/generations", headers=HEADERS, json={
"model": "magi-2",
"prompt": "Котёнок бежит по крыше под луной, неоновые огни города вдали",
"duration": 5,
"aspect_ratio": "16:9",
}).json()
task_id = task["task_id"]
while True:
time.sleep(10)
result = requests.post(f"{API}/videos/fetch", headers=HEADERS, json={
"model": "magi-2",
"id": task_id,
}).json()
if result["status"] == "completed":
print(result["video_url"])
break
if result["status"] in ("rejected", "failed"):
raise RuntimeError(f"{result.get('error')}: {result.get('message')}")
Body
application/json
Response
200 - application/json
Статус задачи
Was this page helpful?
⌘I
Проверка статуса видео
curl --request POST \
--url https://api.nixai.ru/v1/videos/fetch \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "magi-2",
"id": "b22c9ae2-0b55-4398-88df-0191aae664f0"
}
'import requests
url = "https://api.nixai.ru/v1/videos/fetch"
payload = {
"model": "magi-2",
"id": "b22c9ae2-0b55-4398-88df-0191aae664f0"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({model: 'magi-2', id: 'b22c9ae2-0b55-4398-88df-0191aae664f0'})
};
fetch('https://api.nixai.ru/v1/videos/fetch', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));const url = 'https://api.nixai.ru/v1/videos/fetch';
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({model: 'magi-2', id: 'b22c9ae2-0b55-4398-88df-0191aae664f0'})
};
fetch(url, options)
.then(res => res.json())
.then(json => console.log(json))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.nixai.ru/v1/videos/fetch",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model' => 'magi-2',
'id' => 'b22c9ae2-0b55-4398-88df-0191aae664f0'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.nixai.ru/v1/videos/fetch"
payload := strings.NewReader("{\n \"model\": \"magi-2\",\n \"id\": \"b22c9ae2-0b55-4398-88df-0191aae664f0\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.nixai.ru/v1/videos/fetch")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"magi-2\",\n \"id\": \"b22c9ae2-0b55-4398-88df-0191aae664f0\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.nixai.ru/v1/videos/fetch")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"magi-2\",\n \"id\": \"b22c9ae2-0b55-4398-88df-0191aae664f0\"\n}"
response = http.request(request)
puts response.read_body$headers=@{}
$headers.Add("Authorization", "Bearer <token>")
$headers.Add("Content-Type", "application/json")
$response = Invoke-WebRequest -Uri 'https://api.nixai.ru/v1/videos/fetch' -Method POST -Headers $headers -ContentType 'application/json' -Body '{
"model": "magi-2",
"id": "b22c9ae2-0b55-4398-88df-0191aae664f0"
}'import Foundation
let parameters = [
"model": "magi-2",
"id": "b22c9ae2-0b55-4398-88df-0191aae664f0"
] as [String : Any?]
let postData = try JSONSerialization.data(withJSONObject: parameters, options: [])
let url = URL(string: "https://api.nixai.ru/v1/videos/fetch")!
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.timeoutInterval = 10
request.allHTTPHeaderFields = [
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
]
request.httpBody = postData
let (data, _) = try await URLSession.shared.data(for: request)
print(String(decoding: data, as: UTF8.self))using RestSharp;
var options = new RestClientOptions("https://api.nixai.ru/v1/videos/fetch");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddHeader("Authorization", "Bearer <token>");
request.AddJsonBody("{\n \"model\": \"magi-2\",\n \"id\": \"b22c9ae2-0b55-4398-88df-0191aae664f0\"\n}", false);
var response = await client.PostAsync(request);
Console.WriteLine("{0}", response.Content);
using RestSharp;
var options = new RestClientOptions("https://api.nixai.ru/v1/videos/fetch");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddHeader("Authorization", "Bearer <token>");
request.AddJsonBody("{\n \"model\": \"magi-2\",\n \"id\": \"b22c9ae2-0b55-4398-88df-0191aae664f0\"\n}", false);
var response = await client.PostAsync(request);
Console.WriteLine("{0}", response.Content);
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({model: 'magi-2', id: 'b22c9ae2-0b55-4398-88df-0191aae664f0'})
};
fetch('https://api.nixai.ru/v1/videos/fetch', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_WRITEDATA, stdout);
curl_easy_setopt(hnd, CURLOPT_URL, "https://api.nixai.ru/v1/videos/fetch");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Authorization: Bearer <token>");
headers = curl_slist_append(headers, "Content-Type: application/json");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{\n \"model\": \"magi-2\",\n \"id\": \"b22c9ae2-0b55-4398-88df-0191aae664f0\"\n}");
CURLcode ret = curl_easy_perform(hnd);CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_WRITEDATA, stdout);
curl_easy_setopt(hnd, CURLOPT_URL, "https://api.nixai.ru/v1/videos/fetch");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Authorization: Bearer <token>");
headers = curl_slist_append(headers, "Content-Type: application/json");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{\n \"model\": \"magi-2\",\n \"id\": \"b22c9ae2-0b55-4398-88df-0191aae664f0\"\n}");
CURLcode ret = curl_easy_perform(hnd);val client = OkHttpClient()
val mediaType = MediaType.parse("application/json")
val body = RequestBody.create(mediaType, "{\n \"model\": \"magi-2\",\n \"id\": \"b22c9ae2-0b55-4398-88df-0191aae664f0\"\n}")
val request = Request.Builder()
.url("https://api.nixai.ru/v1/videos/fetch")
.post(body)
.addHeader("Authorization", "Bearer <token>")
.addHeader("Content-Type", "application/json")
.build()
val response = client.newCall(request).execute()falsefalse{
"task_id": "b22c9ae2-0b55-4398-88df-0191aae664f0",
"status": "processing"
}