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

# Wan 2.6 Video API：使用文字、图片或参考素材生成视频

> 选择 Wan 2.6 Video API 模式，用于生成提示、单张源图像，或图像与视频参考的混合。支持标准请求和 Flash 请求，并提供音频控制功能。

## 概览

若需为单张图像生成动画，请使用 `wan-2-6-video` 模式，将图像发送至 `image_urls` 字段，通过 [图生视频](#image-to-video) 实现。若需组合多个主体生成镜头，请为每个主体分别提供一张图像或视频片段，发送至 `reference_urls` 字段，使用 [参考生成视频](#reference-to-video)。对于仅使用提示的视频请求（[仅提示视频](#copy-paste-async-quickstart)），可省略两个数组。

两种 Flash 模式支持 `sound` 参数。使用 [图生视频闪存](#image-to-video-flash) 可为肖像添加音频轨道生成动画，使用 [参考生成视频闪存](#reference-to-video-flash) 可从参考素材中合成无声镜头。

| 功能 | 值 |
| - | - |
| 模型 ID | `wan-2-6-video` |
| 模式 | `text-to-video`, `image-to-video-flash`, `image-to-video`, `reference-to-video-flash`, `reference-to-video` |
| 提示词 | 所有模式均需提供，不能为空，最大长度为 `1500` 个字符。 |
| 负面提示 | 可选，最大长度为 `500` 个字符。 |
| 分辨率档位 | `720p`, `1080p` |
| 时长 | `text/image`：`2-15`秒（默认`5`）； `reference`：`2-10` 秒（默认 `5`） |
| 提示重写 | `prompt_extend` 可选布尔值；`true`（默认）启用重写，`false` 禁用重写 |
| 图像输入 | 确切地 `1` URL 为了 `image-to-video-flash` 和 `image-to-video`; `JPEG/JPG/PNG(no alpha)/BMP/WEBP`, `240-8000` 像素, `<=20MB` |
| 参考输入 | `1-5` `reference-to-video-flash` 和 `reference-to-video` 的 URL；与 `images<=5`、`videos<=3`、`images+videos<=5` 混合图像/视频 |
| 音频输入（`audio_urls`） | 可选的 `1` URL 用于文本转视频和图像转视频模式。 `wav/mp3`、`3-30s`、`<=15MB` |
| 闪光音频开关 | `sound` 仅在闪存模式下生效，默认为 `true` |

## 接口与身份验证

API 基础地址：

```text theme={null}
https://api.apixo.ai/api/v1
```

| 方法 | 端点 | 用途 |
| - | - | - |
| `POST` | `/generateTask/wan-2-6-video` | 提交生成任务 |
| `GET` | `/statusTask/wan-2-6-video?taskId={taskId}` | 查询任务状态并获取结果 |

每个请求都必须携带 APIXO API 密钥：

```http theme={null}
Authorization: Bearer YOUR_API_KEY
```

提交任务时，还需要设置以下请求头：

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

## 异步请求示例

以下示例提交一个最简单的文生视频任务，响应中会返回 `taskId`。

```bash theme={null}
curl -X POST "https://api.apixo.ai/api/v1/generateTask/wan-2-6-video" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "request_type": "async",
    "input": {
      "mode": "text-to-video",
      "prompt": "a cinematic fox walking through neon rain",
      "resolution": "720p",
      "duration": 5,
      "prompt_extend": true
    }
  }'
```

成功响应：

```json theme={null}
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_12345678"
  }
}
```

从您提交的响应中保存 `data.taskId` 并在状态查询请求中使用它。

## 轮询结果

```bash theme={null}
TASK_ID="paste-your-returned-task-id"
curl -X GET "https://api.apixo.ai/api/v1/statusTask/wan-2-6-video?taskId=$TASK_ID" \
  -H "Authorization: Bearer YOUR_API_KEY"
```

任务处理中的响应示例：

```json theme={null}
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_12345678",
    "state": "processing",
    "createTime": 1767965610929
  }
}
```

成功响应：

```json theme={null}
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_12345678",
    "state": "success",
    "resultJson": "{\"resultUrls\":[\"https://file.apixo.ai/video.mp4\"]}",
    "createTime": 1767965610929,
    "completeTime": 1767965752317,
    "costTime": 141388
  }
}
```

任务失败时的响应示例：

```json theme={null}
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_12345678",
    "state": "failed",
    "failCode": "PromptInvalid",
    "failMsg": "Prompt is invalid or rejected",
    "createTime": 1767965610929,
    "completeTime": 1767965620132
  }
}
```

等 `state` 变为 `success` 后，再解析 `resultJson`：

```javascript theme={null}
const payload = JSON.parse(data.resultJson);
const videoUrls = payload.resultUrls;
```

## 请求体

在提交请求前，请将示例媒体 URL 替换为可公开访问的文件

### 文生视频

```json theme={null}
{
  "request_type": "async",
  "input": {
    "mode": "text-to-video",
    "prompt": "a cinematic fox walking through neon rain",
    "audio_urls": [
      "https://example.com/background.mp3"
    ],
    "negative_prompt": "blurry, low quality",
    "resolution": "1080p",
    "duration": 8,
    "prompt_extend": true,
    "shot_type": "multi",
    "seed": 42,
    "watermark": false
  }
}
```

### 图生视频

将一张图像动画化，最长持续 15 秒。使用包含一个条目的 `image_urls`，并省略仅闪存模式的 `sound` 字段

```json theme={null}
{
  "request_type": "async",
  "input": {
    "mode": "image-to-video",
    "prompt": "Move the camera slowly toward the cyclist as she looks up from the map.",
    "image_urls": ["https://example.com/cyclist.png"],
    "duration": 12
  }
}
```

### 图生视频 Flash

对于带有音轨的肖像，请将肖像传入 `image_urls`，并提供一个公开的 MP3 或 WAV 文件至 `audio_urls`。保持 `sound` 为启用状态以使用音频。

```json theme={null}
{
  "request_type": "async",
  "input": {
    "mode": "image-to-video-flash",
    "prompt": "make the character speak with subtle camera motion",
    "image_urls": [
      "https://example.com/hero.png"
    ],
    "audio_urls": [
      "https://example.com/voice.mp3"
    ],
    "resolution": "1080p",
    "duration": 5,
    "sound": true
  }
}
```

### 参考生成视频

为每个主体提供单独的参考文件。数组顺序对应提示中角色名称的分配。此处，`character1` 指第一张图像中的骑车者，`character2` 指第二张图像中的跑步者。参考模式最多支持五个文件（包括最多三个视频），输出时长为 2–10 秒。

```json theme={null}
{
  "request_type": "async",
  "input": {
    "mode": "reference-to-video",
    "prompt": "character1 rolls her bicycle up to character2. They greet each other at the finish line.",
    "reference_urls": [
      "https://example.com/cyclist.png",
      "https://example.com/runner.mp4"
    ],
    "resolution": "720p",
    "duration": 6
  }
}
```

### 参考视频 Flash

若需静音拍摄，请将 `sound` 设置为 `false`；若为有声镜头，请保持 `sound` 启用，并使用参考视频片段提供角色语音。在两种参考视频模式中均不需提供 `audio_urls`。

```json theme={null}
{
  "request_type": "async",
  "input": {
    "mode": "reference-to-video-flash",
    "prompt": "character1 hands the race map to character2 at the finish line.",
    "reference_urls": ["https://example.com/cyclist.png", "https://example.com/runner.mp4"],
    "duration": 6,
    "sound": false
  }
}
```

## 参数

**request\_type** `string` *required* (default: async)

结果获取方式。选择 `async` 时，通过 `statusTask` 轮询结果；选择 `callback` 时，通过 Webhook 接收结果。

**callback\_url** `string`

当 `request_type` 为 `callback` 时必需。必须是可接收最终任务负载的公共回调 URL。详情请参见 [Webhooks](https://apixo.ai/docs/zh/api-reference/webhooks.md)。

**input** `object` *required*

Wan 2.6 Video 的输入参数。

**属性**

**mode** `string` *required*

生成模式。可选值为 `text-to-video`、`image-to-video-flash`、`image-to-video`、`reference-to-video-flash`、`reference-to-video`。

**prompt** `string` *required*

提示文字。所有模式都需要，并且修剪后不能为空。支持中文、英文；最大长度为 `1500` 个字符，多余的内容将被模型服务截断。

**negative\_prompt** `string`

可选的否定提示。支持中文、英文；最大长度为 `500` 个字符，多余的内容将被模型服务截断。

**image\_urls** `string[]`

用于 `image-to-video-flash` 和 `image-to-video`。必须恰好包含一个 URL。图像约束：格式 `JPEG/JPG/PNG`（无alpha）、`BMP`、`WEBP`；宽度和高度 `240-8000` px；文件大小 `<= 20MB`。

**reference\_urls** `string[]`

用于 `reference-to-video-flash` 和 `reference-to-video`。必须包含 `1-5` 个 URL。支持图像/视频混合，但有限制：图像 `0-5`、视频 `0-3`，且总和 `images + videos <= 5`。每个文件仅限一个主要主题。参考顺序对应角色顺序（`character1`、`character2`、...）。当音频启用时，参考视频可提供角色语音。参考视频限制：`mp4/mov`、`1-30s`、文件大小 `<= 100MB`。参考图像限制：`JPEG/JPG/PNG`（无 Alpha）、`BMP`、`WEBP`、宽度/高度 `240-8000` px、文件大小 `<= 20MB`。

**audio\_urls** `string[]`

可选的公共音频输入，用于 `text-to-video`、`image-to-video` 和 `image-to-video-flash`。在参考视频模式中省略此字段。`reference_urls` 中的参考视频可提供角色的声音。如果提供，请仅发送一个 URL。音频限制：格式 `wav/mp3`，持续时间 `3-30s`，文件大小 `<= 15MB`。如果音频长度超过 `duration`，则使用前 `duration` 秒的内容。如果音频长度短于输出视频，则剩余部分保持静音。在 `image-to-video-flash` 中，将 `sound` 设置为 `true` 以使用该音频。

**resolution** `string`

输出分辨率等级。支持的值：`720p`、`1080p`。默认设置：`text-to-video` 为 `720p`；`image-to-video` 和 `image-to-video-flash` 为 `720p`；`reference-to-video` 和 `reference-to-video-flash` 为 `1080p`。

**duration** `integer` (default: 5)

接受整数或数字字符串输入。`text-to-video`、`image-to-video-flash` 和 `image-to-video`：`2-15`；`reference-to-video-flash` 和 `reference-to-video`：`2-10`。

**prompt\_extend** `boolean` (default: true)

是否在生成前启用提示重写。`true`（默认）启用重写并可以改善简短的提示，但可能会增加延迟。`false` 禁用重写。

**shot\_type** `string`

可选拍摄模式。支持的值：`single`、`multi`。当 `shot_type` 和拍摄指令同时存在时，`shot_type` 优先。

**seed** `integer`

从 `0` 到 `2147483647`（含）的可选整数。比较运行时可重复使用种子。结果仍可能不同。

**watermark** `boolean`

可选水印开关。`false`（默认）表示无水印。`true` 添加带有固定文本 `AI 生成`（AI 生成）的右下水印。

**sound** `boolean` (default: true (flash modes only))

音频生成开关（用于 `image-to-video-flash` 和 `reference-to-video-flash`）。`true`（默认）启用音频生成；`false` 生成无声视频。对于无声的 `image-to-video-flash` 请求，可省略 `audio_urls`。

**nsfw\_checker** `boolean` (default: false)

设为 `true` 可在支持的生成路由上启用上游内容审核。API 默认值为 `false`。

## 响应格式

### 提交任务时的响应

任务受理后，`POST /generateTask/wan-2-6-video` 会返回任务 ID：

**code** `integer`

API 状态码。`200` 表示任务已受理。

**message** `string`

状态说明。

**data.taskId** `string`

任务的唯一 ID，用于查询任务状态。

### 状态响应字段

**taskId** `string`

任务的唯一标识符。

**state** `string`

当前任务状态，可能的值为 `pending`、`processing`、`success`、`failed`。

**resultJson** `string`

当 `state` 为 `success` 时返回。解析此 JSON 字符串后，可从 `resultUrls` 读取生成的视频链接。

**failCode** `string`

供程序处理的错误码，仅在 `state` 为 `failed` 时返回。

**failMsg** `string`

失败原因说明，仅在 `state` 为 `failed` 时返回。

**createTime** `integer`

任务创建时的 Unix 时间戳，单位为毫秒。

**completeTime** `integer`

任务完成时的 Unix 时间戳，单位为毫秒。任务完成后返回。

**costTime** `integer`

处理耗时，以毫秒为单位。任务完成且有计时数据时返回。

## Webhook 回调模式

如果希望服务端自动收到最终结果，可以使用回调模式，无需轮询。

```bash theme={null}
curl -X POST "https://api.apixo.ai/api/v1/generateTask/wan-2-6-video" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "request_type": "callback",
    "callback_url": "https://your-server.com/webhooks/apixo",
    "input": {
      "mode": "image-to-video-flash",
      "prompt": "make the character speak with subtle camera motion",
      "image_urls": [
        "https://example.com/hero.png"
      ],
      "resolution": "720p",
      "duration": 5,
      "sound": false
    }
  }'
```

Webhook 接收要求和重试规则见 [Webhook 文档](https://apixo.ai/docs/zh/api-reference/webhooks.md)。

## 计费

新提交的非 LLM 请求按 **1 积分 = `$0.001`** 计费。先按用量和附加项目计算总额，再应用账号折扣，最后将请求总额向上取整到整数积分。如果约定了固定单价，则按该单价的原始精度计算，不再使用标准价或另行打折；最终积分仍向上取整。详见[积分换算与取整](https://apixo.ai/docs/zh/pricing.md#credit-conversion-and-rounding)。

Wan 2.6 Video 按秒计费。总费用为 `duration * unitPrice`。

标准（非闪光）模式：

| 模式 | 分辨率 | APIXO 官方价格 |
| - | - | - |
| `text-to-video` | `720p` | `$0.10 / second` |
| `text-to-video` | `1080p` | `$0.15 / second` |
| `image-to-video` | `720p` | `$0.10 / second` |
| `image-to-video` | `1080p` | `$0.15 / second` |
| `reference-to-video` | `720p` | `$0.20 / second` |
| `reference-to-video` | `1080p` | `$0.30 / second` |

闪光模式：

| 模式 | 分辨率 | `sound=false` | `sound=true` |
| - | - | - | - |
| `image-to-video-flash` | `720p` | `$0.025 / second` | `$0.05 / second` |
| `image-to-video-flash` | `1080p` | `$0.038 / second` | `$0.075 / second` |
| `reference-to-video-flash` | `720p` | `$0.05 / second` | `$0.10 / second` |
| `reference-to-video-flash` | `1080p` | `$0.08 / second` | `$0.16 / second` |

最新的美元费率见 [API 价目表](https://apixo.ai/pricing/api)。

## 延迟与轮询

Wan 2.6 Video 任务是异步的。后端不提供固定的公共延迟SLA；实际延迟因模式、持续时间、分辨率、提示复杂性、媒体获取速度和队列负载而异。

| 工作流程 | 建议首次查询时间 | 轮询间隔 |
| - | - | - |
| `text-to-video` | 任务创建 30 秒后 | 10s |
| `image-to-video` / `image-to-video-flash` | 任务创建 30 秒后 | 10s |
| `reference-to-video` / `reference-to-video-flash` | 任务创建 45 秒后 | 10s-15s |

> [!TIP]
>
> 对于生产工作负载，请使用回调模式以避免对长时间运行的视频作业进行频繁轮询。

请求频率和并发上限因账号、API 密钥和路由而异。收到 `429` 时，请降低请求频率，逐步延长重试间隔。账号级限制见[系统 API](https://apixo.ai/docs/zh/api-reference/system.md)。

## 错误与排查

### HTTP 错误

| 代码 | 含义 | 处理方式 |
| - | - | - |
| `400` | 请求体、模式、参数或媒体 URL 格式无效 | 在重试前修复请求 |
| `401` | 缺少 API 密钥，或密钥无效 | 检查 `Authorization` 请求头 |
| `402` | 余额或配额不足 | 充值或更换账号或API密钥 |
| `403` | 密钥或路由无权访问该模型 | 检查权限和路由策略 |
| `429` | 已达到速率或并发限制 | 按指数退避策略重试 |
| `500` | 服务器错误 | 逐步延长间隔后重试 |
| `502` | 服务错误 | 逐步延长间隔后重试 |
| `504` | 服务超时 | 重试或使用回调模式 |

### 任务失败错误码

`failCode` 表示任务失败的原因，常见值如下。

| 错误码 | 含义 | 处理方式 |
| - | - | - |
| `PromptInvalid` | 提示无效或被模型服务拒绝 | 修改提示词后重试 |
| `MissingParameter` / `BadRequest` | 必填字段缺失或格式错误 | 检查特定模式的必填字段 |
| `SensitiveContent` / `SensitiveContentDetected` | 提示或媒体未通过安全检查 | 修改提示或媒体 |
| `RateLimitExceeded` | 已达到模型服务或路由速率限制 | 按指数退避策略重试 |
| `Task TimeOut` / `Timeout` | 模型生成超时 | 重试或使用回调模式 |

### 参数排查

* `prompt` 是必需的，并且对于所有模式都必须非空。
* `image-to-video-flash` 和 `image-to-video` 恰好需要一个 `image_urls` 项。
* `reference-to-video-flash` 和 `reference-to-video` 需要 `reference_urls` 和 `1-5` 项目。
* `sound` 仅对闪光模式有效。
* `duration` 默认为 `5`，但 `reference` 模式最多只允许 `10`。
* 对于自定义音轨，请在启用声音的情况下将 `audio_urls` 与 `text-to-video`、`image-to-video` 或 `image-to-video-flash` 结合使用。对于参考模式，请使用角色声音的参考视频剪辑。

完整列表见[错误码](https://apixo.ai/docs/zh/api-reference/errors.md)。

## MCP 集成

[完整模型 Schema](https://apixo.ai/docs/models/schemas/video/wan-2-6-video.json) 中的 `mcp.result` 指定了结果的解析方式，`mcp.attachments` 列出支持绑定文件的字段。这些元数据供客户端集成使用，无需作为生成参数提交。附件字段为 `image_urls`, `reference_urls`, `audio_urls`。请保留用户指定的文件顺序。API 负责校验模型参数。

## 相关链接

* [生成 API 概览](https://apixo.ai/docs/zh/models.md)
* [视频模型](https://apixo.ai/docs/zh/models/video)
* [提交生成任务](https://apixo.ai/docs/zh/api-reference/generate-task.md)
* [查询任务状态](https://apixo.ai/docs/zh/api-reference/status-task.md)
* [Webhook](https://apixo.ai/docs/zh/api-reference/webhooks.md)
* [错误码](https://apixo.ai/docs/zh/api-reference/errors.md)
* [参数规范](https://apixo.ai/docs/zh/api-reference/parameters.md)
* [路由策略](https://apixo.ai/docs/zh/concepts/routing-strategies.md)
* [在 APIXO Playground 尝试 Wan 2.6 Video](https://apixo.ai/models/wan-2-6-video)
* [API定价](https://apixo.ai/pricing/api)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.