> ## Documentation Index
> Fetch the complete documentation index at: https://apidoc.cometapi.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Kling Omni動画の作成

> URLにモデルIDを指定してKling Omni動画タスクを作成し、タスクIDを使って結果を取得します。

`POST /omni-video/{model}`を使用して、非同期のKling Omni動画タスクを作成します。URLにモデルIDを指定し、`contents`に入力を指定します。

## モデルを選択する

* `kling-4.0`: `720p` または`1080p`。3〜30秒。`audio`フィールドなし。固定のアスペクト比に加えて`adaptive`のアスペクト比をサポートし、`middle_frame`コンテンツを受け付けます。
* `kling-3.0-omni`: `720p`, `1080p`、または`4k`。3〜15秒。音声は`native`、`original`、または`off`。
* `kling-o1`: `720p` または`1080p`。3〜10秒。音声は`original`または`off`。

テキストのみの例では`kling-3.0-omni`を使用します。無音の動画を作成するには、`settings.audio`を`off`に設定します。

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

| フィールド | 必須 | 説明 |
| - | - | - |
| パス `model` | はい | URL内のモデルID。上記のリストからIDを選択してください。リクエスト本文には追加しないでください。 |
| `contents` | はい | 空でない動画入力の配列。テキストのみのリクエストでは、`prompt`項目を含めてください。 |
| `contents[].type` | はい | `prompt`, `first_frame`, `middle_frame`, `last_frame`, `refer_image`, `feature_video`、または`base_video`。`middle_frame`は`kling-4.0`で使用できます。`last_frame`に必要なのは `first_frame`. |
| `contents[].text` | `prompt`項目の場合 | 動画を説明するテキスト。 |
| `contents[].url` | 画像または動画項目の場合 | 画像URLまたはBase64画像データ。動画項目には公開動画のURLを使用します。 |
| `settings.resolution` | いいえ | 出力解像度。省略した場合、リクエストには`720p`が使用されます。使用可能な値は次によって異なります： `model`. |
| `settings.aspect_ratio` | いいえ | フレームの形状：`adaptive`は`kling-4.0`のみ、`16:9`、`9:16`、または`1:1`。デフォルト値は `16:9`. |
| `settings.duration` | いいえ | 動画の長さを秒単位の整数で指定します。デフォルト値は、`10`が`kling-4.0`に、`5`がその他のモデルに適用されます。選択したモデルの範囲内の長さを指定してください。文字列ではなく整数を送信してください。 |
| `settings.multi_shot` | いいえ | `kling-3.0-omni`では、複数のショットには`true`を、連続した1つのショットには`false`を設定します。次の場合はこのフィールドを含めないでください： `kling-o1`. |
| `settings.audio` | いいえ | 選択したモデルと入力に応じて、`native`、`original`、または`off`を設定します。次ではサポートされません： `kling-4.0`. |
| `options.callback_url` | いいえ | タスクステータスのコールバックを受信するHTTPS URL。 |
| `options.external_task_id` | いいえ | 対応付けに使用する独自のタスク識別子。問い合わせには返された`data.id`を保持して使用してください。 |
| `options.watermark_info.enabled` | いいえ | ウォーターマークをリクエストするには、`true`に設定します。 |

`kling-4.0`では、`base_video`コンテンツ項目は最大1つまでです。`kling-3.0-omni`では、`feature_video`入力に`settings.multi_shot: true`と`settings.audio: off`が必要です。`base_video`入力には`settings.multi_shot: false`が必要で、`settings.audio: native`は使用できません。`base_video`を最初または最後のフレームと組み合わせないでください。

`kling-3.0-omni`の公式デフォルト値は`multi_shot: true`です。ショットモードを明示的に指定する必要がある場合は、このフィールドを設定してください。`kling-o1`では、プロンプト（Prompt）は最大2500文字までです。リクエストに`first_frame`のみが含まれ、他の参照画像や動画がない場合は、長さを5秒または10秒にしてください。

5秒間のテキストのみの動画を作成するには、次のリクエスト本文を`POST /omni-video/kling-3.0-omni`に送信します：

```json theme={null}
{
  "contents": [
    {
      "type": "prompt",
      "text": "A paper boat drifts on a pond."
    }
  ],
  "settings": {
    "resolution": "720p",
    "aspect_ratio": "16:9",
    "duration": 5,
    "multi_shot": false,
    "audio": "off"
  }
}
```

レスポンスには、非同期タスクの`id`が返されます：

