> ## 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 image-to-video task by model

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

Send a source image to `POST /image-to-video/{model}` to create a video task. You can add a prompt to describe the motion. 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

Put each input in `contents`. A `prompt` entry uses `text`; a frame entry uses `url`. The first-frame URL must be accessible to the video service.

| Field                      | Type    | Required                  | Description                                                                                                                                    |
| -------------------------- | ------- | ------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
| `model`                    | string  | Yes                       | Model ID in the URL. Choose an ID from the table above.                                                                                        |
| `contents`                 | array   | Yes                       | Input entries. Include a `first_frame` image; add a `prompt` entry to describe the motion.                                                     |
| `contents[].type`          | string  | Yes                       | `prompt` or `first_frame`.                                                                                                                     |
| `contents[].text`          | string  | For a `prompt` entry      | Text that describes the motion.                                                                                                                |
| `contents[].url`           | string  | For a `first_frame` entry | Public image URL for the source image.                                                                                                         |
| `settings.resolution`      | string  | No                        | Output resolution from the selected model's row above. Defaults to `720p`.                                                                     |
| `settings.aspect_ratio`    | string  | No                        | Optional aspect ratio hint. Match it to the source image; generated framing may follow the image. The example uses `16:9`. 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                        | For `kling-3.0`, set `true` to request multiple shots. Use `false` for the single-shot example. Defaults to `false`.                           |
| `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 animates one source image as a five-second video:

```json theme={null}
{
  "contents": [
    {
      "type": "prompt",
      "text": "The camera slowly moves closer to the scene."
    },
    {
      "type": "first_frame",
      "url": "https://raw.githubusercontent.com/ultralytics/yolov5/402e17ddf820996f51a191cbb798376e1144f069/data/images/zidane.jpg"
    }
  ],
  "settings": {
    "resolution": "720p",
    "aspect_ratio": "16:9",
    "duration": 5,
    "multi_shot": false
  }
}
```

Replace the image URL with a public URL for your source image when you use a different image. Send this body to `https://api.cometapi.com/image-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-image-to-video.openapi.json POST /image-to-video/{model}
openapi: 3.1.0
info:
  title: Kling image-to-video model route
  version: 1.0.0
  description: Create a Kling video task from a source image, with an optional prompt.
servers:
  - url: https://api.cometapi.com
security:
  - bearerAuth: []
paths:
  /image-to-video/{model}:
    post:
      summary: Create an image-to-video task
      description: >-
        Submit a source image with optional motion text, then receive a task ID
        for retrieving the generated video.
      operationId: createKlingModelImageToVideoTask
      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/ImageToVideoRequest'
            example:
              contents:
                - type: prompt
                  text: The camera slowly moves closer to the scene.
                - type: first_frame
                  url: >-
                    https://raw.githubusercontent.com/ultralytics/yolov5/402e17ddf820996f51a191cbb798376e1144f069/data/images/zidane.jpg
              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/image-to-video/kling-3.0-turbo \
              -X POST \
              -H "Authorization: Bearer $COMETAPI_KEY" \
              -H "Content-Type: application/json" \
              --data-raw '{
              "contents": [
                {
                  "type": "prompt",
                  "text": "The camera slowly moves closer to the scene."
                },
                {
                  "type": "first_frame",
                  "url": "https://raw.githubusercontent.com/ultralytics/yolov5/402e17ddf820996f51a191cbb798376e1144f069/data/images/zidane.jpg"
                }
              ],
              "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/image-to-video/kling-3.0-turbo",
                headers={"Authorization": "Bearer " + os.environ["COMETAPI_KEY"]},
                json={
                    "contents": [
                        {
                            "type": "prompt",
                            "text": "The camera slowly moves closer to the scene.",
                        },
                        {
                            "type": "first_frame",
                            "url": "https://raw.githubusercontent.com/ultralytics/yolov5/402e17ddf820996f51a191cbb798376e1144f069/data/images/zidane.jpg",
                        },
                    ],
                    "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/image-to-video/kling-3.0-turbo",
              {
                method: "POST",
                headers: {
                  Authorization: `Bearer ${process.env.COMETAPI_KEY}`,
                  "Content-Type": "application/json",
                },
                body: JSON.stringify({
                  contents: [
                    { type: "prompt", text: "The camera slowly moves closer to the scene." },
                    {
                      type: "first_frame",
                      url: "https://raw.githubusercontent.com/ultralytics/yolov5/402e17ddf820996f51a191cbb798376e1144f069/data/images/zidane.jpg",
                    },
                  ],
                  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:
    ImageToVideoRequest:
      type: object
      required:
        - contents
      properties:
        contents:
          type: array
          minItems: 1
          description: >-
            Image and text inputs. Include a `first_frame` image. Add a `prompt`
            entry to describe the motion.
          contains:
            type: object
            required:
              - type
            properties:
              type:
                const: first_frame
                description: >-
                  Identifies the source image required for image-to-video
                  generation.
          minContains: 1
          items:
            type: object
            required:
              - type
            properties:
              type:
                type: string
                enum:
                  - prompt
                  - first_frame
                description: >-
                  Input role. Use `prompt` for motion text or `first_frame` for
                  the source image.
              text:
                type: string
                description: Motion description for a `prompt` entry.
              url:
                type: string
                format: uri
                description: Public image URL for a `first_frame` entry.
            allOf:
              - if:
                  properties:
                    type:
                      const: prompt
                      description: Identifies an optional motion prompt.
                then:
                  required:
                    - text
                else:
                  required:
                    - url
            additionalProperties: false
        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
          default: '16:9'
          description: >-
            Optional aspect ratio hint. Match it to the source image; generated
            framing may follow the image. The example uses `16:9`.
        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: >-
            For `kling-3.0`, set `true` to request multiple shots. Use `false`
            for the single-shot example.
        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.

````