> ## 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 動画生成

>  - Google 公式のオールインワン・マルチモーダル動画生成モデル Gemini Omni 1.1 Flash
- テキストから動画、画像から動画、複数被写体の参照、開始・終了フレーム補間、動画編集、延長に対応
- 360p / 720p / 1080p / 4K、24fps、3～10 秒の音声付き出力に対応
- 非同期タスク API。送信後、タスク 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": "gemini-omni-1.1-flash",
      "prompt": "A marble rolling fast on a chain reaction style track, continuous smooth shot.",
      "aspect_ratio": "16:9",
      "resolution": "1080p"
    }'
  ```

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

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

  payload = {
      "model": "gemini-omni-1.1-flash",
      "prompt": "A marble rolling fast on a chain reaction style track, continuous smooth shot.",
      "aspect_ratio": "16:9",
      "resolution": "1080p"
  }

  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",
    prompt: "A marble rolling fast on a chain reaction style track, continuous smooth shot.",
    aspect_ratio: "16:9",
    resolution: "1080p"
  };

  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",
          "prompt":       "A marble rolling fast on a chain reaction style track, continuous smooth shot.",
          "aspect_ratio": "16:9",
          "resolution":   "1080p",
      }

      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": "リクエストパラメータが無効です",
      "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"
    }
  }
  ```
</ResponseExample>

## 認証

