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

# Kling 4.0

> Kling 4.0, Kuaishou's flagship video model. Text-to-video and image-to-video with single takes of up to **30 seconds**: start from a first frame, guide the take through up to 8 middle `keyframes`, and optionally end on a last frame.

**Audio** — every generated video comes with a native audio track. It is always on: the model has no switch for it, so `sound` / `generate_audio` are rejected.

**Pricing** — per second of generated video, in tokens (USD at $0.02/token). Text-to-video and image-to-video cost the same; first, middle and last frames are not charged:

| resolution | tokens/s | USD/s |
|---|---|---|
| 720p | 10.205 | $0.2041 |
| 1080p | 15.275 | $0.3055 |

Example: a 5-second video at 720p costs 51.03 tokens.

Returns an `img_uuid`; poll GET /api/v1/jobs/detail (or use `custom_callback_url`) to get the generated video.

**Not accepted by this model** (rejected before any tokens are charged): `sound` / `generate_audio` (audio is always generated), `negative_prompt` (describe what to avoid in `prompt`), `model_params.multi_shot` (use `keyframes` to guide one take), reference images (`image_urls`; use [Kling 4.0 Reference to Video](/api-reference/video-generations/kling-4-0-refs)), and 4K.



## OpenAPI

````yaml api-reference/video-generations/openapi-kling-4-0.json POST /api/v1/videos/generations
openapi: 3.1.0
info:
  title: GoEnhance API - Kling 4.0
  description: >-
    Video generation with Kling 4.0. Same endpoint as the other Kling models;
    the model is selected by model.
  version: 1.0.0
servers:
  - url: https://api.goenhance.ai
security: []
paths:
  /api/v1/videos/generations:
    post:
      tags:
        - VideoGenerations
      summary: Kling 4.0
      description: >-
        Kling 4.0, Kuaishou's flagship video model. Text-to-video and
        image-to-video with single takes of up to **30 seconds**: start from a
        first frame, guide the take through up to 8 middle `keyframes`, and
        optionally end on a last frame.


        **Audio** — every generated video comes with a native audio track. It is
        always on: the model has no switch for it, so `sound` / `generate_audio`
        are rejected.


        **Pricing** — per second of generated video, in tokens (USD at
        $0.02/token). Text-to-video and image-to-video cost the same; first,
        middle and last frames are not charged:


        | resolution | tokens/s | USD/s |

        |---|---|---|

        | 720p | 10.205 | $0.2041 |

        | 1080p | 15.275 | $0.3055 |


        Example: a 5-second video at 720p costs 51.03 tokens.


        Returns an `img_uuid`; poll GET /api/v1/jobs/detail (or use
        `custom_callback_url`) to get the generated video.


        **Not accepted by this model** (rejected before any tokens are charged):
        `sound` / `generate_audio` (audio is always generated),
        `negative_prompt` (describe what to avoid in `prompt`),
        `model_params.multi_shot` (use `keyframes` to guide one take), reference
        images (`image_urls`; use [Kling 4.0 Reference to
        Video](/api-reference/video-generations/kling-4-0-refs)), and 4K.
      parameters:
        - name: Authorization
          in: header
          description: ''
          required: false
          example: '{{Authorization}}'
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              type: object
              description: >-
                Kling 4.0 text-to-video and image-to-video (first frame,
                optional middle keyframes, optional last frame).


                **Pricing** — per second of generated video:


                - 720p — 10.205 tokens ($0.2041)

                - 1080p — 15.275 tokens ($0.3055)
              properties:
                model:
                  type: string
                  enum:
                    - kling-4-0
                  description: Model name. Must be `kling-4-0` on this page.
                prompt:
                  type: string
                  maxLength: 2500
                  description: >-
                    Text prompt describing the scene, motion and camera.
                    Required, up to 2500 characters.
                image_url:
                  type: string
                  format: uri
                  description: >-
                    First-frame image URL. If provided, runs image-to-video (the
                    aspect ratio follows this image); otherwise text-to-video.


                    JPG or PNG, up to 10MB, width and height at least 300px,
                    aspect ratio between 1:2.5 and 2.5:1. Smaller images are
                    upscaled automatically.
                keyframes:
                  type: array
                  maxItems: 8
                  items:
                    type: string
                    format: uri
                  description: >-
                    Optional middle-frame image URLs (1-8), in playback order.
                    The model spaces them evenly between the first and last
                    frame. Requires `image_url`.


                    First, middle and last frames together allow at most 10
                    images and at most `duration` + 1 (a 3-second video takes up
                    to 4). Same image requirements as `image_url`.
                image_end_url:
                  type: string
                  format: uri
                  description: >-
                    Optional last-frame image URL. Requires `image_url`. Same
                    image requirements as `image_url`.
                duration:
                  type: integer
                  minimum: 3
                  maximum: 30
                  default: 5
                  description: Video duration in seconds, any integer from 3 to 30.
                resolution:
                  type: string
                  enum:
                    - 720p
                    - 1080p
                  default: 720p
                  description: >-
                    Output resolution. `quality` is accepted as a compatible
                    alias.
                ratio:
                  type: string
                  enum:
                    - '16:9'
                    - '9:16'
                    - '1:1'
                    - '21:9'
                  default: '16:9'
                  description: >-
                    Aspect ratio. Text-to-video only; ignored when `image_url`
                    is provided.
                custom_callback_url:
                  type: string
                  format: uri
                  description: >-
                    Optional. A publicly accessible HTTPS URL. When the task
                    status changes (processing / success / failed), GoEnhance
                    sends a POST request to this URL. The request body is
                    identical to the response of GET /api/v1/jobs/detail. If
                    your server does not respond with HTTP 200, the notification
                    is retried up to 3 times, with a 3-second timeout per
                    attempt.
                  example: https://your-server.com/goenhance/callback
              required:
                - model
                - prompt
            example:
              model: kling-4-0
              prompt: >-
                The product slowly rotates on a marble pedestal, soft studio
                light, the camera pushes in for a close-up of the logo
              image_url: https://your-cdn.com/product-front.jpg
              keyframes:
                - https://your-cdn.com/product-side.jpg
              image_end_url: https://your-cdn.com/product-logo.jpg
              duration: 10
              resolution: 1080p
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: integer
                  msg:
                    type: string
                  data:
                    type: object
                    properties:
                      img_uuid:
                        type: string
                      cost:
                        type: number
                        description: >-
                          Tokens deducted for this request. This is the amount
                          actually charged, so it already reflects any discount
                          active on your account and can be lower than the
                          listed price. Tokens are deducted when the task is
                          accepted, and refunded automatically if the generation
                          ends in failure.
                        example: 5.82
                    required:
                      - img_uuid
                      - cost
                required:
                  - code
                  - msg
                  - data
              examples:
                '1':
                  summary: Success
                  value:
                    code: 0
                    msg: Success
                    data:
                      img_uuid: c12b656c-747a-44fd-9c80-add79b0c52d5
                      cost: 5.82
                '2':
                  summary: Insufficient tokens
                  value:
                    code: 100
                    msg: tokens is not enough
                quota:
                  summary: API key quota exceeded
                  value:
                    code: 101
                    msg: 'API key quota exceeded: 4990 of 5000 tokens used (monthly)'
          headers: {}
        '401':
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: integer
                  msg:
                    type: string
                required:
                  - code
                  - msg
              examples:
                '1':
                  summary: Unauthorized
                  value:
                    code: 401
                    msg: Unauthorized
          headers: {}
      deprecated: false
      security: []

````

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