> ## 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.

# Veo 3.1 API：Google 文字生成影片與畫面影格控制

> Google 影片產生 API 用於文字轉影片、第一影格/最後一影格、參考引導和擴展工作流程

## 概覽

Veo 3.1 是 Google 的影片生成模型，支援文字生成影片、首尾影格動畫和參考素材引導生成，還可以延長已完成的 Veo 3.1 任務所生成的影片。在 APIXO Playground 試用後，可依本頁範例呼叫 API。

| 功能 | 值 |
| - | - |
| 模型 ID | `veo-3-1` |
| 模式 | `lite`, `fast`, `quality`, `extend-fast`, `extend-quality` |
| 生成類型 | `TEXT_2_VIDEO`, `FIRST_AND_LAST_FRAMES_2_VIDEO`, `REFERENCE_2_VIDEO` |
| 擴充來源 | 從同一帳戶完成非延期 APIXO `veo-3-1` `taskId` |
| 提示詞長度 | 1 至 10000 個字元 |
| 支援的持續時間 | `4`、`6`、`8` 秒 |
| 縱橫比 | `16:9`, `9:16`, `auto` |
| 輸出解析度 | `720p`, `1080p`, `4k` |
| 第一影格/最後一影格輸入 | 最多 2 個圖片 URL |
| 參考輸入 | 最多 3 個影像 URL；僅限 `fast` 模式；`REFERENCE_2_VIDEO` 僅支援 8 秒 |
| 輸出 | `resultJson.resultUrls` 中的影片 URL |

## 端點與身分驗證

API 基底網址：

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

| 方法 | 端點 | 用途 |
| - | - | - |
| `POST` | `/generateTask/veo-3-1` | 送出生成任務 |
| `GET` | `/statusTask/veo-3-1?taskId={taskId}` | 查詢任務狀態並取得結果 |

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

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

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

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

## 非同步請求範例

以下範例提交一個最簡單的文字生成影片任務，回應中會傳回 `taskId`。

```bash theme={null}
curl -X POST "https://api.apixo.ai/api/v1/generateTask/veo-3-1" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "request_type": "async",
    "input": {
      "mode": "lite",
      "prompt": "a cinematic flyover of a futuristic city at sunrise",
      "generationType": "TEXT_2_VIDEO",
      "duration": 6,
      "resolution": "1080p",
      "aspect_ratio": "16:9"
    }
  }'
```

成功回應：

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

請保留 `taskId`，後續輪詢結果時會用到。

## 輪詢結果

```bash theme={null}
curl -X GET "https://api.apixo.ai/api/v1/statusTask/veo-3-1?taskId=task_12345678" \
  -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/xxx.mp4\"]}",
    "createTime": 1767965610929,
    "completeTime": 1767965730929,
    "costTime": 120000
  }
}
```

任務失敗時的回應範例：

```json theme={null}
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_12345678",
    "state": "failed",
    "failCode": "SensitiveContent",
    "failMsg": "Content violates safety policy, please adjust the prompt",
    "createTime": 1767965610929,
    "completeTime": 1767965620132,
    "costTime": 9203
  }
}
```

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

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

## 請求體

### 文生影片

```json theme={null}
{
  "request_type": "async",
  "input": {
    "mode": "lite",
    "prompt": "a cinematic flyover of a futuristic city at sunrise",
    "generationType": "TEXT_2_VIDEO",
    "duration": 6,
    "resolution": "1080p",
    "aspect_ratio": "16:9"
  }
}
```

### 影片的第一影格/最後一影格

```json theme={null}
{
  "request_type": "async",
  "input": {
    "mode": "quality",
    "prompt": "a calm ocean turning into a storm",
    "generationType": "FIRST_AND_LAST_FRAMES_2_VIDEO",
    "duration": 6,
    "resolution": "720p",
    "image_urls": [
      "https://example.com/frame_start.jpg",
      "https://example.com/frame_end.jpg"
    ],
    "aspect_ratio": "9:16"
  }
}
```

### 參考生成影片

```json theme={null}
{
  "request_type": "async",
  "input": {
    "mode": "fast",
    "prompt": "turn these references into a dynamic action shot",
    "duration": 8,
    "resolution": "720p",
    "generationType": "REFERENCE_2_VIDEO",
    "image_urls": [
      "https://example.com/ref1.jpg",
      "https://example.com/ref2.jpg"
    ],
    "aspect_ratio": "9:16"
  }
}
```

### 延長已完成的 Veo 3.1 任務

