搜索

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

返回博客
教程3 分钟阅读

Grok Imagine 1.5 Lite 图生视频 API 怎么用?照片动起来

一张图变 1–15 秒带音效视频:价格含输入图费、画幅跟图走、curl/Python 示例。

HiAPI 编辑部Grok ImagineAPI 接入图生视频

TL;DR

  • Grok Imagine 1.5 Lite Image to Video(grok-imagine-1.5-lite/image-to-video)上传 1 张图让它动起来:1–15 秒、自带音效、画幅跟随输入图。打开模型页上传一张图就能试,新用户注册送 200 积分。
  • 价格 = 每秒价 × 秒数 + 每条 $0.015 输入图费:720P 6 秒一条 $0.273;480P $0.189;1080P $1.215。
  • 调用走 HiAPI /v1/tasks 接口:image_url 是字符串(不是数组),恰好 1 张公网地址。

它能做什么

  • 一张照片变成一段带声音的镜头:动效、运镜和音效由提示词描述,画面主体保持原图。
  • 画幅跟随输入图:横图出 16:9(1264×720)、竖图出 9:16(720×1264)、方图出 1:1(960×960)、4:3 出 1104×816——像素取整到支持的尺寸,比例不变。
  • 1–15 秒任意整数秒,三档分辨率。
  • 同系列文生视频:从零生成看文生视频接入指南;两个接口同价(图生多一笔 $0.015 输入图费)、同一个 /v1/tasks,代码只差 model 和 image_url。

价格表怎么读:

  • 「每秒价 × 秒数」是视频本身的费用,和文生视频完全一样;
  • $0.015 是输入图的附加费,每条固定一笔,跟分辨率、时长无关;
  • 所以同参数下图生比文生贵 $0.015:720P 6 秒 $0.258 + $0.015 = $0.273。批量一千条时这笔差价是 $15,预算里要留出来。

下面是真实成片(冲浪照片 → 6 秒跟拍镜头,自带海浪声):

The wave curls and breaks behind the surfer as he carves down its face, white spray bursts and sparkles in the golden backlight, water rushes past. Smooth tracking camera following the surfer. Loud ocean surf and rushing water. Keep the photo realistic. No text, no logos.

(中文意思:海浪在冲浪者身后翻卷破碎,他沿浪面滑下,白色水花在金色逆光中迸发闪烁。镜头平稳跟拍冲浪者。响亮的海浪与水流声。保持照片写实质感。不要文字,不要标志。)

输入图 · 封面帧

grok-imagine-1.5-lite/image-to-video,720P,6 秒,16:9,1264×720,自带音效,$0.273(含 $0.015 输入图费)。看完整成片 →

用这个提示词生成 →

价格:每秒价 + 输入图费

档位每秒6 秒一条(含 $0.015 输入图费)
480P$0.029$0.189
720P(默认)$0.043$0.273
1080P$0.20$1.215

HiAPI 现价,2026 年 10 月 23 日核对。 image_url 必填所以每条都有这 $0.015;1080P 每秒 $0.2(约 720P 的 4.65 倍),批量探索用 480P。失败不扣费。

两条上手路线

浏览器 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": "grok-imagine-1.5-lite/image-to-video",
  "input": {
    "prompt": "The wave curls and breaks behind the surfer as he carves down its face, white spray bursts and sparkles in the golden backlight, water rushes past. Smooth tracking camera following the surfer. Loud ocean surf and rushing water. Keep the photo realistic. No text, no logos.",
    "image_url": "https://static.hiapi.ai/gallery/2026/10/3f75ff28db9e0070.png",
    "duration": 6,
    "resolution": "720p"
  }
}'

注意 image_url 是字符串、只传一张——传数组会 400。

Python:提交、轮询、下载

import time, uuid, requests

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

payload = {
    "model": "grok-imagine-1.5-lite/image-to-video",
    "input": {
        "prompt": "The wave curls and breaks behind the surfer as he carves down its face, white spray bursts and sparkles in the golden backlight, water rushes past. Smooth tracking camera following the surfer. Loud ocean surf and rushing water. Keep the photo realistic. No text, no logos.",
        "image_url": "https://example.com/your-image.png",
        "duration": 6,
        "resolution": "720p",
    },
}

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_url是字符串,恰好 1 张公网地址输出比例跟随此图
prompt是1–4096 字符描述想要的运动或变化,含音效
duration否1–15 任意整数,默认 6
resolution否480p / 720p / 1080p,默认 720p

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

你会遇到的报错

状态码含义怎么处理
400 INVALID_REQUEST请求体不合法(缺 image_url、把 image_url 传成数组、传表外字段)image_url 用字符串
402 INSUFFICIENT_QUOTA余额不足(不扣费)充值后重试
429 RATE_LIMITED触发限流降低提交频率
409 / 422 IDEMPOTENCY_KEY_*同一幂等键重复提交换新的 Idempotency-Key

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

上线前注意

  • 回调:视频任务耗时长,顶层传 "callback": {"url": "https://..."} 省轮询。
  • 及时转存:output 里的视频地址是临时的,拿到就下载存进自己的存储,别拿临时链接当素材库用。
  • 同一张图可以反复用:换个提示词就是新的一条(新计费),特别适合同一张产品图快速产出一整套多角度运镜的成套展示素材。
  • 算账别漏 $0.015:批量预算按「每秒价 × 秒数 + $0.015 × 条数」算。
  • 声音不能关:要无声素材后期剪;价格不变。

常见问题

  • 是的,每条都自带音效:提示词里写音效(海浪、踩雪声)会跟着生成,没有关闭开关。
  • 是的,画幅跟随输入图:16:9 图出 1264×720、方图出 960×960,像素取整、比例不变。
  • 是的,image_url 是字符串,只能 1 张;传数组或多张会 400。
  • 是的,时长 1–15 任意整数秒,一个动作 5–6 秒、一段连续动作 10 秒以上。
  • 是的,输入图质量决定成片上限:模糊的小图动起来不会变清楚;尽量给 720p 以上的清晰原图。
  • 是的,批量算账有公式:每秒价 × 秒数 + $0.015 × 条数;720P 6 秒一百条 $27.30,一千条 $273.00。

下一步:拿一张你的照片去模型页动起来,四个图生视频场景的提示词可以在图生视频模型页直接试。

现在就用 HiAPI 生成

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

HiAPI Blog

相关文章

HiAPI

现在就用 HiAPI 生成

开始生成