> ## 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.5 Video API：文生视频与图生视频

> 支持文生视频和图生视频工作流的阿里巴巴风格视频生成 API

## 概览

Wan 2.5 可根据文本提示或一张参考图像加提示生成短视频。

| 功能 | 值 |
| - | - |
| 模型 ID | `wan-2-5-video` |
| 模式 | `text-to-video`, `image-to-video` |
| 提示词 | 最多 `1500` 个字符（`text-to-video` 必填且不能为空，`image-to-video` 可选） |
| 负面提示 | 可选，最多 `500` 个字符 |
| 参考图片 | `image-to-video` 正好需要 1 URL； `JPEG/JPG/PNG(no alpha)/BMP/WEBP`，宽度和高度 `240-8000` px，文件大小 `<=20MB` |
| 音频输入 | `audio_urls` 可选，与 1 URL 完全相同； `wav/mp3`、`3-30s`、文件大小 `<=15MB` |
| 可选分辨率 | `480p`, `720p`, `1080p` |
| 时长 | `5` 或 `10` 秒 |
| 提示重写 | `prompt_extend` 可选布尔值；`true`（默认）启用重写，`false` 禁用重写 |
| 文本与视频的宽高比 | `16:9`、`9:16`、`1:1`（所有分辨率），支持 `4:3`、`3:4` 用于 `720p`/`1080p` |

## 接口与身份验证

API 基础地址：

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

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

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

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

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

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

## 异步请求示例

```bash theme={null}
curl -X POST "https://api.apixo.ai/api/v1/generateTask/wan-2-5-video" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "request_type": "async",
    "input": {
      "mode": "text-to-video",
      "prompt": "a cinematic shot of clouds drifting over a quiet mountain lake",
      "audio_urls": [
        "https://example.com/music.mp3"
      ],
      "resolution": "720p",
      "duration": 5,
      "aspect_ratio": "16:9",
      "prompt_extend": true
    }
  }'
```

成功响应：

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

保存 `taskId`，后续轮询结果时需要用到它。

## 轮询结果

```bash theme={null}
curl -X GET "https://api.apixo.ai/api/v1/statusTask/wan-2-5-video?taskId=task_12345678" \
  -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": "INVALID_PARAMETER",
    "failMsg": "The parameter {{resolution}} is invalid",
    "createTime": 1767965610929,
    "completeTime": 1767965620132
  }
}
```

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

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

## 请求体

### 文生视频

```json theme={null}
{
  "request_type": "async",
  "input": {
    "mode": "text-to-video",
    "prompt": "a serene mountain landscape with moving clouds and gentle breeze",
    "audio_urls": [
      "https://example.com/music.mp3"
    ],
    "resolution": "480p",
    "duration": 5,
    "aspect_ratio": "1:1",
    "prompt_extend": true,
    "negative_prompt": "low quality, blurry",
    "watermark": false,
    "seed": 20260413
  }
}
```

### 图生视频

```json theme={null}
{
  "request_type": "callback",
  "callback_url": "https://your-server.com/webhooks/apixo",
  "input": {
    "mode": "image-to-video",
    "image_urls": [
      "https://example.com/reference.png"
    ],
    "prompt": "turn this photo into a smooth cinematic shot with a slow push-in camera move",
    "audio_urls": [
      "https://example.com/music.mp3"
    ],
    "resolution": "1080p",
    "duration": 10
  }
}
```

## 参数

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

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

**callback\_url** `string`

当 `request_type` 为 `callback` 时必填。请提供公网可访问的 HTTPS 地址，用于接收任务的最终结果。详见 [Webhook](https://apixo.ai/docs/zh/api-reference/webhooks.md)。

**input** `object` *required*

Wan 2.5 的输入参数。

**属性**

**mode** `string` *required*

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

**prompt** `string`

提示文字。`text-to-video` 必填；`image-to-video` 可选。支持中文和英文；最大长度为 `1500` 个字符

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

参考图像URL列表。 `image-to-video` 所需。必须恰好包含 1 URL。图像限制：格式`JPEG/JPG/PNG`（无alpha）、`BMP`、`WEBP`；宽度和高度 `240-8000` px；文件大小 `<= 20MB`。

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

可选音频 URL 列表。完全支持 1 URL。音频限制：格式 `wav/mp3`、持续时间 `3-30s`、文件大小 `<= 15MB`。如果音频长于 `duration`，则仅使用前 `duration` 秒；如果音频短于输出视频持续时间，则剩余片段将保持静音。

**resolution** `string` (default: 1080p)

输出分辨率。可选值为 `480p`、`720p`、`1080p`。

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

输出时长，单位为秒。可选值为 `5`、`10`。

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

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

**aspect\_ratio** `string` (default: 16:9)

仅限文本转视频。`480p`支持`16:9`、`9:16`、`1:1`；`720p`和`1080p`支持`16:9`、`9:16`、`1:1`、`4:3`、`3:4`。

**negative\_prompt** `string`

可选的负面提示，描述要避免的内容。支持中文、英文；最大长度为 `500` 个字符。

**watermark** `boolean`

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

**seed** `integer`

`[0, 2147483647]` 中的可选随机种子。固定种子可以提高再现性，但相同的种子并不能保证相同的输出。

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

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

## 响应格式

### 提交任务时的响应

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

**code** `integer`

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

**message** `string`

状态说明。

**data.taskId** `string`

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

### 状态响应字段

**taskId** `string`

任务的唯一标识符。

**state** `string`

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

**resultJson** `string`

包含生成视频 URL 的 JSON 字符串。当 `state` 为 `success` 时返回。

**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-5-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": "text-to-video",
      "prompt": "a polished product demo video with gentle camera movement",
      "resolution": "720p",
      "duration": 5,
      "aspect_ratio": "16:9"
    }
  }'
