> ## 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 官方直連模型生成高質量視頻，支持音頻生成、首尾幀控制等高級功能

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

<Warning>
  **重要變更**：爲了更好的性能和成本控制，我們不再支持在 `image_urls` 中直接傳入 base64 圖片數據。請先使用 [上傳圖片接口](../../uploads/images) 上傳圖片，獲取 URL 後再調用本接口。
</Warning>

## Authorizations

<ParamField header="Authorization" type="string" required>
  所有接口均需要使用Bearer Token進行認證

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

  使用時在請求頭中添加：

  ```
  Authorization: Bearer YOUR_API_KEY
  ```
</ParamField>

## Body

<ParamField body="model" type="string" default="Veo3.1-quality-official" required>
  視頻生成模型名稱

  可用模型：

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

  Example: `"Veo3.1-quality-official"`
</ParamField>

<ParamField body="prompt" type="string" required>
  視頻生成的文本描述
</ParamField>

<ParamField body="duration" type="integer">
  視頻時長（秒）

  支持的值：

  * `4` - 4 秒
  * `6` - 6 秒
  * `8` - 8 秒（默認）
</ParamField>

<ParamField body="size" type="string">
  視頻寬高比

  支持的格式：

  * `16:9` (橫屏，默認)
  * `9:16` (豎屏)
</ParamField>

<ParamField body="resolution" type="string">
  視頻分辨率

  支持的值：

  * `720p`（默認）
  * `1080p`
  * `4k`（預覽）
</ParamField>

<ParamField body="image_urls" type="string[]">
  圖生視頻的**首幀參考圖**，視頻將從該圖像開始生成。僅使用數組中的第一個 URL。

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

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

  **限制：**

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

  <Warning>
    `image_urls` 與 `metadata.referenceImages` **不可同時使用**。如果同時傳入，`image_urls`（首幀）優先，`referenceImages` 將被忽略。
  </Warning>
</ParamField>

<ParamField body="metadata" type="object">
  Veo3 Official 特有擴展參數

  <Expandable title="顯示 metadata 字段">
    <ParamField body="generateAudio" type="boolean">
      是否生成音頻。默認：`false`

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

    <ParamField body="negativePrompt" type="string">
      負面提示詞，描述不希望在視頻中出現的內容

      Example: `"模糊, 低質量, 畸變"`
    </ParamField>

    <ParamField body="personGeneration" type="string">
      人物生成安全設置

      支持的值：

      * `allow_adult` - 允許生成成年人
      * `dont_allow` - 不允許生成人物
    </ParamField>

    <ParamField body="lastFrame" type="string">
      尾幀圖片 URL，用於首尾幀插值生成視頻

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

    <ParamField body="referenceImages" type="string[]">
      素材/風格參考圖 URL 數組，視頻內容將參考這些圖片的視覺風格和元素進行生成（不作爲視頻起始幀）

      **限制：最多 3 張**

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

    <ParamField body="compressionQuality" type="string">
      視頻壓縮質量

      支持的值：

      * `optimized`（默認）- 優化壓縮
      * `lossless` - 無損壓縮
    </ParamField>

    <ParamField body="resizeMode" type="string">
      圖生視頻時的圖片調整模式

      支持的值：

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

## Response

<ResponseField name="id" type="string">
  任務唯一標識符，用於查詢任務狀態
</ResponseField>

<ResponseField name="object" type="string">
  對象類型，固定爲 `generation.task`
</ResponseField>

<ResponseField name="model" type="string">
  使用的模型名稱
</ResponseField>

<ResponseField name="status" type="string">
  任務狀態

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

<ResponseField name="progress" type="integer">
  任務進度百分比（0-100）
</ResponseField>

<ResponseField name="created_at" type="integer">
  任務創建時間戳（Unix 時間戳）
</ResponseField>

<ResponseField name="metadata" type="object">
  任務元數據
</ResponseField>

<RequestExample>
  ```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}`);
  ```
</RequestExample>

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