```json theme={null}
{
  "code": 0,
  "message": "SUCCEED",
  "data": {
    "id": "example-task-id",
    "status": "submitted"
  }
}
```

`data.id`の値を指定して、 [Klingタスクを取得](https://apidoc.cometapi.com/ja/api/video/kling/model-routes/tasks.md) をタスクが完了するまで実行します。完成した動画のURLは、タスクの`outputs`配列から取得します。継続的にアクセスする必要がある場合は、動画を自身のストレージに保存してください。

OpenAPIパネルには、対応するShell、Python、JavaScriptのリクエストが含まれています。入力の組み合わせについて詳しくは、次を参照してください： [Kling 3.0 Omni動画APIリファレンス](https://kling.ai/document-api/api/video/3-0-omni/video-omni) または [Kling O1 Omni動画APIリファレンス](https://kling.ai/document-api/api/video/o1/video-omni).


## OpenAPI

````yaml api/openapi/video/kling/model-routes/post-omni-video.openapi.json POST /omni-video/{model}
openapi: 3.1.0
info:
  title: Kling Omni video model routes
  version: 1.0.0
  description: Create a Kling Omni video task with a model ID in the URL.
servers:
  - url: https://api.cometapi.com
security:
  - bearerAuth: []
paths:
  /omni-video/{model}:
    post:
      summary: Create a Kling Omni video task
      description: Submit video inputs and save the returned task ID for status queries.
      operationId: createKlingModelRouteOmniVideo
      parameters:
        - name: model
          in: path
          required: true
          description: >-
            Kling Omni model ID. The selected model controls resolution,
            duration, and audio choices. `kling-4.0` adds the `adaptive` ratio
            and the `middle_frame` input role.
          schema:
            type: string
            enum:
              - kling-4.0
              - kling-3.0-omni
              - kling-o1
          example: kling-3.0-omni
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/OmniVideoRequest'
            example:
              contents:
                - type: prompt
                  text: A paper boat drifts on a pond.
              settings:
                resolution: 720p
                aspect_ratio: '16:9'
                duration: 5
                multi_shot: false
                audio: 'off'
      responses:
        '200':
          description: Task created. Store `data.id` for a `GET /tasks` query.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SubmitResponse'
              example:
                code: 0
                message: SUCCEED
                data:
                  id: example-task-id
                  status: submitted
      x-codeSamples:
        - lang: Shell
          label: Create task
          source: |
            curl https://api.cometapi.com/omni-video/kling-3.0-omni \
              -H "Authorization: Bearer $COMETAPI_KEY" \
              -H "Content-Type: application/json" \
              --data-binary @- <<'JSON'
            {
              "contents": [
                {
                  "type": "prompt",
                  "text": "A paper boat drifts on a pond."
                }
              ],
              "settings": {
                "resolution": "720p",
                "aspect_ratio": "16:9",
                "duration": 5,
                "multi_shot": false,
                "audio": "off"
              }
            }
            JSON
        - lang: Python
          label: Create task
          source: |
            import os
            import requests

            response = requests.post(
                "https://api.cometapi.com/omni-video/kling-3.0-omni",
                headers={"Authorization": "Bearer " + os.environ["COMETAPI_KEY"]},
                json={
                    "contents": [
                        {
                            "type": "prompt",
                            "text": "A paper boat drifts on a pond.",
                        }
                    ],
                    "settings": {
                        "resolution": "720p",
                        "aspect_ratio": "16:9",
                        "duration": 5,
                        "multi_shot": False,
                        "audio": "off",
                    },
                },
            )
            response.raise_for_status()
            result = response.json()
            print(result["data"]["id"])
        - lang: JavaScript
          label: Create task
          source: |
            const response = await fetch(
              "https://api.cometapi.com/omni-video/kling-3.0-omni",
              {
                method: "POST",
                headers: {
                  Authorization: `Bearer ${process.env.COMETAPI_KEY}`,
                  "Content-Type": "application/json",
                },
                body: JSON.stringify({
                  "contents": [
                    {
                      "type": "prompt",
                      "text": "A paper boat drifts on a pond."
                    }
                  ],
                  "settings": {
                    "resolution": "720p",
                    "aspect_ratio": "16:9",
                    "duration": 5,
                    "multi_shot": false,
                    "audio": "off"
                  }
                }),
              },
            );
            if (!response.ok) throw new Error(`HTTP ${response.status}`);
            const result = await response.json();
            console.log(result.data.id);
components:
  schemas:
    OmniVideoRequest:
      type: object
      required:
        - contents
      properties:
        contents:
          type: array
          minItems: 1
          description: Video input items. Send a prompt item for text-only generation.
          items:
            $ref: '#/components/schemas/ContentItem'
        settings:
          $ref: '#/components/schemas/OmniSettings'
        options:
          $ref: '#/components/schemas/TaskOptions'
      additionalProperties: false
      description: >-
        Omni video request fields exposed by the CometAPI route. The model ID is
        a path parameter, not a body field.
    SubmitResponse:
      type: object
      required:
        - code
        - message
        - data
      properties:
        code:
          type:
            - integer
            - string
          description: Result code. `0` indicates task creation.
        message:
          type: string
          description: Result message.
        msg:
          type: string
          description: Additional result message, when included.
        data:
          type: object
          description: Task identification and submission status.
          required:
            - id
            - status
          properties:
            id:
              type: string
              description: System task ID for a `GET /tasks` query.
            status:
              type: string
              enum:
                - submitted
                - processing
                - succeeded
                - failed
              description: Task status.
    ContentItem:
      type: object
      required:
        - type
      properties:
        type:
          type: string
          enum:
            - prompt
            - first_frame
            - last_frame
            - refer_image
            - feature_video
            - base_video
          description: >-
            Input role. Use `prompt` for text, an image role for a frame or
            image reference, or a video role for a video reference. A last frame
            requires a first frame.
        text:
          type: string
          maxLength: 3072
          description: >-
            Text prompt, required when `type` is `prompt`. `kling-3.0-omni`
            accepts up to 3072 characters; `kling-o1` accepts up to 2500
            characters.
        url:
          type: string
          description: >-
            Required for non-prompt items. Image items accept a public URL or
            Base64 JPG/PNG; video items accept a public MP4/MOV URL.
      allOf:
        - if:
            properties:
              type:
                const: prompt
                description: Text-prompt input role.
          then:
            required:
              - text
          else:
            required:
              - url
      additionalProperties: false
      description: Content input fields exposed by the CometAPI route.
    OmniSettings:
      type: object
      description: >-
        Output settings exposed by the CometAPI route. Set model-specific fields
        explicitly for the intended result.
      properties:
        resolution:
          type: string
          enum:
            - 720p
            - 1080p
            - 4k
          default: 720p
          description: Output resolution. `4k` applies only to `kling-3.0-omni`.
        aspect_ratio:
          type: string
          enum:
            - adaptive
            - '16:9'
            - '9:16'
            - '1:1'
          default: '16:9'
          description: >-
            Output frame shape. If you omit it, the request uses `16:9`. Set
            `adaptive` with `kling-4.0` to infer the frame from the prompt and
            reference inputs; the other models accept only the fixed ratios.
        duration:
          type: integer
          minimum: 3
          maximum: 30
          description: >-
            Requested duration in whole seconds. `kling-4.0` accepts 3 to 30
            seconds; `kling-3.0-omni` accepts 3 to 15 seconds; `kling-o1`
            accepts 3 to 10 seconds. If omitted, the request uses 10 seconds for
            `kling-4.0` and 5 seconds for the other models. For `kling-o1`, a
            request with only a `first_frame` and no other reference image or
            video must use 5 or 10 seconds. Send a JSON number, not a string.
        multi_shot:
          type: boolean
          description: >-
            For `kling-3.0-omni` only, set `true` for multiple shots or `false`
            for one continuous shot. Omit this field for `kling-o1`; the
            official default for `kling-3.0-omni` is `true`.
        audio:
          type: string
          enum:
            - native
            - original
            - 'off'
          default: 'off'
          description: >-
            `native` creates audio with `kling-3.0-omni`; `original` retains
            sound from an input video; `off` makes silent output. `kling-o1`
            accepts only `original` and `off`.
      additionalProperties: false
    TaskOptions:
      type: object
      description: Optional task fields exposed by the CometAPI route.
      properties:
        callback_url:
          type: string
          format: uri
          description: HTTPS URL that receives task status callbacks.
        external_task_id:
          type: string
          description: >-
            Your own task identifier, unique within your account. The response
            still returns the system task ID.
        watermark_info:
          type: object
          description: Watermark setting for the generated output.
          required:
            - enabled
          properties:
            enabled:
              type: boolean
              description: Set to `true` to request a watermarked result.
          additionalProperties: false
      additionalProperties: false
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: Authenticate with your CometAPI API key.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.