搜索

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

返回博客
教程6 分钟阅读

Veo 3.1 API 怎么用?5 分钟跑通第一条视频

标准版、Fast、Lite 三档怎么选,curl 和 Python 可直接运行,图生视频参数和上线前注意事项。

HiAPI 编辑部Veo 3.1API 教程视频生成

TL;DR

  • Veo 3.1 是 Google 的视频生成模型,在 HiAPI 上分标准版、Fast、Lite 三档,文生视频和图生视频都有,打开模型页 就能在线生成,新用户注册送 200 积分。
  • 按秒计费:Lite 720p 无声音每秒 $0.06,Fast 720p/1080p 带声音每秒 $0.25,标准版每秒 $0.57;4 秒的 Lite 草稿只要 $0.24。
  • API 两步走:POST /v1/tasks 提交,拿 taskId 查结果。下面的 curl 和 Python 复制就能跑。

Veo 3.1 能做什么?

  • 原生声音:画面和声音一起生成,环境音、音效、动作的声响都跟着画面走;generate_audio 默认开启,关掉更便宜。
  • 4、6、8 秒三种时长,16:9 横屏或 9:16 竖屏。
  • 最高 4K:标准版和 Fast 支持 720p、1080p、4K;Lite 支持 720p、1080p。
  • 图生视频:传一张图当首帧,模型让它动起来,画幅可以跟随原图。

下面这条 6 秒 1080p 竖屏视频,是用一张运动鞋产品图、一次请求生成的,落地的闷响和低音鼓点都是模型自己配的:

The sneaker slowly rotates about 90 degrees as the camera pushes in from a low angle. Dust particles drift through the rim light. The shoe settles onto the wet stone pedestal with a deep, satisfying thud, sending a soft ring of mist rolling off the edges. A warm light sweep travels across the suede texture. Subtle bass-heavy electronic pulse builds in the background with a low whoosh on the landing. Cinematic product commercial, smooth stabilized motion, no text overlays.

用这个提示词生成 →(先上传一张 9:16 的产品图)

veo-3.1/image-to-video,1080p,6 秒,带声音,$3.42,从提交到完成约 115 秒。

三档怎么选?

档位720p/1080p 带声音720p/1080p 无声音4K 带声音适合
Lite veo-3.1-lite$0.1(720p)/ $0.14(1080p)$0.06(720p)/ $0.1(1080p)—调提示词、批量草稿
Fast veo-3.1-fast$0.25$0.17$0.6社交短视频成片
标准版 veo-3.1$0.57$0.29$0.86广告、品牌片

单位都是每秒。8 秒带声音:Lite 1080p $1.12,Fast $2,标准版 $4.56。更细的账看 Veo 3.1 API 价格。

两条上手路线

在线试用(不写代码)

  1. 打开 Veo 3.1 Lite 文生视频 模型页,注册或登录。
  2. 粘贴提示词,选时长、分辨率、画幅,决定要不要声音。
  3. 点生成,出片后直接下载。

API 调用

  1. 在控制台创建 API Key。
  2. POST https://api.hiapi.ai/v1/tasks 提交任务,返回 taskId。
  3. GET /v1/tasks/{taskId} 查状态,status 为 success 时从 output[0].url 下载视频。

curl:第一条视频

先用最便宜的 Lite 跑通,4 秒 720p 无声音 $0.24:

curl -X POST https://api.hiapi.ai/v1/tasks \
  -H "Authorization: Bearer $HIAPI_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "veo-3.1-lite/text-to-video",
    "input": {
      "prompt": "A matte-black wireless earbud case slowly rotates on a reflective black surface under a single overhead spotlight.",
      "duration": 4,
      "resolution": "720p",
      "aspect_ratio": "9:16",
      "generate_audio": false
    }
  }'

返回:

{"code": 200, "data": {"taskId": "tk-hiapi-..."}, "message": "success"}

查结果:

curl https://api.hiapi.ai/v1/tasks/tk-hiapi-... \
  -H "Authorization: Bearer $HIAPI_KEY"

