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

# wan2.7

> Wan2.7 文生视频、图生视频和参考图生视频 API。

通过 `POST /v1/video/generations` 创建 Wan2.7 视频任务。请在下方选择工作流；三种工作流使用相同的接口，但模型 ID 和请求体中的媒体结构不同。

<Tabs sync={false}>
  <Tab title="文生视频">
    ## 创建任务

    `POST /v1/video/generations`

    <div className="kling-api-example-panel wan-api-example-panel">
      ```bash cURL theme={null}
      curl --request POST \
        --url https://www.anyfast.ai/v1/video/generations \
        --header 'Authorization: Bearer YOUR_API_KEY' \
        --header 'Content-Type: application/json' \
        --data '{
          "model": "wan2.7-t2v",
          "input": {
            "prompt": "一只纸船驶过霓虹灯照亮的雨夜城市，电影感跟拍镜头。",
            "negative_prompt": "模糊、变形、低画质",
            "audio_url": "https://example.com/music.mp3"
          },
          "parameters": {
            "resolution": "720P",
            "ratio": "16:9",
            "duration": 5,
            "prompt_extend": true,
            "watermark": false,
            "seed": 42
          }
        }'
      ```

      ```json 200 theme={null}
      {
        "id": "asyntask_example123",
        "task_id": "asyntask_example123",
        "object": "video",
        "model": "wan2.7-t2v",
        "status": "queued",
        "progress": 0,
        "created_at": 1784520000
      }
      ```
    </div>

    ## 请求头

    <ParamField header="Authorization" type="string" required>Bearer 鉴权，格式为 `Bearer YOUR_API_KEY`。</ParamField>
    <ParamField header="Content-Type" type="string" default="application/json" required>请求体格式。</ParamField>

    ## 请求参数

    <ParamField body="model" type="string" required>必须为 `wan2.7-t2v`。</ParamField>
    <ParamField body="input.prompt" type="string" required>中文或英文的视频描述。最多 5,000 个非中文字符或 2,500 个中文字符。</ParamField>
    <ParamField body="input.negative_prompt" type="string">希望排除的内容。最多 500 个字符。</ParamField>
    <ParamField body="input.audio_url" type="string">公开的 WAV 或 MP3 地址。音频时长须为 2-30 秒，且不超过 15 MB。</ParamField>
    <ParamField body="parameters.resolution" type="string" default="1080P">输出分辨率：`720P` 或 `1080P`。</ParamField>
    <ParamField body="parameters.ratio" type="string" default="16:9">输出宽高比：`16:9`、`9:16`、`1:1`、`4:3` 或 `3:4`。</ParamField>
    <ParamField body="parameters.duration" type="integer" default={5}>视频时长为 2-15 秒。</ParamField>
    <ParamField body="parameters.prompt_extend" type="boolean" default={true}>是否改写并扩展提示词。对于特定内容请求，请选择 `Special-Ns` 资源分组，并将此参数设置为 `false`。</ParamField>
    <ParamField body="parameters.watermark" type="boolean" default={false}>是否添加 AI Generated 水印。</ParamField>
    <ParamField body="parameters.seed" type="integer">随机种子，范围为 `[0, 2147483647]`。</ParamField>
  </Tab>

  <Tab title="图生视频">
    ## 创建任务

    `POST /v1/video/generations`

    <div className="kling-api-example-panel wan-api-example-panel">
      ```bash cURL theme={null}
      curl --request POST \
        --url https://www.anyfast.ai/v1/video/generations \
        --header 'Authorization: Bearer YOUR_API_KEY' \
        --header 'Content-Type: application/json' \
        --data '{
          "model": "wan2.7-i2v",
          "input": {
            "prompt": "镜头逐渐靠近，灯笼开始发光。",
            "negative_prompt": "模糊、变形、低画质",
            "media": [
              {
                "type": "first_frame",
                "url": "https://example.com/first-frame.png"
              },
              {
                "type": "driving_audio",
                "url": "https://example.com/driving-audio.mp3"
              }
            ]
          },
          "parameters": {
            "resolution": "720P",
            "duration": 5,
            "prompt_extend": true,
            "watermark": false,
            "seed": 42
          }
        }'
      ```

      ```json 200 theme={null}
      {
        "id": "asyntask_example123",
        "task_id": "asyntask_example123",
        "object": "video",
        "model": "wan2.7-i2v",
        "status": "queued",
        "progress": 0,
        "created_at": 1784520000
      }
      ```
    </div>

    ## 请求头

    <ParamField header="Authorization" type="string" required>Bearer 鉴权，格式为 `Bearer YOUR_API_KEY`。</ParamField>
    <ParamField header="Content-Type" type="string" default="application/json" required>请求体格式。</ParamField>

    ## 请求参数

    <ParamField body="model" type="string" required>必须为 `wan2.7-i2v`。</ParamField>
    <ParamField body="input.prompt" type="string">动作和场景描述。最多 5,000 个非中文字符或 2,500 个中文字符。</ParamField>
    <ParamField body="input.negative_prompt" type="string">希望排除的内容。最多 500 个字符。</ParamField>
    <ParamField body="input.media" type="object[]" required>1-3 个媒体对象。同一种媒体类型只能使用一个对象。</ParamField>
    <ParamField body="input.media[].type" type="string" required>媒体类型：`first_frame`、`last_frame`、`driving_audio` 或 `first_clip`。</ParamField>
    <ParamField body="input.media[].url" type="string" required>公开的媒体地址。`first_frame` 和 `last_frame` 也支持 Base64 数据 URL。</ParamField>
    <ParamField body="parameters.resolution" type="string" default="1080P">输出分辨率：`720P` 或 `1080P`。</ParamField>
    <ParamField body="parameters.duration" type="integer" default={5}>最终输出时长为 2-15 秒。续写场景下，该时长包含输入视频片段。</ParamField>
    <ParamField body="parameters.prompt_extend" type="boolean" default={true}>是否改写并扩展提示词。对于特定内容请求，请选择 `Special-Ns` 资源分组，并将此参数设置为 `false`。</ParamField>
    <ParamField body="parameters.watermark" type="boolean" default={false}>是否添加 AI Generated 水印。</ParamField>
    <ParamField body="parameters.seed" type="integer">随机种子，范围为 `[0, 2147483647]`。</ParamField>
  </Tab>

  <Tab title="参考图生视频">
    ## 创建任务

    `POST /v1/video/generations`

    <div className="kling-api-example-panel wan-api-example-panel">
      ```bash cURL theme={null}
      curl --request POST \
        --url https://www.anyfast.ai/v1/video/generations \
        --header 'Authorization: Bearer YOUR_API_KEY' \
        --header 'Content-Type: application/json' \
        --data '{
          "model": "wan2.7-r2v",
          "input": {
            "prompt": "图 1 中的人物沿着视频 1 中的街道行走。",
            "negative_prompt": "模糊、变形、低画质",
            "media": [
              {
                "type": "reference_image",
                "url": "https://example.com/character.png",
                "reference_voice": "https://example.com/voice.mp3"
              },
              {
                "type": "reference_video",
                "url": "https://example.com/street.mp4"
              }
            ]
          },
          "parameters": {
            "resolution": "720P",
            "ratio": "16:9",
            "duration": 5,
            "prompt_extend": true,
            "watermark": false,
            "seed": 42
          }
        }'
      ```

      ```json 200 theme={null}
      {
        "id": "asyntask_example123",
        "task_id": "asyntask_example123",
        "object": "video",
        "model": "wan2.7-r2v",
        "status": "queued",
        "progress": 0,
        "created_at": 1784520000
      }
      ```
    </div>

    ## 请求头

    <ParamField header="Authorization" type="string" required>Bearer 鉴权，格式为 `Bearer YOUR_API_KEY`。</ParamField>
    <ParamField header="Content-Type" type="string" default="application/json" required>请求体格式。</ParamField>

    ## 请求参数

    <ParamField body="model" type="string" required>必须为 `wan2.7-r2v`。</ParamField>
    <ParamField body="input.prompt" type="string" required>描述场景，并使用 `Image 1`、`Image 2`、`Video 1` 和 `Video 2` 引用素材。最多 5,000 个非中文字符或 2,500 个中文字符。</ParamField>
    <ParamField body="input.negative_prompt" type="string">希望排除的内容。最多 500 个字符。</ParamField>
    <ParamField body="input.media" type="object[]" required>1-6 个媒体对象。参考图和参考视频总数不能超过 5 个。</ParamField>
    <ParamField body="input.media[].type" type="string" required>媒体类型：`reference_image`、`reference_video` 或 `first_frame`。</ParamField>
    <ParamField body="input.media[].url" type="string" required>参考媒体地址。图片也支持 Base64 数据 URL。</ParamField>
    <ParamField body="input.media[].reference_voice" type="string">可选的公开 WAV 或 MP3 音色参考地址，可用于参考图片或参考视频。</ParamField>
    <ParamField body="parameters.resolution" type="string" default="1080P">输出分辨率：`720P` 或 `1080P`。</ParamField>
    <ParamField body="parameters.ratio" type="string" default="16:9">输出宽高比：`16:9`、`9:16`、`1:1`、`4:3` 或 `3:4`。提供 `first_frame` 时忽略此参数。</ParamField>
    <ParamField body="parameters.duration" type="integer" default={5}>视频时长为 2-15 秒。存在参考视频时，最大时长为 10 秒。</ParamField>
    <ParamField body="parameters.prompt_extend" type="boolean" default={true}>是否改写并扩展提示词。对于特定内容请求，请选择 `Special-Ns` 资源分组，并将此参数设置为 `false`。</ParamField>
    <ParamField body="parameters.watermark" type="boolean" default={false}>是否添加 AI Generated 水印。</ParamField>
    <ParamField body="parameters.seed" type="integer">随机种子，范围为 `[0, 2147483647]`。</ParamField>
  </Tab>
</Tabs>

## 响应

<ResponseField name="id" type="string">创建的任务 ID。</ResponseField>
<ResponseField name="task_id" type="string">创建的任务 ID，用于查询任务。</ResponseField>
<ResponseField name="object" type="string">响应对象类型，返回 `video`。</ResponseField>
<ResponseField name="model" type="string">创建任务时使用的模型。</ResponseField>
<ResponseField name="status" type="string">初始任务状态，通常为 `queued`。</ResponseField>
<ResponseField name="progress" type="integer">初始任务进度，通常为 `0`。</ResponseField>
<ResponseField name="created_at" type="integer">任务创建时间，Unix 时间戳。</ResponseField>

## 错误响应

* `400 Bad Request`：输入无效，或参数、媒体组合不受支持。
* `401 Unauthorized`：API 密钥缺失或无效。
* `429 Rate limit exceeded`：请求频率超过适用限制。

<script src="/public/feedback.js" />
