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

# Omni-Flash-Ext Video Generation

>  - Omni-Flash-Ext unified video generation model
- Supports Text-to-Video, single-image Image-to-Video, reference video, and 3-reference-image fusion
- Supports 720p/1080p/4k resolution and 4/6/8/10 second duration
- Asynchronous task API. Submit a task first, then query the result by task 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": "Omni-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": "Omni-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: "Omni-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":        "Omni-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))
  }
  ```
</RequestExample>

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

## Authentication

<ParamField header="Authorization" type="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
  ```
</ParamField>

## Request Parameters

<ParamField body="model" type="string" required>
  Video generation model name. Must be `Omni-Flash-Ext`.
</ParamField>

<ParamField body="prompt" type="string" required>
  Video content description. We recommend describing the scene, subject, action, environment, camera movement, visual style, and audio cues in detail.

  Example: `"a girl is dancing happily in a sunny garden"`
</ParamField>

<ParamField body="duration" type="integer" default="6">
  Video duration in seconds.

  Supported values: `4`, `6`, `8`, `10`.

  <Warning>
    Other values such as `5` or `7` will return an `invalid_duration` error.
  </Warning>

  <Warning>
    Do not pass `duration` when uploading a reference video. `duration` and `video_urls` cannot be passed at the same time.
  </Warning>
</ParamField>

<ParamField body="resolution" type="string" default="720p">
  Video resolution. Values are case-insensitive.

  Supported values:

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

  <Warning>
    Other resolutions will return an `invalid_resolution` error.
  </Warning>
</ParamField>

<ParamField body="aspect_ratio" type="string" default="16:9">
  Video aspect ratio. Use it to control landscape or portrait output.

  Common values:

  * `16:9` - landscape
  * `9:16` - portrait

  Default: `16:9`
</ParamField>

<ParamField body="size" type="string">
  Compatibility field. It has the same meaning as `aspect_ratio`. If both are provided, keep them consistent.
</ParamField>

<ParamField body="generation_type" type="string">
  Generation type, used to specify how the images are used.

  Options:

  * `frame` - First-frame mode. `image_urls` can only contain 1 image, used as the first frame of the video.
  * `reference` - Reference mode. `image_urls` can contain 1 or 3 images, used as reference images.

  <Warning>
    When `generation_type` is `frame`, `image_urls` only supports 1 image; passing any other count returns an `unsupported_image_count` error.
  </Warning>
</ParamField>

<ParamField body="image_urls" type="array<url>">
  Reference image URL array. You can omit it, provide 1 image, or provide 3 images, depending on `generation_type`:

  * Omitted or empty array: Text-to-Video
  * 1 image: single-image Image-to-Video
  * 3 images: reference image fusion (only supported when `generation_type` is `reference`)

  Relationship with `generation_type`:

  * `generation_type` is `frame`: only 1 image can be uploaded.
  * `generation_type` is `reference`: 1 or 3 images can be uploaded.

  Only publicly accessible image URLs are supported.

  <Warning>
    The first-frame plus last-frame mode with 2 images is not supported. Passing 2 images returns an `unsupported_image_count` error. 4 or more images have not been fully verified and are not recommended.
  </Warning>
</ParamField>

<ParamField body="video_urls" type="array<url>">
  Reference video URL array. You can omit it or provide 1 reference video.

  Only publicly accessible HTTP/HTTPS video URLs are supported. You can pass it together with `image_urls`: images are used as identity or composition references, while the video is used as motion reference.

  <Warning>
    `Omni-Flash-Ext` supports only 0 or 1 reference video. Passing 2 or more videos returns an `unsupported_video_count` error.
  </Warning>

  <Warning>
    Do not pass `duration` when passing `video_urls`. `video_urls` and `duration` cannot be passed at the same time.
  </Warning>
</ParamField>

## Response

<ResponseField name="code" type="integer">
  Response status code. Successful requests return `200`.
</ResponseField>

<ResponseField name="data" type="array">
  Returned task array.

  <Expandable title="Array item">
    <ResponseField name="status" type="string">
      Initial task status. It is `submitted` after successful submission.
    </ResponseField>

    <ResponseField name="task_id" type="string">
      Unique task ID for querying task status and result.
    </ResponseField>
  </Expandable>
</ResponseField>

## Query Task Result

Video generation is asynchronous. After submission, the API returns a `task_id`. Use the [Get task status](/en/api-reference/tasks/status) endpoint to query progress and results.

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

We recommend waiting 5-10 seconds after submission before the first query, then polling every 5-10 seconds. A single task usually completes in about 3-5 minutes.

### Successful Result Example

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

### Failed Result Example

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

## Use Cases

### Scenario 1: Text-to-Video

```json theme={null}
{
  "model": "Omni-Flash-Ext",
  "prompt": "a beautiful sunset over the ocean with seagulls flying",
  "duration": 6,
  "resolution": "720p",
  "aspect_ratio": "16:9"
}
```

### Scenario 2: Single-Image Video

```json theme={null}
{
  "model": "Omni-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"]
}
```

### Scenario 3: 3-Reference-Image Fusion

```json theme={null}
{
  "model": "Omni-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"
  ]
}
```

### Scenario 4: 4K Short Video

```json theme={null}
{
  "model": "Omni-Flash-Ext",
  "prompt": "close-up of a hummingbird hovering in front of a red flower",
  "duration": 4,
  "resolution": "4k",
  "aspect_ratio": "16:9"
}
```

### Scenario 5: Reference Video Generation

```json theme={null}
{
  "model": "Omni-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"]
}
```

## Error Codes

| HTTP | Error type                | Meaning                                                                                | Suggested action                      |
| ---- | ------------------------- | -------------------------------------------------------------------------------------- | ------------------------------------- |
| 400  | `invalid_request_error`   | `model` is not `Omni-Flash-Ext`, `prompt` is empty, or the JSON format is invalid      | Check the request body                |
| 400  | `invalid_duration`        | `duration` is not `4`, `6`, `8`, or `10`                                               | Use a supported duration              |
| 400  | `invalid_resolution`      | `resolution` is not `720p`, `1080p`, or `4k`                                           | Use a supported resolution            |
| 400  | `unsupported_image_count` | The number of `image_urls` is unsupported, commonly caused by passing 2 images         | Use 0, 1, or 3 images                 |
| 400  | `unsupported_video_count` | The number of `video_urls` is unsupported, commonly caused by passing 2 or more videos | Use 0 or 1 reference video            |
| 401  | `authentication_error`    | Invalid token                                                                          | Check the Bearer Token                |
| 402  | `payment_required`        | Insufficient balance                                                                   | Recharge and try again                |
| 429  | `rate_limit_error`        | Rate limit exceeded                                                                    | Reduce concurrency or try again later |

When a task fails, the task status API returns the failure reason in `data.error`. Common causes include temporary upstream quota exhaustion, content moderation failure, or upstream timeout.
