Top.Mail.Ru
General icon
General
Галерея icon
Галерея
Unitool Labs icon
Unitool Labs
Блог icon
Блог
MCP icon
MCP
← All models

MAGI-2

magi-2 · Video · unitool

Видео до 30 секунд в 1080p со звуком и речью: из текста, из кадра или по вашим фото, видео и аудио. Держит героя и детали в длинных сценах.

Generations are async: create, wait or poll, the result by link for 7 days. Details: Media generations

Текст → видео

Mode t2v · magi-2:t2v

Price

Depends on the parameters: 68 tokens for the example below, base 68. Get the exact price of your request from POST /v1/quotes.

Price make-up (pricing from GET /v1/models/{id})
JSON
{
  "unit": "tokens",
  "kind": "by_parameters",
  "base": 68,
  "example_price": 68,
  "matrix": [
    {
      "when": {},
      "when_set": [
        "duration"
      ],
      "rate": 13.56,
      "per": "duration"
    }
  ]
}

Parameters

ParameterTypeDescription
promptrequiredstring
aspect_ratio16:9 | 9:16 | 1:1 | 4:3 | 3:4 | 21:9Формат кадраDefault "16:9"
durationnumber 4–30Длительность. От 4 до 30 секунд. Цена за каждую секунду ролика: сначала проверьте идею на 4–5 секундах.Default 5
generate_audiobooleanЗвук и речь. Реплики, шумы и музыка создаются вместе с видео. Выключите для немого ролика — цена та же.Default true
video_urlarray of file (≤ 5)Видео-референсы. Необязательно. До 5 роликов по 2–30 секунд, вместе не больше 30 секунд: модель возьмёт из них движение, пластику или подачу. Не оплачиваются. A file_ref (asset:… or attachment:…), an https URL or a data: URL.
audio_urlarray of file (≤ 5)Аудио-референсы. Необязательно. До 5 записей по 2–30 секунд, вместе не больше 30 секунд: голос героя, музыка или звук. Не оплачиваются. A file_ref (asset:… or attachment:…), an https URL or a data: URL.
reference_image_urlsarray of file (≤ 10)A file_ref (asset:… or attachment:…), an https URL or a data: URL.

Example request

curl
curl https://api.unitool.ai/v1/generations \
  -H "Authorization: Bearer $UNITOOL_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Prefer: wait=60" \
  -d '{
  "model": "magi-2",
  "mode": "t2v",
  "input": {
    "prompt": "A red fox running through fresh snow at sunrise",
    "aspect_ratio": "16:9",
    "duration": 5,
    "generate_audio": true
  }
}'
Python (requests)
import json, os, time, uuid, requests

API = "https://api.unitool.ai/v1"
headers = {"Authorization": f"Bearer {os.environ['UNITOOL_API_KEY']}"}
body = json.loads(r'''{
  "model": "magi-2",
  "mode": "t2v",
  "input": {
    "prompt": "A red fox running through fresh snow at sunrise",
    "aspect_ratio": "16:9",
    "duration": 5,
    "generate_audio": true
  }
}''')
gen = requests.post(f"{API}/generations", json=body,
                    headers={**headers, "Idempotency-Key": str(uuid.uuid4()), "Prefer": "wait=60"}).json()
while gen["status"] in ("queued", "running"):
    time.sleep(5)
    gen = requests.get(f"{API}/generations/{gen['id']}", headers=headers).json()
print(gen["status"], [o["url"] for o in gen["outputs"]])
JavaScript (fetch)
const API = "https://api.unitool.ai/v1";
const headers = { Authorization: `Bearer ${process.env.UNITOOL_API_KEY}`, "Content-Type": "application/json" };
const body = {
  "model": "magi-2",
  "mode": "t2v",
  "input": {
    "prompt": "A red fox running through fresh snow at sunrise",
    "aspect_ratio": "16:9",
    "duration": 5,
    "generate_audio": true
  }
};
let gen = await (await fetch(`${API}/generations`, {
  method: "POST", body: JSON.stringify(body),
  headers: { ...headers, "Idempotency-Key": crypto.randomUUID(), Prefer: "wait=60" },
})).json();
while (gen.status === "queued" || gen.status === "running") {
  await new Promise((resolve) => setTimeout(resolve, 5000));
  gen = await (await fetch(`${API}/generations/${gen.id}`, { headers })).json();
}
console.log(gen.status, gen.outputs.map((output) => output.url));

