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

# FLUX 3 Video API：文字生成影片、圖片生成影片與影片續寫

> 使用 FLUX 3 生成一段 5–20 秒的影片。從提示開始，動畫一至兩張影像影格，或擴展一段公開的 MP4 影片。

## 概覽

使用`flux-3`生成MP4。從 [單獨提示開始](#copy-paste-async-quickstart)，[為一張影像設定動畫](#image-to-video)，或 [提供開始影格和結束影格](#image-to-video-with-start-and-end-frames)。若要繼續您已有的素材，請使用 [影片擴充請求](#video-extend)。對於靜態影像輸出，請使用 [FLUX 3 Image](https://apixo.ai/docs/zh-hant/models/image/flux-3-image.md)。

| 功能 | 值 |
| - | - |
| 模型 ID | `flux-3` |
| 模式 | `text-to-video`, `image-to-video`, `video-extend` |
| 提示詞長度 | 1 至 5000 個字元 |
| 長度 | 5-20 秒 |
| 可用解析度 | `720p`, `1080p` |
| 縱橫比 | `21:9`, `2:1`, `16:9`, `4:3`, `1:1`, `3:4`, `9:16` |
| 影像到影片來源 | 1 影像 URL 或 2 開始影格和結束影格的影像 URL |
| 影片擴充源 | 正好 1 公共 MP4 URL，最多 50 MB 和 15 秒 |
| 音訊 | 預設啟用 `sound: true` |
| 輸出 | MP4 影片網址位於 `resultJson.resultUrls` |

## 端點與身分驗證

API 基底網址：

```text theme={null}
https://api.apixo.ai/api/v1
```

| 方法 | 端點 | 用途 |
| - | - | - |
| `POST` | `/generateTask/flux-3` | 提交影片生成任務 |
| `GET` | `/statusTask/flux-3?taskId={taskId}` | 查詢任務狀態並取得結果 |

每個請求都必須附上 APIXO API 金鑰：

```http theme={null}
Authorization: Bearer YOUR_API_KEY
```

送出任務時，還需設定以下請求標頭：

```http theme={null}
Content-Type: application/json
```

## 非同步請求範例

文字轉影片作業只需要 `mode` 和 `prompt`。此請求使用持續時間（5 秒）、解析度（720p）、寬高比（9:16）和聲音（開啟）的預設值。

```bash theme={null}
curl -X POST "https://api.apixo.ai/api/v1/generateTask/flux-3" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "request_type": "async",
    "input": {
      "mode": "text-to-video",
      "prompt": "a cinematic macro shot of glass sculptures forming from liquid light"
    }
  }'
```

成功回應：

```json theme={null}
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_12345678"
  }
}
```

從您提交的內容中儲存 `data.taskId` 並在狀態請求中使用它。

## 輪詢結果

```bash theme={null}
TASK_ID="paste-your-returned-task-id"
curl -X GET "https://api.apixo.ai/api/v1/statusTask/flux-3?taskId=$TASK_ID" \
  -H "Authorization: Bearer YOUR_API_KEY"
```

任務處理中的回應範例：

```json theme={null}
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_12345678",
    "state": "processing",
    "createTime": 1767965610929
  }
}
```

成功回應：

```json theme={null}
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_12345678",
    "state": "success",
    "resultJson": "{\"resultUrls\":[\"https://file.apixo.ai/flux-3.mp4\"]}",
    "createTime": 1767965610929,
    "completeTime": 1767965680929,
    "costTime": 70000
  }
}
```

任務失敗時的回應範例：

```json theme={null}
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_12345678",
    "state": "failed",
    "failCode": "INVALID_PARAMETER",
    "failMsg": "One or more input parameters are invalid.",
    "createTime": 1767965610929,
    "completeTime": 1767965620132
  }
}
```

等 `state` 變為 `success` 後，再解析 `resultJson`：

```javascript theme={null}
const payload = JSON.parse(data.resultJson);
const videoUrls = payload.resultUrls;
```

## 請求體

### 文生影片

```json theme={null}
{
  "request_type": "async",
  "input": {
    "mode": "text-to-video",
    "prompt": "a wide cinematic desert highway at sunrise, gentle aerial camera movement",
    "duration": 8,
    "resolution": "1080p",
    "aspect_ratio": "16:9",
    "sound": true
  }
}
```

### 圖生影片

```json theme={null}
{
  "request_type": "async",
  "input": {
    "mode": "image-to-video",
    "prompt": "animate the portrait with a subtle smile and soft studio camera drift",
    "image_urls": [
      "https://example.com/source.png"
    ],
    "duration": 5,
    "resolution": "720p",
    "aspect_ratio": "9:16",
    "sound": true
  }
}
```

### 指定首尾影格的圖片轉影片

在 `image_urls` 中首先放置開始影像，然後放置結束影像。描述`prompt`中它們之間的運動。提交前將範例 URL 替換為公用影像 URL。

```json theme={null}
{
  "request_type": "async",
  "input": {
    "mode": "image-to-video",
    "prompt": "transition smoothly from the empty room into the decorated final scene",
    "image_urls": [
      "https://example.com/start-frame.png",
      "https://example.com/end-frame.png"
    ],
    "duration": 10,
    "resolution": "1080p",
    "aspect_ratio": "16:9",
    "sound": false
  }
}
```

### 影片擴充

將範例 URL 替換為一個公共 MP4 文件，最長 15 秒，最多 50 MB。 `duration` 欄位設定請求的輸出持續時間（5–20 秒）。

```json theme={null}
{
  "request_type": "async",
  "input": {
    "mode": "video-extend",
    "prompt": "continue the camera move forward as the scene opens into a bright atrium",
    "video_urls": [
      "https://example.com/source.mp4"
    ],
    "duration": 8,
    "resolution": "720p",
    "aspect_ratio": "16:9",
    "sound": true
  }
}
```

## 參數

**request\_type** `string` (default: async)

指定取得結果的方式。省略此欄位或設為 `async` 時，可透過 `statusTask` 輪詢；設為 `callback` 時，透過 Webhook 接收。

**callback\_url** `string`

當 `request_type` 為 `callback` 時必填。請提供可從網際網路存取的 HTTPS 網址，以接收任務的最終結果。詳見 [Webhook](https://apixo.ai/docs/zh-hant/api-reference/webhooks.md)。

**input** `object` *required*

FLUX 3 的輸入參數。

**屬性**

**mode** `string` *required*

生成模式。可用值為 `text-to-video`、`image-to-video`、`video-extend`。

**prompt** `string` *required*

用文字描述想生成的影片。長度須為 1 至 5000 個字元。提示詞為空時，請求會遭拒。

**duration** `integer|string` (default: 5)

輸出持續時間（以秒為單位）。支援從 `5` 到 `20` 的整數或整數字串。小數值無效。

**resolution** `string` (default: 720p)

輸出解析度。可用值為 `720p`、`1080p`。

**aspect\_ratio** `string` (default: 9:16)

輸出畫面的長寬比。可用值為 `21:9`、`2:1`、`16:9`、`4:3`、`1:1`、`3:4`、`9:16`。

**sound** `boolean` (default: true)

是否產生同步音訊。支援的值：`true`、`false`。音訊不另外加收費用。

**image\_urls** `string[]`

參考影像 URL。`image-to-video` 所需。提供 1 可公開存取的影像 URL 或 2 可公開存取的影像 URL，其中第一個 URL 是開始影格，第二個 URL 是結束影格。

**video\_urls** `string[]`

來源影片 URL。`video-extend` 所需。準確提供 1 公共 MP4 URL。來源影片不得大於 50 MB 且不長於 15 秒。

### 模式選項

| 模式 | 所需媒體 | 使用案例 |
| - | - | - |
| `text-to-video` | 無 | 根據提示生成影片 |
| `image-to-video` | `image_urls` 與 1 或 2 個 URL | 對一張影像進行動畫處理，或在開始影格和結束影格之間產生運動 |
| `video-extend` | `video_urls` 恰好為 1 個 MP4 URL | 繼續現有的短影片 |

## 回應格式

### 送出任務時的回應

任務受理後，`POST /generateTask/flux-3` 會傳回任務 ID：

**code** `integer`

API 狀態碼。`200` 表示任務已受理。

**message** `string`

狀態說明。

**data.taskId** `string`

任務的唯一 ID，用於查詢任務狀態。

### 狀態回應欄位

**taskId** `string`

任務的唯一識別碼。

**state** `string`

目前的任務狀態，可能的值為 `pending`、`processing`、`processing_r2`、`success`、`failed`。

**resultJson** `string`

當 `state` 為 `success` 時傳回。解析此 JSON 字串後，即可從 `resultUrls` 取得生成的影片連結。

**failCode** `string`

供程式判讀的錯誤碼，僅在 `state` 為 `failed` 時傳回。

**failMsg** `string`

失敗原因說明，僅在 `state` 為 `failed` 時傳回。

**createTime** `integer`

任務建立時的 Unix 時間戳記，單位為毫秒。

**completeTime** `integer`

任務完成時的 Unix 時間戳記，單位為毫秒。任務完成後才會傳回。

**costTime** `integer`

處理時間，以毫秒為單位。有計時資料時才會傳回。

## Webhook 回呼模式

若希望後端自動收到最終結果，可使用回呼模式，無須輪詢。

```bash theme={null}
curl -X POST "https://api.apixo.ai/api/v1/generateTask/flux-3" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "request_type": "callback",
    "callback_url": "https://your-server.com/webhooks/apixo",
    "input": {
      "mode": "image-to-video",
      "prompt": "turn the product photo into a premium reveal shot with slow camera motion",
      "image_urls": [
        "https://example.com/product.png"
      ],
      "duration": 5,
      "resolution": "720p",
      "aspect_ratio": "9:16",
      "sound": true
    }
  }'
```

回呼傳遞使用與狀態回應相同的最終有效負載形狀。請參閱 [Webhooks](https://apixo.ai/docs/zh-hant/api-reference/webhooks.md) 以了解傳送要求與重試行為。

## 計費

新提交的非 LLM 請求按 **1 點 = `$0.001`** 計費。先依用量和加購項目計算總額，再套用帳戶折扣，最後將請求總額無條件進位至整數點數。若已約定固定單價，則保留該單價的精度，不再使用標準價或另行打折；最終點數仍須進位。詳見[積分換算與進位](https://apixo.ai/docs/zh-hant/pricing.md#credit-conversion-and-rounding)。

FLUX 3 按輸出秒數計費。所選的 `mode` 和 `resolution` 決定每秒單價，`duration` 決定計費秒數。`text-to-video` 與 `image-to-video` 同代定價；開始/結束影格圖生影片使用 `image-to-video` 價格。`video-extend` 使用延展價格。

| 模式 | 解析度 | APIXO 價格 | 總計範例 |
| - | - | -: | -: |
| `text-to-video`或`image-to-video` | `720p` | `$0.17 / second` | 5s: `$0.85` |
| `text-to-video`或`image-to-video` | `1080p` | `$0.29 / second` | 10s: `$2.90` |
| `video-extend` | `720p` | `$0.41 / second` | 5s: `$2.05` |
| `video-extend` | `1080p` | `$0.53 / second` | 10s: `$5.30` |

公式：

```text theme={null}
total cost = duration * selected mode and resolution unit price
```

使用 `sound: true` 產生音訊不會增加單獨的費用。有關最新發布的定價，請參閱[API定價](https://apixo.ai/pricing/api)。

## 耗時與輪詢

實際延遲可能會因提示複雜性、所選模式、媒體可存取性、持續時間、解析度和目前佇列負載而異。

| 請求結構 | 一般生成時間 | 建議首次查詢時間 | 輪詢間隔 |
| - | - | - | - |
| `5-8`秒剪輯 | 60s-120s | 任務建立 60 秒後 | 5s-10s |
| `9-15`秒剪輯 | 120s-240s | 任務建立 90 秒後 | 10s |
| `16-20`秒剪輯 | 240s+ | 任務建立 120 秒後 | 10s-15s |

> [!TIP]
>
> 對於生產影片工作負載，請使用回呼模式以避免在生成仍在運行時頻繁輪詢。

## 錯誤與排查

### HTTP 錯誤

| 代碼 | 含義 | 處理方式 |
| - | - | - |
| `400` | 請求主體無效、缺少 `mode`、缺少 `prompt`、媒體輸入無效、無效 `duration`、無效 `resolution` 或無效 `aspect_ratio` | 修正請求後再試 |
| `401` | 缺少 API 金鑰，或金鑰無效 | 檢查 `Authorization` 請求標頭 |
| `402` | 餘額或配額不足 | 充值或更換帳號或金鑰 |
| `403` | 此API鍵無法存取模型 | 檢查帳戶權限 |
| `404` | 輪詢時未找到任務 | 檢查`taskId` |
| `429` | 已達到速率或並行限制 | 以指數退避方式重試 |
| `500` | 內部錯誤或未知任務失敗 | 重試後退或聯絡支援人員（如果問題仍然存在） |
| `502` | 產生服務或網路錯誤 | 逐步拉長間隔後重試 |
| `503` | 服務暫時無法使用 | 稍後重試 |
| `504` | 生成超時 | 稍後重試或對長時間運行的作業使用回呼模式 |

### 驗證說明

| 參數 | 後端行為 |
| - | - |
| `input.mode` | 必需的。使用`text-to-video`、`image-to-video`或`video-extend`。 |
| `input.prompt` | 必需的字串。不能為空且不能超過 5000 個字元。 |
| `input.duration` | 選填。預設為 `5`。接受從 `5` 到 `20` 的整數或整數字串；小數被拒絕。 |
| `input.resolution` | 選填。使用 `720p`（預設）或 `1080p`。 |
| `input.aspect_ratio` | 選填。預設為 `9:16`。如果提供，必須是 `21:9`、`2:1`、`16:9`、`4:3`、`1:1`、`3:4`、`9:16` 之一。 |
| `input.sound` | 選填。預設為 `true`。必須是布林值。 |
| `input.image_urls` | `image-to-video` 所需。必須包含 1 或 2 非空的公開影像 URL。 |
| `input.video_urls` | `video-extend` 所需。必須恰好包含 1 個非空的公開 MP4 URL；來源必須不大於 50 MB 且不長於 15 秒。 |

完整列表見[錯誤碼](https://apixo.ai/docs/zh-hant/api-reference/errors.md)。

## MCP 整合

[完整模型 Schema](https://apixo.ai/docs/models/schemas/video/flux-3.json) 中的 `mcp.result` 指定結果的解析方式，`mcp.attachments` 列出可繫結檔案的欄位。這些中繼資料供用戶端整合使用，無須當作生成參數提交。附件欄位為 `image_urls`, `video_urls`。請保留使用者指定的檔案順序。模型參數由 API 驗證。

## 相關連結

* [生成 API 總覽](https://apixo.ai/docs/zh-hant/models.md)
* [影片模型](https://apixo.ai/docs/zh-hant/models/video)
* [送出生成任務](https://apixo.ai/docs/zh-hant/api-reference/generate-task.md)
* [查詢任務狀態](https://apixo.ai/docs/zh-hant/api-reference/status-task.md)
* [Webhook](https://apixo.ai/docs/zh-hant/api-reference/webhooks.md)
* [錯誤碼](https://apixo.ai/docs/zh-hant/api-reference/errors.md)
* [參數規範](https://apixo.ai/docs/zh-hant/api-reference/parameters.md)
* [在 APIXO Playground 嘗試 FLUX 3](https://apixo.ai/models/flux-3)
* [API定價](https://apixo.ai/pricing/api)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.