> ## Documentation Index
> Fetch the complete documentation index at: https://docs.magic666.top/llms.txt
> Use this file to discover all available pages before exploring further.

# Wan 3.0 视频生成

> 使用 POST /v1/videos 调用通义万相 Wan 3.0，支持文生、图生、首尾帧、多图参考和多模态参考。

# Wan 3.0 视频生成

Wan 3.0 通过 `POST /v1/videos` 提交异步视频任务。请求体使用 `application/json`，客户端统一访问 `https://magic666.top`。

## 方法与路径

```http theme={null}
POST /v1/videos
```

## 认证

```http theme={null}
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json
```

## 请求示例

<RequestExample>
  ```bash 文生视频 cURL theme={null}
  curl -X POST https://magic666.top/v1/videos \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "wan3.0-video",
      "prompt": "一只小猫在月光下的屋顶上奔跑，电影感镜头，细腻光影",
      "seconds": 5,
      "size": "1080P",
      "aspect_ratio": "16x9"
    }'
  ```

  ```bash 图生视频（首帧） cURL theme={null}
  curl -X POST https://magic666.top/v1/videos \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "wan3.0-video",
      "prompt": "角色从墙上活过来，缓缓转头并走向镜头",
      "image": "https://example.com/first-frame.png",
      "seconds": 5,
      "size": "720P",
      "aspect_ratio": "9x16"
    }'
  ```

  ```bash 首尾帧视频 cURL theme={null}
  curl -X POST https://magic666.top/v1/videos \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "wan3.0-video-prime",
      "prompt": "画面中的人物从微笑慢慢变为大笑，镜头平滑推进",
      "mode": "first-last-frame",
      "image": "https://example.com/first.png",
      "images": [
        "https://example.com/last.png"
      ],
      "metadata": {
        "first_frame_url": "https://example.com/first.png",
        "last_frame_url": "https://example.com/last.png"
      },
      "seconds": 5,
      "size": "1080P",
      "aspect_ratio": "16x9"
    }'
  ```

  ```bash 多图参考 cURL theme={null}
  curl -X POST https://magic666.top/v1/videos \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "wan3.0-video",
      "prompt": "参考人物、道具和场景风格生成一段自然行走的视频",
      "images": [
        "https://example.com/character.png",
        "https://example.com/prop.png",
        "https://example.com/scene.png"
      ],
      "mode": "all-reference",
      "seconds": 10,
      "size": "1080P",
      "aspect_ratio": "16x9"
    }'
  ```

  ```bash 全模态参考（视频 + 图片） cURL theme={null}
  curl -X POST https://magic666.top/v1/videos \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "wan3.0-video",
      "input": {
        "prompt": "视频中的人物抱着图片中的物体，在场景图片的房间内弹奏",
        "media": [
          {
            "type": "reference_video",
            "url": "https://example.com/role.mp4"
          },
          {
            "type": "reference_image",
            "url": "https://example.com/object.png"
          },
          {
            "type": "reference_image",
            "url": "https://example.com/scene.png"
          }
        ]
      },
      "parameters": {
        "resolution": "480P",
        "ratio": "adaptive",
        "duration": 10,
        "audio": true
      }
    }'
  ```

  ```python Python theme={null}
  import requests

  response = requests.post(
      "https://magic666.top/v1/videos",
      headers={
          "Authorization": "Bearer YOUR_API_KEY",
          "Content-Type": "application/json",
      },
      json={
          "model": "wan3.0-video",
          "prompt": "一只小猫在月光下的屋顶上奔跑，电影感镜头，细腻光影",
          "seconds": 5,
          "size": "1080P",
          "aspect_ratio": "16x9",
      },
      timeout=60,
  )

  print(response.json())
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch("https://magic666.top/v1/videos", {
    method: "POST",
    headers: {
      Authorization: "Bearer YOUR_API_KEY",
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      model: "wan3.0-video",
      prompt: "一只小猫在月光下的屋顶上奔跑，电影感镜头，细腻光影",
      seconds: 5,
      size: "1080P",
      aspect_ratio: "16x9",
    }),
  });

  console.log(await response.json());
  ```
</RequestExample>

## 响应示例

<ResponseExample>
  ```json 200 - 提交成功 theme={null}
  {
    "id": "task_xxxx",
    "object": "video",
    "model": "wan3.0-video",
    "status": "queued",
    "created_at": 1782690295
  }
  ```

  ```json 400 - 参数错误 theme={null}
  {
    "error": {
      "message": "prompt is required",
      "type": "invalid_request_error",
      "param": "prompt",
      "code": "invalid_request_error"
    }
  }
  ```

  ```json 401 - 认证失败 theme={null}
  {
    "error": {
      "message": "invalid token",
      "type": "invalid_request_error",
      "code": "invalid_api_key"
    }
  }
  ```

  ```json 402 - 额度不足 theme={null}
  {
    "error": {
      "message": "insufficient quota",
      "type": "invalid_request_error",
      "code": "insufficient_quota"
    }
  }
  ```

  ```json 429 - 请求过多 theme={null}
  {
    "error": {
      "message": "rate limit exceeded",
      "type": "rate_limit_error",
      "code": "rate_limit_exceeded"
    }
  }
  ```
