HappyHorse
happyhorse · Видео · unitool
Генерация асинхронная: создание, ожидание или опрос, результат по ссылке на 7 дней. Подробно: Генерации медиа
HappyHorse 1.1
Режим happyhorse-1-1 · happyhorse:happyhorse-1-1
Цена
Зависит от параметров: 88 токенов на примере ниже, база 23. Точную цену своего запроса узнайте через POST /v1/quotes.
Состав цены (pricing из GET /v1/models/{id})
{
"unit": "tokens",
"kind": "by_parameters",
"base": 23,
"example_price": 88,
"matrix": [
{
"when": {
"resolution": "1080p"
},
"rate": 23.3,
"per": "duration"
},
{
"when": {
"resolution": "720p"
},
"rate": 17.5,
"per": "duration"
}
]
}Параметры
| Параметр | Тип | Описание |
|---|---|---|
promptобязательный | string | |
resolution | 720p | 1080p | РазрешениеПо умолчанию "720p" |
aspect_ratio | 16:9 | 9:16 | 1:1 | 4:3 | 3:4 | 4:5 | 5:4 | 9:21 | 21:9 | Соотношение сторонПо умолчанию "16:9" |
duration | number 3–15 | ДлительностьПо умолчанию 5 |
reference_image | array of file | Референс-изображения. До 9 изображений (reference-to-video). В промпте ссылайтесь как [Image 1], [Image 2] 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 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": "happyhorse",
"mode": "happyhorse-1-1",
"input": {
"prompt": "A red fox running through fresh snow at sunrise",
"resolution": "720p",
"aspect_ratio": "16:9",
"duration": 5
}
}'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": "happyhorse",
"mode": "happyhorse-1-1",
"input": {
"prompt": "A red fox running through fresh snow at sunrise",
"resolution": "720p",
"aspect_ratio": "16:9",
"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"]])const API = "https://api.unitool.ai/v1";
const headers = { Authorization: `Bearer ${process.env.UNITOOL_API_KEY}`, "Content-Type": "application/json" };
const body = {
"model": "happyhorse",
"mode": "happyhorse-1-1",
"input": {
"prompt": "A red fox running through fresh snow at sunrise",
"resolution": "720p",
"aspect_ratio": "16:9",
"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));Text/Image to video
Режим happyhorse · happyhorse:happyhorse
Цена
Зависит от параметров: 135 токенов на примере ниже, база 20. Точную цену своего запроса узнайте через POST /v1/quotes.
Состав цены (pricing из GET /v1/models/{id})
{
"unit": "tokens",
"kind": "by_parameters",
"base": 20,
"example_price": 135,
"matrix": [
{
"when": {
"resolution": "1080p"
},
"rate": 47,
"per": "duration"
},
{
"when": {
"resolution": "720p"
},
"rate": 27,
"per": "duration"
}
]
}Параметры
| Параметр | Тип | Описание |
|---|---|---|
promptобязательный | string | |
resolution | 1080p | 720p | РазрешениеПо умолчанию "720p" |
aspect_ratio | 16:9 | 9:16 | 1:1 | 4:3 | 3:4 | Соотношение сторонПо умолчанию "16:9" |
duration | number 3–15 | ДлительностьПо умолчанию 5 |
seed | number | seed |
image_urls | array of file (≤ 1) | A file_ref (asset:… or attachment:…), an https URL or a data: URL. |
Пример запроса
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": "happyhorse",
"mode": "happyhorse",
"input": {
"prompt": "A red fox running through fresh snow at sunrise",
"resolution": "720p",
"aspect_ratio": "16:9",
"duration": 5
}
}'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": "happyhorse",
"mode": "happyhorse",
"input": {
"prompt": "A red fox running through fresh snow at sunrise",
"resolution": "720p",
"aspect_ratio": "16:9",
"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"]])const API = "https://api.unitool.ai/v1";
const headers = { Authorization: `Bearer ${process.env.UNITOOL_API_KEY}`, "Content-Type": "application/json" };
const body = {
"model": "happyhorse",
"mode": "happyhorse",
"input": {
"prompt": "A red fox running through fresh snow at sunrise",
"resolution": "720p",
"aspect_ratio": "16:9",
"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));Reference to video
Режим happyhorse-reference-to-video · happyhorse:happyhorse-reference-to-video
Цена
Зависит от параметров: 135 токенов на примере ниже, база 20. Точную цену своего запроса узнайте через POST /v1/quotes.
Состав цены (pricing из GET /v1/models/{id})
{
"unit": "tokens",
"kind": "by_parameters",
"base": 20,
"example_price": 135,
"matrix": [
{
"when": {
"resolution": "720p"
},
"rate": 27,
"per": "duration"
},
{
"when": {
"resolution": "1080p"
},
"rate": 47,
"per": "duration"
}
]
}Параметры
| Параметр | Тип | Описание |
|---|---|---|
prompt | string | |
resolution | 1080p | 720p | РазрешениеПо умолчанию "720p" |
aspect_ratio | 16:9 | 9:16 | 1:1 | 4:3 | 3:4 | Соотношение сторонПо умолчанию "16:9" |
duration | number 3–15 | ДлительностьПо умолчанию 5 |
seed | number | seed |
reference_imageобязательный | array of file (≤ 9) | A file_ref (asset:… or attachment:…), an https URL or a data: URL. |
Пример запроса
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": "happyhorse",
"mode": "happyhorse-reference-to-video",
"input": {
"prompt": "A red fox running through fresh snow at sunrise",
"resolution": "720p",
"aspect_ratio": "16:9",
"duration": 5,
"reference_image": [
"https://example.com/input.png"
]
}
}'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": "happyhorse",
"mode": "happyhorse-reference-to-video",
"input": {
"prompt": "A red fox running through fresh snow at sunrise",
"resolution": "720p",
"aspect_ratio": "16:9",
"duration": 5,
"reference_image": [
"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"]])const API = "https://api.unitool.ai/v1";
const headers = { Authorization: `Bearer ${process.env.UNITOOL_API_KEY}`, "Content-Type": "application/json" };
const body = {
"model": "happyhorse",
"mode": "happyhorse-reference-to-video",
"input": {
"prompt": "A red fox running through fresh snow at sunrise",
"resolution": "720p",
"aspect_ratio": "16:9",
"duration": 5,
"reference_image": [
"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));Video edit
Режим happyhorse-video-edit · happyhorse:happyhorse-video-edit
Цена
Зависит от параметров: 135 токенов на примере ниже, база 20. Точную цену своего запроса узнайте через POST /v1/quotes.
Состав цены (pricing из GET /v1/models/{id})
{
"unit": "tokens",
"kind": "by_parameters",
"base": 20,
"example_price": 135,
"matrix": [
{
"when": {
"resolution": "720p"
},
"when_set": [
"duration"
],
"rate": 27,
"per": "duration"
},
{
"when": {
"resolution": "1080p"
},
"rate": 47,
"per": "duration"
}
]
}Параметры
| Параметр | Тип | Описание |
|---|---|---|
prompt | string | |
resolution | 1080p | 720p | РазрешениеПо умолчанию "720p" |
aspect_ratio | 16:9 | 9:16 | 1:1 | 4:3 | 3:4 | Соотношение сторонПо умолчанию "16:9" |
duration | number 3–15 | ДлительностьПо умолчанию 5 |
video_urlобязательный | file | video_url. A file_ref (asset:… or attachment:…), an https URL or a data: URL. |
seed | number | seed |
reference_image | array of file (≤ 5) | A file_ref (asset:… or attachment:…), an https URL or a data: URL. |
Пример запроса
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": "happyhorse",
"mode": "happyhorse-video-edit",
"input": {
"prompt": "A red fox running through fresh snow at sunrise",
"resolution": "720p",
"aspect_ratio": "16:9",
"duration": 5,
"video_url": "https://example.com/input.mp4"
}
}'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": "happyhorse",
"mode": "happyhorse-video-edit",
"input": {
"prompt": "A red fox running through fresh snow at sunrise",
"resolution": "720p",
"aspect_ratio": "16:9",
"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"]])const API = "https://api.unitool.ai/v1";
const headers = { Authorization: `Bearer ${process.env.UNITOOL_API_KEY}`, "Content-Type": "application/json" };
const body = {
"model": "happyhorse",
"mode": "happyhorse-video-edit",
"input": {
"prompt": "A red fox running through fresh snow at sunrise",
"resolution": "720p",
"aspect_ratio": "16:9",
"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));