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

# Veo3 Official 視頻生成

> 使用 Google Veo3 官方直連模型生成高質量視頻，支持音頻生成、首尾幀控制等高級功能

> [!NOTE]
>
> **中國大陸用戶請注意：** 中國大陸用戶請使用 `https://toapis.cn` 作為接口地址（Base URL）。文檔示例中的 `https://toapis.com` 請替換為 `https://toapis.cn`。

* 異步處理模式，返回任務ID用於後續查詢
* 直連 Google Vertex AI，支持 Veo 原生全部參數
* 支持文生視頻、圖生視頻、首尾幀插值等多種生成模式
* 生成的視頻鏈接，有效期爲24小時，請儘快保存

> [!WARNING]
>
> **重要變更**：爲了更好的性能和成本控制，我們不再支持在 `image_urls` 中直接傳入 base64 圖片數據。請先使用 [上傳圖片接口](https://docs.toapis.com/docs/zh-Hant/api-reference/uploads/images.md) 上傳圖片，獲取 URL 後再調用本接口。

## Authorizations

**Authorization** `string` *required*

所有接口均需要使用Bearer Token進行認證

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

使用時在請求頭中添加：

```
Authorization: Bearer YOUR_API_KEY
```

## Body

**model** `string` *required* (default: Veo3.1-quality-official)

視頻生成模型名稱

可用模型：

* `Veo3.1-quality-official` - 高質量生成模型，適用於最終制作
* `Veo3.1-fast-official` - 快速生成模型，適用於快速預覽和迭代
* `Veo3.1-lite-official` - Lite 720p
  Example: `"Veo3.1-quality-official"`

**prompt** `string` *required*

視頻生成的文本描述

**duration** `integer`

視頻時長（秒）

支持的值：

* `4` - 4 秒
* `6` - 6 秒
* `8` - 8 秒（默認）

**size** `string`

視頻寬高比

支持的格式：

* `16:9` (橫屏，默認)
* `9:16` (豎屏)

**resolution** `string`

視頻分辨率

支持的值：

* `720p`（默認）
* `1080p`
* `4k`（預覽）

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

圖生視頻的**首幀參考圖**，視頻將從該圖像開始生成。僅使用數組中的第一個 URL。

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

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

**限制：**

* 最大文件大小：10MB
* 支持格式：.jpeg、.jpg、.png、.webp

> [!WARNING]
>
> `image_urls` 與 `metadata.referenceImages` **不可同時使用**。如果同時傳入，`image_urls`（首幀）優先，`referenceImages` 將被忽略。

**metadata** `object`

Veo3 Official 特有擴展參數

**顯示 metadata 字段**

**generateAudio** `boolean`

是否生成音頻。默認：`false`

啓用後視頻將包含 AI 生成的音效和環境音

**negativePrompt** `string`

負面提示詞，描述不希望在視頻中出現的內容

Example: `"模糊, 低質量, 畸變"`

**personGeneration** `string`

人物生成安全設置

支持的值：

* `allow_adult` - 允許生成成年人
* `dont_allow` - 不允許生成人物

**lastFrame** `string`

尾幀圖片 URL，用於首尾幀插值生成視頻

**必須**與 `image_urls`（首幀）配合使用，生成從首幀到尾幀的過渡視頻。單獨使用無效。

**referenceImages** `string[]`

素材/風格參考圖 URL 數組，視頻內容將參考這些圖片的視覺風格和元素進行生成（不作爲視頻起始幀）

**限制：最多 3 張**

**⚠️ 不可與 `image_urls` 同時使用**——二者在 Veo API 中互斥。如需首幀控制，請使用 `image_urls`。

**compressionQuality** `string`

視頻壓縮質量

支持的值：

* `optimized`（默認）- 優化壓縮
* `lossless` - 無損壓縮

**resizeMode** `string`

圖生視頻時的圖片調整模式

支持的值：

* `pad` - 填充模式，保持原始比例
* `crop` - 裁剪模式，填滿畫面

## Response

**id** `string`

任務唯一標識符，用於查詢任務狀態

**object** `string`

對象類型，固定爲 `generation.task`

**model** `string`

使用的模型名稱

**status** `string`

任務狀態

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

**progress** `integer`

任務進度百分比（0-100）

**created\_at** `integer`

任務創建時間戳（Unix 時間戳）

**metadata** `object`

任務元數據

```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": "Veo3.1-quality-official",
    "prompt": "海豚在碧藍海洋中跳躍，濺起水花，陽光灑在海面上",
    "duration": 8,
    "size": "16:9",
    "resolution": "1080p",
    "metadata": {
      "generateAudio": true,
      "negativePrompt": "模糊, 低質量"
    }
  }'
```

```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": "Veo3.1-quality-official",
        "prompt": "海豚在碧藍海洋中跳躍，濺起水花，陽光灑在海面上",
        "duration": 8,
        "size": "16:9",
        "resolution": "1080p",
        "metadata": {
            "generateAudio": True,
            "negativePrompt": "模糊, 低質量"
        }
    }
)

task = response.json()
print(f"任務 ID: {task['id']}")
print(f"狀態: {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: 'Veo3.1-quality-official',
    prompt: '海豚在碧藍海洋中跳躍，濺起水花，陽光灑在海面上',
    duration: 8,
    size: '16:9',
    resolution: '1080p',
    metadata: {
      generateAudio: true,
      negativePrompt: '模糊, 低質量'
    }
  })
});

const task = await response.json();
console.log(`任務 ID: ${task.id}`);
console.log(`狀態: ${task.status}`);
```

```json 200 theme={null}
{
  "id": "video_01K8SGYNNNVBQTXNR4MM964S7K",
  "object": "generation.task",
  "model": "Veo3.1-quality-official",
  "status": "queued",
  "progress": 0,
  "created_at": 1768380224,
  "metadata": {}
}
```


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