> ## 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 Video Generation

>  - gemini-omni-1.2-flash-ext unified video generation model
- Supports Text-to-Video, first-frame Image-to-Video, first-and-last-frame video, multi-image reference, and video editing and extension
- Supports 360p/720p/1080p/4k resolution and 3–15 second duration, billed per second
- Asynchronous task API. Submit a task first, then query the result by task 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": "Invalid request parameters",
    "type": "invalid_request_error"
  }
}
```

```json 401 theme={null}
{
  "error": {
    "code": 401,
    "message": "Authentication failed. Please check your API key",
    "type": "authentication_error"
  }
}
```

```json 402 theme={null}
{
  "error": {
    "code": 402,
    "message": "Insufficient account balance. Please recharge and try again",
    "type": "payment_required"
  }
}
```

```json 429 theme={null}
{
  "error": {
    "code": 429,
    "message": "Too many requests. Please try again later",
    "type": "rate_limit_error"
  }
}
```

## Authentication

**Authorization** `string` *required*

All requests require Bearer Token authentication.

Get an API key:

Visit the [API Key management page](https://apimart.ai/keys) to get your API key.

Add the following header when making requests:

```
Authorization: Bearer YOUR_API_KEY
```

## Request Parameters

**model** `string` *required*

Video generation model name. Fixed as `gemini-omni-1.2-flash-ext`.

**prompt** `string` *required*

Video description or editing instruction. It cannot be empty after leading and trailing whitespace is trimmed. For Text-to-Video, describe the scene, characters, actions, camera, and sound; with images or videos, describe the motion, style, or changes you want.

Example: `"Aerial shot over a misty mountain lake at sunrise."`

> [!WARNING]
>
> `prompt` is required in every mode, including first frame, multi-image reference, editing, and extension. A 400 error is returned if it is missing.

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

Video duration in seconds. Must be an integer.

* Text-to-Video / first frame / multi-image reference: output duration, `3`–`15`
* First and last frames: output duration, `3`–`10`
* Extension (`extend`): duration of the **newly added segment**, `3`–`10`
* Editing (`edit`): must not be passed; the output duration follows the source video

The alias `seconds` is also accepted. If both are passed, they must be equal.

> [!WARNING]
>
> Passing `duration` in editing mode returns a `video edit does not accept duration` error.

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

Video resolution, case-insensitive. It determines the per-second price.

Allowed values:

* `360p`
* `720p`
* `1080p`
* `4k` (`2160p` is also accepted)

> [!WARNING]
>
> Any other resolution returns a 400 error.

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

Only `16:9` (landscape, default) and `9:16` (portrait) are supported; other values return a 400 error.

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

Task type, specifying how the input material is used.

Allowed values:

* `edit` - Edit a video. Use with `video_urls` or `extend_from_task_id`
* `extend` - Extend a video by appending new content at the end. Use with `video_urls` or `extend_from_task_id`
* `reference` - Multi-image reference. Use with `image_urls`
* `text_to_video` / `image_to_video` / `reference_to_video` - Text-to-Video / first frame / reference images
* `auto` - Detected from the input; treated as `edit` when a video is provided

Optional when no video is provided; the mode is detected from the input.

> [!WARNING]
>
> When `video_urls` or `extend_from_task_id` is passed, a task type is required (`omni_reference_task_type`, or the compatible field `generation_type`); omitting it returns a 400 error. Passing `edit` or `extend` explicitly is recommended; `auto` is treated as `edit`.

**generation\_type** `string`

Compatible field, equivalent to `omni_reference_task_type`. Allowed values: `frame` (same as `image_to_video`), `reference`, `edit`, `extend`.

> [!WARNING]
>
> `generation_type` and `omni_reference_task_type` cannot be passed together.

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

Reference image array for multi-image reference (characters, products, styles, etc.). Supports 1–10 images.

Only publicly accessible HTTP/HTTPS image URLs are supported. Upload local images first to get a public URL, then pass that URL; Base64 Data URLs are currently not supported and return a 400 error.

When only 1 image is passed, how it is used depends on the task type:

* `omni_reference_task_type` omitted: used as a reference image
* `omni_reference_task_type` is `auto` or `image_to_video`: used as the first frame

For first-frame generation, use `first_frame_image` directly instead of relying on the number of images.

> [!WARNING]
>
> `image_urls` cannot be passed together with `first_frame_image` or `last_frame_image`, and images in `image_urls` are never treated as the first frame; images cannot be passed when editing or extending either.

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

First-frame image. The first frame of the generated video is this image. Only publicly accessible HTTP/HTTPS image URLs are supported; Base64 Data URLs are not supported.

Passing it together with `last_frame_image` generates a first-and-last-frame video.

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

Last-frame image for first-and-last-frame generation; the video transitions from the first frame to this image. Only publicly accessible HTTP/HTTPS image URLs are supported; Base64 Data URLs are not supported.

In first-and-last-frame mode:

* `duration` supports `3`–`10`; 10 seconds if omitted
* `system_prompt` and `negative_prompt` cannot be passed

> [!WARNING]
>
> `last_frame_image` must be passed together with `first_frame_image`; passing only the last frame returns a `last_frame_image requires first_frame_image` error. It cannot be passed together with `image_urls`.

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

Image array with roles, an equivalent way to write `first_frame_image` / `last_frame_image` / `image_urls`.

**Array item**

**url** `string` *required*

Publicly accessible HTTP/HTTPS image URL. Base64 Data URLs are not supported.

**role** `string`

`first_frame` is the first frame and `last_frame` is the last frame (1 image each); any other value or an empty role is treated as a reference image.

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

Array of videos to edit or extend. Only 1 video is supported. You can also use the single-value field `video_url` instead; pass only one of them.

Only publicly accessible HTTP/HTTPS video URLs are supported. Format: MP4 / MOV / WebM, up to 15 seconds and 64 MB.

> [!WARNING]
>
> When passing `video_urls`, a task type is required. `omni_reference_task_type` set to `edit` or `extend` is recommended (`auto` is treated as `edit`); omitting it returns a 400 error. Passing 2 or more videos returns a 400 error.

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

A task ID on this platform (`task_01…`). Continue editing or extending one of your previously completed `gemini-omni-1.2-flash-ext` tasks without re-uploading the video.

Requirements:

* The task belongs to the current account
* The task model is `gemini-omni-1.2-flash-ext`
* The task status is `completed`
* The channel that generated the original task is still available; otherwise 503 `source_channel_unavailable` is returned
* The original output is no longer than 15 seconds (applies to both editing and extension); in editing mode, its duration must also be detectable

If the channel is unavailable or the original output's duration cannot be detected, download the original output and upload it with `video_urls` instead. If the original output is longer than 15 seconds, trim it to 15 seconds or less before uploading.

> [!WARNING]
>
> `extend_from_task_id` cannot be passed together with `video_urls`, and a task type is required. `omni_reference_task_type` set to `edit` or `extend` is recommended (`auto` is treated as `edit`).

**negative\_prompt** `string`

Content you do not want to appear in the video.

Example: `"people, cars, color"`

> [!WARNING]
>
> `negative_prompt` cannot be passed in first-and-last-frame mode.

**system\_prompt** `string`

System instruction, such as fixing the visual style or forbidding on-screen text. Must be a string.

Example: `"Render as a black-and-white silent film."`

> [!WARNING]
>
> `system_prompt` cannot be passed in first-and-last-frame mode.

## Response

**code** `integer`

Response status code. Successful requests return `200`.

**data** `array`

Returned task array.

**Array item**

**status** `string`

Initial task status. It is `submitted` after successful submission.

**task\_id** `string`

Unique task ID for querying task status and result.

## Query Task Result

Video generation is asynchronous. After submission, a `task_id` is returned. Use the [Get Task Status](https://docs.apimart.ai/en/api-reference/tasks/status.md) API to query generation progress and results.

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

Poll every 5-10 seconds and set the client timeout to at least 10 minutes. Reference generation times (including queueing): about 46 seconds for a 15-second 360p video, about 99 seconds for 15-second 1080p, and about 4-5 minutes for 15-second 4k. Progress may stay at 10% for a long time until the task completes.

### Successful Result Example

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

The video URL is `data.result.videos[0].url[0]`. `data.actual_time` is the task processing time in seconds, not the video length. The output is MP4 (H.264, 24fps) with an AAC audio track and an invisible SynthID watermark; 4k outputs occasionally have no audio track.

### Failed Result Example

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

Failed tasks are fully refunded.

## Billing

Billed per second: cost = per-second price of the selected resolution × billed seconds. All modes are billed at the requested resolution tier. See the [pricing page](https://apimart.ai/pricing) for actual prices.

| Mode | Billed seconds |
| - | - |
| Text-to-Video / first frame / multi-image reference | `duration`; 10 seconds if omitted |
| First and last frames | `duration` (up to 10 seconds); 10 seconds if omitted |
| Editing | Source video duration (0.15 seconds of container tolerance is subtracted, then rounded up, minimum 1 second; e.g. 8.019 seconds bills as 8 seconds, 8.3 seconds as 9 seconds) |
| Extension | Added seconds `duration`; 10 seconds if omitted. The original video is not billed |

## Use Cases

### Scenario 1: Text-to-Video

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

### Scenario 2: First-Frame Video

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

### Scenario 3: First-and-Last-Frame Video

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

In first-and-last-frame mode, `duration` supports 3–10 seconds (10 seconds if omitted), and `system_prompt` / `negative_prompt` cannot be passed.

### Scenario 4: Multi-Image Reference

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

### Scenario 5: Video Editing

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

Do not pass `duration` when editing; the output duration follows the source video.

### Scenario 6: Video Extension

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

### Scenario 7: Extend an Existing Task

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

### Scenario 8: System Prompt and Negative Prompt

```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.