---
title: "開發者 API · AI圖片、影片和聲音生成API — shuut"
description: "一個 API 呼叫最新 AI 圖片、影片和聲音模型。用 API 金鑰從程式碼呼叫 shuut：驗證、生成、預估、上傳、Webhook、錯誤，附範例。"
url: https://shuut.ai/developers?lang=zh-Hant
lang: zh-Hant
updated: 2026-12-01T04:16:58+00:00
---

# 開發者 API

一個 API 呼叫最新 AI 圖片、影片和聲音模型。用 API 金鑰從程式碼呼叫 shuut：驗證、生成、預估、上傳、Webhook、錯誤，附範例。

用 API 金鑰在你的程式碼中呼叫 shuut 的圖片、影片、聲音生成。價格、限額和安全規則與網頁版相同。

基礎網址 `https://shuut.ai/v1`

[查看模型](https://shuut.ai/developers/models?lang=zh-Hant) · [API 價格](https://shuut.ai/developers/pricing?lang=zh-Hant)

## 快速開始

### 建立金鑰

在我的帳戶「API 金鑰」中建立金鑰。以 `shuut_sk_` 開頭的金鑰只會在建立時顯示一次。

### 傳送建立請求

將模型和輸入傳送到 `/v1/generations`。會立即回傳 202 和生成 id。

```bash
curl https://shuut.ai/v1/generations \
  -H "Authorization: Bearer $SHUUT_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
    "model": "bytedance/seedance-2.5-flash",
    "input": {
      "prompt": "A paper boat drifting down a rainy street",
      "duration": 8,
      "aspect_ratio": "9:16"
    },
    "webhook_url": "https://example.com/hooks/shuut"
  }'
```

### 等到完成為止

用 `?wait=1~20` 查詢狀態時，完成或經過該秒數就會回覆。設定 Webhook 後就不必查詢。

### 取得結果

outputs 中的網址可使用 24 小時。再問一次就會取得新網址。

## 驗證

將金鑰放在 `Authorization: Bearer` 標頭或 `x-api-key` 標頭。不會讀取 Cookie。

金鑰如同密碼，只放在伺服器上，不要放進瀏覽器或應用程式的程式碼。外洩時，請立即到「我的帳戶」撤銷。

模型列表、模型詳情與 OpenAPI 不需要金鑰也能讀取。

## 生成

`POST /v1/generations`

| 欄位 | 型別 | 必填 | 說明 |
| --- | --- | --- | --- |
| `model` | string | 必填 | 模型 id。請到模型參考中查找。 |
| `input` | object | 選填 | 該模型的輸入。欄位依模型參考中的表格而定。 |
| `webhook_url` | string | 選填 | 完成時接收通知的公開 https 網址。 |
| `max_cost_credits` | integer | 選填 | 費用高於這個值時，就不會生成。 |

### 狀態

| 狀態 | 意思 |
| --- | --- |
| `queued` | 正在排隊等候。 |
| `processing` | 正在生成中。 |
| `completed` | 完成了。結果在 outputs 中。 |
| `failed` | 失敗了。點數會退還。 |
| `canceled` | 已取消。點數會退回。 |

如果出現 unconfirmed: true，表示正在確認結果。請在 poll_after_seconds 秒後再查詢一次，不要重新建立。重新建立會重複扣除點數。

- `GET /v1/generations/{id}` — 查看狀態與結果。
- `GET /v1/generations` — 透過 API 生成的清單，也會顯示在網頁版的素材中。
- `POST /v1/generations/{id}/cancel` — 只有在開始前才能取消，點數會全數退還。

### 冪等金鑰

傳送 `Idempotency-Key`（最多 100 個字元），連線中斷後重新傳送也只會生成一次、只扣一次。回傳同一筆生成時，會收到 200 和 `idempotent-replayed: true`。

相同的金鑰搭配不同的內容會回傳 409。失敗或已取消的生成，其金鑰無法再次使用。

### 報價與價格上限

`POST /v1/generations/estimate`

`/v1/generations/estimate` 使用相同的內容，只告知價格，不會扣除點數。生成時若指定 `max_cost_credits`，當報價高於該值就不會扣款，並以 409 停止。

如果輸入內容的長度未知，報價會以 `quote_seconds` 秒計算最高金額，並加上 `quote_is_upper_bound: true`。實際扣除的金額可能會更少。

## 檔案

`POST /v1/files`

上傳到 `/v1/files`，可用原始內容，或用 `multipart/form-data` 並把檔案放在 `file` 欄位。圖片和音訊最大 20MB，影片最大 100MB。把收到的 id 填入 `input` 的媒體欄位。

媒體欄位也可以填入公開的 https 網址。伺服器會取得內容並製成檔案。

要使用檔案，需先在網頁上同意一次媒體上傳。未同意時會收到 403 和 `consent_url`。API 不會代為同意。

## Webhook

建立時提供 webhook_url，完成後會以 POST 通知。通知會在完成後約 1 分鐘內送出。請在 5 秒內回應 2xx。

`generation.completed` · `generation.failed` · `generation.canceled`

失敗時會在 ~1m · 2m · 10m · 30m · 1h · 3h · 6h 後重新傳送（最多 8 次）。其他 4xx 回應則會停止。相同通知的 webhook-id 相同，可用它篩除重複。

### 驗證簽章

`webhook-id` · `webhook-timestamp` · `webhook-signature`

簽章密鑰可在我的帳戶「API 金鑰」中查看。請依收到的原始內容驗證簽章，若時間相差超過 5 分鐘，請捨棄該請求。

## 錯誤

所有錯誤的格式都相同。用 code 區分，message 是給人看的英文。

| code | HTTP | 意思 |
| --- | --- | --- |
| `missing_api_key` | 401 | 未傳送金鑰。 |
| `invalid_api_key` | 401 | 金鑰錯誤，或已撤銷、過期。兩個標頭送出不同的金鑰，也會出現此錯誤。 |
| `invalid_input` | 400 | 本文或欄位值有誤。param 會指出是哪個欄位。 |
| `prompt_too_long` | 400 | 提示詞超過模型的上限。 |
| `invalid_url` | 400 | 參考網址不是公開的 https 網址。 |
| `insufficient_balance` | 402 | 餘額不足。未扣除點數。 |
| `media_consent_required` | 403 | 尚未同意媒體上傳。請至 consent_url 同意。 |
| `model_not_found` | 404 | 沒有這個模型。 |
| `model_retired` | 410 | 這個模型已停用。請改用 successor 中的模型重新傳送。 |
| `generation_not_found` | 404 | 這筆生成不存在，或不屬於你。 |
| `file_not_found` | 404 | input 中的檔案 id 不存在，或不是你的檔案。 |
| `idempotency_conflict` | 409 | 同一個冪等鍵被用在不同的內容上。 |
| `idempotency_key_reused` | 409 | 該冪等鍵的生成失敗或已取消。請改用新的鍵傳送。 |
| `max_cost_exceeded` | 409 | 報價高於 max_cost_credits，所以未生成。 |
| `quote_changed` | 409 | 取得報價後，報價有所變更。請重新取得報價。 |
| `job_started` | 409 | 已經開始，無法取消。 |
| `too_large` | 413 | 檔案太大。 |
| `unsupported_type` | 415 | 不接受此檔案格式。 |
| `url_unavailable` | 422 | 無法從該網址下載檔案。 |
| `rate_limited` | 429 | 已超過每分鐘請求上限。請在 retry-after 秒後再傳送。 |
| `concurrency_limit` | 429 | 同時製作的數量已滿。請在進行中的作業完成後再傳送。 |
| `upload_daily_cap` | 429 | 今天的上傳額度已用完。 |
| `webhook_backlog` | 429 | 尚未送達的 Webhook 太多了。積壓減少後，請再傳送一次。 |
| `country_blocked` | 451 | 這個地區無法使用。 |
| `internal_error` | 500 · 503 | 伺服器發生錯誤。503（區域中繼失敗）稍後重新傳送即可，若持續發生，請連同 request_id 一起洽詢客服。 |
| `import_timeout` | 504 | 從網址下載檔案花了太久時間。 |

表中沒有的 code，意思與網頁上相同。不認識的 code 請依 HTTP 狀態處理。

## 限制與同時執行

- 建立、報價、取消、檔案：每分鐘 120 次
- 讀取：每分鐘 4,800 次
- 沒有金鑰的請求：每個 IP 位址每分鐘 1,200 次

回應會附上 `ratelimit-limit · ratelimit-reset`，生成、報價、取消和檔案回應也會附上 `ratelimit-remaining`。收到 429 時，請在 `retry-after` 秒後再送出。

同時製作的數量與網頁版採用相同的方案上限。超過時不會排隊等候，而是回傳 429 concurrency_limit。

你的上限與目前正在生成的數量，可在 GET /v1/account 的 concurrency 欄位查看。

## OpenAPI

可將端點與回應格式下載為 OpenAPI 3.1 檔案，用來建立 SDK。各模型的輸入欄位在模型詳情中。

- `GET /v1/models`
- `GET /v1/models/{id}`
- `POST /v1/generations`
- `POST /v1/generations/estimate`
- `GET /v1/generations/{id}`
- `GET /v1/generations`
- `POST /v1/generations/{id}/cancel`
- `POST /v1/files`
- `GET /v1/account`
- `GET /v1/openapi.json`

[https://shuut.ai/v1/openapi.json](https://shuut.ai/v1/openapi.json)

更新於 2026年12月1日

## 工具

- [圖片](https://shuut.ai/image?lang=zh-Hant) — 用文字繪圖
- [影片](https://shuut.ai/video?lang=zh-Hant) — 用文字或照片製作影片
- [影片編輯](https://shuut.ai/videoedit?lang=zh-Hant) — 修飾你的影片
- [Reverse Video](https://shuut.ai/reverse?lang=zh-Hant) — 重新製作影片以便編輯
- [音訊](https://shuut.ai/sound?lang=zh-Hant) — 製作語音和音樂
- [AI 虛擬人物](https://shuut.ai/avatar?lang=zh-Hant) — 讓照片中的人開口說話
- [字幕](https://shuut.ai/captions?lang=zh-Hant) — 為影片加上字幕
- [SWAP](https://shuut.ai/swap?lang=zh-Hant) — 換掉影片中的人物和物品
- [更換比例](https://shuut.ai/resize?lang=zh-Hant) — 一次轉成 4 種比例
- [照片編輯](https://shuut.ai/edit?lang=zh-Hant) — 編輯並擴展照片
- [穿搭圖](https://shuut.ai/tryon?lang=zh-Hant) — 幫模特兒換上衣服
- [連續場景](https://shuut.ai/scenes?lang=zh-Hant) — 用同一個人物製作多個畫面
- [電影工作室](https://shuut.ai/cinema?lang=zh-Hant) — 把多個場景做成短片
- [UGC 研究](https://shuut.ai/ugc?lang=zh-Hant) — 找找成效好的短影音
- [文案](https://shuut.ai/copy?lang=zh-Hant) — 撰寫貼文和主題標籤
- [翻譯](https://shuut.ai/translate?lang=zh-Hant) — 翻譯成 6 種語言
- [用語檢查](https://shuut.ai/check?lang=zh-Hant) — 檢查廣告用語
- [商品圖](https://shuut.ai/product?lang=zh-Hant) — 把物品照片變成棚拍畫面
- [3D](https://shuut.ai/3d?lang=zh-Hant) — 用照片或文字製作 3D 模型

[探索](https://shuut.ai/?lang=zh-Hant) · [SWAP](https://shuut.ai/swap?lang=zh-Hant) · [特效](https://shuut.ai/effects?lang=zh-Hant) · [價格](https://shuut.ai/pricing?lang=zh-Hant) · [客戶支援](https://shuut.ai/support?lang=zh-Hant) · [MCP 連結](https://shuut.ai/mcp?lang=zh-Hant) · [開發者 API](https://shuut.ai/developers?lang=zh-Hant) · [AI影片費用計算器](https://shuut.ai/free/ai-video-cost-calculator?lang=zh-Hant) · [依廣告目的選AI影片模型](https://shuut.ai/free/ai-video-model-picker?lang=zh-Hant)

- [AI 模型 (English)](https://shuut.ai/en/models)
- [影片模型價格 (English)](https://shuut.ai/en/pricing/video)
- [圖片模型價格 (English)](https://shuut.ai/en/pricing/image)

## 法律聲明

- [服務條款](https://shuut.ai/legal/terms?lang=zh-Hant)
- [隱私權政策](https://shuut.ai/legal/privacy?lang=zh-Hant)
- [退款政策](https://shuut.ai/legal/refund?lang=zh-Hant)
- [使用政策](https://shuut.ai/legal/acceptable-use?lang=zh-Hant)
- [公司資訊](https://shuut.ai/legal/business?lang=zh-Hant)
