Happy Pony API Get an API key →

Reference to video

Pricing: MiniMax H3 video

Reference images, an optional reference video and voice clips in, one video with sound out (MiniMax H3). The model keeps the identity of the people, products and places in your references and the timbre of the voices, in a new scene that your prompt describes. The same job as the Reference assets mode of www.happypony.io/minimax-h3. A video takes a few minutes; longer, higher-resolution and quality jobs take longer.

POST https://api.happypony.io/api/v1/jobs/reference-to-video
GET  https://api.happypony.io/api/v1/jobs/:requestId/status
GET  https://api.happypony.io/api/v1/jobs/:requestId
PUT  https://api.happypony.io/api/v1/jobs/:requestId/cancel

1) Create a request

POST https://api.happypony.io/api/v1/jobs/reference-to-video with Content-Type: application/json.

Field Type Required Default Description
prompt string yes — The scene, referring to the references by label (see Writing the prompt). At most 8000 characters.
reference_image_urls string[] one reference is required [] Up to 9 images: people, characters, products, costumes, places, style. Labelled <Picture 1>, <Picture 2>, … in this order.
reference_video_url string one reference is required — One video: motion, identity or the voice in it. Labelled <Video 1>.
reference_audio_urls string[] one reference is required [] Up to 3 voice clips (timbre only; the words come from the prompt). Labelled <Audio 1>, <Audio 2>, … in this order.
duration integer no 5 Seconds, from 5 to the canvas limit (Reference-to-video duration limits).
short_edge integer no 768 480, 768 or 1080: the shorter side in pixels. 768 is native; 1080 is rendered smaller and upscaled.
aspect_ratio string no "auto" "auto", "21:9", "16:9", "4:3", "1:1", "3:4" or "9:16". "auto" follows the references; pick a ratio when they have different shapes.
tier string no "turbo" "turbo" (fast) or "quality" (slower, more detail).

At least one of reference_image_urls, reference_video_url and reference_audio_urls is required; any mix of the three works. There are no first / last frames here: to pin the opening or closing frame use image to video.

Request body:

{
  "prompt": "<Picture 1> is a young woman with short silver hair; <Picture 2> is a red trail-running shoe. At dawn on a mountain ridge, <Picture 1> laces up <Picture 2>, stands and says in the voice of <Audio 1>: \"Today we go higher.\" She starts to run; the camera follows from the side. Wind, footsteps on gravel, distant birds.",
  "reference_image_urls": ["https://cdn.example.com/runner.png", "https://cdn.example.com/shoe.png"],
  "reference_audio_urls": ["https://cdn.example.com/voice.mp3"],
  "duration": 10,
  "short_edge": 768,
  "aspect_ratio": "16:9",
  "tier": "turbo"
}
curl -X POST https://api.happypony.io/api/v1/jobs/reference-to-video \
  -H "Authorization: Bearer $HP_KEY" -H "Content-Type: application/json" \
  -d '{"prompt": "<Picture 1> is a young woman with short silver hair; <Picture 2> is a red trail-running shoe. At dawn on a mountain ridge, <Picture 1> laces up <Picture 2>, stands and says in the voice of <Audio 1>: \"Today we go higher.\" She starts to run; the camera follows from the side. Wind, footsteps on gravel, distant birds.", "reference_image_urls": ["https://cdn.example.com/runner.png", "https://cdn.example.com/shoe.png"], "reference_audio_urls": ["https://cdn.example.com/voice.mp3"], "duration": 10, "short_edge": 768, "aspect_ratio": "16:9", "tier": "turbo"}'

Response 202 (fields: Create response):

{
  "request_id": "48301",
  "type": "reference-to-video",
  "status": "IN_QUEUE",
  "credits": 40,
  "status_url": "https://api.happypony.io/api/v1/jobs/48301/status",
  "response_url": "https://api.happypony.io/api/v1/jobs/48301",
  "cancel_url": "https://api.happypony.io/api/v1/jobs/48301/cancel"
}