```

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.5 按生成的秒数计费。

| 模式 | 分辨率 | 单价 |
| - | - | - |
| `text-to-video` | `480p` | `$0.05 / second` |
| `text-to-video` | `720p` | `$0.10 / second` |
| `text-to-video` | `1080p` | `$0.15 / second` |
| `image-to-video` | `480p` | `$0.05 / second` |
| `image-to-video` | `720p` | `$0.10 / second` |
| `image-to-video` | `1080p` | `$0.15 / second` |

最终成本公式：

```text theme={null}
total_cost = duration_seconds * resolution_unit_price
```

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

## 延迟与轮询

视频生成是长期运行的。实际延迟可能因提示复杂性、模式、所选分辨率和当前队列负载而异。

| 请求结构 | 通常生成耗时 | 建议首次查询时间 | 轮询间隔 |
| - | - | - | - |
| `480p` | 40s-120s | 任务创建 40 秒后 | 10s |
| `720p` | 60s-180s | 任务创建 60 秒后 | 10s |
| `1080p` | 90s-250s | 任务创建 90 秒后 | 10s |

> [!TIP]
>
> 生产环境并发量较高时，建议使用回调，以免频繁轮询。

实用注意事项：

* `aspect_ratio` 仅与 `text-to-video` 模式一起使用。
* `audio_urls` 支持一个 MP3/WAV URL，最大大小为 15 MB；建议持续时间范围为 3 到 30 秒。
* 对于 `image-to-video`，`image_urls` 必须恰好包含一个图像 URL，且图像文件大小不得超过 20 MB。
* 结果 URL 为临时链接，需及时下载重要输出。

请求频率和并发上限因账号、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` | 第三方模型超时 | 重试；耗时较长的任务可改用回调模式 |

### 任务失败错误码

| 错误码 | 含义 | 处理方式 |
| - | - | - |
| `CONTENT_VIOLATION` | 提示或参考图像未通过安全检查 | 更改提示或输入图像 |
| `INVALID_IMAGE_URL` | 无法获取或解码参考图像 URL | 请使用公共且可直接访问的媒体 URL |
| `INVALID_PARAMETER` | 模型参数不受支持或格式错误 | 检查`mode`、`resolution`、`duration`、`aspect_ratio`、`image_urls`和`audio_urls` |
| `INSUFFICIENT_BALANCE` | 该账户没有足够的余额来执行任务 | 重试前需添加余额 |
| `TIMEOUT` | 生成任务超时 | 重试、降低输入复杂度或使用回调模式 |

### 参数排查

* `prompt`对于`text-to-video`是必需的，对于`image-to-video`是可选的。
* `image_urls` 仅对于 `image-to-video` 是必需的，并且必须恰好包含一个 URL。
* `audio_urls` 在提供时仅支持一个 MP3/WAV URL；文件大小应≤ 15 MB，建议的持续时间范围为 3-30 秒。
* 省略时，`resolution` 默认为 `1080p`。
* 省略时，`duration` 默认为 `5`，且仅接受 `5` 或 `10`。
* `aspect_ratio`仅适用于`text-to-video`。

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

## MCP 集成

[完整模型 Schema](https://apixo.ai/docs/models/schemas/video/wan-2-5-video.json) 中的 `mcp.result` 指定了结果的解析方式，`mcp.attachments` 列出支持绑定文件的字段。这些元数据供客户端集成使用，无需作为生成参数提交。附件字段为 `image_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)
* [在 APIXO Playground 尝试 Wan 2.5 Video](https://apixo.ai/models/wan-2-5-video)
* [API定价](https://apixo.ai/pricing/api)


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