```json theme={null}
{
  "request_type": "async",
  "input": {
    "mode": "extend-quality",
    "taskId": "task_id_from_completed_veo31_task",
    "prompt": "extend this scene into a dramatic sunset over the city skyline",
    "watermark": "YourBrand"
  }
}
```

## 參數

**request\_type** `string` *required* (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*

Veo 3.1 的輸入參數。

**屬性**

**mode** `string` *required*

模型模式。支援的值：`lite`、`fast`、`quality`、`extend-fast`、`extend-quality`。`REFERENCE_2_VIDEO`僅支援`fast`。

**taskId** `string`

僅需用於 `extend-fast` 和 `extend-quality`。使用 APIXO 任務 ID 由已完成的非擴展傳回 `/generateTask/veo-3-1` 來自同一帳戶的任務。

**prompt** `string` *required*

描述影片的文字提示。支援1-10000字元。

**generationType** `string`

`lite`、`fast` 和 `quality` 生成模式所需。支援的值：`TEXT_2_VIDEO`、`FIRST_AND_LAST_FRAMES_2_VIDEO`、`REFERENCE_2_VIDEO`。`extend-fast` 或 `extend-quality` 不使用。

**duration** `integer`

可選影片時長（以秒為單位）。支援的值：`4`、`6`、`8`。預設值為 `8`。對於 `REFERENCE_2_VIDEO`，僅支援 `8`。

**resolution** `string`

可選輸出解析度。支援的值：`720p`、`1080p`、`4k`。預設值為 `720p`。

**aspect\_ratio** `string`

輸出畫面的長寬比。可用值為 `16:9`、`9:16`、`auto`。

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

用於影像引導工作流程的影像 URL。對於 `FIRST_AND_LAST_FRAMES_2_VIDEO` 和 `REFERENCE_2_VIDEO` 是必需的。支援最多 2 個影像用於第一影格/最後一影格生成，最多支援 3 個影像用於參考生成。

**watermark** `string`

可選浮水印文字。

**seed** `integer`

用於可重複產生嘗試的可選隨機種子。

> [!WARNING]
>
> `REFERENCE_2_VIDEO` 需要 `mode: "fast"`。使用最多 3 個可公開存取的影像 URL 來產生參考。它僅支援 `8` 秒。

> [!WARNING]
>
> `extend-fast` 和 `extend-quality` 需要 `input.taskId`。基本任務必須是同一帳戶擁有的已完成的非擴充 Veo 3.1 任務。擴展任務不能用作另一個擴展請求的基本任務。

使用可公開存取且可直接存取的影像 URL。對於影像引導工作流程，建議使用 JPG、JPEG 和 PNG 輸入，最高可達 10 MB。

## 回應格式

### 送出任務時的回應

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

**code** `integer`

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

**message** `string`

狀態說明。

**data.taskId** `string`

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

### 狀態回應欄位

**taskId** `string`

任務的唯一識別碼。

**state** `string`

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

**resultJson** `string`

內含生成影片 URL 的 JSON 字串。`state` 為 `success` 時傳回。

**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/veo-3-1" \
  -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": "fast",
      "prompt": "a product reveal shot with smooth camera motion and dramatic lighting",
      "generationType": "TEXT_2_VIDEO",
      "duration": 6,
      "resolution": "1080p",
      "aspect_ratio": "16:9"
    }
  }'