Reference inputs

Every reference is a URL, under the same rules as image inputs: a public https:// URL, or the url from POST /api/v1/jobs/uploads for a file on your disk (send kind=video or kind=audio for those). The create call checks each URL without downloading it, and the job reads your URL when it renders, so a link has to work until the job has finished (see Image inputs). A URL that is refused is a 400 invalid_media whose field names it (e.g. reference_audio_urls[0]), and nothing is charged; a file that turns out to be unusable fails the job, and the credits are refunded.

Kind Formats Largest file
Image jpg, png, webp 20 MB
Video mp4, mov, webm, mkv 200 MB
Audio wav, mp3, m4a, aac, ogg, flac 30 MB

A reference image narrower than 1:4 or wider than 4:1 is center-cropped to that range before rendering.

Reference-to-video duration limits

The longest clip depends on the canvas (auto follows the 1:1 column). A longer duration is a 400.

short_edge auto, 1:1 4:3, 3:4 16:9, 9:16 21:9
480 20 s 20 s 20 s 20 s
768 20 s 20 s 15 s 10 s
1080 20 s 20 s 20 s 20 s

Writing the prompt

Name each reference by its label and say what it is the first time: "<Picture 1> is a young woman with short silver hair", "<Picture 2> is a red trail-running shoe". Then, in one paragraph, write the new scene: where it happens, what the subjects do in order, how the camera moves, and the sounds. For speech, put the line in quotation marks (about 3 words per second of clip) and say whose voice speaks it ("in the voice of <Audio 1>"). References keep identity, not composition: the shot is generated fresh, so describe it. There is no negative prompt: write "Ambient sound only." rather than "no music". Write the prompt out in full: a prompt under 3200 characters is expanded automatically (see Prompt enrichment) and the expansion can lose the labels.

2) Poll for status

Poll the status_url until status is COMPLETED, FAILED or CANCELLED (fields: Status response). A queued job can be cancelled with PUT on the cancel_url (Cancel a request).

curl https://api.happypony.io/api/v1/jobs/48301/status -H "Authorization: Bearer $HP_KEY"
{
  "request_id": "48301",
  "type": "reference-to-video",
  "status": "IN_PROGRESS",
  "created_at": "2026-10-18T10:00:00.000Z",
  "completed_at": null,
  "credits": 40,
  "eta_seconds": 200,
  "status_url": "…", "response_url": "…", "cancel_url": "…"
}

3) Fetch the result

When status is COMPLETED, fetch the response_url (common fields: Result response):

curl https://api.happypony.io/api/v1/jobs/48301 -H "Authorization: Bearer $HP_KEY"
{
  "request_id": "48301",
  "type": "reference-to-video",
  "status": "COMPLETED",
  "created_at": "2026-10-18T10:00:00.000Z",
  "completed_at": "2026-10-18T10:04:40.000Z",
  "credits": 40,
  "videos": [{ "url": "https://…signed…", "format": "mp4" }],
  "expires_in": 259200,
  "parameters": { "prompt": "<Picture 1> is a young woman with short silver hair; …",
                  "tier": "turbo", "duration": 10, "short_edge": 768, "aspect_ratio": "16:9",
                  "references": { "images": 2, "videos": 0, "audio": 1 } },
  "status_url": "…", "response_url": "…", "cancel_url": "…"
}
Field Type Description
videos object[] One mp4 with its soundtrack.
parameters object prompt, tier, duration, short_edge, aspect_ratio, and references: how many images, videos and audio clips the job used.

Full example

Create, poll until done, download:

curl (bash)

# Needs curl and jq. Usage: HP_KEY=hp_… ./r2v.sh voice.mp3
# The voice is a local file: upload it first, then use its URL.
VOICE=$(curl -s -X POST https://api.happypony.io/api/v1/jobs/uploads \
  -H "Authorization: Bearer $HP_KEY" -F file=@"$1" -F kind=audio | jq -r .url)

