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

# Gemini 原生（視訊）

> Google Veo 視訊生成模型

## 簡介

Veo 是 Google Vertex AI 推出的多模態視訊生成模型，支援 文生視訊（T2V）、 首幀約束 與 首尾幀約束（僅 3.1 系列）生成連貫視訊。透過 MixRoute 視訊 API 呼叫：先 [提交任務](/zh-hant/api-reference/endpoint/submit-video-task) 取得 `task_id`，再 [查詢任務](/zh-hant/api-reference/endpoint/query-video-task) 輪詢狀態並取得結果。

## 認證

Bearer Token，如 `Bearer sk-xxxxxxxxxx`

## 支援的模型

| 模型 ID                           | 說明                   |
| ------------------------------- | -------------------- |
| `veo-3.0-fast-generate-001`     | 文生視訊、首幀模式，快速版（預設含音訊） |
| `veo-3.1-fast-generate-preview` | 文生視訊、首幀/首尾幀模式，快速版    |
| `veo-3.0-generate-preview`      | 文生視訊、首幀模式            |
| `veo-3.1-generate-preview`      | 文生視訊、首幀/首尾幀模式        |

## 呼叫流程

1. **提交任務**：`POST /v1/video/generations`，傳入 `model`、`prompt` 及 Veo 專用參數。
2. **輪詢狀態**：`GET /v1/video/generations/{task_id}`，直到 `status` 為 `succeeded` 或 `failed`。
3. **取得結果**：成功時回應中的 `url` 為視訊資料（Veo 可能為 `data:video/mp4;base64,...` 或 OSS 連結）。

## Veo 專用參數

<ParamField body="prompt" type="string" required>
  視訊生成提示詞，描述畫面與動作。
</ParamField>

<ParamField body="durationSeconds" type="integer">
  視訊時長（秒），支援：`4`、`6`、`8`。
</ParamField>

<ParamField body="aspectRatio" type="string">
  寬高比，僅支援：`16:9`、`9:16`。
</ParamField>

<ParamField body="resolution" type="string">
  解析度：`720p`、`1080p`。
</ParamField>

<ParamField body="image" type="string">
  首幀參考圖（URL 或 Base64），用於圖生視訊/首幀約束。
</ParamField>

<ParamField body="lastFrameImage" type="string">
  尾幀參考圖（僅 `veo-3.1` 系列支援），與首幀配合實現首尾幀約束。
</ParamField>

<ParamField body="generateAudio" type="boolean">
  是否生成同步音訊。快速版模型會忽略該參數並始終包含音訊。
</ParamField>

<ParamField body="sampleCount" type="integer">
  每次生成的視訊數量，範圍 `1-4`。
</ParamField>

更多參數（如 `personGeneration`、`addWatermark`、`seed`）見 [提交視訊任務](/zh-hant/api-reference/endpoint/submit-video-task)。

## 請求範例

<Tabs>
  <Tab title="提交 Veo 任務（文生視訊）">
    ```bash theme={null}
    curl -X POST "https://api.mixroute.ai/v1/video/generations" \
      -H "Authorization: Bearer sk-xxxxxxxxxx" \
      -H "Content-Type: application/json" \
      -d '{
        "model": "veo-3.1-fast-generate-preview",
        "prompt": "清晨陽光灑在賽博城市的高樓群，鏡頭慢慢推進",
        "durationSeconds": 6,
        "aspectRatio": "16:9",
        "resolution": "1080p",
        "generateAudio": false
      }'
    ```
  </Tab>

  <Tab title="查詢任務狀態">
    ```bash theme={null}
    curl -X GET "https://api.mixroute.ai/v1/video/generations/{task_id}" \
      -H "Authorization: Bearer sk-xxxxxxxxxx"
    ```
  </Tab>
</Tabs>

完整請求/回應說明與多模型對比請參見 [提交視訊任務](/zh-hant/api-reference/endpoint/submit-video-task) 與 [查詢視訊任務](/zh-hant/api-reference/endpoint/query-video-task)。