Python:提交、轮询、下载

# pip install requests;先 export HIAPI_KEY=你的 Key
import os, time, uuid, requests

KEY = os.environ["HIAPI_KEY"]
H = {"Authorization": f"Bearer {KEY}"}

def generate(prompt, model="veo-3.1-lite/text-to-video", timeout_s=900, **params):
    body = {"model": model, "input": {"prompt": prompt, **params}}
    # 重试提交同一个任务时带同一个 Idempotency-Key,避免重复扣费
    headers = {**H, "Idempotency-Key": str(uuid.uuid4())}
    r = requests.post("https://api.hiapi.ai/v1/tasks", json=body, headers=headers, timeout=30)
    r.raise_for_status()
    res = r.json()
    if res.get("code") != 200:
        raise RuntimeError(res)
    task_id = res["data"]["taskId"]
    deadline = time.time() + timeout_s
    while time.time() < deadline:
        d = requests.get(f"https://api.hiapi.ai/v1/tasks/{task_id}", headers=H, timeout=30).json()["data"]
        if d["status"] == "success":
            return d["output"][0]["url"]
        if d["status"] == "fail":
            raise RuntimeError(d)
        time.sleep(10)
    raise TimeoutError(task_id)

url = generate(
    "A barista pours hot water in a slow spiral over ground coffee, steam rising in morning light",
    duration=4, resolution="720p", aspect_ratio="16:9", generate_audio=True,
)
with open("clip.mp4", "wb") as f:
    f.write(requests.get(url).content)

提示词定下来以后,把 model 换成 veo-3.1-fast/text-to-video 或 veo-3.1/text-to-video 出成片,其他参数不变。

图生视频

模型名换成 …/image-to-video,在 input 里加一张图(image_url 是字符串,只收一张):

{
  "model": "veo-3.1/image-to-video",
  "input": {
    "prompt": "The sneaker slowly rotates and settles onto the wet stone pedestal with a deep thud",
    "image_url": "https://your-cdn.example.com/sneaker-916.jpg",
    "aspect_ratio": "auto",
    "resolution": "1080p",
    "duration": 6
  }
}
  • aspect_ratio 写 auto 跟随原图;也可以指定 16:9 或 9:16,其他比例的图会被裁切。
  • 原图建议 720p 以上、16:9 或 9:16,不支持 SVG。
  • 提示词写"接下来几秒怎么动",不用重新描述整张图。

上线前注意

  • 用回调代替轮询:请求顶层加 "callback": {"url": "https://你的域名/hiapi/callback"},任务结束时 HiAPI 主动通知,按 taskId 去重。
  • 及时转存:output[0].url 是临时链接,拿到后马上存到自己的存储。
  • 参数写全:duration 默认 8 秒,标准版和 Fast 的 resolution 必填;显式写上时长、分辨率和 generate_audio,费用才能和预算对上。
  • 不要声音就关掉:generate_audio: false 后,Lite 720p 从每秒 $0.1 降到 $0.06,标准版从 $0.57 降到 $0.29。
  • 失败自动退款:只按成功生成的视频计费。

常见问题

提示词能写中文吗?

能,中英文都可以。镜头、动作、声音分句写,效果最稳。

能生成 10 秒视频吗?

单次只支持 4、6、8 秒。更长的成片可以分段生成后剪辑。

声音能单独控制吗?

可以在提示词里写清每一层声音(近处的动作声、环境人声、风声),模型会分别生成;不要声音就把 generate_audio 设为 false。

用 Lite 调好的提示词,换标准版要改什么?

只换模型名。prompt、duration、aspect_ratio、generate_audio 都通用;要 4K 时再把 resolution 改成 4k(Lite 没有 4K)。

想要现成的提示词,看 Veo 3.1 提示词案例;也可以复制上面的运动鞋提示词,去模型页生成。

现在就用 HiAPI 生成

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

HiAPI Blog

相关文章

HiAPI

现在就用 HiAPI 生成

开始生成