Кадр → видео

Mode i2v · magi-2:i2v

Price

Depends on the parameters: 68 tokens for the example below, base 68. Get the exact price of your request from POST /v1/quotes.

Price make-up (pricing from GET /v1/models/{id})
JSON
{
  "unit": "tokens",
  "kind": "by_parameters",
  "base": 68,
  "example_price": 68,
  "matrix": [
    {
      "when": {},
      "when_set": [
        "duration"
      ],
      "rate": 13.56,
      "per": "duration"
    }
  ]
}

Parameters

ParameterTypeDescription
promptstring
last_frame_urlfileПоследний кадр. Необязательно. Если приложить, ролик закончится этим кадром. A file_ref (asset:… or attachment:…), an https URL or a data: URL.
durationnumber 4–30Длительность. От 4 до 30 секунд. Цена за каждую секунду ролика: сначала проверьте идею на 4–5 секундах.Default 5
generate_audiobooleanЗвук и речь. Реплики, шумы и музыка создаются вместе с видео. Выключите для немого ролика — цена та же.Default true
image_urlsrequiredarray of file (≤ 1)A file_ref (asset:… or attachment:…), an https URL or a data: URL.

Example request

curl
curl https://api.unitool.ai/v1/generations \
  -H "Authorization: Bearer $UNITOOL_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Prefer: wait=60" \
  -d '{
  "model": "magi-2",
  "mode": "i2v",
  "input": {
    "prompt": "A red fox running through fresh snow at sunrise",
    "duration": 5,
    "generate_audio": true,
    "image_urls": [
      "https://example.com/input.png"
    ]
  }
}'
Python (requests)
import json, os, time, uuid, requests

API = "https://api.unitool.ai/v1"
headers = {"Authorization": f"Bearer {os.environ['UNITOOL_API_KEY']}"}
body = json.loads(r'''{
  "model": "magi-2",
  "mode": "i2v",
  "input": {
    "prompt": "A red fox running through fresh snow at sunrise",
    "duration": 5,
    "generate_audio": true,
    "image_urls": [
      "https://example.com/input.png"
    ]
  }
}''')
gen = requests.post(f"{API}/generations", json=body,
                    headers={**headers, "Idempotency-Key": str(uuid.uuid4()), "Prefer": "wait=60"}).json()
while gen["status"] in ("queued", "running"):
    time.sleep(5)
    gen = requests.get(f"{API}/generations/{gen['id']}", headers=headers).json()
print(gen["status"], [o["url"] for o in gen["outputs"]])
JavaScript (fetch)
const API = "https://api.unitool.ai/v1";
const headers = { Authorization: `Bearer ${process.env.UNITOOL_API_KEY}`, "Content-Type": "application/json" };
const body = {
  "model": "magi-2",
  "mode": "i2v",
  "input": {
    "prompt": "A red fox running through fresh snow at sunrise",
    "duration": 5,
    "generate_audio": true,
    "image_urls": [
      "https://example.com/input.png"
    ]
  }
};
let gen = await (await fetch(`${API}/generations`, {
  method: "POST", body: JSON.stringify(body),
  headers: { ...headers, "Idempotency-Key": crypto.randomUUID(), Prefer: "wait=60" },
})).json();
while (gen.status === "queued" || gen.status === "running") {
  await new Promise((resolve) => setTimeout(resolve, 5000));
  gen = await (await fetch(`${API}/generations/${gen.id}`, { headers })).json();
}
console.log(gen.status, gen.outputs.map((output) => output.url));

We use cookies

By continuing to use the site you agree to our Privacy Policy.