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

# Create a Kling text-to-video task by model

> Create a Kling video from a text prompt with a model-specific route, then retrieve the video by task ID.

Send a prompt to `POST /text-to-video/{model}` to create a video task. The response contains an `id` that you use to retrieve the result.

## Choose a model

Put the model ID in the URL. Do not add a model field to the JSON body.

| Model ID          | Resolution            | Duration                     | Audio                                        |
| ----------------- | --------------------- | ---------------------------- | -------------------------------------------- |
| `kling-3.0-turbo` | `720p`, `1080p`       | Integer from 3 to 15 seconds | Omit `audio`                                 |
| `kling-3.0`       | `720p`, `1080p`, `4k` | Integer from 3 to 15 seconds | `native` or `off`                            |
| `kling-2.6`       | `720p`, `1080p`       | 5 or 10 seconds              | `native` or `off`; use `1080p` with `native` |
| `kling-2.5-turbo` | `720p`, `1080p`       | 5 or 10 seconds              | Omit `audio`                                 |

## Request parameters

| Field                      | Type    | Required | Description                                                                                                                           |
| -------------------------- | ------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------- |
| `model`                    | string  | Yes      | Model ID in the URL. Choose an ID from the table above.                                                                               |
| `prompt`                   | string  | Yes      | Description of the video to generate.                                                                                                 |
| `settings.resolution`      | string  | No       | Output resolution from the selected model's row above. Defaults to `720p`.                                                            |
| `settings.aspect_ratio`    | string  | No       | Output frame ratio: `16:9`, `9:16`, or `1:1`. Defaults to `16:9`.                                                                     |
| `settings.duration`        | integer | No       | Video length in seconds from the selected model's row above. Defaults to `5`.                                                         |
| `settings.multi_shot`      | boolean | No       | Controls multi-shot generation. Defaults to `false` for a single shot.                                                                |
| `settings.audio`           | string  | No       | For `kling-3.0` or `kling-2.6`, set `native` for generated audio or `off` for no generated audio. Defaults to `off` for those models. |
| `options.callback_url`     | string  | No       | Public URL that receives task updates.                                                                                                |
| `options.external_task_id` | string  | No       | Your identifier for matching the task to your application.                                                                            |
| `options.watermark_info`   | object  | No       | Watermark configuration for the output.                                                                                               |

The following request creates a five-second, single-shot video:

```json theme={null}
{
  "prompt": "A paper boat drifts across a calm pond at sunrise.",
  "settings": {
    "resolution": "720p",
    "aspect_ratio": "16:9",
    "duration": 5,
    "multi_shot": false
  }
}
```

Send this body to `https://api.cometapi.com/text-to-video/kling-3.0-turbo` with your CometAPI API key. The OpenAPI code panel provides Shell, Python, and JavaScript requests with the same body.

## Retrieve the video

The create response has this shape:

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

Save `data.id`. Use [Get a Kling task](./tasks) with that ID until the task reaches a terminal status. Read the video URL from the task's `outputs` array.


## OpenAPI

````yaml api/openapi/video/kling/model-routes/post-text-to-video.openapi.json POST /text-to-video/{model}
openapi: 3.1.0
info:
  title: Kling text-to-video model route
  version: 1.0.0
  description: Create a Kling video task from a text prompt.
servers:
  - url: https://api.cometapi.com
security:
  - bearerAuth: []