JOB=$(jq -n --arg voice "$VOICE" '{
  prompt: "<Picture 1> is a young woman with short silver hair; <Picture 2> is a red trail-running shoe. At dawn on a mountain ridge, <Picture 1> laces up <Picture 2>, stands and says in the voice of <Audio 1>: \"Today we go higher.\" She starts to run; the camera follows from the side. Wind, footsteps on gravel, distant birds.",
  reference_image_urls: ["https://cdn.example.com/runner.png", "https://cdn.example.com/shoe.png"],
  reference_audio_urls: [$voice],
  duration: 10, aspect_ratio: "16:9"}' |
  curl -s -X POST https://api.happypony.io/api/v1/jobs/reference-to-video \
    -H "Authorization: Bearer $HP_KEY" -H "Content-Type: application/json" -d @-)
echo "$JOB" | jq .
STATUS_URL=$(echo "$JOB" | jq -r .status_url)
RESPONSE_URL=$(echo "$JOB" | jq -r .response_url)

while :; do
  STATUS=$(curl -s "$STATUS_URL" -H "Authorization: Bearer $HP_KEY" | jq -r .status)
  [ "$STATUS" = IN_QUEUE ] || [ "$STATUS" = IN_PROGRESS ] || break
  sleep 10
done
echo "$STATUS"
curl -s "$RESPONSE_URL" -H "Authorization: Bearer $HP_KEY" | jq -r '.videos[] | "\(.format) \(.url)"' |
  while read -r FORMAT URL; do curl -s -o "video-$((++i)).$FORMAT" "$URL"; done

Python

# pip install requests   |   HP_KEY=hp_… python r2v.py
import os, time, requests

BASE = "https://api.happypony.io/api/v1/jobs"
H = {"Authorization": f"Bearer {os.environ['HP_KEY']}"}

# A local voice clip: upload it, then use the returned URL.
with open("voice.mp3", "rb") as f:
    voice = requests.post(f"{BASE}/uploads", headers=H, files={"file": f}, data={"kind": "audio"})
voice.raise_for_status()

job = requests.post(f"{BASE}/reference-to-video", headers=H, json={
    "prompt": "<Picture 1> is a young woman with short silver hair; <Picture 2> is a red trail-running shoe. "
              "At dawn on a mountain ridge, <Picture 1> laces up <Picture 2>, stands and says in the voice of "
              "<Audio 1>: \"Today we go higher.\" She starts to run; the camera follows from the side. "
              "Wind, footsteps on gravel, distant birds.",
    "reference_image_urls": ["https://cdn.example.com/runner.png", "https://cdn.example.com/shoe.png"],
    "reference_audio_urls": [voice.json()["url"]],
    "duration": 10,
    "aspect_ratio": "16:9",
})
job.raise_for_status()
job = job.json()
print("job", job["request_id"], "costs", job["credits"], "credits")

while (s := requests.get(job["status_url"], headers=H).json())["status"] in ("IN_QUEUE", "IN_PROGRESS"):
    time.sleep(10)

result = requests.get(job["response_url"], headers=H).json()
if result["status"] != "COMPLETED":
    raise SystemExit(f"{result['status']}: {result.get('error', '')}")
for i, video in enumerate(result["videos"]):
    with open(f"video-{job['request_id']}-{i}.{video['format']}", "wb") as f:
        f.write(requests.get(video["url"]).content)

TypeScript

// Node 18+ (global fetch).   HP_KEY=hp_… npx tsx r2v.ts
import { readFile, writeFile } from 'node:fs/promises';

const BASE = 'https://api.happypony.io/api/v1/jobs';
const AUTH = { Authorization: `Bearer ${process.env.HP_KEY}` };
const H = { ...AUTH, 'Content-Type': 'application/json' };

