# Gemini Omni Flash 1.2

Call gemini-omni-1.2-flash with POST /v1/videos. Text, first frame, first-last frames, and reference images.

`gemini-omni-1.2-flash` generates an MP4 with audio. It supports text-to-video, a first frame, a first and last frame, or 1 to 3 reference images. Output is 720p or 1080p, from 3 to 15 seconds.

The create request waits until the video is finished. Set the client timeout to at least 900 seconds. Prices are listed in the console.

```http
POST /v1/videos
GET /v1/videos/{task_id}
GET /v1/videos/{task_id}/content
```

## Request fields

| Field | Required | Type | Range | Notes |
| --- | --- | --- | --- | --- |
| `model` | yes | string | `gemini-omni-1.2-flash` | This model ID only |
| `prompt` | yes | string | — | Scene, action, and camera. With reference images, say "the person in the first reference image" |
| `seconds` | no | string | see below | In JSON this must be a string, such as `"6"`. A number is rejected. Omitted requests use 8 seconds |
| `aspect_ratio` | no | string | `16:9`, `9:16` | Defaults to `16:9` |
| `size` | no | string | `WIDTHxHEIGHT` | Used only to choose landscape or portrait. `aspect_ratio` wins when both are set |
| `resolution` | no | string | `720p`, `1080p` | Defaults to `720p` |
| `first_frame` | no | string | data URL or file | First frame. `image` and `input_reference` are also accepted |
| `last_frame` | no | string | data URL or file | Last frame. `end_frame` is also accepted. Requires a first frame |
| `reference_images` | no | array | 1–3 | Reference images. They constrain the subject, not the first frame |

Do not send `mode`. The images you send select the mode.

| Use | Input | `seconds` |
| --- | --- | --- |
| Text to video | `prompt` only | integer from 3 to 15 |
| Image to video | one `first_frame` | integer from 3 to 15 |
| First and last frame | one `first_frame` and one `last_frame` | integer from 3 to 10 |
| Reference images | 1 to 3 `reference_images` | integer from 3 to 15 |

| Resolution | 16:9 | 9:16 |
| --- | --- | --- |
| `720p` | 1280×720 | 720×1280 |
| `1080p` | 1920×1080 | 1080×1920 |

The clip length is the requested duration. A 1080p clip can be a fraction of a second shorter.

## Text to video

```bash
curl --max-time 900 https://kaienapi.com/v1/videos \
  -H "Authorization: Bearer <YOUR_API_KEY>" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gemini-omni-1.2-flash",
    "prompt": "a rider moving slowly along a beach at dusk, waves breaking, the camera pushing in",
    "seconds": "8",
    "aspect_ratio": "16:9"
  }'
```

720p usually returns in 50–80 seconds. 1080p usually returns in 90–130 seconds. Peaks take longer. If the request times out or returns 504, the task may already exist. Query it before submitting again.

## Image to video

Image URLs are not accepted. An `https://` value returns 400 and creates no task. Send a `data:image/...;base64,...` URL, or upload a file with multipart. PNG, JPEG, and WebP are supported. The type written in the data URL must match the file. The prompt and images together must stay within 15 MB. Use multipart for larger images.

```json
{
  "model": "gemini-omni-1.2-flash",
  "prompt": "the paper boat drifts downstream and the camera follows",
  "seconds": "7",
  "aspect_ratio": "9:16",
  "resolution": "720p",
  "first_frame": "data:image/png;base64,iVBORw0KGgo..."
}
```

Do not set `Content-Type` yourself when uploading a file:

```bash
curl --max-time 900 https://kaienapi.com/v1/videos \
  -H "Authorization: Bearer <YOUR_API_KEY>" \
  -F model=gemini-omni-1.2-flash \
  -F prompt="a small black cat hops into the frame" \
  -F seconds=4 \
  -F aspect_ratio=16:9 \
  -F resolution=720p \
  -F first_frame=@first.png
```

