搜索

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

返回博客
教程5 分钟阅读

Wan 3.0 API 接入教程:curl、Python 和全部参数

万相 Wan 3.0 标准版怎么调:提交和取结果、首尾帧与参考模式、全部参数、常见报错,480P 5 秒 $0.20。

HiAPI 编辑部Wan 3.0API 教程视频生成

万相 Wan 3.0 标准版(wan3.0-video)在 HiAPI 上走统一异步接口:POST /v1/tasks 提交,拿到 taskId,再用 GET /v1/tasks/{taskId} 取结果。只写一句提示词就能出带声音的视频;也能加首帧、尾帧,或者最多 10 张参考图、5 段参考视频、5 段参考音频一起控制生成。这篇给出能直接跑的 curl 和 Python 示例、现在的全部参数,以及上线前要注意的几件事。

先看价格

分辨率每秒5 秒
480P$0.04$0.20
720P$0.08$0.40
1080P(默认)$0.16$0.80

HiAPI 现价,2026 年 10 月 18 日核对。声音默认开,不另收费。

注意默认值:不写 resolution 就是 1080P,不写 duration 就是 5 秒,一条 $0.80。试提示词时记得显式写 "resolution": "480P"。

要更快出片可以用加速版 wan3.0-video-prime,价格是标准版的两倍多(480P 每秒 $0.0875)。

一条真实成片

480P,16:9,5 秒,带声音:

A steaming noodle stall at a night market, close on the cook's hands as she lifts a tangle of noodles from a boiling pot and swirls them into a blue-rimmed bowl; slow push-in, warm tungsten light against cool blue street glow, steam drifting through the frame. Sound: rolling boil, the clink of a ladle, crowd murmur and a scooter passing in the distance.

用这条提示词生成 →

wan3.0-video,480P,5 秒,$0.20。

跑通第一条

准备:在 控制台 创建 API Key。新用户注册送 200 积分。

curl:提交任务

curl -s -X POST https://api.hiapi.ai/v1/tasks \
  -H "Authorization: Bearer $HIAPI_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "wan3.0-video",
    "input": {
      "prompt": "A steaming cup of coffee on a wooden table, soft morning light, gentle steam rising. Sound: a quiet cafe.",
      "resolution": "480P",
      "duration": 5,
      "aspect_ratio": "16:9"
    }
  }'

马上返回 taskId,生成在后台进行:

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

curl:查结果

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

data.status 变成 success 后,data.output[0].url 就是视频地址。临时地址大约 7 天后过期,要尽快下载转存。fail 表示失败,不扣费。

Python

import os, time, requests

KEY = os.environ["HIAPI_KEY"]
BASE = "https://api.hiapi.ai/v1"
H = {"Authorization": f"Bearer {KEY}", "Content-Type": "application/json"}

r = requests.post(f"{BASE}/tasks", headers=H, json={
    "model": "wan3.0-video",
    "input": {
        "prompt": "A steaming cup of coffee on a wooden table, soft morning light, gentle steam rising. Sound: a quiet cafe.",
        "resolution": "480P",
        "duration": 5,
    },
})
task_id = r.json()["data"]["taskId"]

while True:
    d = requests.get(f"{BASE}/tasks/{task_id}", headers=H).json()["data"]
    if d["status"] in ("success", "fail"):
        break
    time.sleep(10)

print(d["output"][0]["url"] if d["status"] == "success" else d)

短视频一般几分钟出片,轮询间隔 10 秒就够。

全部参数

字段必填取值说明
prompt是文本场景、动作、镜头、光线和声音都写这里;参考模式下用 Image1、Video1、Audio1 指代素材
resolution否480P / 720P / 1080P(默认)决定每秒单价
duration否整数 2–30,默认 5参考视频总时长加输出时长不能超过 30 秒
aspect_ratio否adaptive(默认)/ 16:9 / 4:3 / 1:1 / 3:4 / 9:16adaptive 按素材和提示词自动选
audio否布尔,默认 true是否带同步音轨
seed否0–2147483647固定后便于复现
first_frame_url否1 个图片 URL首帧模式
last_frame_url否1 个图片 URL和首帧一起用,指定尾帧
reference_image_urls否最多 10 个参考图
reference_video_urls否最多 5 个,单段 1–15 秒,合计 ≤15 秒参考视频
reference_audio_urls否最多 5 个 WAV/MP3要和图片或视频一起用
reference_file_urls否最多 1 个文档或演示文稿
reference_link_urls否最多 1 个无需登录的网页

两个模式不能混用:首帧/尾帧模式和 reference_* 参考模式互斥,一次请求只能选一种。

参考模式的写法示例:

{
  "model": "wan3.0-video",
  "input": {
    "prompt": "Use Image1 as the product: slow quarter orbit around it on a wooden counter, soft morning window light. Sound: gentle pouring water.",
    "reference_image_urls": ["https://example.com/product.jpg"],
    "resolution": "480P",
    "duration": 5
  }
}

常见报错

都是提交时同步返回 HTTP 400,不会建任务、不扣费:

  • duration: maximum: got 99, want 30:时长超过 30 秒。
  • resolution: value must be one of '480P', '720P', '1080P':分辨率要大写 P。
  • additional properties 'negative_prompt', 'image_urls' not allowed:这个模型没有负面提示词;参考图字段叫 reference_image_urls,不叫 image_urls。
  • API Key 错误返回 HTTP 401,余额不足返回 402。

任务建好之后失败的,在查询结果里是 status: "fail",HTTP 状态码仍是 200,所以要看 data.status。

上线前注意

  • 用回调代替轮询:请求体顶层加 "callback": {"url": "https://你的域名/hiapi/callback", "when": "final"},任务结束时 HiAPI 主动通知你。callback 放在顶层,不要放进 input。
  • 防重复扣费:提交时带 Idempotency-Key 请求头。网络超时重试时用同一个 key,会返回原来的 taskId,不会多建一个任务。
  • 及时转存:临时地址约 7 天过期。需要长期保存,创建时传 "storage": "persistent",或之后转为持久存储,见 创建任务文档。

常见问题

不给参考图能用吗?

能。只写 prompt 就能出视频,参考素材是可选的。

声音要加钱吗?

不加。audio 默认开,价格只看分辨率和秒数。不要声音就传 false。

想要竖屏?

aspect_ratio 传 9:16。

首帧和参考图能一起用吗?

不能,二选一。

更多提示词写法见 Wan 3.0 提示词大全,4 个场景都配了真实成片。也可以直接复制上面的面摊提示词,花 $0.20 生成一条。

现在就用 HiAPI 生成

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

HiAPI Blog

相关文章

HiAPI

现在就用 HiAPI 生成

开始生成