// A local voice clip: upload it, then use the returned URL.
const form = new FormData();
form.append('file', new Blob([await readFile('voice.mp3')], { type: 'audio/mpeg' }), 'voice.mp3');
form.append('kind', 'audio');
const voice = await (await fetch(`${BASE}/uploads`, { method: 'POST', headers: AUTH, body: form })).json();

const res = await fetch(`${BASE}/reference-to-video`, {
  method: 'POST', headers: H,
  body: JSON.stringify({
    prompt: '<Picture 1> is a young woman with short silver hair; <Picture 2> is a red trail-running shoe. ' +
      'At dawn on a mountain ridge, <Picture 1> laces up <Picture 2>, stands and says in the voice of <Audio 1>: ' +
      '"Today we go higher." She starts to run; the camera follows from the side. Wind, footsteps on gravel, distant birds.',
    reference_image_urls: ['https://cdn.example.com/runner.png', 'https://cdn.example.com/shoe.png'],
    reference_audio_urls: [voice.url],
    duration: 10,
    aspect_ratio: '16:9',
  }),
});
const job = await res.json();
if (!res.ok) throw new Error(`${res.status}: ${job.message}`);

let status = 'IN_QUEUE';
while (status === 'IN_QUEUE' || status === 'IN_PROGRESS') {
  await new Promise((r) => setTimeout(r, 10_000));
  status = (await (await fetch(job.status_url, { headers: H })).json()).status;
}
const result = await (await fetch(job.response_url, { headers: H })).json();
if (result.status !== 'COMPLETED') throw new Error(`${result.status}: ${result.error ?? ''}`);
for (const [i, video] of result.videos.entries()) {
  await writeFile(`video-${job.request_id}-${i}.${video.format}`, Buffer.from(await (await fetch(video.url)).arrayBuffer()));
}

参考生视频

价格:MiniMax H3 视频

传入参考图片、可选的参考视频和声音片段,生成一段带声音的视频(MiniMax H3)。模型会在提示词描述的新场景中保留参考里的人物、产品和地点的身份特征,以及声音的音色。与 www.happypony.io/minimax-h3 参考素材模式的任务完全相同。生成一段视频需要几分钟;时长越长、分辨率越高或使用 quality 都会更久。

POST https://api.happypony.io/api/v1/jobs/reference-to-video
GET  https://api.happypony.io/api/v1/jobs/:requestId/status
GET  https://api.happypony.io/api/v1/jobs/:requestId
PUT  https://api.happypony.io/api/v1/jobs/:requestId/cancel

1) 创建请求

POST https://api.happypony.io/api/v1/jobs/reference-to-video,Content-Type: application/json。

字段 类型 必填 默认值 说明
prompt string 是 — 场景,用标签指代各个参考(见提示词写法)。最多 8000 个字符。
reference_image_urls string[] 至少一个参考 [] 最多 9 张图片:人物、角色、产品、服装、地点、风格。按顺序标记为 <Picture 1>、<Picture 2>……
reference_video_url string 至少一个参考 — 一个视频:动作、身份或其中的声音。标记为 <Video 1>。
reference_audio_urls string[] 至少一个参考 [] 最多 3 段声音(只取音色;台词来自提示词)。按顺序标记为 <Audio 1>、<Audio 2>……
duration integer 否 5 秒数,从 5 到画布上限(见参考生视频时长上限)。
short_edge integer 否 768 480、768 或 1080:短边像素数。768 为原生尺寸;1080 先以较小尺寸渲染再放大。
aspect_ratio string 否 "auto" "auto"、"21:9"、"16:9"、"4:3"、"1:1"、"3:4" 或 "9:16"。"auto" 跟随参考素材;参考形状不一时请指定比例。
tier string 否 "turbo" "turbo"(快)或 "quality"(较慢,细节更多)。

reference_image_urls、reference_video_url、reference_audio_urls 至少填一个,三者可任意组合。这里没有首帧 / 尾帧:要固定开头或结尾画面,请用图生视频。

