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

# Crie um vídeo com o Kling Omni

> Crie uma tarefa de vídeo do Kling Omni com o ID do modelo na URL e, em seguida, obtenha o resultado pelo ID da tarefa.

Use `POST /omni-video/{model}` para criar uma tarefa de vídeo assíncrona do Kling Omni. Insira o ID do modelo na URL e forneça a entrada em `contents`.

## Escolha um modelo

* `kling-4.0`: `720p` ou `1080p`; de 3 a 30 segundos; sem o campo `audio`. Suporta a proporção de imagem `adaptive` além das proporções fixas e aceita conteúdo `middle_frame`.
* `kling-3.0-omni`: `720p`, `1080p`, ou `4k`; de 3 a 15 segundos; áudio `native`, `original` ou `off`.
* `kling-o1`: `720p` ou `1080p`; de 3 a 10 segundos; áudio `original` ou `off`.

O exemplo somente com texto usa `kling-3.0-omni`. Para criar um vídeo sem áudio, defina `settings.audio` como `off`.

## Parâmetros da solicitação

| Campo | Obrigatório | Descrição |
| - | - | - |
| Caminho `model` | Sim | ID do modelo na URL. Escolha um ID da lista acima; não o adicione ao corpo da solicitação. |
| `contents` | Sim | Array não vazio de entradas de vídeo. Para uma solicitação somente de texto, inclua um item `prompt`. |
| `contents[].type` | Sim | `prompt`, `first_frame`, `middle_frame`, `last_frame`, `refer_image`, `feature_video`, ou `base_video`. `middle_frame` está disponível com `kling-4.0`. Um `last_frame` precisa de um `first_frame`. |
| `contents[].text` | Para um item `prompt` | Texto que descreve o vídeo. |
| `contents[].url` | Para itens de imagem ou vídeo | URL da imagem ou dados de imagem em Base64; itens de vídeo usam uma URL de vídeo pública. |
| `settings.resolution` | Não | Resolução de saída. Se omitida, a solicitação usa `720p`. Os valores disponíveis dependem de `model`. |
| `settings.aspect_ratio` | Não | Formato do quadro: `adaptive` (somente `kling-4.0`), `16:9`, `9:16` ou `1:1`. O padrão é `16:9`. |
| `settings.duration` | Não | Duração do vídeo em segundos inteiros. O padrão é `10` para `kling-4.0` e `5` para os demais modelos. Use uma duração dentro do intervalo do modelo selecionado. Envie um número inteiro, não uma string. |
| `settings.multi_shot` | Não | Para `kling-3.0-omni`, defina `true` para múltiplas tomadas ou `false` para uma tomada contínua. Não inclua este campo para `kling-o1`. |
| `settings.audio` | Não | Defina `native`, `original` ou `off` de acordo com o modelo e as entradas selecionados. Não é compatível com `kling-4.0`. |
| `options.callback_url` | Não | URL HTTPS que recebe callbacks de status da tarefa. |
| `options.external_task_id` | Não | Seu próprio identificador de tarefa para correlação; mantenha o `data.id` retornado para consultas. |
| `options.watermark_info.enabled` | Não | Defina como `true` para solicitar uma marca d'água. |

Para `kling-4.0`, é permitido no máximo um item de conteúdo `base_video`. Para `kling-3.0-omni`, uma entrada `feature_video` exige `settings.multi_shot: true` e `settings.audio: off`. Uma entrada `base_video` exige `settings.multi_shot: false` e não pode usar `settings.audio: native`. Não combine `base_video` com um primeiro ou último quadro.

O padrão oficial para `kling-3.0-omni` é `multi_shot: true`; defina o campo explicitamente quando precisar de um modo de tomada definido. Para `kling-o1`, Prompts podem conter até 2500 caracteres. Se a solicitação contiver apenas um `first_frame` e nenhuma outra imagem ou vídeo de referência, use uma duração de 5 ou 10 segundos.

Para criar um vídeo de cinco segundos somente de texto, envie este corpo de solicitação para `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"
  }
}
```

A resposta retorna um `id` para a tarefa assíncrona:

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

Use o valor de `data.id` com a operação [Obter uma tarefa Kling](https://apidoc.cometapi.com/pt/api/video/kling/model-routes/tasks.md) até que a tarefa seja concluída. Consulte a URL do vídeo concluído no array `outputs` da tarefa. Armazene o vídeo em seu próprio armazenamento se precisar de acesso duradouro.

O painel OpenAPI contém solicitações correspondentes em Shell, Python e JavaScript. Para mais combinações de entradas, consulte a [referência da API de vídeo Kling 3.0 Omni](https://kling.ai/document-api/api/video/3-0-omni/video-omni) ou a [referência da API de vídeo Kling O1 Omni](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.