<ParamField header="Authorization" type="string" required>
  すべての API で Bearer Token による認証が必要です。

  API キーの取得：

  [API キー管理ページ](https://apimart.ai/keys)にアクセスして API キーを取得します。

  使用時はリクエストヘッダーに追加します：

  ```
  Authorization: Bearer YOUR_API_KEY
  ```
</ParamField>

## リクエストパラメータ

<ParamField body="model" type="string" required>
  動画生成モデル名。`gemini-omni-1.1-flash` 固定です。
</ParamField>

<ParamField body="prompt" type="string">
  テキスト指示。テキストから動画ではシーンを、画像から動画、動画編集、延長では動き、スタイル、編集内容を記述します。

  <Note>
    `prompt` または素材（`image_urls`、開始・終了フレーム画像、`video_urls`）のいずれかを少なくとも 1 つ指定してください。
  </Note>
</ParamField>

<ParamField body="resolution" type="string" default="720p">
  出力動画の解像度。大文字と小文字は区別されません。

  選択可能な値：

  * `360p`
  * `720p`（デフォルト）
  * `1080p`
  * `4k`

  `2160p` は `4k` として扱われます。解像度によってタスクのデポジット区分と主な動画出力コストが決まります。

  <Warning>
    未対応の解像度を指定すると `invalid_resolution` エラーが返されます。
  </Warning>
</ParamField>

<ParamField body="aspect_ratio" type="string" default="16:9">
  動画のアスペクト比。横向きまたは縦向きの出力を指定します。

  対応値：

  * `16:9` - 横向き（デフォルト）
  * `9:16` - 縦向き

  その他の値は `16:9` として扱われます。

  <Warning>
    `video_urls` を指定した場合、出力は通常入力動画のアスペクト比に従うため、`aspect_ratio` が反映されないことがあります。
  </Warning>
</ParamField>

<ParamField body="image_urls" type="array<string>">
  参照画像の配列。公開アクセス可能な HTTP/HTTPS URL のみ対応します。

  * 画像を 1 枚指定：デフォルトで動画の開始フレームとして使用
  * 複数画像を指定：複数被写体またはスタイルの参照として使用。各画像の用途と関係を `prompt` に記述してください

  <Warning>
    `image_urls` と開始・終了フレーム画像は合計 10 枚までです。
  </Warning>
</ParamField>

<ParamField body="first_frame_image" type="string">
  開始フレーム画像。公開アクセス可能な HTTP/HTTPS URL のみ対応します。

  * 単独で指定：動画の開始フレームとして使用
  * `last_frame_image` と同時に指定：開始フレームから終了フレームへ滑らかに遷移する動画を生成
</ParamField>

<ParamField body="last_frame_image" type="string">
  終了フレーム画像。公開アクセス可能な HTTP/HTTPS URL のみ対応し、`first_frame_image` と同時に指定する必要があります。

  <Warning>
    `last_frame_image` のみを指定すると `invalid_frame_images` エラーが返されます。開始・終了フレーム画像は同じ比率にし、`aspect_ratio` と一致させることを推奨します。
  </Warning>
</ParamField>

<Note>
  開始フレームまたは開始・終了フレーム生成では、次の 2 つの指定方法は同じ効果です。**いずれか一方を選び、同時に指定しないでください**：

  * `first_frame_image` / `last_frame_image` を使用
  * `image_with_roles` を使用し、`role` を `first_frame` / `last_frame` に設定
</Note>

<ParamField body="image_with_roles" type="array<object>">
  ロール付き画像の配列。`first_frame_image` / `last_frame_image` と同等の指定方法として使用でき、参照画像の宣言にも使用できます。

  <Expandable title="image_with_roles の要素">
    <ParamField body="url" type="string" required>
      公開アクセス可能な画像の HTTP/HTTPS URL。
    </ParamField>

    <ParamField body="role" type="string" required>
      画像のロール：

      * `first_frame`：開始フレーム
      * `last_frame`：終了フレーム。開始フレームも必要です
      * `reference`：参照画像。開始・終了フレーム以外のロールも参照画像として扱われます
    </ParamField>
  </Expandable>

  例：

  ```json theme={null}
  [
    {"url": "https://example.com/start.jpg", "role": "first_frame"},
    {"url": "https://example.com/end.jpg", "role": "last_frame"}
  ]
  ```

  <Note>
    `image_urls` も指定した場合、参照画像は `image_urls` が優先され、`image_with_roles` の参照画像とは結合されません。実際に使用されるすべての画像は、開始・終了フレームを含め合計 10 枚までです。
  </Note>
</ParamField>

<ParamField body="video_urls" type="array<string>">
  編集または延長する動画の配列。現在は最大 1 本で、長さは 10 秒以下である必要があります。

  公開アクセス可能な HTTP/HTTPS 動画の直接 URL のみ対応します。YouTube リンクは対応していません。

  <Warning>
    `video_urls` と `extend_from_task_id` は相互排他です。いずれか一方のみ指定してください。
  </Warning>
</ParamField>

<ParamField body="metadata" type="object">
  生成目的を明示するための追加パラメータオブジェクトです。

  <Expandable title="metadata フィールド">
    <ParamField body="task" type="string">
      選択可能なタスクタイプ：

      * `text_to_video`：テキストから動画
      * `image_to_video`：画像から動画
      * `reference_to_video`：参照素材から動画
      * `edit`：動画編集
      * `extend`：動画延長

      省略した場合、入力内容とプロンプトからシステムが自動判定します。
    </ParamField>
  </Expandable>

  <Note>
    開始・終了フレーム補間では、モデルがタスクタイプを自動推論し、プラットフォームは `metadata.task` を渡しません。
  </Note>
</ParamField>

<ParamField body="extend_from_task_id" type="string">
  前回の生成タスクのローカル `task_id`。会話形式の編集や追加延長に使用し、前回の動画を再アップロードする必要はありません。

  参照するタスクは現在のユーザーに属し、成功済みの Gemini Omni モデルタスクである必要があります。

  <Warning>
    `extend_from_task_id` と `video_urls` は相互排他です。いずれか一方のみ指定してください。
  </Warning>
</ParamField>

<Warning>
  このモデルには `duration` パラメータがありません。1 回の出力時間は内容に応じてモデルが自動決定し、通常は 3～10 秒です。テンポを制御するには、`prompt` に自然言語または時間範囲で記述してください。
</Warning>

## レスポンス

<ResponseField name="code" type="integer">
  レスポンスステータスコード。成功時は `200` です。
</ResponseField>

<ResponseField name="data" type="array">
  タスクの配列を返します。

  <Expandable title="配列要素">
    <ResponseField name="status" type="string">
      タスクの初期状態。送信成功時は `submitted` です。
    </ResponseField>

    <ResponseField name="task_id" type="string">
      タスクの状態と結果の照会に使用する一意の識別子です。
    </ResponseField>
  </Expandable>
</ResponseField>

## タスク結果の照会

動画生成は非同期タスクです。送信後に返される `task_id` を使い、[タスク状態の取得](/ja/api-reference/tasks/status) API で進捗と結果を照会します。

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

5～10 秒ごとにポーリングし、状態が `completed` または `failed` になったら停止してください。クライアント全体のタイムアウトは 10 分を推奨します。

### 成功結果の例

```json theme={null}
{
  "code": 200,
  "data": {
    "id": "task_01KS1H7ZYSJWH1N779S2FSHTKA",
    "status": "completed",
    "progress": 100,
    "cost": 1.52,
    "credits_cost": 15.2,
    "result": {
      "videos": [
        {
          "url": ["https://cdn.example.com/gemini_omni_xxx.mp4"],
          "expires_at": 1788518400
        }
      ]
    }
  }
}
```

## 使用例

### 使用例 1：テキストから動画（4K）

```json theme={null}
{
  "model": "gemini-omni-1.1-flash",
  "prompt": "a blue butterfly landing on a flower, macro, soft light, no dialogue",
  "aspect_ratio": "9:16",
  "resolution": "4k"
}
```

### 使用例 2：開始・終了フレーム補間

```json theme={null}
{
  "model": "gemini-omni-1.1-flash",
  "prompt": "smooth transition, camera slowly pushes in",
  "first_frame_image": "https://example.com/start.jpg",
  "last_frame_image": "https://example.com/end.jpg",
  "resolution": "720p"
}
```

### 使用例 3：複数被写体の参照

```json theme={null}
{
  "model": "gemini-omni-1.1-flash",
  "prompt": "the cat playfully bats at the ball of yarn",
  "image_urls": [
    "https://example.com/cat.png",
    "https://example.com/yarn.png"
  ],
  "resolution": "720p"
}
```

### 使用例 4：画像ロールで開始・終了フレームを指定

```json theme={null}
{
  "model": "gemini-omni-1.1-flash",
  "prompt": "a smooth cinematic transition from sunrise to a starry night",
  "image_with_roles": [
    {"url": "https://example.com/sunrise.jpg", "role": "first_frame"},
    {"url": "https://example.com/night.jpg", "role": "last_frame"}
  ],
  "resolution": "1080p"
}
```

### 使用例 5：動画編集

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

動画編集には短く明確なプロンプトを推奨します。一部分だけを変更する場合は、他の部分の一貫性を保つため `Keep everything else the same` を追加してください。

### 使用例 6：会話形式の延長

```json theme={null}
{
  "model": "gemini-omni-1.1-flash",
  "prompt": "Extend this video: the camera pans across the mountains.",
  "extend_from_task_id": "task_01AAA"
}
```