请求体:

{
  "prompt": "<Picture 1> is a young woman with short silver hair; <Picture 2> is a red trail-running shoe. At dawn on a mountain ridge, <Picture 1> laces up <Picture 2>, stands and says in the voice of <Audio 1>: \"Today we go higher.\" She starts to run; the camera follows from the side. Wind, footsteps on gravel, distant birds.",
  "reference_image_urls": ["https://cdn.example.com/runner.png", "https://cdn.example.com/shoe.png"],
  "reference_audio_urls": ["https://cdn.example.com/voice.mp3"],
  "duration": 10,
  "short_edge": 768,
  "aspect_ratio": "16:9",
  "tier": "turbo"
}
curl -X POST https://api.happypony.io/api/v1/jobs/reference-to-video \
  -H "Authorization: Bearer $HP_KEY" -H "Content-Type: application/json" \
  -d '{"prompt": "<Picture 1> is a young woman with short silver hair; <Picture 2> is a red trail-running shoe. At dawn on a mountain ridge, <Picture 1> laces up <Picture 2>, stands and says in the voice of <Audio 1>: \"Today we go higher.\" She starts to run; the camera follows from the side. Wind, footsteps on gravel, distant birds.", "reference_image_urls": ["https://cdn.example.com/runner.png", "https://cdn.example.com/shoe.png"], "reference_audio_urls": ["https://cdn.example.com/voice.mp3"], "duration": 10, "short_edge": 768, "aspect_ratio": "16:9", "tier": "turbo"}'

响应 202(字段见创建响应):

{
  "request_id": "48301",
  "type": "reference-to-video",
  "status": "IN_QUEUE",
  "credits": 40,
  "status_url": "https://api.happypony.io/api/v1/jobs/48301/status",
  "response_url": "https://api.happypony.io/api/v1/jobs/48301",
  "cancel_url": "https://api.happypony.io/api/v1/jobs/48301/cancel"
}

参考素材

每个参考都是一个 URL,规则与图片输入相同:公开的 https:// URL,或本地文件经 POST /api/v1/jobs/uploads 上传后返回的 url(视频和音频请传 kind=video 或 kind=audio)。创建请求只检查每个 URL,不下载;任务在渲染时读取你的 URL,所以链接必须在任务完成前一直有效(见图片输入)。被拒绝的 URL 返回 400 invalid_media,field 指出是哪一个(如 reference_audio_urls[0]),且不扣费;之后才发现无法使用的文件会让任务失败,积分退还。

类型 格式 最大文件
图片 jpg、png、webp 20 MB
视频 mp4、mov、webm、mkv 200 MB
音频 wav、mp3、m4a、aac、ogg、flac 30 MB

比 1:4 更窄或比 4:1 更宽的参考图片会在渲染前居中裁剪到该范围内。

参考生视频时长上限

最长时长取决于画布(auto 按 1:1 一列计算)。超过上限的 duration 返回 400。

short_edge auto、1:1 4:3、3:4 16:9、9:16 21:9
480 20 秒 20 秒 20 秒 20 秒
768 20 秒 20 秒 15 秒 10 秒
1080 20 秒 20 秒 20 秒 20 秒

提示词写法

用标签指代每个参考,并在第一次出现时说明它是什么:“<Picture 1> 是一位银色短发的年轻女子”,“<Picture 2> 是一只红色越野跑鞋”。然后用一段话写出新场景:发生在哪里,主体按顺序做了什么,镜头如何运动,以及声音。台词放在引号里(每秒视频约 3 个词),并写明用谁的声音说(“用 <Audio 1> 的声音”)。参考保留的是身份,而不是构图:画面会重新生成,所以请描述镜头。不支持负面提示词:写“Ambient sound only.”而不是“no music”。请把提示词写完整:不足 3200 个字符的提示词会自动扩写(见提示词增强),扩写可能丢失标签。