</ResponseExample>

## Body

<ParamField body="model" type="string" required>
  模型名称。支持 `wan3.0-video`（标准版）和 `wan3.0-video-prime`（优速版）。模型必须已在当前账户分组中开通。
</ParamField>

<ParamField body="prompt" type="string" required>
  视频生成提示词。建议描述主体、动作、镜头运动、构图、光影和风格。文生、图生和参考素材场景都建议传入。
</ParamField>

<ParamField body="seconds" type="string | integer">
  生成时长，单位为秒。支持 `2` 到 `30` 秒，默认值为 `5`。可以传数字 `5`，也可以传字符串 `"5"`。
</ParamField>

<ParamField body="duration" type="integer">
  时长兼容字段，单位为秒。与顶层 `seconds` 同时传入时，优先使用 `seconds`。
</ParamField>

<ParamField body="size" type="string">
  输出分辨率档位。支持 `480P`、`720P`、`1080P`，未传时默认使用 `1080P`。Wan 3.0 不使用 WxH 字符串作为主分辨率字段。
</ParamField>

<ParamField body="aspect_ratio" type="string">
  输出画幅比例。支持 `16x9` / `16:9`、`9x16` / `9:16`、`1x1` / `1:1`、`4x3` / `4:3`、`3x4` / `3:4` 和 `adaptive`。
</ParamField>

<ParamField body="image" type="string">
  单张首帧图或参考图 URL。必须是服务端可访问的 `http://` 或 `https://` 地址。单独传一张图时会映射为上游的 `first_frame`。
</ParamField>

<ParamField body="images" type="array<string>">
  多张参考图 URL。没有首尾帧标记且传入至少两张时，会映射为多个 `reference_image`；参考图最多 `10` 张。
</ParamField>

<ParamField body="input_reference" type="string | array<string>">
  OpenAI Videos 兼容的参考图字段。传字符串时等同于一张图片，传数组时会并入 `images`。
</ParamField>

<ParamField body="mode" type="string">
  生成模式提示。`first-last-frame`、`first_last_frame` 和 `kf2v` 表示首尾帧；`all-reference`、`reference` 和 `r2v` 表示全能参考。
</ParamField>

<ParamField body="metadata" type="object">
  扩展参数。常用字段包括 `first_frame_url`、`last_frame_url`、`reference_image_urls`、`reference_video_urls`、`reference_audio_urls` 和 `parameters.audio`。
</ParamField>

<ParamField body="input" type="object">
  高级原生请求结构。`input.media` 存在时会原样透传，媒体类型使用 `first_frame`、`last_frame`、`reference_image`、`reference_video` 或 `reference_audio`。
</ParamField>

<ParamField body="parameters" type="object">
  高级参数对象。原生结构中常用 `resolution`、`ratio`、`duration` 和 `audio`。
</ParamField>

## 参数优先级

时长优先级：

1. 顶层 `seconds`
2. 顶层 `duration`
3. `metadata.parameters.duration`
4. 默认值 `5`

分辨率优先级：

1. 顶层 `size`
2. `metadata.parameters.resolution`
3. 默认值 `1080P`

画幅优先级：

1. 顶层 `aspect_ratio`
2. `metadata.parameters.ratio`

## 请求构造规则

| 场景   | 关键字段                                                     | 上游媒体类型                       |
| ---- | -------------------------------------------------------- | ---------------------------- |
| 文生视频 | `model` + `prompt`                                       | 无 media                      |
| 图生视频 | `image`                                                  | `first_frame`                |
| 首尾帧  | `mode: first-last-frame` + 首尾帧 metadata                  | `first_frame` + `last_frame` |
| 多图参考 | `images`（至少 2 张）或 `mode: all-reference`                  | 多个 `reference_image`         |
| 参考视频 | `metadata.reference_video_urls` 或原生 `input.media`        | `reference_video`            |
| 参考音频 | `metadata.reference_audio_urls` 或原生 `input.media`        | `reference_audio`            |
| 有声视频 | `metadata.parameters.audio: true` 或原生 `parameters.audio` | 由模型能力决定                      |

<Warning>
  首尾帧和参考素材是互斥场景。不要在同一个请求中混合 `first_frame` / `last_frame` 与 `reference_image` / `reference_video` / `reference_audio`。需要首尾帧时，显式传 `mode` 和首尾帧 URL。
</Warning>

## 相关接口

* [Wan 3.0 视频概览](./overview)
* [Wan 3.0 查询视频任务](./query)
* [视频模型支持矩阵](/api-reference/videos/model-matrix)
