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

# Gemini Omni 1.1 Flash 视频生成

>  - Google 官方 Gemini Omni 1.1 Flash 全能多模态视频生成模型
- 支持文生视频、图生视频、多主体参考、首尾帧插值、视频编辑与续写
- 支持 360p / 720p / 1080p / 4K、24fps、3–10 秒，并生成音频
- 异步任务接口，提交后通过任务 ID 查询生成结果 

<RequestExample>
  ```bash cURL theme={null}
  curl --request POST \
    --url https://api.apimart.ai/v1/videos/generations \
    --header 'Authorization: Bearer <token>' \
    --header 'Content-Type: application/json' \
    --data '{
      "model": "gemini-omni-1.1-flash",
      "prompt": "A marble rolling fast on a chain reaction style track, continuous smooth shot.",
      "aspect_ratio": "16:9",
      "resolution": "1080p"
    }'
  ```

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

  url = "https://api.apimart.ai/v1/videos/generations"

  payload = {
      "model": "gemini-omni-1.1-flash",
      "prompt": "A marble rolling fast on a chain reaction style track, continuous smooth shot.",
      "aspect_ratio": "16:9",
      "resolution": "1080p"
  }

  headers = {
      "Authorization": "Bearer <token>",
      "Content-Type": "application/json"
  }

  response = requests.post(url, json=payload, headers=headers)

  print(response.json())
  ```

  ```javascript JavaScript theme={null}
  const url = "https://api.apimart.ai/v1/videos/generations";

  const payload = {
    model: "gemini-omni-1.1-flash",
    prompt: "A marble rolling fast on a chain reaction style track, continuous smooth shot.",
    aspect_ratio: "16:9",
    resolution: "1080p"
  };

  const headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
  };

  fetch(url, {
    method: "POST",
    headers: headers,
    body: JSON.stringify(payload)
  })
    .then(response => response.json())
    .then(data => console.log(data))
    .catch(error => console.error("Error:", error));
  ```

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

  import (
      "bytes"
      "encoding/json"
      "fmt"
      "io/ioutil"
      "net/http"
  )

  func main() {
      url := "https://api.apimart.ai/v1/videos/generations"

      payload := map[string]interface{}{
          "model":        "gemini-omni-1.1-flash",
          "prompt":       "A marble rolling fast on a chain reaction style track, continuous smooth shot.",
          "aspect_ratio": "16:9",
          "resolution":   "1080p",
      }

      jsonData, _ := json.Marshal(payload)

      req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
      req.Header.Set("Authorization", "Bearer <token>")
      req.Header.Set("Content-Type", "application/json")

      client := &http.Client{}
      resp, err := client.Do(req)
      if err != nil {
          panic(err)
      }
      defer resp.Body.Close()

      body, _ := ioutil.ReadAll(resp.Body)
      fmt.Println(string(body))
  }
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "code": 200,
    "data": [
      {
        "status": "submitted",
        "task_id": "task_01KS1H7ZYSJWH1N779S2FSHTKA"
      }
    ]
  }
  ```

  ```json 400 theme={null}
  {
    "error": {
      "code": 400,
      "message": "请求参数无效",
      "type": "invalid_request_error"
    }
  }
  ```

  ```json 401 theme={null}
  {
    "error": {
      "code": 401,
      "message": "身份验证失败，请检查您的API密钥",
      "type": "authentication_error"
    }
  }
  ```

  ```json 402 theme={null}
  {
    "error": {
      "code": 402,
      "message": "账户余额不足，请充值后再试",
      "type": "payment_required"
    }
  }
  ```

  ```json 429 theme={null}
  {
    "error": {
      "code": 429,
      "message": "请求过于频繁，请稍后再试",
      "type": "rate_limit_error"
    }
  }
  ```
</ResponseExample>

## 认证