2) 轮询状态

轮询 status_url,直到 status 为 COMPLETED、FAILED 或 CANCELLED(字段见状态响应)。排队中的任务可以对 cancel_url 发送 PUT 取消(见取消请求)。

curl https://api.happypony.io/api/v1/jobs/48301/status -H "Authorization: Bearer $HP_KEY"
{
  "request_id": "48301",
  "type": "reference-to-video",
  "status": "IN_PROGRESS",
  "created_at": "2026-10-18T10:00:00.000Z",
  "completed_at": null,
  "credits": 40,
  "eta_seconds": 200,
  "status_url": "…", "response_url": "…", "cancel_url": "…"
}

3) 获取结果

status 为 COMPLETED 后,获取 response_url(通用字段见结果响应):

curl https://api.happypony.io/api/v1/jobs/48301 -H "Authorization: Bearer $HP_KEY"
{
  "request_id": "48301",
  "type": "reference-to-video",
  "status": "COMPLETED",
  "created_at": "2026-10-18T10:00:00.000Z",
  "completed_at": "2026-10-18T10:04:40.000Z",
  "credits": 40,
  "videos": [{ "url": "https://…signed…", "format": "mp4" }],
  "expires_in": 259200,
  "parameters": { "prompt": "<Picture 1> is a young woman with short silver hair; …",
                  "tier": "turbo", "duration": 10, "short_edge": 768, "aspect_ratio": "16:9",
                  "references": { "images": 2, "videos": 0, "audio": 1 } },
  "status_url": "…", "response_url": "…", "cancel_url": "…"
}
字段 类型 说明
videos object[] 一个带声音的 mp4。
parameters object prompt、tier、duration、short_edge、aspect_ratio,以及 references:任务用到的图片、视频和音频数量。

完整示例

创建、轮询直到完成、下载:

curl (bash)

# Needs curl and jq. Usage: HP_KEY=hp_… ./r2v.sh voice.mp3
# The voice is a local file: upload it first, then use its URL.
VOICE=$(curl -s -X POST https://api.happypony.io/api/v1/jobs/uploads \
  -H "Authorization: Bearer $HP_KEY" -F file=@"$1" -F kind=audio | jq -r .url)

JOB=$(jq -n --arg voice "$VOICE" '{
  prompt: "<Picture 1> is a young woman with short silver hair; <Picture 2> is a red trail-running shoe. At dawn on a mountain ridge, <Picture 1> laces up <Picture 2>, stands and says in the voice of <Audio 1>: \"Today we go higher.\" She starts to run; the camera follows from the side. Wind, footsteps on gravel, distant birds.",
  reference_image_urls: ["https://cdn.example.com/runner.png", "https://cdn.example.com/shoe.png"],
  reference_audio_urls: [$voice],
  duration: 10, aspect_ratio: "16:9"}' |
  curl -s -X POST https://api.happypony.io/api/v1/jobs/reference-to-video \
    -H "Authorization: Bearer $HP_KEY" -H "Content-Type: application/json" -d @-)
echo "$JOB" | jq .
STATUS_URL=$(echo "$JOB" | jq -r .status_url)
RESPONSE_URL=$(echo "$JOB" | jq -r .response_url)

while :; do
  STATUS=$(curl -s "$STATUS_URL" -H "Authorization: Bearer $HP_KEY" | jq -r .status)
  [ "$STATUS" = IN_QUEUE ] || [ "$STATUS" = IN_PROGRESS ] || break
  sleep 10
done
echo "$STATUS"
curl -s "$RESPONSE_URL" -H "Authorization: Bearer $HP_KEY" | jq -r '.videos[] | "\(.format) \(.url)"' |
  while read -r FORMAT URL; do curl -s -o "video-$((++i)).$FORMAT" "$URL"; done

Python

# pip install requests   |   HP_KEY=hp_… python r2v.py
import os, time, requests

