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

>  - gemini-omni-1.1-flash-ext 统一视频生成模型
- 支持文生视频、单图生视频、参考视频和 3 张参考图融合
- 支持 720p/1080p/4k 分辨率，4/6/8/10 秒时长
- 异步任务接口，提交后通过任务 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.1-flash-ext",
    "prompt": "a girl is dancing happily in a sunny garden",
    "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.1-flash-ext",
    "prompt": "a girl is dancing happily in a sunny garden",
    "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.1-flash-ext",
  prompt: "a girl is dancing happily in a sunny garden",
  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.1-flash-ext",
        "prompt":       "a girl is dancing happily in a sunny garden",
        "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.1-flash-ext`。

**nsfw\_check** `boolean` (default: false)

是否在提交视频任务前执行内容审核。

* `true`：使用 `omni-moderation-latest` 审核提示词和输入图片
* `false` 或不传：不发起审核请求，不增加审核成本与延迟（默认）

**prompt** `string` *required*

视频内容描述。建议详细描述场景、人物、动作、环境、镜头运动、画面风格和音频提示。

示例：`"a girl is dancing happily in a sunny garden"`

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

视频时长，单位为秒。

仅支持：`4`、`6`、`8`、`10`。

> [!WARNING]
>
> 传入 `5`、`7` 等其他时长会返回 `invalid_duration` 错误。

> [!WARNING]
>
> 上传参考视频时不需要传入 `duration`。`duration` 与 `video_urls` 不可以同时传入。

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

视频分辨率，不区分大小写。

可选值：

* `360p`
* `720p`
* `1080p`
* `4k`

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

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

视频宽高比，用于控制横屏或竖屏。

常用值：

* `16:9` - 横屏
* `9:16` - 竖屏

默认值：`16:9`

**size** `string`

兼容字段，含义与 `aspect_ratio` 相同。若同时传入，建议保持与 `aspect_ratio` 一致。

**generation\_type** `string`

生成类型，用于指定图片的使用方式。

可选值：

* `frame` - 首帧模式。`image_urls` 只可以上传 1 张图片，作为视频首帧。
* `reference` - 参考模式。`image_urls` 可以上传 1 张或 3 张图片，作为参考图。

> [!WARNING]
>
> 当 `generation_type` 为 `frame` 时，`image_urls` 仅支持 1 张图片；传入其他数量会返回 `unsupported_image_count` 错误。

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

参考图片 URL 数组。可不传、传 1 张或传 3 张，具体数量取决于 `generation_type`：

* 不传或空数组：文生视频
* 1 张图片：单图生视频
* 3 张图片：参考图融合（仅在 `generation_type` 为 `reference` 时支持）

与 `generation_type` 的关系：

* `generation_type` 为 `frame`：只可以上传 1 张图片。
* `generation_type` 为 `reference`：可以上传 1 张或 3 张图片。

只支持公网可访问的图片 URL。

> [!WARNING]
>
> 不支持 2 张图的首尾帧模式。传入 2 张图片会返回 `unsupported_image_count` 错误。4 张及以上未实测验证，不建议使用。

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

参考视频 URL 数组。可不传或传 1 个参考视频。

只支持公网可访问的 HTTP/HTTPS 视频 URL。可与 `image_urls` 同时传入，图片作为身份或构图参考，视频作为动态参考。

> [!WARNING]
>
> `gemini-omni-1.1-flash-ext` 仅支持 0 或 1 个参考视频。传入 2 个及以上视频会返回 `unsupported_video_count` 错误。

> [!WARNING]
>
> 传入 `video_urls` 时不需要传入 `duration`。`video_urls` 与 `duration` 不可以同时传入。

## 响应

**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 秒再开始查询，后续每 5-10 秒轮询一次。单个任务通常约 3-5 分钟完成。

### 成功结果示例

