搜索

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

返回博客
教程3 分钟阅读

Wan 3.0 Prime API 中文教程:文生、首尾帧、参考生视频

curl 和 Python 示例,参考图、音频、文档和网页怎么传,参数一览、费用和容易踩的坑。

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

TL;DR

  • Wan 3.0 Prime(万相 3.0 加速版)是阿里 Wan 3.0 的快速线路,模型名 wan3.0-video-prime。一个模型就能做文生视频、首尾帧生视频和参考生视频,参考素材可以是图片、音频,甚至一份文档或一个网页。单条 2–30 秒,默认带声音。打开模型页 就能在线生成。
  • 按秒计费:480P 每秒 $0.0875,720P $0.18,1080P $0.36。5 秒 480P 只要 $0.4375。
  • 两个坑:分辨率必须写大写 480P / 720P / 1080P,而且默认是 1080P;Prime 不收参考视频。

先看效果

文生视频,480P、5 秒,带声音(打开声音能听到雨声、车流和烤炉的滋滋声):

Rain streaking down a narrow neon-lit alley at night; a slow dolly-forward past
steaming street-food stalls, magenta and cyan reflections rippling in the wet
pavement, a tabby cat darting between crates mid-shot. Ambient sound: steady
rain, distant traffic hiss, the sizzle of a grill and a low synth drone.

用这个提示词生成 →(5 秒、480P、16:9、开声音)

wan3.0-video-prime,480P,5 秒,带声音,$0.4375。

参考生视频:传一张陶瓷狐狸摆件的图,让它动起来,外观保持不变。

参考图:灰色背景前围着芥末黄围巾的陶瓷狐狸

Bring the referenced ceramic fox figurine to life: it slowly turns its head
toward camera, blinks, and tilts with a curious expression; subtle idle
breathing, a light breeze stirring the tiny scarf, soft studio key light on a
clean seamless backdrop, smooth loopable motion.

用这个提示词生成 →(上传你的参考图,5 秒、480P、9:16)

wan3.0-video-prime,参考图,480P,5 秒,9:16,$0.4375。

curl:第一条视频

5 秒 480P,$0.4375:

curl -X POST https://api.hiapi.ai/v1/tasks \
  -H "Authorization: Bearer $HIAPI_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "wan3.0-video-prime",
    "input": {
      "prompt": "一只橘猫趴在洒满阳光的窗台上打哈欠,尾巴轻轻摆动,镜头缓慢推近,暖色调",
      "resolution": "480P",
      "duration": 5,
      "aspect_ratio": "16:9",
      "audio": false
    }
  }'

返回 data.taskId 后,用 GET /v1/tasks/{taskId} 查到 status 为 success,再下载 output[0].url。

Python:提交、轮询、下载

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

API = "https://api.hiapi.ai/v1/tasks"
H = {"Authorization": f"Bearer {os.environ['HIAPI_KEY']}"}

def generate(timeout_s=900, **inp):
    # 重试提交同一个任务时带同一个 Idempotency-Key,避免重复扣费
    r = requests.post(API, json={"model": "wan3.0-video-prime", "input": inp},
                      headers={**H, "Idempotency-Key": str(uuid.uuid4())}, timeout=30)
    r.raise_for_status()
    task_id = r.json()["data"]["taskId"]
    deadline = time.time() + timeout_s
    while time.time() < deadline:
        d = requests.get(f"{API}/{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)

# 参考生视频:让参考图里的产品动起来,480P 5 秒($0.4375)
url = generate(
    prompt="让参考图里的香水瓶在黑色大理石上缓慢旋转,侧逆光扫过瓶身,镜头缓慢推近",
    reference_image_urls=["https://your-cdn.example.com/perfume.jpg"],
    resolution="480P", duration=5, aspect_ratio="9:16", audio=False,
)
with open("clip.mp4", "wb") as f:
    f.write(requests.get(url).content)

三种用法

用法传什么说明
文生视频只传 prompt
首尾帧first_frame_url,可再加 last_frame_url不能和参考素材同时用
参考生视频reference_image_urls(最多 10 张)、reference_audio_urls(最多 5 段,要和图片一起用)、reference_file_urls 或 reference_link_urls(各最多 1 个,二选一)提示词里按顺序用 Image1、Audio1 指代素材

参考文档和网页是 Wan 3.0 的特色:可以把一份品牌规范 PDF 或一个商品页链接交给模型,让它按里面的信息出片。网页要无需登录就能打开。

参数一览

参数取值说明
prompt字符串,必填写场景、动作、镜头、光线和声音
resolution480P / 720P / 1080P,默认 1080P大写,直接决定价格
duration2–30 的整数,默认 5单位秒
aspect_ratioadaptive 16:9 4:3 1:1 3:4 9:16,默认 adaptiveadaptive 按素材和提示词自动选
audio默认 true同步音轨,不额外收费
seed0–2147483647固定种子方便复现
first_frame_url / last_frame_url图片地址首尾帧
reference_image_urls 等见上表参考生视频

算一下费用

时长480P($0.0875/秒)720P($0.18/秒)1080P($0.36/秒)
5 秒$0.4375$0.90$1.80
10 秒$0.875$1.80$3.60
30 秒$2.625$5.40$10.80

先用 480P 调提示词,定稿再上 720P 或 1080P。不赶时间的话,Wan 3.0 标准版(wan3.0-video)720P 每秒只要 $0.08,还能传参考视频。完整价格见 Wan 3.0 Prime API 价格。

上线前注意

  • 用回调代替轮询:请求顶层(和 input 同级)加 "callback": {"url": "https://你的域名/hiapi/callback"},按 taskId 去重。
  • 及时转存:output[0].url 是临时链接。
  • 重试带幂等键:请求头加 Idempotency-Key,同一个键重试只创建一次任务。
  • 失败自动退款:只按成功生成的视频计费。

常见问题

为什么传 720p 报错?

分辨率要写大写。传小写会返回 400:resolution: value must be one of '480P', '720P', '1080P'。

能传参考视频吗?

Prime 不能,传 reference_video_urls 会返回 400。要参考视频,换 Wan 3.0 标准版 wan3.0-video。

声音能关吗?

能,audio: false。默认是开的,价格不变。

Prime 和 Wan 3.0 标准版有什么区别?

参数和输出规格相同,Prime 生成更快、定价页多列了 480P 档,但 720P 和 1080P 每秒贵一倍多,也不收参考视频。

更多提示词写法看 Wan 3.0 Prime 提示词案例,和上一代的对比看 Wan 3.0 和 Wan 2.7 怎么选。也可以直接去模型页生成雨夜小巷这条。

现在就用 HiAPI 生成

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

HiAPI Blog

相关文章

HiAPI

现在就用 HiAPI 生成

开始生成