搜索

搜索 HiAPI 模型、工具和资源。

返回博客
教程3 分钟阅读

LTX 2.5 Fast 图生视频 API 怎么用?静态图动起来

首帧(可加尾帧)变 2–20 秒视频:curl/Python 示例、首尾帧用法和参数表。

HiAPI 编辑部LTXAPI 接入图生视频

TL;DR

  • LTX 2.5 Fast Image to Video(ltx-2.5-fast/image-to-video)让静态图动起来:上传 1 张首帧图(可再加 1 张尾帧),生成 2–20 秒的 720p / 1080p 视频并配原生音频。打开模型页上传一张图就能试,新用户注册送 200 积分。
  • 价格和文生视频同规则:720p 每秒 $0.043、1080p 每秒 $0.086,按 duration 秒数计费;音频开关不影响价格。
  • 调用走 HiAPI /v1/tasks 接口:image_urls 传 1–2 张图(首帧 / 首帧+尾帧),成功后从 output 取视频。

它能做什么

  • 首帧动起来:一张静态照片 + 一句运动描述,画面主体保持不变,加入运动、镜头和声音。
  • 首帧 + 尾帧:传两张图,模型补出从首帧到尾帧的过渡过程(比如白天小屋到星夜小屋)。
  • 竖版跟随:输出画幅由 aspect_ratio 决定(16:9 / 9:16),建议和首帧一致,避免裁切或留边。
  • 同系列文生视频:从零生成看文生视频接入指南,两个接口价格规则完全一样。

下面是真实成片(静态灯塔照片 → 6 秒有声镜头):

Waves crash against the rocks below the lighthouse, seagulls glide across the golden sky, the camera slowly pushes in, sound of surf and gulls

(中文意思:浪花拍打灯塔下的礁石,海鸥掠过金色天空,镜头缓慢推进,海浪与海鸥的声音。首帧用素材里的灯塔照片,参数:720p、6 秒、16:9。)

首帧图 → 视频封面帧

ltx-2.5-fast/image-to-video,720p,6 秒,16:9,1280×720,有声,$0.258。看完整成片 →

用这个提示词生成 →

首帧 / 首帧 + 尾帧怎么传

输入image_urls效果
1 张["首帧图"]从这张图开始动,主体不变
2 张["首帧图", "尾帧图"]从首帧过渡到尾帧,模型补中间过程

图支持 JPG / PNG / WebP 的公网地址;两张图的画幅建议一致,aspect_ratio 跟首帧设成一样。

两条上手路线

浏览器 3 步:打开模型页 → 上传首帧图、写好运动描述 → 点生成,出片后直接预览。

API 3 步:POST /v1/tasks 提交 → 拿 taskId → GET /v1/tasks/<taskId> 查到 success 后下载。

curl:第一条(单首帧)

curl -X POST https://api.hiapi.ai/v1/tasks \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: your-unique-key-001" \
  -d '{
  "model": "ltx-2.5-fast/image-to-video",
  "input": {
    "prompt": "Waves crash against the rocks below the lighthouse, seagulls glide across the golden sky, the camera slowly pushes in, sound of surf and gulls",
    "image_urls": ["https://static.hiapi.ai/gallery/2026/10/0ca26560398eae72.jpg"],
    "resolution": "720p",
    "duration": 6,
    "aspect_ratio": "16:9"
  }
}'

首帧 + 尾帧(白天小屋 → 星夜小屋)只改 image_urls:

curl -X POST https://api.hiapi.ai/v1/tasks \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "ltx-2.5-fast/image-to-video",
  "input": {
    "prompt": "Time passes from bright winter day to starry night, the sky darkens, the cabin windows light up warmly and smoke rises from the chimney, an aurora appears, fixed camera",
    "image_urls": [
      "https://static.hiapi.ai/gallery/2026/10/7756ea1a228b0b88.jpg",
      "https://static.hiapi.ai/gallery/2026/10/16e267619aa1b003.jpg"
    ],
    "resolution": "720p",
    "duration": 5,
    "aspect_ratio": "16:9"
  }
}'

Python:提交、轮询、下载

import time, uuid, requests