```json theme={null}
{
  "code": 200,
  "data": {
    "id": "task_01KS1H7ZYSJWH1N779S2FSHTKA",
    "status": "completed",
    "progress": 100,
    "created": 1779246294,
    "completed": 1779246534,
    "actual_time": 240,
    "estimated_time": 600,
    "cost": 0.4,
    "credits_cost": 4,
    "result": {
      "videos": [
        {
          "url": ["https://cdn.example.com/videos/abc.mp4"],
          "expires_at": 1779332760
        }
      ]
    }
  }
}
```

### 失败结果示例

```json theme={null}
{
  "code": 200,
  "data": {
    "id": "task_01KS1H7ZYSJWH1N779S2FSHTKA",
    "status": "failed",
    "progress": 100,
    "created": 1779246294,
    "completed": 1779246534,
    "actual_time": 240,
    "estimated_time": 600,
    "cost": 0,
    "credits_cost": 0,
    "error": {
      "message": "invalid duration 7, must be one of 4/6/8/10",
      "code": "task_failed"
    }
  }
}
```

## 使用场景

### 场景 1：文生视频

```json theme={null}
{
  "model": "gemini-omni-1.1-flash-ext",
  "prompt": "a beautiful sunset over the ocean with seagulls flying",
  "duration": 6,
  "resolution": "720p",
  "aspect_ratio": "16:9"
}
```

### 场景 2：单图生视频

```json theme={null}
{
  "model": "gemini-omni-1.1-flash-ext",
  "prompt": "make the character smile and slowly turn around, cinematic camera motion",
  "duration": 6,
  "resolution": "1080p",
  "aspect_ratio": "9:16",
  "image_urls": ["https://example.com/character.jpg"]
}
```

### 场景 3：3 张参考图融合

```json theme={null}
{
  "model": "gemini-omni-1.1-flash-ext",
  "prompt": "a creative scene combining these elements with smooth camera motion",
  "duration": 10,
  "resolution": "1080p",
  "aspect_ratio": "9:16",
  "image_urls": [
    "https://example.com/scene.jpg",
    "https://example.com/character.jpg",
    "https://example.com/product.jpg"
  ]
}
```

### 场景 4：4K 短视频

```json theme={null}
{
  "model": "gemini-omni-1.1-flash-ext",
  "prompt": "close-up of a hummingbird hovering in front of a red flower",
  "duration": 4,
  "resolution": "4k",
  "aspect_ratio": "16:9"
}
```

### 场景 5：参考视频生成

```json theme={null}
{
  "model": "gemini-omni-1.1-flash-ext",
  "prompt": "the same scene but at night with neon lights",
  "resolution": "720p",
  "aspect_ratio": "16:9",
  "video_urls": ["https://example.com/reference.mp4"]
}
```

## 错误码

| HTTP | 错误类型 | 含义 | 处理建议 |
| - | - | - | - |
| 400 | `invalid_request_error` | `model` 不是 `gemini-omni-1.1-flash-ext`、`prompt` 为空或 JSON 格式错误 | 检查请求体 |
| 400 | `invalid_duration` | `duration` 不是 `4`、`6`、`8` 或 `10` | 改成支持的时长 |
| 400 | `invalid_resolution` | `resolution` 不是 `720p`、`1080p` 或 `4k` | 改成支持的分辨率 |
| 400 | `unsupported_image_count` | `image_urls` 数量不受支持，常见于传入 2 张图 | 改成 0、1 或 3 张图片 |
| 400 | `unsupported_video_count` | `video_urls` 数量不受支持，常见于传入 2 个及以上视频 | 改成 0 或 1 个参考视频 |
| 401 | `authentication_error` | Token 无效 | 检查 Bearer Token |
| 402 | `payment_required` | 账户余额不足 | 充值后重试 |
| 429 | `rate_limit_error` | 触发限流 | 降低并发或稍后重试 |

任务失败时，任务查询接口会在 `data.error` 中返回失败原因。常见原因包括上游配额暂时耗尽、内容审核未通过或上游超时。


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