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

# Kling v3 Omni 動画生成

>  - 非同期処理モード、タスクIDを返してその後の照会に使用
- 統一されたテキストから動画/画像から動画インターフェース、画像参照構文をサポート
- スタンダードモード（720P）、プロフェッショナルモード（1080P）と 4K モードをサポート
- image_N 画像参照構文でプロンプト内から画像を参照
- 音声付き動画の生成をサポート（video_list と排他） 

<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": "kling-v3-omni",
      "prompt": "<<<image_1>>>の人物がカメラに向かって手を振る",
      "image_urls": ["https://upload.apimart.ai/f/models/9998230426123070-e9d6af04-cb5e-4731-8ae7-abf144cb0d29-9998230586368386-29641169-f698-4ab9-9b6d-380899e6521e-9998230593110693-c1741a3a-.webp"],
      "mode": "std",
      "duration": 5,
      "aspect_ratio": "16:9"
    }'
  ```

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

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

  payload = {
      "model": "kling-v3-omni",
      "prompt": "<<<image_1>>>の人物がカメラに向かって手を振る",
      "image_urls": ["https://upload.apimart.ai/f/models/9998230426123070-e9d6af04-cb5e-4731-8ae7-abf144cb0d29-9998230586368386-29641169-f698-4ab9-9b6d-380899e6521e-9998230593110693-c1741a3a-.webp"],
      "mode": "std",
      "duration": 5,
      "aspect_ratio": "16:9"
  }

  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: "kling-v3-omni",
    prompt: "<<<image_1>>>の人物がカメラに向かって手を振る",
    image_urls: ["https://upload.apimart.ai/f/models/9998230426123070-e9d6af04-cb5e-4731-8ae7-abf144cb0d29-9998230586368386-29641169-f698-4ab9-9b6d-380899e6521e-9998230593110693-c1741a3a-.webp"],
    mode: "std",
    duration: 5,
    aspect_ratio: "16:9"
  };

  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":        "kling-v3-omni",
          "prompt":       "<<<image_1>>>の人物がカメラに向かって手を振る",
          "image_urls":   []string{"https://upload.apimart.ai/f/models/9998230426123070-e9d6af04-cb5e-4731-8ae7-abf144cb0d29-9998230586368386-29641169-f698-4ab9-9b6d-380899e6521e-9998230593110693-c1741a3a-.webp"},
          "mode":         "std",
          "duration":     5,
          "aspect_ratio": "16:9",
      }

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

  ```java Java theme={null}
  import java.net.http.HttpClient;
  import java.net.http.HttpRequest;
  import java.net.http.HttpResponse;
  import java.net.URI;

  public class Main {
      public static void main(String[] args) throws Exception {
          String url = "https://api.apimart.ai/v1/videos/generations";

          String payload = """
          {
            "model": "kling-v3-omni",
            "prompt": "<<<image_1>>>の人物がカメラに向かって手を振る",
            "image_urls": ["https://upload.apimart.ai/f/models/9998230426123070-e9d6af04-cb5e-4731-8ae7-abf144cb0d29-9998230586368386-29641169-f698-4ab9-9b6d-380899e6521e-9998230593110693-c1741a3a-.webp"],
            "mode": "std",
            "duration": 5,
            "aspect_ratio": "16:9"
          }
          """;

          HttpClient client = HttpClient.newHttpClient();
          HttpRequest request = HttpRequest.newBuilder()
              .uri(URI.create(url))
              .header("Authorization", "Bearer <token>")
              .header("Content-Type", "application/json")
              .POST(HttpRequest.BodyPublishers.ofString(payload))
              .build();

          HttpResponse<String> response = client.send(request,
              HttpResponse.BodyHandlers.ofString());

          System.out.println(response.body());
      }
  }
  ```

  ```php PHP theme={null}
  <?php

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

  $payload = [
      "model" => "kling-v3-omni",
      "prompt" => "<<<image_1>>>の人物がカメラに向かって手を振る",
      "image_urls" => ["https://upload.apimart.ai/f/models/9998230426123070-e9d6af04-cb5e-4731-8ae7-abf144cb0d29-9998230586368386-29641169-f698-4ab9-9b6d-380899e6521e-9998230593110693-c1741a3a-.webp"],
      "mode" => "std",
      "duration" => 5,
      "aspect_ratio" => "16:9"
  ];

  $ch = curl_init($url);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_POST, true);
  curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
  curl_setopt($ch, CURLOPT_HTTPHEADER, [
      "Authorization: Bearer <token>",
      "Content-Type: application/json"
  ]);

  $response = curl_exec($ch);
  curl_close($ch);

  echo $response;
  ?>
  ```

  ```ruby Ruby theme={null}
  require 'net/http'
  require 'json'
  require 'uri'

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

  payload = {
    model: "kling-v3-omni",
    prompt: "<<<image_1>>>の人物がカメラに向かって手を振る",
    image_urls: ["https://upload.apimart.ai/f/models/9998230426123070-e9d6af04-cb5e-4731-8ae7-abf144cb0d29-9998230586368386-29641169-f698-4ab9-9b6d-380899e6521e-9998230593110693-c1741a3a-.webp"],
    mode: "std",
    duration: 5,
    aspect_ratio: "16:9"
  }

  http = Net::HTTP.new(url.host, url.port)
  http.use_ssl = true

  request = Net::HTTP::Post.new(url)
  request["Authorization"] = "Bearer <token>"
  request["Content-Type"] = "application/json"
  request.body = payload.to_json

  response = http.request(request)
  puts response.body
  ```

  ```swift Swift theme={null}
  import Foundation

  let url = URL(string: "https://api.apimart.ai/v1/videos/generations")!

  let payload: [String: Any] = [
      "model": "kling-v3-omni",
      "prompt": "<<<image_1>>>の人物がカメラに向かって手を振る",
      "image_urls": ["https://upload.apimart.ai/f/models/9998230426123070-e9d6af04-cb5e-4731-8ae7-abf144cb0d29-9998230586368386-29641169-f698-4ab9-9b6d-380899e6521e-9998230593110693-c1741a3a-.webp"],
      "mode": "std",
      "duration": 5,
      "aspect_ratio": "16:9"
  ]

  var request = URLRequest(url: url)
  request.httpMethod = "POST"
  request.setValue("Bearer <token>", forHTTPHeaderField: "Authorization")
  request.setValue("application/json", forHTTPHeaderField: "Content-Type")
  request.httpBody = try? JSONSerialization.data(withJSONObject: payload)

  let task = URLSession.shared.dataTask(with: request) { data, response, error in
      if let error = error {
          print("Error: \(error)")
          return
      }

      if let data = data, let responseString = String(data: data, encoding: .utf8) {
          print(responseString)
      }
  }

  task.resume()
  ```

  ```csharp C# theme={null}
  using System;
  using System.Net.Http;
  using System.Text;
  using System.Threading.Tasks;

  class Program
  {
      static async Task Main(string[] args)
      {
          var url = "https://api.apimart.ai/v1/videos/generations";

          var payload = @"{
              ""model"": ""kling-v3-omni"",
              ""prompt"": ""<<<image_1>>>の人物がカメラに向かって手を振る"",
              ""image_urls"": [""https://upload.apimart.ai/f/models/9998230426123070-e9d6af04-cb5e-4731-8ae7-abf144cb0d29-9998230586368386-29641169-f698-4ab9-9b6d-380899e6521e-9998230593110693-c1741a3a-.webp""],
              ""mode"": ""std"",
              ""duration"": 5,
              ""aspect_ratio"": ""16:9""
          }";

          using var client = new HttpClient();
          client.DefaultRequestHeaders.Add("Authorization", "Bearer <token>");

          var content = new StringContent(payload, Encoding.UTF8, "application/json");
          var response = await client.PostAsync(url, content);
          var result = await response.Content.ReadAsStringAsync();

          Console.WriteLine(result);
      }
  }
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "code": 200,
    "data": [
      {
        "status": "submitted",
        "task_id": "task_xxxxxxxxxx"
      }
    ]
  }
  ```

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

  ```json 500 theme={null}
  {
    "error": {
      "code": 500,
      "message": "サーバー内部エラーです。しばらくしてから再試行してください",
      "type": "server_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>
  動画生成モデル名

  サポートされているモデル：

  * `kling-v3-omni` - Kling v3 Omni（統一インターフェース）
</ParamField>

<ParamField body="prompt" type="string" required>
  ポジティブテキストプロンプト

  `<<<image_N>>>` 構文で `image_urls` 内の画像を参照できます。`N` は 1 から始まります。

  例：`"<<<image_1>>>の人物がカメラに向かって手を振る"`

  <Note>
    画像が提供されているがプロンプトに `<<<image_N>>>` 参照がない場合、システムは自動的にプロンプトの先頭に `<<<image_1>>>` を追加します。
  </Note>
</ParamField>

<ParamField body="negative_prompt" type="string">
  不要なコンテンツを除外するためのネガティブプロンプト。最大長は 2500 文字です。
</ParamField>

<ParamField body="mode" type="string" default="std">
  生成モード

  オプション：

  * `std` - スタンダードモード（720P）
  * `pro` - プロフェッショナルモード（1080P）
  * `4k` - 4K 超高精細モード

  デフォルト：`std`
</ParamField>

<ParamField body="duration" type="integer" default="5">
  デフォルト：`5`
  動画の長さ（秒）

  値の範囲：3-15（最短3秒、最長15秒）

  **⚠️ 注意：** 純粋な数値（例：`6`）を入力してください。引用符を付けるとエラーが発生します
</ParamField>

<ParamField body="aspect_ratio" type="string" default="16:9">
  動画のアスペクト比

  オプション：

  * `16:9` - 横向き
  * `9:16` - 縦向き
  * `1:1` - 正方形

  デフォルト：`16:9`
</ParamField>

<ParamField body="image_urls" type="array<url>">
  画像参照用の画像URL配列

  プロンプト内で `<<<image_N>>>` 構文を使用して対応する画像を参照します（N は 1 から開始）

  例：`["https://example.com/photo.jpg"]`

  <Warning>
    * 画像URLは公開アクセス可能で、ホットリンク保護がないものである必要があります
    * 画像から動画モードでは、`aspect_ratio` が画像の実際の比率で上書きされる場合があります
  </Warning>
</ParamField>

<ParamField body="image_with_roles" type="array<object>">
  役割付き画像配列。画像から動画では推奨です。

  各項目の形式：`{ "url": "...", "role": "..." }`

  * `first_frame`：先頭フレーム
  * `last_frame`：末尾フレーム
  * `reference`：参照画像

  <Warning>
    `image_urls` と `image_with_roles` は二者択一で、同時に渡さないでください。
  </Warning>
</ParamField>

<ParamField body="video_list" type="array" optional>
  参照動画リスト（URL方式）、最大 1 本まで。

  `refer_type` で種類を区別します：

  * `base`：編集対象動画（デフォルト）
  * `feature`：特徴参照動画

  `keep_original_sound` で元音声の保持可否を設定します：

  * `no`：保持しない（デフォルト）
  * `yes`：元音声を保持する

  リクエスト形式：

  ```json theme={null}
  "video_list":[
    { "video_url": "video_url", "refer_type": "base", "keep_original_sound": "no" }
  ]
  ```

  <Warning>
    * `video_url` は空にできず、動画URLはアクセス可能である必要があります
    * `refer_type=base` の場合：
      * 動画の開始/終了フレームは定義できません
      * 参照動画は 3-10 秒である必要があります
      * 生成動画の長さはアップロードした動画に従います
    * `refer_type=feature` かつ `video_url` が空でない場合：
      * `image_urls` には先頭フレーム画像のみアップロードできます
    * 動画要件：MP4/MOV のみ対応；長さは 3 秒以上；解像度は 720px-2160px；フレームレートは 24-60fps（出力は 24fps）；サイズは 200MB 以下
  </Warning>
</ParamField>

<ParamField body="multi_shot" type="boolean" default="false">
  マルチショット分鏡モードを有効化するかどうか。
</ParamField>

<ParamField body="shot_type" type="string">
  分鏡方式：`customize`（カスタム）/ `intelligence`（インテリジェント）。

  `multi_shot=true` の場合は必須です。
</ParamField>

<ParamField body="multi_prompt" type="array<object>">
  分鏡リスト。各項目は `{ index, prompt, duration }`。

  * 最小 1 分鏡、最大 6 分鏡
  * 各分鏡の `duration` は整数かつ 1 以上
  * 全分鏡の `duration` 合計はトップレベル `duration` と一致
  * `index` は 1 から始まり連続増加
  * `multi_shot=true` かつ `shot_type=customize` の場合は必須

  例：

  ```json theme={null}
  [
    { "index": 1, "prompt": "a happy dog in running@element_cat", "duration": 3 },
    { "index": 2, "prompt": "a happy dog play with a cat@element_dog", "duration": 3 }
  ]
  ```
</ParamField>

<ParamField body="element_list" type="array<object>">
  参照主体リスト。最大 3 主体まで。以下をサポート：

  * `name`、`description`、`element_input_urls` でその場作成

  一般的な形式：

  ```json theme={null}
  [
    {
      "name": "element_dog",
      "description": "a golden retriever, fluffy fur, friendly expression",
      "element_input_urls": [
        "https://example.com/image1.png",
        "https://example.com/image2.png"
      ]
    },
    {
      "name": "element_cat",
      "description": "an orange tabby cat, round face, bright eyes",
      "element_input_urls": [
        "https://example.com/image1.png",
        "https://example.com/image2.png"
      ]
    }
  ]
  ```

  説明：

  * その場作成では `name`、`description`、`element_input_urls` が必須
  * `element_input_urls`：主体ごとに 2〜4 枚（1 枚目は正面、残りは参照）
  * `prompt` 内で `@name` を使って参照（例：`"@element_dog と @element_cat が芝生で追いかける"`）
</ParamField>

<ParamField body="watermark" type="boolean">
  ウォーターマークを追加するかどうか
</ParamField>

<ParamField body="audio" type="boolean" default="false">
  音声付き動画を生成するかどうか

  <Warning>
    このパラメータは `video_list` と互いに排他的です。

    `video_list` に値がある場合、`audio` パラメータは不要です。
  </Warning>
</ParamField>

### パラメータの相互制約と境界

* `image_urls` と `image_with_roles` は二者択一
* `mode=4k` は `kling-v3-omni` で利用可能
* 末尾フレームのみ入力（先頭なし）は不正
* 先頭/末尾フレームと動画編集は相互排他：`video_list.refer_type=base`（または未指定）の場合は先頭/末尾フレーム不可
* `video_list` がある場合、`audio` は無視されます
* `video_list` は最大 1 本
* `multi_prompt` は最大 6 分鏡、`index` は 1 から連続増加

## 画像参照構文

Omni モデルは `<<<image_N>>>` 構文を使用してプロンプト内で画像を参照し、統一されたテキストから動画/画像から動画体験を提供します：

| 構文              | 説明                        |
| --------------- | ------------------------- |
| `<<<image_1>>>` | `image_urls` 配列の1番目の画像を参照 |
| `<<<image_2>>>` | `image_urls` 配列の2番目の画像を参照 |

<Note>
  **自動参照**：`image_urls` が提供されているがプロンプトに `<<<image_N>>>` 参照がない場合、システムは自動的にプロンプトの先頭に `<<<image_1>>>` を追加します。
</Note>

## レスポンス

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

## 使用シーン

### シーン 1：テキストから動画（スタンダードモード）

```json theme={null}
{
  "model": "kling-v3-omni",
  "prompt": "a golden retriever running on the beach, sunset, cinematic",
  "mode": "std",
  "duration": 5,
  "aspect_ratio": "16:9"
}
```

### シーン 2：画像参照（単一画像）

```json theme={null}
{
  "model": "kling-v3-omni",
  "prompt": "<<<image_1>>>の人物がカメラに向かって手を振る",
  "image_urls": ["https://upload.apimart.ai/f/models/9998230426123070-e9d6af04-cb5e-4731-8ae7-abf144cb0d29-9998230586368386-29641169-f698-4ab9-9b6d-380899e6521e-9998230593110693-c1741a3a-.webp"],
  "mode": "pro",
  "duration": 5
}
```

### シーン 3：複数画像参照

```json theme={null}
{
  "model": "kling-v3-omni",
  "prompt": "<<<image_1>>>のキャラクターが<<<image_2>>>のシーンに向かって歩く",
  "image_urls": [
    "https://example.com/character.jpg",
    "https://example.com/scene.jpg"
  ],
  "mode": "pro",
  "duration": 5
}
```

### シーン 4：画像提供で明示的な参照なし（自動追加）

```json theme={null}
{
  "model": "kling-v3-omni",
  "prompt": "人物がゆっくり振り返って微笑む",
  "image_urls": ["https://upload.apimart.ai/f/models/9998230426123070-e9d6af04-cb5e-4731-8ae7-abf144cb0d29-9998230586368386-29641169-f698-4ab9-9b6d-380899e6521e-9998230593110693-c1741a3a-.webp"],
  "mode": "std",
  "duration": 5
}
```

> システムは自動的にプロンプトの先頭に `<<<image_1>>>` を追加し、`"<<<image_1>>>人物がゆっくり振り返って微笑む"` と同等になります。

### シーン 5：音声付き動画の生成

```json theme={null}
{
  "model": "kling-v3-omni",
  "prompt": "枝の上でさえずる黄色いカナリア",
  "audio": true,
  "mode": "std",
  "duration": 5
}
```

> **注意**：`audio` と `video_list` は互いに排他的です。`video_list` に値がある場合、`audio` パラメータは不要です。

<Note>
  **タスク結果の照会**

  動画生成は非同期タスクです。送信後に `task_id` が返されます。[タスクステータスの取得](/ja/api-reference/tasks/status) エンドポイントで生成の進捗と結果を照会できます。
</Note>