```

Webhook 的接收條件與重試規則請見 [Webhook 文件](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)。

Veo 3.1 依產生或擴充的影片任務計費。對於生成模式，選擇的 `mode` 和 `resolution` 決定單價。擴展模式在定價頁面上有自己的按任務定價。

當前定價不隨 `duration` 變化；`4`、`6` 和 `8` 秒請求對於給定的 `mode` + `resolution` 使用相同的每影片價格。

| 生成模式 | `720p` | `1080p` | `4k` |
| - | - | - | - |
| `lite` | `$0.15 / video` | `$0.25 / video` | `$0.75 / video` |
| `fast` | `$0.30 / video` | `$0.375 / video` | `$0.90 / video` |
| `quality` | `$1.60 / video` | `$1.80 / video` | `$2.40 / video` |

用於比較的市場參考定價：

| 生成模式 | `720p` | `1080p` | `4k` |
| - | - | - | - |
| `lite` | `$3.20 / video` | `$3.20 / video` | `$4.80 / video` |
| `fast` | `$1.20 / video` | `$1.20 / video` | `$2.40 / video` |
| `quality` | `$3.20 / video` | `$3.20 / video` | `$4.80 / video` |

最新的美元費率請見 [API 價目表](https://apixo.ai/pricing/api)。

## 耗時與輪詢

實際延遲可能會因提示複雜性、影像輸入、所選路線和目前佇列負載而異。

| 模式 | 一般生成時間 | 建議首次查詢時間 | 輪詢間隔 |
| - | - | - | - |
| `lite` | 1-3 分鐘 | 任務建立 60 至 90 秒後 | 5-10s |
| `fast` | 1-3 分鐘 | 任務建立 60 至 90 秒後 | 5-10s |
| `quality` | 1-3 分鐘 | 任務建立 90 秒後 | 5-10s |
| `extend-fast` | 1-3 分鐘 | 任務建立 30 至 60 秒後 | 5-10s |
| `extend-quality` | 1-3 分鐘 | 任務建立 60 至 90 秒後 | 5-10s |

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

請求頻率與並行數上限會依帳戶、API 金鑰和路由而異。收到 `429` 時，請降低請求頻率，並逐步拉長重試間隔。帳戶層級的限制請見[系統 API](https://apixo.ai/docs/zh-hant/api-reference/system.md)。

## 錯誤與排查

### HTTP 錯誤

| 代碼 | 含義 | 處理方式 |
| - | - | - |
| `400` | 無效的請求主體、缺少參數、不支援的模式、不支援的生成類型或無效的影像輸入 | 修正請求後再試 |
| `401` | 缺少 API 金鑰，或金鑰無效 | 檢查 `Authorization` 請求標頭 |
| `402` | 餘額或配額不足 | 充值或更換帳號或金鑰 |
| `403` | 金鑰或路由無權訪問該模型 | 檢查權限和路由策略 |
| `429` | 已達到速率或並行限制 | 以指數退避方式重試 |
| `500` | 伺服器錯誤 | 逐步拉長間隔後重試 |
| `502` | 服務錯誤 | 逐步拉長間隔後重試 |
| `504` | 服務超時 | 重新嘗試；耗時較長的任務可改用回呼模式 |

### 任務失敗代碼

| 錯誤碼 | 含義 | 處理方式 |
| - | - | - |
| `SensitiveContent` | 提示或影像輸入被安全檢查拒絕 | 更改提示或輸入影像 |
| `PromptInvalid` | 提示詞無效或遭拒 | 修改提示詞後再試一次 |
| `ImageFormatIncorrect` | 不接受輸入影像格式 | 使用公共 JPG、JPEG 或 PNG URL |
| `MissingParameter` | 缺少必需的參數 | 檢查`mode`、`prompt`、`generationType`和條件`image_urls` |
| `RateLimited` | 請求頻率已達上限 | 以指數退避方式重試 |
| `Timeout` | 任務逾時 | 重試、降低輸入複雜度或使用回呼模式 |
| `Unknown error` | 任務因不明原因失敗 | 稍後重試或透過 `taskId` 聯繫支援人員 |

### 常見驗證問題

| 問題 | 處理方式 |
| - | - |
| 缺少 `mode` | 將`mode`設定為`lite`、`fast`、`quality`、`extend-fast`或`extend-quality` |
| 缺少 `generationType` | 對於 `lite`、`fast` 和 `quality`，設定支援的生成類型值之一 |
| 缺少擴充 `taskId` | 為了 `extend-fast` 和 `extend-quality`，提供 APIXO `taskId` 從已完成的非擴展 Veo 3.1 任務 |
| 擴展擴展任務 | 使用已完成的非擴展 Veo 3.1 任務作為基本任務 |
| `REFERENCE_2_VIDEO` 與 `lite` 或 `quality` | 使用`mode: "fast"` |
| `REFERENCE_2_VIDEO` 的持續時間不是 `8` | 使用`duration: 8` |
| 圖片太多 | 使用最多 2 個影像來產生第一影格/最後一影格，或使用最多 3 個影像來產生參考影像 |
| 空影像 URL | 提供非空、可公開存取的影像 URL |

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

## MCP 整合

[完整模型 Schema](https://apixo.ai/docs/models/schemas/video/veo-3-1.json) 中的 `mcp.result` 指定結果的解析方式，`mcp.attachments` 列出可繫結檔案的欄位。這些中繼資料供用戶端整合使用，無須當作生成參數提交。附件欄位為 `image_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)
* [路由策略](https://apixo.ai/docs/zh-hant/concepts/routing-strategies.md)
* [嘗試 Veo 3.1 在 APIXO Playground](https://apixo.ai/models/veo-3-1)
* [API定價](https://apixo.ai/pricing/api)


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