Top.Mail.Ru
Главная icon
Главная
Галерея icon
Галерея
Unitool Labs icon
Unitool Labs
Блог icon
Блог
MCP icon
MCP
← Все модели

Kling 4.0

kling-4-0 · Видео · unitool

Видео до 30 секунд в 720p и 1080p: из текста, по ключевым кадрам или по вашим видео. Можно добавить своих персонажей и голоса.

Генерация асинхронная: создание, ожидание или опрос, результат по ссылке на 7 дней. Подробно: Генерации медиа

Текст → видео

Режим t2v · kling-4-0:t2v

Цена

Зависит от параметров: 108 токенов на примере ниже, база 108. Точную цену своего запроса узнайте через POST /v1/quotes.

Состав цены (pricing из GET /v1/models/{id})
JSON
{
  "unit": "tokens",
  "kind": "by_parameters",
  "base": 108,
  "example_price": 108,
  "matrix": [
    {
      "when": {
        "resolution": "720p"
      },
      "when_set": [
        "elements_duration_sec"
      ],
      "rate": 12.84,
      "per": "duration",
      "plus": [
        "elements_duration_sec"
      ],
      "plus_mode": "max"
    },
    {
      "when": {
        "resolution": "1080p"
      },
      "when_set": [
        "elements_duration_sec"
      ],
      "rate": 19.25,
      "per": "duration",
      "plus": [
        "elements_duration_sec"
      ],
      "plus_mode": "max"
    },
    {
      "when": {
        "resolution": "720p"
      },
      "rate": 21.52,
      "per": "duration"
    },
    {
      "when": {
        "resolution": "1080p"
      },
      "rate": 32.09,
      "per": "duration"
    }
  ]
}

Параметры

ПараметрТипОписание
promptобязательныйstring
aspect_ratioauto | 16:9 | 9:16 | 1:1 | 21:9Формат кадраПо умолчанию "auto"
resolution720p | 1080pКачествоПо умолчанию "720p"
durationnumber 3–30Длительность. От 3 до 30 секунд. Цена считается за каждую секунду ролика.По умолчанию 5
elementsarray of object (≤ 7)Персонажи и предметы. До 7 штук, из них не больше 3 по видео. Упоминайте их в описании по имени: @Имя.
voicesarray of object (≤ 3)Голоса. До 3 голосов по образцу записи. Упоминайте в описании по имени: @Имя.
reference_image_urlsarray of file (≤ 10)A file_ref (asset:… or attachment:…), an https URL or a data: URL.

