Wan 2.6

Wan 2.6 是阿里巴巴的视频生成模型,支持文生视频、单首帧图生视频,以及基于参考图片/视频的参考生视频,可输出 720p1080p

模型

模型名模式
wan-2.6-text-to-video文生视频
wan-2.6-image-to-video图生视频(单首帧)
wan-2.6-reference-to-video参考生视频(参考图片与参考视频)

计费

按每秒 x 分辨率计费,价格与 Wan 2.7 保持一致:

分辨率积分/秒
720p24
1080p40

创建任务

POST https://api.aivideoapi.ai/v1/videos/generations

请求体

字段类型必填说明
modelstring上表中的模型名之一
inputobject生成参数
callback_urlstring任务完成/失败的回调通知地址

公共 Input

字段类型必填说明
promptstring文本提示词,最长 1500 字符
negative_promptstring反向提示词,最长 500 字符
resolutionstring720p1080p,默认 1080p
shot_typestringsinglemulti,默认 singlemulti 要求 prompt_extend 为 true。
prompt_extendboolean是否启用提示词扩写,默认 true
watermarkboolean是否添加水印,默认 false
seedinteger02147483647 之间的整数

文生视频 Input

字段类型必填说明
promptstring文本提示词
aspect_ratiostring16:99:161:14:33:4;默认 16:9
durationinteger2-15 秒,默认 5
audio_urlsstring[]可选参考音频 URL,取第一个

图生视频 Input

字段类型必填说明
promptstring文本提示词
image_urlsstring[]恰好 1 个公网 HTTP(S) 首帧图片 URL。不支持 Base64。
audio_urlsstring[]可选驱动音频 URL,取第一个
durationinteger2-15 秒,默认 5
audioboolean是否生成音频,默认由上游模型决定

输出宽高比跟随首帧图片。

参考生视频 Input

字段类型必填说明
promptstring文本提示词,可用 character1character2 等按顺序引用参考素材
image_urlsstring[]否*参考图片 URL,最多 5 个
video_urlsstring[]否*参考视频 URL,最多 3 个
aspect_ratiostring16:99:161:14:33:4;默认 16:9
durationinteger2-10 秒,默认 5
audioboolean是否生成音频,默认由上游模型决定

* image_urlsvideo_urls 至少传一个非空,且二者合计不超过 5 个。

示例

文生视频

curl -X POST https://api.aivideoapi.ai/v1/videos/generations \
  -H "Authorization: Bearer sk-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "wan-2.6-text-to-video",
    "callback_url": "https://your-server.com/webhook",
    "input": {
      "prompt": "雨夜霓虹小巷中,一个小机器人缓慢前行的电影感镜头",
      "aspect_ratio": "16:9",
      "resolution": "1080p",
      "duration": 5
    }
  }'

图生视频

curl -X POST https://api.aivideoapi.ai/v1/videos/generations \
  -H "Authorization: Bearer sk-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "wan-2.6-image-to-video",
    "callback_url": "https://your-server.com/webhook",
    "input": {
      "prompt": "主体转向镜头,背景灯光轻微流动",
      "image_urls": ["https://example.com/first-frame.png"],
      "resolution": "1080p",
      "duration": 5
    }
  }'

参考生视频

curl -X POST https://api.aivideoapi.ai/v1/videos/generations \
  -H "Authorization: Bearer sk-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "wan-2.6-reference-to-video",
    "callback_url": "https://your-server.com/webhook",
    "input": {
      "prompt": "character1 走进房间并和 character2 说话。",
      "image_urls": ["https://example.com/character1.png"],
      "video_urls": ["https://example.com/character2.mp4"],
      "aspect_ratio": "16:9",
      "resolution": "1080p",
      "duration": 8,
      "shot_type": "multi"
    }
  }'

响应

{
  "code": 200,
  "msg": "success",
  "data": {
    "taskId": "8b6a5162-5c91-4a42-8e80-4c8ef5486f24"
  }
}

查询任务

curl https://api.aivideoapi.ai/v1/tasks/{taskId} \
  -H "Authorization: Bearer sk-your-api-key"

状态流转:pending -> processing -> completedfailed

任务失败时,预扣的积分将自动退还。


常见错误码

请求失败时,API 返回 JSON 格式的错误响应:

{
  "error": {
    "code": "insufficient_credits",
    "message": "Your credit balance is too low. Please top up.",
    "type": "billing_error"
  }
}

错误码一览

HTTP 状态码错误码类型说明
400invalid_requestinvalid_request_error缺少必填参数或参数无效
401invalid_api_keyauthentication_errorAPI Key 无效、已禁用或已删除
402insufficient_creditsbilling_error积分余额不足,请充值
403ip_not_allowedpermission_error请求 IP 不在 Key 的白名单中
404model_not_foundinvalid_request_error模型不存在或已停用
404task_not_foundinvalid_request_error任务 ID 不存在
429rate_limit_exceededrate_limit_error请求过于频繁,请降低频率
429spend_limit_exceededbilling_error达到 Key 的消费限额(每小时/每天/总量)
500internal_errorapi_error服务器内部错误
503upstream_errorupstream_error上游 AI 服务返回错误

常见场景

invalid_request (400)

缺少必填字段或参数格式错误时返回。

{
  "error": {
    "code": "invalid_request",
    "message": "'model' is required.",
    "type": "invalid_request_error"
  }
}

insufficient_credits (402)

积分不足。可通过 GET /v1/credits 查询余额,前往 Dashboard > Billing 充值。

invalid_api_key (401)

可能原因:

  • Key 不以 sk- 开头
  • Key 已被禁用或删除
  • 用户账户已被封禁

upstream_error (503)

上游 AI 服务返回错误,可能原因:

  • 输入内容包含敏感或违规信息
  • 上游服务暂时不可用
  • 请求参数不被上游支持

因上游错误导致任务失败时,预扣积分会自动退还。