<ParamField header="Authorization" type="string" required>
  所有接口均需要使用 Bearer Token 进行认证。

  获取 API Key：

  访问 [API Key 管理页面](https://apimart.ai/keys) 获取您的 API Key。

  使用时在请求头中添加：

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

## 请求参数

<ParamField body="model" type="string" required>
  视频生成模型名称，固定为 `gemini-omni-1.1-flash`。
</ParamField>

<ParamField body="prompt" type="string">
  文本指令。文生视频时用于描述场景；图生视频、视频编辑或续写时用于描述动作、风格和编辑要求。

  <Note>
    `prompt` 与素材（`image_urls`、首尾帧图片或 `video_urls`）至少提供一项。
  </Note>
</ParamField>

<ParamField body="resolution" type="string" default="720p">
  输出视频分辨率，不区分大小写。

  可选值：

  * `360p`
  * `720p`（默认）
  * `1080p`
  * `4k`

  `2160p` 会按 `4k` 处理。分辨率决定任务的预扣押金档位和主要视频输出成本。

  <Warning>
    传入不支持的分辨率会返回 `invalid_resolution` 错误。
  </Warning>
</ParamField>

<ParamField body="aspect_ratio" type="string" default="16:9">
  视频宽高比，用于控制横屏或竖屏。

  支持：

  * `16:9` - 横屏（默认）
  * `9:16` - 竖屏

  其它值按 `16:9` 处理。

  <Warning>
    传入 `video_urls` 后，输出画面比例通常跟随输入视频，`aspect_ratio` 可能不生效。
  </Warning>
</ParamField>

<ParamField body="image_urls" type="array<string>">
  参考图片数组。仅支持公网可访问的 HTTP/HTTPS URL。

  * 传入 1 张图片：默认作为视频的起始画面
  * 传入多张图片：作为多主体或风格参考图，请在 `prompt` 中说明各图片的用途和互动关系

  <Warning>
    `image_urls` 与首尾帧图片合计最多 10 张。
  </Warning>
</ParamField>

<ParamField body="first_frame_image" type="string">
  首帧图片。仅支持公网可访问的 HTTP/HTTPS URL。

  * 单独传入：以该图片作为视频的起始画面
  * 与 `last_frame_image` 同时传入：生成从首帧平滑过渡到尾帧的视频
</ParamField>

<ParamField body="last_frame_image" type="string">
  尾帧图片。仅支持公网可访问的 HTTP/HTTPS URL，且必须与 `first_frame_image` 同时传入。

  <Warning>
    只传 `last_frame_image` 会返回 `invalid_frame_images` 错误。首尾帧图片建议使用相同比例，并与 `aspect_ratio` 保持一致。
  </Warning>
</ParamField>

<Note>
  在首帧或首尾帧场景中，以下两种传参方式效果相同，**二选一即可，请勿同时传入**：

  * 使用 `first_frame_image` / `last_frame_image`
  * 使用 `image_with_roles`，并将 `role` 设置为 `first_frame` / `last_frame`
</Note>

<ParamField body="image_with_roles" type="array<object>">
  带角色的图片数组，可作为 `first_frame_image` / `last_frame_image` 的等价写法，也可以用于声明参考图。

  <Expandable title="image_with_roles 元素">
    <ParamField body="url" type="string" required>
      公网可访问的图片 HTTP/HTTPS URL。
    </ParamField>

    <ParamField body="role" type="string" required>
      图片角色：

      * `first_frame`：首帧
      * `last_frame`：尾帧，必须同时存在首帧
      * `reference`：参考图；其它非首尾帧角色也按参考图处理
    </ParamField>
  </Expandable>

  示例：

  ```json theme={null}
  [
    {"url": "https://example.com/start.jpg", "role": "first_frame"},
    {"url": "https://example.com/end.jpg", "role": "last_frame"}
  ]
  ```

  <Note>
    若同时传入 `image_urls`，参考图以 `image_urls` 为准，不与 `image_with_roles` 中的参考图叠加。所有实际使用的图片与首尾帧合计最多 10 张。
  </Note>
</ParamField>

<ParamField body="video_urls" type="array<string>">
  待编辑或续写的视频数组，当前最多传入 1 段，且视频时长不得超过 10 秒。

  仅支持公网可访问的 HTTP/HTTPS 视频直链，不支持 YouTube 链接。

  <Warning>
    `video_urls` 与 `extend_from_task_id` 互斥，二者只能提供一项。
  </Warning>
</ParamField>

<ParamField body="metadata" type="object">
  附加参数对象，用于显式指定生成意图。

  <Expandable title="metadata 字段">
    <ParamField body="task" type="string">
      可选任务类型：

      * `text_to_video`：文生视频
      * `image_to_video`：图生视频
      * `reference_to_video`：参考素材生视频
      * `edit`：视频编辑
      * `extend`：视频续写

      不传时，系统根据输入内容和提示词自动判断。
    </ParamField>
  </Expandable>

  <Note>
    使用首尾帧插值时，任务类型由模型自动推断，平台不会下发 `metadata.task`。
  </Note>
</ParamField>

<ParamField body="extend_from_task_id" type="string">
  上一次生成任务的本地 `task_id`，用于对话式编辑或继续延长视频，无需重新上传上一轮视频。

  被引用的任务必须属于当前用户、状态为成功，并且是 Gemini Omni 模型任务。

  <Warning>
    `extend_from_task_id` 与 `video_urls` 互斥，二者只能提供一项。
  </Warning>
</ParamField>

<Warning>
  该模型没有 `duration` 参数。单次输出时长由模型根据内容自动决定，通常为 3–10 秒。如需控制节奏，请在 `prompt` 中使用自然语言或时间段描述。
</Warning>

## 响应

<ResponseField name="code" type="integer">
  响应状态码，成功时为 `200`。
</ResponseField>

<ResponseField name="data" type="array">
  返回任务数组。

  <Expandable title="数组元素">
    <ResponseField name="status" type="string">
      任务初始状态，提交成功时为 `submitted`。
    </ResponseField>

    <ResponseField name="task_id" type="string">
      任务唯一标识符，用于查询任务状态和结果。
    </ResponseField>
  </Expandable>
</ResponseField>

## 查询任务结果

视频生成为异步任务。提交后会返回 `task_id`，使用 [获取任务状态](/cn/api-reference/tasks/status) 接口查询生成进度和结果。

```bash cURL theme={null}
curl --request GET \
  --url https://api.apimart.ai/v1/tasks/task_01KS1H7ZYSJWH1N779S2FSHTKA \
  --header 'Authorization: Bearer <token>'
```

建议每 5–10 秒轮询一次，并在状态变为 `completed` 或 `failed` 后停止。客户端整体超时建议设置为 10 分钟。

### 成功结果示例

```json theme={null}
{
  "code": 200,
  "data": {
    "id": "task_01KS1H7ZYSJWH1N779S2FSHTKA",
    "status": "completed",
    "progress": 100,
    "cost": 1.52,
    "credits_cost": 15.2,
    "result": {
      "videos": [
        {
          "url": ["https://cdn.example.com/gemini_omni_xxx.mp4"],
          "expires_at": 1788518400
        }
      ]
    }
  }
}
```

## 使用场景

### 场景 1：文生视频（4K）

```json theme={null}
{
  "model": "gemini-omni-1.1-flash",
  "prompt": "a blue butterfly landing on a flower, macro, soft light, no dialogue",
  "aspect_ratio": "9:16",
  "resolution": "4k"
}
```

### 场景 2：首尾帧插值

```json theme={null}
{
  "model": "gemini-omni-1.1-flash",
  "prompt": "smooth transition, camera slowly pushes in",
  "first_frame_image": "https://example.com/start.jpg",
  "last_frame_image": "https://example.com/end.jpg",
  "resolution": "720p"
}
```

### 场景 3：多主体参考

```json theme={null}
{
  "model": "gemini-omni-1.1-flash",
  "prompt": "the cat playfully bats at the ball of yarn",
  "image_urls": [
    "https://example.com/cat.png",
    "https://example.com/yarn.png"
  ],
  "resolution": "720p"
}
```

### 场景 4：使用图片角色声明首尾帧

```json theme={null}
{
  "model": "gemini-omni-1.1-flash",
  "prompt": "a smooth cinematic transition from sunrise to a starry night",
  "image_with_roles": [
    {"url": "https://example.com/sunrise.jpg", "role": "first_frame"},
    {"url": "https://example.com/night.jpg", "role": "last_frame"}
  ],
  "resolution": "1080p"
}
```

### 场景 5：视频编辑

```json theme={null}
{
  "model": "gemini-omni-1.1-flash",
  "prompt": "Make the violin invisible. Keep everything else the same.",
  "video_urls": ["https://example.com/clip.mp4"]
}
```

视频编辑建议使用简短、明确的提示词。若只希望修改某一部分，可在提示词中加入 `Keep everything else the same` 以增强其余画面的一致性。

### 场景 6：对话式续写

```json theme={null}
{
  "model": "gemini-omni-1.1-flash",
  "prompt": "Extend this video: the camera pans across the mountains.",
  "extend_from_task_id": "task_01AAA"
}
```
