# Muse Video API 參考文件 (https://wanapi.app/zh-tw/docs/muse-video)





Muse Video 可依文字提示詞與最多 9 個選填的參考圖片 URL，生成一支具同步 AAC 音訊的 720p MP4 影片片段。影片長度自 10 秒至 60 秒，以 10 秒為單位遞增。

[試用試驗區](/zh-tw/models/muse-video#playground) · [OpenAPI JSON](/models/muse-video/openapi.json) · [整合教學](/zh-tw/blog/muse-video-api-guide)

## 驗證與端點 [#驗證與端點]

請將您的 Wan API 客戶金鑰作為 Bearer 權杖傳入。單一金鑰即可自動存取所有可用模型與群組。

| 方法   | URL                                                       | 用途                             |
| ---- | --------------------------------------------------------- | ------------------------------ |
| POST | `https://api.wanapi.app/muse-video/v1/videos/generations` | 提交一個 Muse Video 任務             |
| GET  | `https://api.wanapi.app/muse-video/v1/tasks/{id}`         | 輪詢該任務直到 `completed` 或 `failed` |

模型 ID 為 &#x2A;*`muse-video`**。兩個端點皆遵循非同步任務介面規範：提交一次 POST 請求內容、持久保存回傳的 `id`，並持續輪詢 GET 路由直到任務結束。請勿在用戶端逾時後自動重複發送 POST 請求。

## 提交文字生成影片任務 [#提交文字生成影片任務]

```bash
curl https://api.wanapi.app/muse-video/v1/videos/generations \
  -H "Authorization: Bearer $WAN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "muse-video",
    "prompt": "Slow motion close-up of a ruby-throated hummingbird hovering at a red trumpet flower during light rain, droplets sparkling in soft backlight, gentle camera drift. Natural ambience: rain patter and wing hum. No text.",
    "aspect_ratio": "16:9",
    "duration": 10
  }'
```

受理的提交請求會立即回傳處理中的任務資訊，而非影片位元組：

```json
{"id":"task_example","model":"muse-video","status":"processing","created_at":1795900800}
```

請每隔 5 至 10 秒輪詢該 `id`：

```bash
curl https://api.wanapi.app/muse-video/v1/tasks/task_example \
  -H "Authorization: Bearer $WAN_API_KEY"
```

請將 `task_example` 保存在持久儲存空間中，以便背景工作程序重新啟動後能接續輪詢，避免重複建立付費任務。

## 請求參數 [#請求參數]

| 參數                            | 類型     | 預設值      | 規則                                                                                                     |
| ----------------------------- | ------ | -------- | ------------------------------------------------------------------------------------------------------ |
| `model`                       | 字串     | 必填       | 必須為 `muse-video`。                                                                                      |
| `prompt`                      | 字串     | 必填       | 最長 20,000 字元的非空白字串。即使提供 `image_urls` 亦為必填。                                                             |
| `image_urls`                  | URL 陣列 | 無        | 0 至 9 個公開 `http(s)` URL（PNG、JPEG 或 WebP，合計 ≤11 MB）。不接受 Base64、data URI 與檔案上傳。                          |
| `aspect_ratio`                | 字串     | 自動（省略）   | `1:1`、`16:9`、`9:16`、`4:3`、`3:4`、`3:2`、`2:3` 其中之一。使用自動構圖時請省略此欄位；此處不接受 `"auto"`。                         |
| `size`                        | 字串     | 無        | 構圖別名欄位，接受上述 7 種比例或 `"auto"`。如 `1280x720` 這類像素字串會遭拒絕。若同時傳送 `aspect_ratio` 與 `size`，以 `aspect_ratio` 優先。 |
| `duration`                    | 整數或字串  | `10`     | `10`、`20`、`30`、`40`、`50` 或 `60`（亦接受如 `"10"` 或 `"10s"` 等字串）。                                            |
| `seconds`, `duration_seconds` | 整數或字串  | 無        | `duration` 的別名欄位。同時傳送多個長度欄位時，解析後的數值必須一致。                                                               |
| `resolution`                  | 字串     | `"720p"` | 選填；僅接受 `"720p"`。`480p`、`1080p` 與 `4K` 會遭拒絕。                                                            |
| `audio`                       | 布林值    | `true`   | 選填；由於每支 Muse Video 輸出皆含原生音訊，僅接受 `true`。                                                                |
| `n`                           | 整數     | `1`      | 選填；僅接受 `1`。                                                                                            |

Muse Video 不提供 `nsfw_checker`、`content_filter`、`seed`、`first_frame`、`last_frame`、`reference_videos` 或 `reference_audios` 欄位。

## 參考圖片與構圖規則 [#參考圖片與構圖規則]

請在 `image_urls` 中傳入 1 至 9 個不含 URL 憑證（`user:pass@`）、反斜線或登入驗證牆的公開 HTTP(S) URL。所有參考圖片須為 PNG、JPEG 或 WebP 格式，且合計資料量不得超過 **11 MB**。

```json
{
  "model": "muse-video",
  "prompt": "The camera glides slowly along the misty lantern canal between floating market boats, lanterns swaying gently, ripples spreading across the water. Ambient water and soft market chatter. No text.",
  "image_urls": [
    "https://your-cdn.example/canal-source.webp"
  ],
  "duration": 10
}
```

當 `image_urls` 非空時：

* 在 **10、30、40、50 或 60 秒**長度下，省略 `aspect_ratio` 可讓模型依提示詞與原始圖片自動選擇構圖。
* 在 **20 秒**長度下，必須傳入明確的 `aspect_ratio`（例如 `"16:9"` 或 `"9:16"`）。

## 完成與失敗的任務回應 [#完成與失敗的任務回應]

生成完成後，`status` 會變為 `"completed"`，且 `output.video_url` 會指向已儲存的 MP4 影片：

```json
{
  "id": "task_example",
  "model": "muse-video",
  "status": "completed",
  "created_at": 1795900800,
  "finished_at": 1795900894,
  "output": {
    "video_url": "https://media.wanapi.app/flexible/v1/expires/2026-12/20261229T14/wanapi-task_example/video.mp4?token=EXAMPLE&expires=1798552800"
  }
}
```

若需要在簽章儲存期限過後永久保留影片，請自行下載並封存 MP4 檔案。透過 `DELETE /v1/tasks/{id}` 刪除已完成任務時，會一併清除儲存的影片檔案與 CDN 快取項目。

若生成失敗，`status` 會變為 `"failed"` 並附帶 `error` 物件（含 `code` 與 `message`），預扣額度則會自動退還。

## 價格 [#價格]

<MuseVideoModelPricing />

Muse Video 嚴格依請求的影片長度，以 10 秒為單位計費：

```text
clip cost = (duration / 10) × live 10-second rate
```

參考圖片（`image_urls`）、長寬比選擇與原生音訊皆不另收附加費。提交任務時會依當下的即時閘道費率快照預扣確切影片費用；完成時結算該筆金額，失敗任務則會全額退還預扣款項。

## 錯誤與重試安全守則 [#錯誤與重試安全守則]

驗證錯誤（`400 invalid_request`）、身分驗證錯誤（`401`/`403`）、額度不足（`402 insufficient_balance`）與速率限制（`429 rate_limited`）皆會在建立計費任務前攔截。

輪詢 `GET /muse-video/v1/tasks/{id}` 時若遇到暫時性的 `429` 或 `5xx` 回應，可安全重試。&#x2A;*當連線中斷或回傳 `submission_unknown` 時，切勿自動重試 `POST /muse-video/v1/videos/generations`**：請先檢查任務紀錄。已受理的任務會等待上游正常完成；若任務連續三小時未收到正常的上游狀態或交付結果，系統會自動判定失敗並全額退款。

完整的 `curl` 搭配 Python 輪詢流程，請參閱 [Muse Video API 教學](/zh-tw/blog/muse-video-api-guide)。