Пример запроса

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": "kling-4-0",
  "mode": "t2v",
  "input": {
    "prompt": "A red fox running through fresh snow at sunrise",
    "aspect_ratio": "auto",
    "resolution": "720p",
    "duration": 5
  }
}'
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": "kling-4-0",
  "mode": "t2v",
  "input": {
    "prompt": "A red fox running through fresh snow at sunrise",
    "aspect_ratio": "auto",
    "resolution": "720p",
    "duration": 5
  }
}''')
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": "kling-4-0",
  "mode": "t2v",
  "input": {
    "prompt": "A red fox running through fresh snow at sunrise",
    "aspect_ratio": "auto",
    "resolution": "720p",
    "duration": 5
  }
};
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));

Кадры → видео

Режим i2v · kling-4-0:i2v

Цена

Зависит от параметров: 108 токенов на примере ниже, база 108. Точную цену своего запроса узнайте через POST /v1/quotes.

Состав цены (pricing из GET /v1/models/{id})
JSON
{
  "unit": "tokens",
  "kind": "by_parameters",
  "base": 108,
  "example_price": 108,
  "matrix": [
    {
      "when": {
        "resolution": "720p"
      },
      "rate": 21.52,
      "per": "duration"
    },
    {
      "when": {
        "resolution": "1080p"
      },
      "rate": 32.09,
      "per": "duration"
    }
  ]
}

Параметры

ПараметрТипОписание
promptstring
resolution720p | 1080pКачествоПо умолчанию "720p"
durationnumber 3–30Длительность. От 3 до 30 секунд. Цена считается за каждую секунду ролика.По умолчанию 5
keyframe_urlsarray of file (≤ 8)Кадры в середине. До 8 кадров по порядку — в описании @keyframe_1, @keyframe_2. Всего кадров не больше, чем секунд + 1 (от 9 секунд — до 10 кадров). A file_ref (asset:… or attachment:…), an https URL or a data: URL.
last_frame_urlfileПоследний кадр. Чем закончится ролик — в описании @last_frame. A file_ref (asset:… or attachment:…), an https URL or a data: URL.
image_urlsобязательныйarray of file (≤ 1)A file_ref (asset:… or attachment:…), an https URL or a data: URL.

Пример запроса

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": "kling-4-0",
  "mode": "i2v",
  "input": {
    "prompt": "A red fox running through fresh snow at sunrise",
    "resolution": "720p",
    "duration": 5,
    "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": "kling-4-0",
  "mode": "i2v",
  "input": {
    "prompt": "A red fox running through fresh snow at sunrise",
    "resolution": "720p",
    "duration": 5,
    "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": "kling-4-0",
  "mode": "i2v",
  "input": {
    "prompt": "A red fox running through fresh snow at sunrise",
    "resolution": "720p",
    "duration": 5,
    "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));

Видео → видео

Режим v2v · kling-4-0:v2v

Цена

Зависит от параметров: 128 токенов на примере ниже, база 128. Точную цену своего запроса узнайте через POST /v1/quotes.

Состав цены (pricing из GET /v1/models/{id})
JSON
{
  "unit": "tokens",
  "kind": "by_parameters",
  "base": 128,
  "example_price": 128,
  "matrix": [
    {
      "when": {
        "resolution": "720p"
      },
      "rate": 12.84,
      "per": "duration",
      "plus": [
        "video_url_duration_sec",
        "elements_duration_sec"
      ],
      "plus_mode": "max"
    },
    {
      "when": {
        "resolution": "1080p"
      },
      "rate": 19.25,
      "per": "duration",
      "plus": [
        "video_url_duration_sec",
        "elements_duration_sec"
      ],
      "plus_mode": "max"
    }
  ]
}

Параметры

ПараметрТипОписание
promptstring
video_urlобязательныйarray of file (≤ 5)Ваши видео. До 5 роликов по 2–30 секунд, вместе не больше 30 секунд. В описании — @video_1, @video_2. Секунды ваших видео тоже оплачиваются, но не меньше длины результата. A file_ref (asset:… or attachment:…), an https URL or a data: URL.
keep_original_soundbooleanСохранить звук из видео. Выключено — модель сама озвучит ролик.По умолчанию false
resolution720p | 1080pКачествоПо умолчанию "720p"
durationnumber 3–30Длительность. От 3 до 30 секунд. Цена считается за каждую секунду ролика.По умолчанию 5
elementsarray of object (≤ 7)Персонажи и предметы. До 7 штук, из них не больше 3 по видео. Упоминайте их в описании по имени: @Имя.
voicesarray of object (≤ 3)Голоса. До 3 голосов по образцу записи. Упоминайте в описании по имени: @Имя.
reference_image_urlsarray of file (≤ 10)A file_ref (asset:… or attachment:…), an https URL or a data: URL.

Пример запроса

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": "kling-4-0",
  "mode": "v2v",
  "input": {
    "prompt": "A red fox running through fresh snow at sunrise",
    "keep_original_sound": false,
    "resolution": "720p",
    "duration": 5,
    "video_url": [
      "https://example.com/input.mp4"
    ]
  }
}'
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": "kling-4-0",
  "mode": "v2v",
  "input": {
    "prompt": "A red fox running through fresh snow at sunrise",
    "keep_original_sound": false,
    "resolution": "720p",
    "duration": 5,
    "video_url": [
      "https://example.com/input.mp4"
    ]
  }
}''')
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": "kling-4-0",
  "mode": "v2v",
  "input": {
    "prompt": "A red fox running through fresh snow at sunrise",
    "keep_original_sound": false,
    "resolution": "720p",
    "duration": 5,
    "video_url": [
      "https://example.com/input.mp4"
    ]
  }
};
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));

Мы используем файлы cookie

Продолжая пользоваться сайтом, вы соглашаетесь с Политикой обработки персональных данных.