Add `-F last_frame=@last.png` for a first-and-last-frame clip. Repeat `reference_images` for each file. The first and last frames must both be files or both be data URLs. Reference images have the same rule.

## Not supported

- Reference video.
- A first frame together with reference images. A last frame alone, or a last frame with reference images.
- Extend, 4K, and 360p.

## Query

The create response is usually already `completed`. If it is not `completed` or `failed`, query every 10 seconds.

```bash
curl "https://kaienapi.com/v1/videos/$TASK_ID" \
  -H "Authorization: Bearer <YOUR_API_KEY>"
```

```json
{
  "id": "task_example",
  "object": "video",
  "model": "gemini-omni-1.2-flash",
  "status": "completed",
  "progress": 100,
  "seconds": "4",
  "url": "https://kaienapi.com/v1/videos/task_example/content"
}
```

| Field | Notes |
| --- | --- |
| `status` | Keep polling `queued` and `in_progress`. Download `completed`. Read `error.message` on `failed`. `unknown` is still being confirmed |
| `seconds` | Billed seconds |
| `url` | Present after completion. It points at `/v1/videos/{id}/content` on this site |
| `error` | Present on failure |

## Download

The response is the `video/mp4` file, not JSON. `Range` is supported.

```bash
curl "https://kaienapi.com/v1/videos/$TASK_ID/content" \
  -H "Authorization: Bearer <YOUR_API_KEY>" \
  --output result.mp4
```

Immediately after create, the download can briefly return 400 with `Task is not completed yet, current status: NOT_START`. Wait a few seconds and download the same `id`. Do not submit the generation again.

## Errors

Invalid parameters return HTTP 400 and create no task. In JSON, `seconds` must be a string:

```json
{"code":"invalid_json","message":"json: cannot unmarshal number into Go struct field .Alias.seconds of type string","data":null}
```

| Text in `message` | Cause |
| --- | --- |
| `prompt is required` | Missing prompt |
| `seconds must be a whole number from 3 to 15` | Duration is not an integer from 3 to 15 |
| `seconds must be a whole number from 3 to 10 with a last frame` | A first-last clip is outside 3 to 10 seconds |
| `must be a whole number of seconds` | Duration is not an integer |
| `seconds and duration must agree` | `seconds` and `duration` differ |
| `resolution must be 720p or 1080p` | Unsupported resolution |
| `aspect_ratio must be 16:9 or 9:16` | Unsupported aspect ratio |
| `must be a data: URL or an uploaded file` | An image URL was sent |
| `must be a PNG, JPEG or WebP image` | Unsupported image, or the data URL type does not match the file |
| `with a matching Content-Type` | The uploaded file has a missing or wrong type |
| `takes a single first-frame image` | More than one first frame |
| `takes a single last-frame image` | More than one last frame |
| `reference_images takes 1 to 3 images` | More than 3 reference images |
| `a last frame needs a first frame` | Last frame without a first frame |
| `cannot be combined` | First frame sent with reference images |
| `send the first and last frames both as uploaded files or both as data: URLs` | Mixed file and base64 for the two frames |
| `send every reference image as an uploaded file or every one as a data: URL` | Mixed file and base64 reference images |
| `must total at most 15 MiB` | Prompt and images exceed 15 MB |
| `cannot edit a reference video` | Reference video is not supported |
| `is not supported by gemini-omni-1.2-flash` | An unsupported field was sent, such as `extend` |
| `does not match the supplied inputs` | `mode` does not match the images. Do not send `mode` |
| `unexpected file field` | Unsupported multipart field name |
| `Task is not completed yet, current status: NOT_START` | The task just finished. Download again in a few seconds |

401 means the key is invalid. 403 means the quota is insufficient. 404 `model_not_found` means the current group does not include this model. A peak can return 5xx. `failed` is often a content check. Change the prompt or the images and submit again. Include the `request id` or the task `id` when asking for help.
