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

# Wan 2.1 文生视频

Wan 2.1 14B 文生视频模型的加速推理，这是一套全面且开放的视频基础模型套件，推动了视频生成的边界。默认情况下，API 将生成 5 秒的视频。

<Warning>
  本模型服务仅针对已完成 PPIO派欧云 平台企业认证的用户开放。具体请参见[实名认证](/support/identity-verification)。
</Warning>

<Tip>
  这是一个**异步**API，只会返回异步任务的 task\_id。您应该使用该 task\_id 请求 [查询任务结果 API](/models/reference-get-async-task-result) 来检索视频生成结果。
</Tip>

## 请求头

<ParamField header="Content-Type" type="string" required={true}>
  枚举值: `application/json`
</ParamField>

<ParamField header="Authorization" type="string" required={true}>
  Bearer 身份验证格式，例如：Bearer \{\{API 密钥}}。
</ParamField>

## 请求体

<ParamField body="prompt" type="string" required={true}>
  指导生成所需的提示文本。

  取值范围：`[1, 2000]`。
</ParamField>

<ParamField body="negative_prompt" type="string" required={false}>
  负面提示指示模型避免生成哪些元素。

  取值范围：`[0, 2000]`。
</ParamField>

<ParamField body="width" type="integer" required={false}>
  输出视频的宽度。

  枚举值：`480`、`720`、`832`、`1280`。

  默认：`832`。如果未指定宽度或高度，宽度和高度将被强制设置为 `832` 和 `480`。
</ParamField>

<ParamField body="height" type="integer" required={false}>
  输出视频的高度。

  支持：

  * (480p) 宽度为 `480` 时高度设置为 `832`
  * (480p) 宽度为 `832` 时高度设置为 `480`
  * (720p) 宽度为 `720` 时高度设置为 `1280`
  * (720p) 宽度为 `1280` 时高度设置为 `720`

  默认：`480`。如果未指定宽度或高度，宽度和高度将被强制设置为 `832` 和 `480`。
</ParamField>

<ParamField body="loras" type="object[]" required={false}>
  应用于视频生成的 LoRA 模型。

  支持最多指定 **3 个 LoRA 模型**。

  <Expandable title="properties" defaultOpen={false}>
    <ParamField body="path" type="string" required={true}>
      LoRA 模型的路径。您可以指定来自 Hugging Face 的 LoRA 模型名称，例如：`Remade-AI/Cyberpunk`；或来自 Civitai 的模型下载 URL，例如：`https://civitai.com/api/download/models/1572591?type=Model&format=SafeTensor`。

      <Warning>
        LoRA 模型必须与 Wan2.1 14B T2V 兼容，否则将无法工作。使用前请检查兼容性。
      </Warning>
    </ParamField>

    <ParamField body="scale" type="number" required={true}>
      LoRA 的缩放值。值越大，LoRA 效果更明显。number(float32) 类型，取值范围：`[0, 4.0]`。
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="seed" type="integer" required={false}>
  随机数种子，稳定扩散产生噪声的数字，取值范围：`[-1, 9999999999]`。默认值为 -1。
</ParamField>

<ParamField body="steps" type="integer" required={false}>
  迭代步数，图片创建过程的迭代数，取值范围：`[1, 40]`。默认：`30`。
</ParamField>

<ParamField body="guidance_scale" type="float" required={false}>
  引导缩放参数控制生成内容对提示的跟随程度。取值范围：`[0, 10]`。默认：`5.0`。
</ParamField>

<ParamField body="flow_shift" type="float" required={false}>
  flow\_shift 参数主要影响视频中物体运动的速度和幅度。更高的值产生更明显和更快的运动，而较低的值使运动更慢更细微。

  取值范围：`[1, 10]`。默认：`5.0`。
</ParamField>

<ParamField body="enable_safety_checker" type="boolean" required={false}>
  enable\_safety\_checker 参数控制是否对生成的内容应用安全过滤器。启用时，它有助于从视频输出中过滤掉潜在的有害或不当内容。

  默认：`true`。
</ParamField>

<ParamField body="fast_mode" type="boolean" required={false}>
  是否启用快速模式，将更快地生成视频但可能降低质量和价格。

  默认：`false`。
</ParamField>

<ParamField body="watermark" type="boolean" required={false} default={false}>
  为生成的视频添加水印。

  * `false`：不添加水印。
  * `true`：在视频添加文字的水印，标识由人工智能生成合成。
</ParamField>

## 响应

<ResponseField name="task_id" type="string" required={true}>
  异步任务的 task\_id。您应该使用该 task\_id 请求 [查询任务结果 API](/models/reference-get-async-task-result) 以获取生成结果
</ResponseField>

## 示例

以下是如何使用 Wan 2.1 文生视频 API 的示例。

1. 通过向 Wan 2.1 文生视频 API 发送 POST 请求生成 task\_id。

`请求：`

```bash theme={null}
curl --location 'https://api.ppio.com/v3/async/wan-t2v' \
--header 'Authorization: Bearer {{API Key}}' \
--header 'Content-Type: application/json' \
--data '{
    "height": 1280,
    "width": 720,
    "seed": -1,
    "prompt": "3D animation of a small, round, fluffy creature with big, expressive eyes explores a vibrant, enchanted forest. The creature, a whimsical blend of a rabbit and a squirrel, has soft blue fur and a bushy, striped tail. It hops along a sparkling stream, its eyes wide with wonder. The forest is alive with magical elements: flowers that glow and change colors, trees with leaves in shades of purple and silver, and small floating lights that resemble fireflies. The creature stops to interact playfully with a group of tiny, fairy-like beings dancing around a mushroom ring. The creature looks up in awe at a large, glowing tree that seems to be the heart of the forest."
}'
```

`响应：`

```js theme={null}
{
    "task_id": "{返回的任务 ID}"
}
```

2. 使用 `task_id` 获取输出视频。

2xx 范围内的 HTTP 状态码表示请求已被成功接受，而 5xx 范围内的状态码表示内部服务器错误。

您可以在响应的 `videos` 中获取视频 URL。

`请求：`

```bash theme={null}
curl --location --request GET 'https://api.ppio.com/v3/async/task-result?task_id={返回的任务 ID}' \
--header 'Authorization: Bearer {{API Key}}'
```

`响应：`

```js theme={null}
{
    "task": {
        "task_id": "{返回的任务 ID}",
        "task_type": "WAN_TXT_TO_VIDEO",
        "status": "TASK_STATUS_SUCCEED",
        "reason": "",
        "eta": 0,
        "progress_percent": 100
    },
    "images": [],
    "videos": [
        {
            "video_url": "{生成视频的 URL}",
            "video_url_ttl": "3600",
            "video_type": "mp4"
        }
    ]
}
```
