> ## 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.2-flash-ext 视频生成

>  - gemini-omni-1.2-flash-ext 统一视频生成模型
- 支持文生视频、首帧生视频、首尾帧生视频、多图参考、视频编辑与续写
- 支持 360p/720p/1080p/4k 分辨率，3–15 秒时长，按秒计费
- 异步任务接口，提交后通过任务 ID 查询生成结果 

```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.2-flash-ext",
    "prompt": "Aerial shot over a misty mountain lake at sunrise.",
    "duration": 10,
    "resolution": "1080p",
    "aspect_ratio": "9:16"
  }'
```

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

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

payload = {
    "model": "gemini-omni-1.2-flash-ext",
    "prompt": "Aerial shot over a misty mountain lake at sunrise.",
    "duration": 10,
    "resolution": "1080p",
    "aspect_ratio": "9:16"
}

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.2-flash-ext",
  prompt: "Aerial shot over a misty mountain lake at sunrise.",
  duration: 10,
  resolution: "1080p",
  aspect_ratio: "9:16"
};

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.2-flash-ext",
        "prompt":       "Aerial shot over a misty mountain lake at sunrise.",
        "duration":     10,
        "resolution":   "1080p",
        "aspect_ratio": "9:16",
    }

    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))
}
```

```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"
  }
}
```

## 认证

**Authorization** `string` *required*

所有接口均需要使用 Bearer Token 进行认证。

获取 API Key：

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

使用时在请求头中添加：

```
Authorization: Bearer YOUR_API_KEY
```

## 请求参数

**model** `string` *required*

视频生成模型名称，固定为 `gemini-omni-1.2-flash-ext`。

**prompt** `string` *required*

视频内容描述或编辑指令，去除首尾空格后不能为空。文生视频描述场景、人物、动作、镜头和声音；带图片或视频时描述动作、风格或修改要求。

示例：`"Aerial shot over a misty mountain lake at sunrise."`

> [!WARNING]
>
> 所有模式都必须传入 `prompt`，包括首帧、多图参考、编辑和续写。缺少时返回 400 错误。

**duration** `integer` (default: 10)

视频时长，单位为秒，必须为整数。

* 文生 / 首帧 / 多图参考：输出时长，支持 `3`–`15`
* 首尾帧：输出时长，支持 `3`–`10`
* 续写（`extend`）：**新增片段**的时长，支持 `3`–`10`
* 编辑（`edit`）：不能传入，输出时长跟随源视频

也可使用别名 `seconds`，两者同时传入时必须相等。

> [!WARNING]
>
> 编辑模式传入 `duration` 会返回 `video edit does not accept duration` 错误。

**resolution** `string` (default: 720p)

视频分辨率，不区分大小写，决定每秒单价。

可选值：

* `360p`
* `720p`
* `1080p`
* `4k`（也可传 `2160p`）

> [!WARNING]
>
> 传入其他分辨率会返回 400 错误。

**aspect\_ratio** `string` (default: 16:9)

仅支持 `16:9`（横屏，默认）和 `9:16`（竖屏）；其他值返回 400 错误。

**omni\_reference\_task\_type** `string`

任务类型，用于指定素材的使用方式。

可选值：

* `edit` - 编辑视频，需配合 `video_urls` 或 `extend_from_task_id`
* `extend` - 续写视频，在片尾追加新内容，需配合 `video_urls` 或 `extend_from_task_id`
* `reference` - 多图参考，需配合 `image_urls`
* `text_to_video` / `image_to_video` / `reference_to_video` - 文生 / 首帧 / 参考图
* `auto` - 按输入自动判断；带视频时视为 `edit`

不带视频时可不传，按输入自动判断。

> [!WARNING]
>
> 传入 `video_urls` 或 `extend_from_task_id` 时必须传入任务类型（`omni_reference_task_type`，或兼容字段 `generation_type`），不传返回 400 错误。推荐显式传入 `edit` 或 `extend`；传 `auto` 时按 `edit` 处理。

**generation\_type** `string`

兼容字段，与 `omni_reference_task_type` 等价。可选值：`frame`（等同 `image_to_video`）、`reference`、`edit`、`extend`。

> [!WARNING]
>
> `generation_type` 与 `omni_reference_task_type` 不可以同时传入。

**image\_urls** `array\<url\>`

参考图片数组，用于多图参考（人物、商品、风格等），支持 1–10 张。

仅支持公网可访问的 HTTP/HTTPS 图片 URL。本地图片请先上传获取公网 URL 再传入；当前不支持 Base64 Data URL，传入会返回 400 错误。

只传 1 张图片时，处理方式取决于任务类型：

* 不传 `omni_reference_task_type`：按参考图处理
* `omni_reference_task_type` 为 `auto` 或 `image_to_video`：按首帧处理

首帧场景建议直接使用 `first_frame_image`，不要依赖图片数量区分。

> [!WARNING]
>
> `image_urls` 不能与 `first_frame_image` 或 `last_frame_image` 同时传入，`image_urls` 中的图片不会被当作首帧；编辑和续写时也不能传入图片。

**first\_frame\_image** `string`

首帧图片，生成视频的第一帧即为该图。仅支持公网可访问的 HTTP/HTTPS 图片 URL，不支持 Base64 Data URL。

与 `last_frame_image` 同时传入时为首尾帧生视频。

**last\_frame\_image** `string`

尾帧图片，用于首尾帧生视频，视频从首帧画面过渡到该图。仅支持公网可访问的 HTTP/HTTPS 图片 URL，不支持 Base64 Data URL。

首尾帧模式下：

* `duration` 支持 `3`–`10`，不传按 10 秒
* 不能传入 `system_prompt` 和 `negative_prompt`

> [!WARNING]
>
> `last_frame_image` 必须与 `first_frame_image` 同时传入，只传尾帧会返回 `last_frame_image requires first_frame_image` 错误；不能与 `image_urls` 同时传入。

**image\_with\_roles** `array\<object\>`

带角色的图片数组，是 `first_frame_image` / `last_frame_image` / `image_urls` 的等价写法。

**数组元素**

**url** `string` *required*

公网可访问的 HTTP/HTTPS 图片 URL，不支持 Base64 Data URL。

**role** `string`

`first_frame` 为首帧、`last_frame` 为尾帧（各只能 1 张）；其他值或留空按参考图处理。

**video\_urls** `array\<url\>`

待编辑或续写的视频数组，仅支持 1 段视频。也可使用单值字段 `video_url`，二选一。

只支持公网可访问的 HTTP/HTTPS 视频 URL，格式为 MP4 / MOV / WebM，时长不超过 15 秒，大小不超过 64 MB。

> [!WARNING]
>
> 传入 `video_urls` 时必须同时传入任务类型，推荐 `omni_reference_task_type` 为 `edit` 或 `extend`（`auto` 按 `edit` 处理）；不传返回 400 错误。传入 2 个及以上视频会返回 400 错误。

**extend\_from\_task\_id** `string`

本平台的任务 ID（`task_01…`），基于自己之前已完成的 `gemini-omni-1.2-flash-ext` 任务继续编辑或续写，无需重新上传视频。

使用条件：

* 任务属于当前账号
* 任务模型为 `gemini-omni-1.2-flash-ext`
* 任务状态为 `completed`
* 生成原任务的通道仍可用，否则返回 503 `source_channel_unavailable`
* 原任务成片不超过 15 秒（编辑和续写均适用）；编辑模式下还需时长可识别

通道不可用或原成片时长无法识别时，请下载原成片后改用 `video_urls` 上传；原成片超过 15 秒时，需先裁剪至 15 秒以内再上传。

> [!WARNING]
>
> `extend_from_task_id` 不能与 `video_urls` 同时传入，且必须同时传入任务类型，推荐 `omni_reference_task_type` 为 `edit` 或 `extend`（`auto` 按 `edit` 处理）。

**negative\_prompt** `string`

不希望出现在画面中的内容。

示例：`"people, cars, color"`

> [!WARNING]
>
> 首尾帧模式不能传入 `negative_prompt`。

**system\_prompt** `string`

系统指令，例如固定画面风格、禁止出现文字。必须为字符串。

示例：`"Render as a black-and-white silent film."`

> [!WARNING]
>
> 首尾帧模式不能传入 `system_prompt`。

## 响应

**code** `integer`

响应状态码，成功时为 `200`。

**data** `array`

返回任务数组。

**数组元素**

**status** `string`

任务初始状态，提交成功时为 `submitted`。

**task\_id** `string`

任务唯一标识符，用于查询任务状态和结果。

## 查询任务结果

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

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

建议每 5-10 秒轮询一次，客户端超时设为 10 分钟以上。生成耗时参考（含排队）：360p 15 秒约 46 秒，1080p 15 秒约 99 秒，4k 15 秒约 4-5 分钟。生成中进度可能长时间停留在 10%，直到完成。

### 成功结果示例

```json theme={null}
{
  "code": 200,
  "data": {
    "id": "task_01KS1H7ZYSJWH1N779S2FSHTKA",
    "status": "completed",
    "progress": 100,
    "actual_time": 99,
    "cost": 0.695,
    "result": {
      "videos": [
        {
          "url": ["https://cdn.example.com/videos/abc.mp4"]
        }
      ]
    }
  }
}
```

视频地址为 `data.result.videos[0].url[0]`。`data.actual_time` 为任务耗时（秒），不是视频时长。输出为 MP4（H.264，24fps），含 AAC 音轨和 SynthID 不可见水印；4k 偶发无音轨。

### 失败结果示例

```json theme={null}
{
  "code": 200,
  "data": {
    "id": "task_01KS1H7ZYSJWH1N779S2FSHTKA",
    "status": "failed",
    "progress": 100,
    "cost": 0,
    "error": {
      "code": "task_failed",
      "message": "content_rejected",
      "type": "task_failed"
    }
  }
}
```

任务失败时全额退款。

## 计费说明

按秒计费：费用 = 所选分辨率的每秒单价 × 计费秒数。所有模式均按请求的分辨率档位计费。实际单价以 [价格页面](https://apimart.ai/pricing) 为准。

| 模式 | 计费秒数 |
| - | - |
| 文生 / 首帧 / 多图参考 | `duration`，不传按 10 秒 |
| 首尾帧 | `duration`（最多 10 秒），不传按 10 秒 |
| 编辑 | 源视频时长（扣除 0.15 秒容器误差后向上取整，最少 1 秒；如 8.019 秒按 8 秒，8.3 秒按 9 秒） |
| 续写 | 新增秒数 `duration`，不传按 10 秒；原视频部分不收费 |

## 使用场景

### 场景 1：文生视频

```json theme={null}
{
  "model": "gemini-omni-1.2-flash-ext",
  "prompt": "Aerial shot over a misty mountain lake at sunrise.",
  "duration": 15,
  "resolution": "1080p",
  "aspect_ratio": "9:16"
}
```

### 场景 2：首帧生视频

```json theme={null}
{
  "model": "gemini-omni-1.2-flash-ext",
  "prompt": "The camera slowly pushes in.",
  "duration": 6,
  "aspect_ratio": "9:16",
  "first_frame_image": "https://example.com/start.jpg"
}
```

### 场景 3：首尾帧生视频

```json theme={null}
{
  "model": "gemini-omni-1.2-flash-ext",
  "prompt": "The flower bud slowly opens into full bloom.",
  "duration": 8,
  "aspect_ratio": "16:9",
  "first_frame_image": "https://example.com/bud.jpg",
  "last_frame_image": "https://example.com/bloom.jpg"
}
```

首尾帧时 `duration` 支持 3–10 秒，不传按 10 秒；不能传入 `system_prompt` / `negative_prompt`。

### 场景 4：多图参考

```json theme={null}
{
  "model": "gemini-omni-1.2-flash-ext",
  "prompt": "The cat bats at the ball of yarn.",
  "duration": 8,
  "image_urls": [
    "https://example.com/cat.png",
    "https://example.com/yarn.png"
  ]
}
```

### 场景 5：视频编辑

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

编辑时不传 `duration`，输出时长跟随源视频。

### 场景 6：视频续写

```json theme={null}
{
  "model": "gemini-omni-1.2-flash-ext",
  "prompt": "Continue the scene: the dancer bows.",
  "video_urls": ["https://example.com/clip.mp4"],
  "omni_reference_task_type": "extend",
  "duration": 4
}
```

### 场景 7：基于已有任务续写

```json theme={null}
{
  "model": "gemini-omni-1.2-flash-ext",
  "prompt": "Extend this video: the camera pans across the mountains.",
  "extend_from_task_id": "task_01KS1H7ZYSJWH1N779S2FSHTKA",
  "omni_reference_task_type": "extend",
  "duration": 6
}
```

### 场景 8：系统指令与反向提示词

```json theme={null}
{
  "model": "gemini-omni-1.2-flash-ext",
  "prompt": "A busy city street at noon.",
  "system_prompt": "Render as a black-and-white silent film.",
  "negative_prompt": "people, cars, color",
  "duration": 6
}
```


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