BASE = "https://api.hiapi.ai/v1/tasks"
HEADERS = {
    "Authorization": "Bearer YOUR_API_KEY",
    "Content-Type": "application/json",
}

payload = {
    "model": "ltx-2.5-fast/image-to-video",
    "input": {
        "prompt": "Waves crash against the rocks below the lighthouse, seagulls glide across the golden sky, the camera slowly pushes in, sound of surf and gulls",
        "image_urls": ["https://example.com/your-first-frame.jpg"],
        "resolution": "720p",
        "duration": 6,
        "aspect_ratio": "16:9",
    },
}

resp = requests.post(
    BASE,
    headers={**HEADERS, "Idempotency-Key": str(uuid.uuid4())},
    json=payload,
    timeout=30,
)
resp.raise_for_status()
task_id = resp.json()["taskId"]

while True:
    task = requests.get(f"{BASE}/{task_id}", headers=HEADERS, timeout=30).json()
    print(task["status"])
    if task["status"] in ("success", "fail"):
        break
    time.sleep(5)

if task["status"] == "success":
    video = next(o for o in task["output"] if o.get("type") == "video")
    mp4 = requests.get(video["url"], timeout=120)   # 临时地址,尽快保存
    with open("output.mp4", "wb") as f:
        f.write(mp4.content)
    print("saved output.mp4")

参数表

字段必填取值说明
image_urls是1–2 张公网地址第 1 张首帧;第 2 张尾帧(JPG/PNG/WebP)
prompt是1–5000 字符描述运动、镜头和声音;不用重复描述画面里已有的东西
resolution否720p / 1080p,默认 720p1080p 每秒价约为 720p 的 2 倍
duration否2/3/4/5/6/8/10/12/14/16/18/20,默认 6枚举值
aspect_ratio否16:9 / 9:16,默认 16:9建议与首帧一致,避免裁切或留边
generate_audio否默认 true原生音频;要后期自配音乐就关掉

请求体里出现表外字段会直接 400。

你会遇到的报错

状态码含义怎么处理
400 INVALID_REQUEST请求体不合法(缺 image_urls 或 prompt、传了 3 张图、duration 非枚举值)对照参数表改请求体
402 INSUFFICIENT_QUOTA余额不足(不扣费)充值后重试
429 RATE_LIMITED触发限流降低提交频率
409 / 422 IDEMPOTENCY_KEY_*同一幂等键重复提交换新的 Idempotency-Key

任务终态失败还有 CONTENT_POLICY_VIOLATION、TASK_FAILED、TASK_TIMEOUT 等;失败不扣费。

上线前注意

  • 回调:视频任务耗时长,请求体顶层传 "callback": {"url": "https://..."} 省轮询。
  • 及时转存:output 里的视频地址是临时的,拿到就下载。
  • 首尾帧画幅一致:两张图比例差太多,过渡容易变形;aspect_ratio 跟首帧设成一样。
  • 要后期自配音乐:generate_audio 传 false 得到干净画面,价格不变。
  • 首帧质量决定成片质量:模糊或分辨率太低的首帧,动起来也不会变清楚;先用清晰大图,再交给模型加动态。

常见问题

  • 是的,最多 2 张图:首帧 1 张或首帧 + 尾帧;第 3 张会 400。
  • 是的,画幅不跟随图片:由 aspect_ratio 决定,所以建议手动设成和首帧一致。
  • 是的,价格和文生视频一样:720p 每秒 $0.043,6 秒一条 $0.258。
  • 是的,尾帧过渡适合做「时间流逝」:白天到夜晚、空场景到摆满产品的场景,两张图一句提示词就够。
  • 是的,产品图动起来是它的强项:商品主图当首帧,提示词写运镜(orbit、push in)和点缀元素,一条展示视频就出来。
  • 是的,竖版照片配 9:16:输出 720×1280,直接发短视频平台;横版照片就保持 16:9。

下一步:拿一张你的产品图去模型页动起来,四个图生视频场景看提示词大全。

现在就用 HiAPI 生成

选一个模型,输入你的提示词,直接查看生成结果。

HiAPI Blog

相关文章

HiAPI

现在就用 HiAPI 生成

开始生成