paths:
  /text-to-video/{model}:
    post:
      summary: Create a text-to-video task
      description: >-
        Submit a prompt and receive a task ID for retrieving the generated
        video.
      operationId: createKlingModelTextToVideoTask
      parameters:
        - name: model
          in: path
          required: true
          description: >-
            Kling model ID. `kling-3.0` supports 4k resolution. The 2.x models
            accept 5- or 10-second duration.
          schema:
            type: string
            enum:
              - kling-3.0-turbo
              - kling-3.0
              - kling-2.6
              - kling-2.5-turbo
            default: kling-3.0-turbo
          example: kling-3.0-turbo
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TextToVideoRequest'
            example:
              prompt: A paper boat drifts across a calm pond at sunrise.
              settings:
                resolution: 720p
                aspect_ratio: '16:9'
                duration: 5
                multi_shot: false
      responses:
        '200':
          description: >-
            The task was created. Use `data.id` to retrieve its status and video
            output.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateTaskResponse'
              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/text-to-video/kling-3.0-turbo \
              -X POST \
              -H "Authorization: Bearer $COMETAPI_KEY" \
              -H "Content-Type: application/json" \
              --data-raw '{
              "prompt": "A paper boat drifts across a calm pond at sunrise.",
              "settings": {
                "resolution": "720p",
                "aspect_ratio": "16:9",
                "duration": 5,
                "multi_shot": false
              }
            }'
        - lang: Python
          label: Create task
          source: |
            import os
            import requests

            response = requests.post(
                "https://api.cometapi.com/text-to-video/kling-3.0-turbo",
                headers={"Authorization": "Bearer " + os.environ["COMETAPI_KEY"]},
                json={
                    "prompt": "A paper boat drifts across a calm pond at sunrise.",
                    "settings": {
                        "resolution": "720p",
                        "aspect_ratio": "16:9",
                        "duration": 5,
                        "multi_shot": False,
                    },
                },
            )
            response.raise_for_status()
            print(response.json()["data"]["id"])
        - lang: JavaScript
          label: Create task
          source: |
            const response = await fetch(
              "https://api.cometapi.com/text-to-video/kling-3.0-turbo",
              {
                method: "POST",
                headers: {
                  Authorization: `Bearer ${process.env.COMETAPI_KEY}`,
                  "Content-Type": "application/json",
                },
                body: JSON.stringify({
                  prompt: "A paper boat drifts across a calm pond at sunrise.",
                  settings: {
                    resolution: "720p",
                    aspect_ratio: "16:9",
                    duration: 5,
                    multi_shot: false,
                  },
                }),
              },
            );
            if (!response.ok) throw new Error(`HTTP ${response.status}`);
            console.log((await response.json()).data.id);
components:
  schemas:
    TextToVideoRequest:
      type: object
      required:
        - prompt
      properties:
        prompt:
          type: string
          minLength: 1
          description: Text description of the video to generate.
        settings:
          $ref: '#/components/schemas/VideoSettings'
        options:
          $ref: '#/components/schemas/TaskOptions'
      additionalProperties: false
    CreateTaskResponse:
      type: object
      required:
        - code
        - message
        - data
      properties:
        code:
          oneOf:
            - type: integer
            - type: string
          description: Request result code. `0` or `success` indicates acceptance.
        message:
          type: string
          description: Result message.
        msg:
          type: string
          description: Additional result message when included in the response.
        data:
          type: object
          description: Task identifier and submission status.
          required:
            - id
            - status
          properties:
            id:
              type: string
              description: Task ID to use in `GET /tasks?task_ids={id}`.
            status:
              type: string
              description: Task status at submission.
    VideoSettings:
      type: object
      description: >-
        Video generation settings. The model ID determines which resolution,
        duration, and audio values are accepted.
      properties:
        resolution:
          type: string
          enum:
            - 720p
            - 1080p
            - 4k
          default: 720p
          description: >-
            Output resolution. `4k` is available with `kling-3.0`; the other
            listed models accept `720p` or `1080p`.
        aspect_ratio:
          type: string
          enum:
            - '16:9'
            - '9:16'
            - '1:1'
          default: '16:9'
          description: Output frame aspect ratio.
        duration:
          type: integer
          minimum: 3
          maximum: 15
          default: 5
          description: >-
            Video length in seconds. Use an integer from 3 to 15 for the 3.0
            models, or 5 or 10 for the 2.x models.
        multi_shot:
          type: boolean
          default: false
          description: Multi-shot generation switch. Set `false` for one shot.
        audio:
          type: string
          enum:
            - native
            - 'off'
          description: >-
            For `kling-3.0` or `kling-2.6`, use `native` for generated audio or
            `off` to disable it. The default is `off`. With `kling-2.6`,
            `native` requires `1080p`. Omit this field for the Turbo models.
      additionalProperties: false
    TaskOptions:
      type: object
      description: Optional task delivery and tracking settings.
      properties:
        callback_url:
          type: string
          format: uri
          description: Public URL that receives task updates.
        external_task_id:
          type: string
          description: >-
            Your identifier for matching this task to a record in your
            application.
        watermark_info:
          type: object
          description: Watermark configuration for the generated video.
          additionalProperties: true
      additionalProperties: false
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: Authenticate with your CometAPI API key.

````