API 参考

回调:视频完成时通知你

不想轮询的话,在创建任务时传入 callback_url。生成成功或失败后,我们会把任务对象 POST 到这个地址。

获取 API 密钥Wan 3 API 团队 ·

回调:视频完成时通知你

不想轮询的话,在创建任务时传入 callback_url。生成成功或失败后,我们会把任务对象 POST 到这个地址。

curl -X POST "https://api.wan3api.org/v1/videos/generations" \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
  "model": "wan-3",
  "prompt": "A red fox runs through fresh snow at sunrise, slow motion, cinematic",
  "duration": 5,
  "resolution": "480P",
  "aspect_ratio": "16:9",
  "callback_url": "https://your-app.com/webhooks/video"
}'

请求内容

JSON 格式的任务对象,与 GET /tasks/:id 返回的一致,Content-Type 为 application/json,并带 X-Task-Id 头。

json
{
  "id": "3f1c9a52-6d1e-4c1b-9a77-2f4d8f0c9e10",
  "object": "video.generation",
  "model": "wan-3",
  "mode": "text",
  "status": "succeeded",
  "progress": 100,
  "prompt": "A red fox runs through fresh snow at sunrise, slow motion, cinematic",
  "duration": 5,
  "resolution": "480P",
  "aspect_ratio": "16:9",
  "video_url": "https://api.wan3api.org/api/video/media/video/outputs/…/3f1c9a52.mp4",
  "credits": 15,
  "refunded": false,
  "error": null,
  "source": "api",
  "created_at": "2026-11-01T08:00:00.000Z",
  "completed_at": "2026-11-01T08:00:41.000Z"
}

投递与重试

请在 10 秒内返回任意 2xx。超时或 5xx 时总共尝试 3 次;返回 4xx 则停止重试。每个任务最多投递一次,请保留轮询作为兜底。

先校验再信任

回调没有签名。请把它当作提示:取出任务 ID 后用你的密钥调用 GET /tasks/:id,以该响应为准。

javascript
// Express: confirm the task with your key before acting on it.
app.post("/webhooks/video", express.json(), async (req, res) => {
  res.sendStatus(200);
  const response = await fetch(`https://api.wan3api.org/v1/tasks/${req.body.id}`, {
    headers: { Authorization: `Bearer ${process.env.API_KEY}` },
  });
  const task = await response.json();
  if (task.status === "succeeded") await saveVideo(task.id, task.video_url);
});