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

# Kling 4.0 API Documentation

> Kling 4.0 API creates up to 30-second videos with stable motion and complex camera movement. Multimodal references and multiple keyframes provide control over characters, scenes, and story progression. Integrate the Kling 4.0 API now.

Check out Kling 4.0 API pricing [here](https://api.pollo.ai/pricing?modelName=kling-v4\&modelType=video), cheaper than Fal AI.


## OpenAPI

````yaml POST /v1/generation/kling-ai/kling-v4/video
openapi: 3.0.3
info:
  title: Pollo | AI Video Collection
  description: >-
    ✨RESTful API Document. Model discovery: GET /api/v1/model-specs (public,
    keyless).
  version: 1.0.0
servers:
  - url: https://pollo.ai/api/platform
security: []
externalDocs:
  url: https://pollo.ai/api/platform/api/openapi.json
paths:
  /v1/generation/kling-ai/kling-v4/video:
    post:
      tags:
        - Video
      summary: kling-v4
      operationId: v1-kling-ai/kling-v4/video
      parameters: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - input
              properties:
                input:
                  oneOf:
                    - type: object
                      properties:
                        prompt:
                          type: string
                          maxLength: 26000
                          description: Text prompt describing the content to generate.
                        image:
                          type: string
                          description: First-frame / reference image URL (HTTP(S).
                        imageTail:
                          type: string
                          description: Tail (end-frame) image URL
                        duration:
                          type: integer
                          minimum: 3
                          maximum: 30
                          default: 10
                          description: The duration of the generated video, in seconds.
                        resolution:
                          type: string
                          enum:
                            - 720p
                            - 1080p
                          default: 1080p
                          description: >-
                            Output resolution of the generated media (e.g. 720p,
                            1080p, 2K, 4K). Values are case-insensitive.
                      required:
                        - image
                      title: Image To Video
                    - type: object
                      properties:
                        prompt:
                          type: string
                          maxLength: 26000
                          minLength: 1
                          description: Text prompt describing the content to generate.
                        aspectRatio:
                          type: string
                          enum:
                            - '21:9'
                            - '16:9'
                            - '9:16'
                            - '1:1'
                          default: '16:9'
                          description: Output aspect ratio, as width:height (e.g. 16:9).
                        duration:
                          type: integer
                          minimum: 3
                          maximum: 30
                          default: 10
                          description: The duration of the generated video, in seconds.
                        resolution:
                          type: string
                          enum:
                            - 720p
                            - 1080p
                          default: 1080p
                          description: >-
                            Output resolution of the generated media (e.g. 720p,
                            1080p, 2K, 4K). Values are case-insensitive.
                      required:
                        - prompt
                      title: Text To Video
                    - type: object
                      properties:
                        refs:
                          type: array
                          items:
                            $ref: '#/components/schemas/Ref'
                          maxItems: 15
                          description: >-
                            Reference items (image / video / audio) for
                            reference-to-video generation. An `audio` item is
                            used as a voice reference: 5–30 s of clean speech
                            from a single speaker (MP3 / WAV, or MP4 / MOV).
                            Mention it in `prompt` as `[@name]` and describe
                            what is said with it. At most 3 voices.
                        prompt:
                          type: string
                          maxLength: 26000
                          minLength: 1
                          description: Text prompt describing the content to generate.
                        duration:
                          type: integer
                          minimum: 3
                          maximum: 30
                          default: 10
                          description: The duration of the generated video, in seconds.
                        aspectRatio:
                          type: string
                          enum:
                            - '21:9'
                            - '16:9'
                            - '9:16'
                            - '1:1'
                            - adaptive
                          default: adaptive
                          description: Output aspect ratio, as width:height (e.g. 16:9).
                        resolution:
                          type: string
                          enum:
                            - 720p
                            - 1080p
                          default: 1080p
                          description: >-
                            Output resolution of the generated media (e.g. 720p,
                            1080p, 2K, 4K). Values are case-insensitive.
                      required:
                        - refs
                        - prompt
                      title: Reference To Video
                      description: >-
                        Constraints:

                        - at most 10 image references are allowed

                        - at most 5 reference videos are allowed (video elements
                        included)

                        - at most 7 elements are allowed, of which at most 3
                        video elements

                        - at most 3 audio (voice) references are allowed
                    - type: object
                      properties:
                        prompt:
                          type: string
                          maxLength: 26000
                          description: Text prompt describing the content to generate.
                        keyframes:
                          type: array
                          items:
                            type: object
                            properties:
                              url:
                                type: string
                                format: uri
                              role:
                                type: string
                                enum:
                                  - first
                                  - middle
                                  - last
                              name:
                                type: string
                                maxLength: 64
                            required:
                              - url
                          maxItems: 10
                          minItems: 2
                          description: >-
                            Ordered keyframes for keyframe-to-video. Each item
                            is `{ url, role? }`: `url` is an HTTP(S) image URL;
                            `role` is `first` / `middle` / `last`. When `role`
                            is omitted the first item is the first frame and the
                            rest are middle frames; to start without a first
                            frame, mark the first item `middle`. `first` is only
                            allowed on the first item and `last` only on the
                            last item. Optional `name` lets `prompt` reference a
                            frame as `[@name]` (sent to the model as `@image{n}`
                            by the frame order).
                        duration:
                          type: integer
                          minimum: 3
                          maximum: 30
                          default: 10
                          description: The duration of the generated video, in seconds.
                        resolution:
                          type: string
                          enum:
                            - 720p
                            - 1080p
                          default: 1080p
                          description: >-
                            Output resolution of the generated media (e.g. 720p,
                            1080p, 2K, 4K). Values are case-insensitive.
                      required:
                        - keyframes
                      title: Keyframes To Video
                webhookUrl:
                  type: string
                  format: uri
                  description: >-
                    Webhook URL (HTTP(S)) that receives status callbacks when
                    the generation succeeds or fails.
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  taskId:
                    type: string
                  status:
                    type: string
                    enum:
                      - waiting
                      - succeed
                      - failed
                      - processing
                required:
                  - taskId
                  - status
                additionalProperties: false
        '400':
          $ref: '#/components/responses/ApiError400'
        '401':
          $ref: '#/components/responses/ApiError401'
        '403':
          $ref: '#/components/responses/ApiError403'
        '404':
          $ref: '#/components/responses/ApiError404'
        '429':
          $ref: '#/components/responses/ApiError429'
        '500':
          $ref: '#/components/responses/ApiError500'
        default:
          $ref: '#/components/responses/error'
      security:
        - ApiKeyAuth: []
components:
  schemas:
    Ref:
      type: object
      description: A reference item specifying url / type.
      properties:
        url:
          type: string
          description: Media URL (HTTP(S)). Required unless `type` is `element`.
          example: https://example.com/ref.jpg
        type:
          type: string
          enum:
            - image
            - video
            - audio
            - element
          description: >-
            Media kind. Auto-detected from the URL when omitted. `element`
            references one of your saved elements by `elementId` instead of a
            URL.
        name:
          type: string
          maxLength: 64
          description: >-
            Mention handle (at most 64 characters, unique within the list);
            reference this item inside `prompt` as `[@name]`. Defaults to
            `ref1`, `ref2`… by position, or to the element / variant name for
            `element` items.
        elementId:
          type: string
          description: >-
            Only with `type: element`: the element id. Resolves to the element
            cover image.
        variantId:
          type: string
          description: >-
            Only with `type: element`: a variant id of that element; uses the
            variant's active image instead of the cover.
    ApiError:
      type: object
      required:
        - errorCode
        - message
        - code
      additionalProperties: true
      properties:
        errorCode:
          type: string
          enum:
            - REJECTED
            - INTERNAL
            - CREDENTIAL_MISSING
            - CREDENTIAL_INVALID
            - CLI_TOKEN_EXPIRED
            - CLI_REFRESH_TOKEN_INVALID
            - PERMISSION_DENIED
            - ACCOUNT_SUSPENDED
            - ACCOUNT_DELETED
            - CREDITS_INSUFFICIENT
            - PLAN_FEATURE_REQUIRED
            - PARALLEL_TASK_LIMIT_REACHED
            - ACTIVITY_DAILY_LIMIT_REACHED
            - QUOTA_ELEMENT_FREE
            - QUOTA_ELEMENT_PAID
            - QUOTA_BRAND_KIT_FREE
            - QUOTA_BRAND_KIT_PAID
            - RATE_LIMIT_EXCEEDED
            - RATE_LIMIT_PRODUCT_EXTRACT
            - INPUT_VALIDATION_FAILED
            - INPUT_NOT_SUPPORTED_BY_MODEL
            - MODERATION_REJECTED
            - ASSET_DISABLED_BY_REVIEW
            - GENERATION_IN_PROGRESS
          description: >-
            Stable business error identifier — **the only field to branch on**.
            Codes are append-only: existing codes are never renamed or
            repurposed, but new ones are added over time, so treat this as an
            open set. Match the exact code you handle, else the family prefix
            (`MODERATION_`, `RATE_LIMIT_`, `QUOTA_`, `ACCOUNT_`, …), else fall
            back to the HTTP status.
        message:
          type: string
          description: >-
            Developer-facing text. Varies with locale and product copy — **never
            match on it**.
        code:
          type: string
          description: >-
            Transport-level code (tRPC / JSON-RPC naming). Deprecated for
            business logic; may be removed.
        requestId:
          type: string
          description: Correlation id — quote it when contacting support.
        issues:
          type: array
          description: >-
            Per-field validation detail. Present when `errorCode` is
            `INPUT_VALIDATION_FAILED`.
          items:
            type: object
            required:
              - message
            additionalProperties: true
            properties:
              message:
                type: string
              path:
                type: array
                items:
                  type: string
                description: Path to the offending field.
  responses:
    ApiError400:
      description: >-
        Invalid request — schema validation failed (`INPUT_VALIDATION_FAILED`,
        detail in `issues`), a cross-field constraint was violated
        (`INPUT_CONSTRAINT_VIOLATED`), or the input did not pass moderation
        (`MODERATION_*`).
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ApiError'
    ApiError401:
      description: >-
        Missing or invalid credential (`CREDENTIAL_*`, `CLI_TOKEN_EXPIRED`,
        `EMAIL_LOGIN_REQUIRED`).
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ApiError'
    ApiError403:
      description: >-
        Rejected — not enough credits (`CREDITS_INSUFFICIENT`), quota exhausted
        (`QUOTA_*`), plan required (`PLAN_FEATURE_REQUIRED`), account state
        (`ACCOUNT_*`), or no permission (`PERMISSION_DENIED`).
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ApiError'
    ApiError404:
      description: >-
        Nothing matched — unknown route, model (`MODEL_NOT_FOUND`), task
        (`TASK_NOT_FOUND`) or asset (`ASSET_NOT_FOUND`).
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ApiError'
    ApiError429:
      description: >-
        Rate limited (`RATE_LIMIT_*`). `RATE_LIMIT_MODERATION` means recent
        content was blocked — adjust the input rather than simply retrying.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ApiError'
    ApiError500:
      description: Unexpected server-side failure (`INTERNAL`).
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ApiError'
    error:
      description: >-
        Error response. Every failure on this API uses this shape; branch on
        `errorCode`.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ApiError'
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: API key to authorize requests

````

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