万相 3.0 API(Wan 3.0 Video API)

万相 3.0 All-in-One 通过单一公开模型 wan-3.0-video,统一支持文生视频、首/尾帧图生视频、多模态参考生视频、参考文件和公开网页生成视频。

本接入使用阿里云百炼获邀的北京 Workspace。官方文档列出的输出档位为 480p、720p、1080p

计费

分辨率每计费秒积分5 秒纯文生视频
480p1260 积分
720p24120 积分
1080p48240 积分

没有参考视频时,计费秒数等于请求的输出时长;带 video_urls 时:

(探测到的输入视频秒数 + 请求输出秒数)× 分辨率费率

图片、音频、文件和网页不会计入输入视频时长。例如 4.5 秒参考视频 + 5 秒 720p 输出,费用为 (4.5 + 5) × 24 = 228 积分。

创建任务

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

请求体

字段类型必填说明
modelstring固定为 wan-3.0-video
inputobject提示词、媒体和输出参数
callback_urlstring接收终态通知的公网回调 URL

input.prompt 与媒体字段各自都可选,但至少需要提供一个有效提示词或媒体输入。

Input 字段

字段类型默认值说明
promptstring最长 20,000 字符
first_frame_urlstring公网 HTTP(S) 首帧图片 URL
last_frame_urlstring公网 HTTP(S) 尾帧图片 URL;必须同时有首帧
image_urlsstring[][]最多 10 张参考图
video_urlsstring[][]最多 5 个 MP4/MOV;单个 1–15 秒,总计不超过 15 秒
audio_urlsstring[][]最多 5 个 MP3/WAV;单个 1–15 秒,总计不超过 15 秒
file_urlstring一个公网文件 URL
link_urlstring一个无需登录的公开网页 URL
resolutionstring1080p480p720p1080p
aspect_ratiostringadaptiveadaptive16:94:31:13:49:16
durationinteger5输出 2–30 秒;不接受 -1
audiobooleantrue输出是否包含音轨
seedinteger0–2147483647
watermarkbooleanfalse是否添加水印

公开契约只接受公网 HTTP(S) URL。Base64、OSS URI、URL 内嵌凭据、localhost 和私网地址不在支持范围内。

模式与时长规则

  • 首/尾帧模式不能与 image_urlsvideo_urlsaudio_urlsfile_urllink_url 混用。
  • last_frame_url 不能脱离 first_frame_url 单独提交。
  • file_urllink_url 互斥。
  • 同类型参考媒体保持数组顺序;提示词中的图、视频、音频分别独立编号。
  • 输入视频总时长 + 输出时长不能超过 30 秒。
  • 为保证准确预扣,自动时长 duration=-1 会被明确拒绝。

创建响应

HTTP 200 会立即返回平台任务 ID。使用 data.taskId 查询任务状态。

{
  "code": 200,
  "msg": "success",
  "data": {
    "taskId": "cbf6b69d-4f03-4817-8ed7-94c0292184a8"
  }
}

示例

文生视频

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-3.0-video",
    "callback_url": "https://your-server.com/webhook",
    "input": {
      "prompt": "一只小猫在月光下的屋顶奔跑,远处城市霓虹闪烁,电影感运镜",
      "resolution": "1080p",
      "aspect_ratio": "16:9",
      "duration": 5,
      "audio": true
    }
  }'

首尾帧生视频

{
  "model": "wan-3.0-video",
  "input": {
    "prompt": "人物从微笑逐渐变为大笑,背景从冷光转为暖光",
    "first_frame_url": "https://example.com/first.jpg",
    "last_frame_url": "https://example.com/last.jpg",
    "duration": 6
  }
}

图片、视频与音频混合参考

{
  "model": "wan-3.0-video",
  "input": {
    "prompt": "视频1提供镜头运动,图1提供角色外观,音频1引导背景音乐",
    "image_urls": ["https://example.com/character.png"],
    "video_urls": ["https://example.com/camera.mp4"],
    "audio_urls": ["https://example.com/music.mp3"],
    "resolution": "720p",
    "duration": 5
  }
}

使用 file_url 传入支持的公网文档,或用 link_url 传入公开网页;一次请求不能同时传两者。

查询任务状态

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

任务状态为 pendingprocessingcompletedfailed。确认失败时只退款一次,成功任务绝不退款。上游记录过期成为 UNKNOWN 时,本地会标记为不可自动退款的失败并保留已消费积分,等待人工核对。Wan 3.0 任务不支持取消。

等待中响应

{
  "id": "cbf6b69d-4f03-4817-8ed7-94c0292184a8",
  "status": "pending",
  "model": "wan-3.0-video",
  "credits_consumed": 0,
  "created_at": 1786330800,
  "estimated_seconds": 300
}

处理中响应

{
  "id": "cbf6b69d-4f03-4817-8ed7-94c0292184a8",
  "status": "processing",
  "model": "wan-3.0-video",
  "credits_consumed": 0,
  "created_at": 1786330800,
  "progress": null
}

成功响应

{
  "id": "cbf6b69d-4f03-4817-8ed7-94c0292184a8",
  "status": "completed",
  "model": "wan-3.0-video",
  "credits_consumed": 240,
  "created_at": 1786330800,
  "completed_at": 1786330928,
  "output": {
    "urls": [
      "https://dashscope-result.oss-cn-beijing.aliyuncs.com/example.mp4"
    ],
    "metadata": {
      "usage": {
        "duration": 5,
        "input_video_duration": 0,
        "output_video_duration": 5,
        "video_count": 1,
        "fps": 24,
        "SR": 1080,
        "ratio": "16:9"
      }
    }
  },
  "usage": {
    "total_seconds": 5,
    "input_seconds": 0,
    "output_seconds": 5,
    "video_count": 1,
    "fps": 24,
    "resolution": 1080,
    "ratio": "16:9"
  }
}

任务进行中以及确认失败退款后,credits_consumed0;成功时为最终实际消耗积分。百炼返回对应字段时,WAN 3.0 成功任务会同时返回顶层 usage

失败响应

{
  "id": "cbf6b69d-4f03-4817-8ed7-94c0292184a8",
  "status": "failed",
  "model": "wan-3.0-video",
  "credits_consumed": 0,
  "created_at": 1786330800,
  "error": {
    "code": "upstream_error",
    "message": "The request failed because an input parameter was rejected."
  }
}

上游记录过期成为 UNKNOWN 时,响应状态同样为 failed,但 credits_consumed 会保留预扣积分,因为该状态不可自动退款。创建任务时若传入 callback_url,成功和失败回调使用与上述终态响应相同的结构。

上游成功链接大约保留 24 小时。账户已开启 Bailian R2 转存时,平台会保存结果;未开启时请及时下载 provider URL。


常见错误码

请求失败时,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 服务返回错误,可能原因:

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

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