搜索

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

返回博客
教程3 分钟阅读

Grok Imagine 1.5 Lite 文生视频 API 怎么用?自带音效

文字生成 1–15 秒带音效视频:三档价格、七种画幅、curl/Python 示例。

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

TL;DR

  • Grok Imagine 1.5 Lite Text to Video(grok-imagine-1.5-lite/text-to-video)用一段文字生成 1–15 秒、自带音效的视频,横屏、竖屏、方形七种画幅原生生成。打开模型页就能试,新用户注册送 200 积分。
  • 价格按秒算:480P $0.029、720P(默认)$0.043、1080P $0.2;一条 720p 6 秒 $0.258。
  • 调用走 HiAPI /v1/tasks 接口:提交任务拿 taskId,再查询结果,成功后从 output 取视频地址(临时地址,及时保存)。

它能做什么

  • 一段话写全画面、动作和声音:镜头怎么走、有什么音效都写进提示词,成片自带音轨(不能关,也不加价)。
  • 1–15 秒任意整数秒:duration 想填几秒填几秒,默认 6。
  • 七种画幅原生生成:16:9、9:16、1:1、4:3、3:2、2:3、3:4——竖屏和方形不是从横屏裁的。
  • 同系列还有图生视频:grok-imagine-1.5-lite/image-to-video 上传一张图让它动起来,见图生视频接入指南。

两个接口怎么选:

grok-imagine-1.5-lite/text-to-video(本页)grok-imagine-1.5-lite/image-to-video
输入一段文字1 张图 + 运动描述
画幅7 种任选跟随输入图
附加费无每条 $0.015 输入图费
适合从零出镜头、广告创意已有照片或产品图

一句话:画面从零构思用文生,画面已经有了用图生;文案创意和素材图都齐的时候,图生更可控。

下面是真实成片(720p · 6 秒 · 16:9,自带风声和鸟鸣):

A glass hot-air balloon drifts slowly over a misty valley of terraced rice fields at sunrise. Golden light spills across the water-filled terraces, mist rolls between the hills, a flock of white egrets glides beneath the balloon. Smooth aerial tracking shot, gentle wind sounds and distant birdsong, cinematic, natural colors. No text, no logos.

(中文意思:一只玻璃热气球在日出时分缓缓飘过云雾缭绕的梯田山谷。金色阳光洒在灌满水的梯田上,薄雾在山间流动,一群白鹭从气球下方滑翔而过。平稳的航拍跟随镜头,轻柔风声与远处鸟鸣,电影感,自然色彩。不要文字,不要标志。)

封面帧

grok-imagine-1.5-lite/text-to-video,720P,6 秒,16:9,1280×720,自带音效,$0.258。看完整成片 →

用这个提示词生成 →

价格:三档按秒

档位每秒5 秒6 秒15 秒
480P$0.029$0.145$0.174$0.435
720P(默认)$0.043$0.215$0.258$0.645
1080P$0.20$1.00$1.20$3.00

HiAPI 现价,2026 年 10 月 23 日核对。 注意 1080P 每秒 $0.2,是 720P 的约 4.65 倍——批量任务建议 720p 出稿、只给定稿升 1080P。失败不扣费。

两条上手路线

浏览器 3 步:打开模型页 → 粘贴提示词、选时长分辨率画幅 → 点生成,720p 6 秒一条 $0.258,出片之后直接在线预览,满意了再决定要不要继续加量去制作更多的素材。

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/text-to-video",
  "input": {
    "prompt": "A glass hot-air balloon drifts slowly over a misty valley of terraced rice fields at sunrise. Golden light spills across the water-filled terraces, mist rolls between the hills, a flock of white egrets glides beneath the balloon. Smooth aerial tracking shot, gentle wind sounds and distant birdsong, cinematic, natural colors. No text, no logos.",
    "duration": 6,
    "resolution": "720p",
    "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": "grok-imagine-1.5-lite/text-to-video",
    "input": {
        "prompt": "A glass hot-air balloon drifts slowly over a misty valley of terraced rice fields at sunrise. Golden light spills across the water-filled terraces, mist rolls between the hills, a flock of white egrets glides beneath the balloon. Smooth aerial tracking shot, gentle wind sounds and distant birdsong, cinematic, natural colors. No text, no logos.",
        "duration": 6,
        "resolution": "720p",
        "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")

参数表

字段必填取值说明
prompt是1–4096 字符画面、动作、镜头和音效一段写完
duration否1–15 任意整数,默认 6和别家视频模型的枚举时长不同
resolution否480p / 720p / 1080p,默认 720p1080P 每秒 $0.2,注意账单
aspect_ratio否7 种,默认 16:9竖屏、方形原生生成

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

你会遇到的报错

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

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

上线前注意

  • 回调:视频任务耗时长,请求体顶层传 "callback": {"url": "https://..."} 省轮询。
  • 及时转存:output 里的视频地址是临时的,拿到就下载。
  • 声音不能关:要无声素材就在后期剪掉音轨;价格不受影响。
  • 1080P 谨慎批量:每秒 $0.2,一条 6 秒 $1.20;批量探索用 480P($0.174 一条)。

常见问题

  • 是的,每条都自带音效:提示词里写音效(风声、鸟鸣、台词)会跟着生成;没有关闭开关。
  • 是的,时长是任意整数秒(1–15),不限于固定档位。
  • 是的,竖屏和方形是原生生成,不是裁切,构图和横屏一样完整。
  • 是的,$10 约 38 条:720P 6 秒一条 $0.258;480P 一条 $0.174,$10 能跑 57 条,创意探索阶段够用。
  • 是的,三档都能出全部七种画幅,分辨率只影响清晰度,不影响可选比例。
  • 是的,人物能说台词:提示词里用引号写台词(如面包师案例),对白和环境声一起出。

下一步:拿热气球提示词去模型页出第一条,五个场景的提示词可以在文生视频模型页直接试。

现在就用 HiAPI 生成

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

HiAPI Blog

相关文章

HiAPI

现在就用 HiAPI 生成

开始生成