BASE = "https://api.happypony.io/api/v1/jobs"
H = {"Authorization": f"Bearer {os.environ['HP_KEY']}"}

# A local voice clip: upload it, then use the returned URL.
with open("voice.mp3", "rb") as f:
    voice = requests.post(f"{BASE}/uploads", headers=H, files={"file": f}, data={"kind": "audio"})
voice.raise_for_status()

job = requests.post(f"{BASE}/reference-to-video", headers=H, json={
    "prompt": "<Picture 1> is a young woman with short silver hair; <Picture 2> is a red trail-running shoe. "
              "At dawn on a mountain ridge, <Picture 1> laces up <Picture 2>, stands and says in the voice of "
              "<Audio 1>: \"Today we go higher.\" She starts to run; the camera follows from the side. "
              "Wind, footsteps on gravel, distant birds.",
    "reference_image_urls": ["https://cdn.example.com/runner.png", "https://cdn.example.com/shoe.png"],
    "reference_audio_urls": [voice.json()["url"]],
    "duration": 10,
    "aspect_ratio": "16:9",
})
job.raise_for_status()
job = job.json()
print("job", job["request_id"], "costs", job["credits"], "credits")

while (s := requests.get(job["status_url"], headers=H).json())["status"] in ("IN_QUEUE", "IN_PROGRESS"):
    time.sleep(10)

result = requests.get(job["response_url"], headers=H).json()
if result["status"] != "COMPLETED":
    raise SystemExit(f"{result['status']}: {result.get('error', '')}")
for i, video in enumerate(result["videos"]):
    with open(f"video-{job['request_id']}-{i}.{video['format']}", "wb") as f:
        f.write(requests.get(video["url"]).content)

TypeScript

// Node 18+ (global fetch).   HP_KEY=hp_… npx tsx r2v.ts
import { readFile, writeFile } from 'node:fs/promises';

const BASE = 'https://api.happypony.io/api/v1/jobs';
const AUTH = { Authorization: `Bearer ${process.env.HP_KEY}` };
const H = { ...AUTH, 'Content-Type': 'application/json' };

// A local voice clip: upload it, then use the returned URL.
const form = new FormData();
form.append('file', new Blob([await readFile('voice.mp3')], { type: 'audio/mpeg' }), 'voice.mp3');
form.append('kind', 'audio');
const voice = await (await fetch(`${BASE}/uploads`, { method: 'POST', headers: AUTH, body: form })).json();

const res = await fetch(`${BASE}/reference-to-video`, {
  method: 'POST', headers: H,
  body: JSON.stringify({
    prompt: '<Picture 1> is a young woman with short silver hair; <Picture 2> is a red trail-running shoe. ' +
      'At dawn on a mountain ridge, <Picture 1> laces up <Picture 2>, stands and says in the voice of <Audio 1>: ' +
      '"Today we go higher." She starts to run; the camera follows from the side. Wind, footsteps on gravel, distant birds.',
    reference_image_urls: ['https://cdn.example.com/runner.png', 'https://cdn.example.com/shoe.png'],
    reference_audio_urls: [voice.url],
    duration: 10,
    aspect_ratio: '16:9',
  }),
});
const job = await res.json();
if (!res.ok) throw new Error(`${res.status}: ${job.message}`);

let status = 'IN_QUEUE';
while (status === 'IN_QUEUE' || status === 'IN_PROGRESS') {
  await new Promise((r) => setTimeout(r, 10_000));
  status = (await (await fetch(job.status_url, { headers: H })).json()).status;
}
const result = await (await fetch(job.response_url, { headers: H })).json();
if (result.status !== 'COMPLETED') throw new Error(`${result.status}: ${result.error ?? ''}`);
for (const [i, video] of result.videos.entries()) {
  await writeFile(`video-${job.request_id}-${i}.${video.format}`, Buffer.from(await (await fetch(video.url)).arrayBuffer()));
}