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

# Wan2.6 Flash 視頻生成

> 使用阿里雲萬相 Wan2.6 Flash 極速版生成視頻 — 支持圖生視頻和參考視頻，速度更快

* 阿里雲萬相極速版視頻生成模型
* 支持**圖生視頻**（Image-to-Video）和**參考視頻**（Reference Video，r2v）兩種模式
* **不支持**純文本生成（必須提供圖片或參考視頻 URL）
* 支持 720p/1080p 分辨率，有聲/無聲選項（影響計費）
* 生成速度更快，適合快速預覽和迭代

<Warning>
  **必須提供圖片或參考視頻 URL**：`image_urls`（圖生視頻）和 `metadata.reference_urls`（參考視頻）必須提供其中之一，否則接口將返回錯誤。
</Warning>

## 路由邏輯

服務端根據請求參數自動選擇上游模型：

| 提供的參數                             | 上游模式               |
| --------------------------------- | ------------------ |
| `metadata.reference_urls`（視頻 URL） | 參考視頻極速版（r2v-flash） |
| `image_urls`（圖片）                  | 圖生視頻極速版（i2v-flash） |
| 僅 `prompt`                        | ❌ 返回錯誤             |

## 認證

<ParamField header="Authorization" type="string" required>
  所有接口均需要使用 Bearer Token 進行認證

  獲取 API Key：訪問 [API Key 管理頁面](https://toapis.com/console/token) 獲取您的 API Key

  使用時在請求頭中添加：

  ```
  Authorization: Bearer YOUR_API_KEY
  ```
</ParamField>

## 請求參數

<ParamField body="model" type="string" required>
  視頻生成模型名稱，固定爲 `wan2.6-flash`
</ParamField>

<ParamField body="image_urls" type="string[]">
  參考圖片 URL 數組（圖生視頻模式，僅支持 1 張圖片）

  **與 `metadata.reference_urls` 二選一必填**

  **⚠️ 僅支持 URL 格式（不再支持 base64）**

  * 公開可訪問的圖像 URL（http\:// 或 https\://）
  * 可使用 [上傳圖片接口](../../uploads/images) 上傳本地圖片獲取 URL

  示例：`["https://example.com/image.jpg"]`
</ParamField>

<ParamField body="prompt" type="string">
  視頻內容描述（可選）

  描述期望的動作或風格，幫助模型理解生成意圖

  示例：`"畫面中的人物動了起來，向鏡頭微笑"`
</ParamField>

<ParamField body="resolution" type="string" default="1080p">
  視頻分辨率

  可選值：

  * `720p` - 標清
  * `1080p` - 高清（默認）

  默認值：`1080p`

  不同分辨率計費不同，請參考模型市場價格
</ParamField>

<ParamField body="duration" type="integer" default="5">
  視頻時長（秒）

  支持：`5`、`10`、`15`

  默認值：`5`
</ParamField>

<ParamField body="audio" type="boolean" default="true">
  是否生成有聲視頻

  * `true` - 生成有聲視頻（默認）
  * `false` - 生成無聲視頻

  **⚠️ 有聲/無聲計費標準不同，請確認後選擇**

  默認值：`true`
</ParamField>

<ParamField body="watermark" type="boolean">
  在生成的視頻上添加阿里雲水印
</ParamField>

<ParamField body="metadata" type="object">
  擴展參數

  <Expandable title="展開查看 metadata 字段">
    <ParamField body="reference_urls" type="string[]">
      **參考視頻（r2v）模式** — 參考視頻 URL 數組

      當提供此字段時，服務端路由到參考視頻極速上游（wan2.6-r2v-flash）。模型將參考這些視頻生成具有一致角色或場景的新視頻。

      * 每個條目必須是公開可訪問的視頻 URL（http\:// 或 https\://）

      示例：`["https://cdn.example.com/ref1.mp4"]`

      **注意：** 不能與 `image_urls` 同時使用
    </ParamField>
  </Expandable>
</ParamField>

## 有聲 vs 無聲計費說明

| 模式                 | 720p 單價  | 1080p 單價 |
| ------------------ | -------- | -------- |
| 有聲（`audio: true`）  | 0.3 元/秒  | 0.5 元/秒  |
| 無聲（`audio: false`） | 0.15 元/秒 | 0.25 元/秒 |

## 響應

<ResponseField name="id" type="string">
  唯一任務標識符，用於後續查詢狀態
</ResponseField>

<ResponseField name="object" type="string">
  對象類型，固定爲 `generation.task`
</ResponseField>

<ResponseField name="model" type="string">
  使用的模型名稱
</ResponseField>

<ResponseField name="status" type="string">
  任務狀態

  * `queued` - 排隊等待
  * `in_progress` - 處理中
  * `completed` - 成功完成
  * `failed` - 失敗
</ResponseField>

<ResponseField name="progress" type="integer">
  任務進度百分比（0-100）
</ResponseField>

<ResponseField name="created_at" type="integer">
  任務創建時間戳（Unix 時間戳）
</ResponseField>

<ResponseField name="metadata" type="object">
  任務元數據
</ResponseField>

## 使用場景

### 場景一：圖生視頻（有聲）

```json theme={null}
{
  "model": "wan2.6-flash",
  "image_urls": ["https://example.com/photo.jpg"],
  "prompt": "畫面中的人活躍起來",
  "resolution": "1080p",
  "duration": 5,
  "audio": true
}
```

### 場景二：圖生視頻（無聲，降低成本）

```json theme={null}
{
  "model": "wan2.6-flash",
  "image_urls": ["https://example.com/photo.jpg"],
  "resolution": "720p",
  "duration": 5,
  "audio": false
}
```

### 場景三：參考視頻（r2v-flash）

```json theme={null}
{
  "model": "wan2.6-flash",
  "prompt": "角色在沙發上看電影",
  "metadata": {
    "reference_urls": ["https://cdn.example.com/ref-character.mp4"]
  },
  "resolution": "1080p",
  "duration": 5,
  "audio": true
}
```

<Note>
  **查詢任務結果**

  視頻生成爲異步任務。提交後返回 `task_id`，使用 [獲取視頻任務狀態](../../tasks/video-status) 接口查詢生成進度和結果。
</Note>

<RequestExample>
  ```bash cURL（圖生視頻） theme={null}
  curl --request POST \
    --url https://toapis.com/v1/videos/generations \
    --header 'Authorization: Bearer <token>' \
    --header 'Content-Type: application/json' \
    --data '{
      "model": "wan2.6-flash",
      "image_urls": ["https://example.com/photo.jpg"],
      "prompt": "畫面中的人活躍起來",
      "resolution": "1080p",
      "duration": 5,
      "audio": true
    }'
  ```

  ```bash cURL（參考視頻） theme={null}
  curl --request POST \
    --url https://toapis.com/v1/videos/generations \
    --header 'Authorization: Bearer <token>' \
    --header 'Content-Type: application/json' \
    --data '{
      "model": "wan2.6-flash",
      "prompt": "角色在沙發上看電影",
      "metadata": {
        "reference_urls": ["https://cdn.example.com/ref-character.mp4"]
      },
      "resolution": "1080p",
      "duration": 5,
      "audio": true
    }'
  ```

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

  response = requests.post(
      "https://toapis.com/v1/videos/generations",
      headers={
          "Authorization": "Bearer your-ToAPIs-key",
          "Content-Type": "application/json"
      },
      json={
          "model": "wan2.6-flash",
          "image_urls": ["https://example.com/photo.jpg"],
          "prompt": "畫面中的人活躍起來",
          "resolution": "1080p",
          "duration": 5,
          "audio": True
      }
  )

  task = response.json()
  print(f"Task ID: {task['id']}")
  print(f"Status: {task['status']}")
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch('https://toapis.com/v1/videos/generations', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer your-ToAPIs-key',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      model: 'wan2.6-flash',
      image_urls: ['https://example.com/photo.jpg'],
      prompt: '畫面中的人活躍起來',
      resolution: '1080p',
      duration: 5,
      audio: true
    })
  });

  const task = await response.json();
  console.log(`Task ID: ${task.id}`);
  console.log(`Status: ${task.status}`);
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "id": "video_01K2ABJPQ9A0Z6JZ3V8M9W6PZ",
    "object": "generation.task",
    "model": "wan2.6-flash",
    "status": "queued",
    "progress": 0,
    "created_at": 1768380224,
    "metadata": {}
  }
  ```
</ResponseExample>
