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

# Kling 4.0

> Generate 3–30 second videos from text, reference images, and reference videos at 720p or 1080p.

> [!TIP]
>
> 1. After submission, a `task_id` will be returned. If you provided a `callback_url`, when the task status becomes `finished` or `failed`, a POST request will be sent to the `callback_url`.
> 2. Regardless of whether `callback_url` is provided, you can retrieve the response result through the unified [Query Task Status](/api-manual/task-management/status.md) endpoint.

Kling 4.0 creates videos from a text prompt and optional visual references. Combine reference images and reference videos to guide appearance, movement, and scene composition.

## Models

* **kling-4.0** — Text and reference-guided video generation

## Features

* **Flexible duration**: Generate 3–30 second videos at `720p` or `1080p`.
* **Visual references**: Supply up to 10 reference images and up to 5 reference videos. Refer to them in the prompt as `@image_1` and `@video_1`, using their positions in the corresponding arrays.
* **Aspect ratios**: Use `auto`, `16:9`, `9:16`, `1:1`, or `21:9`.

## Required parameters

* `prompt` (string): Video instructions, 1–8,000 characters. Must contain at least one non-whitespace character. Reference uploaded materials with `@image_1` or `@video_1`.

## Optional parameters

* `duration` (integer): Output duration from 3 to 30 seconds. Default: `5`.
* `resolution` (string): `720p` or `1080p`. Default: `720p`.
* `aspect_ratio` (string): `auto`, `16:9`, `9:16`, `1:1`, or `21:9`. When omitted, the ratio adapts to supplied materials; without materials, it defaults to `16:9`.
* `reference_image_urls` (array of strings): Up to 10 publicly accessible HTTP or HTTPS image URLs.
* `reference_video_urls` (array of strings): Up to 5 publicly accessible HTTP or HTTPS video URLs. Each video must last 3–30 seconds.

## Examples

* **Text-to-video**: Send a `prompt` without reference materials. Set `duration`, `resolution`, or `aspect_ratio` only when needed.
* **Reference images**: Supply `reference_image_urls` and refer to the first image as `@image_1`.
* **Reference videos**: Supply `reference_video_urls` and use `@video_1` to refer to the first video.

The request examples in the API playground demonstrate these inputs.

## Notes

* Provide at most 10 reference images and at most 5 reference videos. The combined duration of all reference videos cannot exceed 30 seconds.
* Reference indexes start at 1 and follow the order of the corresponding input array. Use publicly accessible media URLs and omit unused optional fields.


## OpenAPI

````yaml api-manual/video-series/kling-4-0.json POST /api/generate/submit
openapi: 3.0.0
info:
  title: Kling 4.0
  description: Generate videos from text, reference images, and reference videos.
  version: 1.0.0
servers:
  - url: https://api.poyo.ai
security:
  - BearerAuth: []
paths:
  /api/generate/submit:
    post:
      summary: Submit a Kling 4.0 video task
      operationId: submit_kling_4_0
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SubmitRequest'
            examples:
              text-to-video:
                summary: Generate video from a text prompt
                value:
                  model: kling-4.0
                  input:
                    prompt: A paper boat floats through a miniature city at sunset.
              reference-image:
                summary: Guide the video with a reference image
                value:
                  model: kling-4.0
                  input:
                    prompt: >-
                      The character in @image_1 walks along a sunlit forest
                      trail.
                    reference_image_urls:
                      - https://example.com/character.png
                    duration: 10
                    resolution: 1080p
                    aspect_ratio: '16:9'
              reference-video:
                summary: Guide movement with a reference video
                value:
                  model: kling-4.0
                  input:
                    prompt: >-
                      Recreate the camera movement from @video_1 in a snowy
                      mountain landscape.
                    reference_video_urls:
                      - https://example.com/camera-motion.mp4
                    duration: 10
      responses:
        '200':
          description: Task submitted successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SubmitResponse'
        '400':
          description: Invalid request parameters
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Unauthorized - Invalid API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    SubmitRequest:
      type: object
      additionalProperties: false
      required:
        - model
        - input
      properties:
        model:
          type: string
          enum:
            - kling-4.0
          description: Public model identifier.
        callback_url:
          type: string
          format: uri
          description: Optional webhook URL for task completion or failure notifications.
        input:
          type: object
          additionalProperties: false
          required:
            - prompt
          description: >-
            Text instructions with up to 10 reference images and up to 5
            reference videos. The combined duration of all reference videos must
            not exceed 30 seconds.
          properties:
            prompt:
              type: string
              minLength: 1
              maxLength: 8000
              description: >-
                Video instructions. Must contain at least one non-whitespace
                character. Use @image_1 and @video_1 to reference the first item
                in the corresponding reference array. Reference indexes start at
                1.
            duration:
              type: integer
              minimum: 3
              maximum: 30
              default: 5
              description: Output duration in whole seconds.
            resolution:
              type: string
              enum:
                - 720p
                - 1080p
              default: 720p
              description: Output video resolution.
            aspect_ratio:
              type: string
              enum:
                - auto
                - '16:9'
                - '9:16'
                - '1:1'
                - '21:9'
              description: >-
                Output aspect ratio. When omitted, adapts to supplied materials;
                without materials, defaults to 16:9.
            reference_image_urls:
              type: array
              maxItems: 10
              items:
                type: string
                format: uri
              description: >-
                Up to 10 publicly accessible HTTP or HTTPS reference image URLs.
                Reference them as @image_1, @image_2, and so on, in array order.
            reference_video_urls:
              type: array
              maxItems: 5
              x-video-duration-seconds:
                minimum: 3
                maximum: 30
              items:
                type: string
                format: uri
              description: >-
                Publicly accessible HTTP or HTTPS reference videos, each lasting
                3-30 seconds. Reference them as @video_1, @video_2, and so on,
                in array order. Provide at most 5 videos with a combined
                duration of at most 30 seconds.
    SubmitResponse:
      type: object
      required:
        - code
        - data
      properties:
        code:
          type: integer
          example: 200
        data:
          type: object
          required:
            - task_id
            - status
            - created_time
          properties:
            task_id:
              type: string
              example: task-unified-1792741800-example
            status:
              type: string
              enum:
                - not_started
              example: not_started
            created_time:
              type: string
              format: date-time
              example: '2026-10-23T10:30:00'
    ErrorResponse:
      type: object
      required:
        - code
        - error
      properties:
        code:
          type: integer
          example: 400
        error:
          type: object
          required:
            - message
            - type
          properties:
            message:
              type: string
              example: Invalid request parameters
            type:
              type: string
              example: invalid_request_error
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key

````

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