<RequestExample>
  ```bash cURL theme={null}
  curl --request POST \
    --url https://api.mixroute.ai/v1/video/generations \
    --header 'Authorization: Bearer sk-xxxxxxxxxx' \
    --header 'Content-Type: application/json' \
    --data '{
      "model": "veo-3.1-fast-generate-preview",
      "prompt": "清晨陽光灑在賽博城市的高樓群，鏡頭慢慢推進",
      "durationSeconds": 6,
      "aspectRatio": "16:9",
      "resolution": "1080p",
      "generateAudio": false
    }'
  ```

  ```python Python theme={null}
  import requests

  url = "https://api.mixroute.ai/v1/video/generations"
  headers = {
      "Authorization": "Bearer sk-xxxxxxxxxx",
      "Content-Type": "application/json"
  }
  payload = {
      "model": "veo-3.1-fast-generate-preview",
      "prompt": "清晨陽光灑在賽博城市的高樓群，鏡頭慢慢推進",
      "durationSeconds": 6,
      "aspectRatio": "16:9",
      "resolution": "1080p",
      "generateAudio": False
  }
  response = requests.post(url, json=payload, headers=headers)
  print(response.json())
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch('https://api.mixroute.ai/v1/video/generations', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer sk-xxxxxxxxxx',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      model: 'veo-3.1-fast-generate-preview',
      prompt: '清晨陽光灑在賽博城市的高樓群，鏡頭慢慢推進',
      durationSeconds: 6,
      aspectRatio: '16:9',
      resolution: '1080p',
      generateAudio: false
    })
  });
  const data = await response.json();
  console.log(data);
  ```

  ```php PHP theme={null}
  <?php
  $client = new GuzzleHttp\Client();
  $response = $client->post('https://api.mixroute.ai/v1/video/generations', [
      'headers' => [
          'Authorization' => 'Bearer sk-xxxxxxxxxx',
          'Content-Type' => 'application/json',
      ],
      'json' => [
          'model' => 'veo-3.1-fast-generate-preview',
          'prompt' => '清晨陽光灑在賽博城市的高樓群，鏡頭慢慢推進',
          'durationSeconds' => 6,
          'aspectRatio' => '16:9',
          'resolution' => '1080p',
          'generateAudio' => false
      ]
  ]);
  echo $response->getBody();
  ```

  ```go Go theme={null}
  package main

  import (
      "bytes"
      "encoding/json"
      "net/http"
  )

  func main() {
      payload := map[string]interface{}{
          "model": "veo-3.1-fast-generate-preview",
          "prompt": "清晨陽光灑在賽博城市的高樓群，鏡頭慢慢推進",
          "durationSeconds": 6,
          "aspectRatio": "16:9",
          "resolution": "1080p",
          "generateAudio": false,
      }
      body, _ := json.Marshal(payload)
      req, _ := http.NewRequest("POST", "https://api.mixroute.ai/v1/video/generations", bytes.NewBuffer(body))
      req.Header.Set("Authorization", "Bearer sk-xxxxxxxxxx")
      req.Header.Set("Content-Type", "application/json")
      http.DefaultClient.Do(req)
  }
  ```

  ```java Java theme={null}
  import java.net.http.*;
  import java.net.URI;

  HttpClient client = HttpClient.newHttpClient();
  String json = """
      {
        "model": "veo-3.1-fast-generate-preview",
        "prompt": "清晨陽光灑在賽博城市的高樓群，鏡頭慢慢推進",
        "durationSeconds": 6,
        "aspectRatio": "16:9",
        "resolution": "1080p",
        "generateAudio": false
      }
      """;
  HttpRequest request = HttpRequest.newBuilder()
      .uri(URI.create("https://api.mixroute.ai/v1/video/generations"))
      .header("Authorization", "Bearer sk-xxxxxxxxxx")
      .header("Content-Type", "application/json")
      .POST(HttpRequest.BodyPublishers.ofString(json))
      .build();
  HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
  System.out.println(response.body());
  ```

  ```ruby Ruby theme={null}
  require 'net/http'
  require 'json'

  uri = URI('https://api.mixroute.ai/v1/video/generations')
  http = Net::HTTP.new(uri.host, uri.port)
  http.use_ssl = true

  request = Net::HTTP::Post.new(uri)
  request['Authorization'] = 'Bearer sk-xxxxxxxxxx'
  request['Content-Type'] = 'application/json'
  request.body = {
    model: 'veo-3.1-fast-generate-preview',
    prompt: '清晨陽光灑在賽博城市的高樓群，鏡頭慢慢推進',
    durationSeconds: 6,
    aspectRatio: '16:9',
    resolution: '1080p',
    generateAudio: false
  }.to_json

  response = http.request(request)
  puts response.body
  ```
</RequestExample>

<ResponseExample>
  ```json Response theme={null}
  {
    "task_id": "task_xxx",
    "status": "pending",
    "created_at": 1709459123
  }
  ```
</ResponseExample>
