{
  "openapi": "3.1.0",
  "info": {
    "title": "Runware API - Kling VIDEO 4.0",
    "summary": "Unified video generation and editing with multi-keyframe control and clips up to 30 seconds",
    "description": "Kling VIDEO 4.0 is a unified video model that generates 1080p clips of up to 30 seconds from text, images, reference videos, and reusable elements. It follows up to 10 keyframes per clip, including first, middle, and last frames, and combines reference images, reference videos, and elements in a single request to hold subjects, style, and motion. It also edits an existing video from a prompt, which suits long narrative shots, storyboard-driven sequences, and reference-driven production work.",
    "version": "1.0.0",
    "x-model-id": "klingai-video-4-0",
    "x-air-id": "klingai:kling-video@4.0",
    "x-status": "live",
    "x-creator": {
      "id": "klingai",
      "name": "Kling AI",
      "logo": "https://assets.runware.ai/f15ad256-9875-47bc-a5bf-0f4d3c45875e.png"
    },
    "x-capabilities": [
      "text-to-video",
      "image-to-video",
      "video-to-video",
      "edit",
      "checkpoint",
      "audio"
    ],
    "x-modes": [
      {
        "id": "text",
        "inputs": []
      },
      {
        "id": "reference-images",
        "inputs": [
          "referenceImages"
        ]
      },
      {
        "id": "first-frame",
        "inputs": [
          "frameImages"
        ],
        "frames": [
          "first"
        ]
      },
      {
        "id": "first-last-frames",
        "inputs": [
          "frameImages"
        ],
        "frames": [
          "first",
          "last"
        ]
      },
      {
        "id": "multiple-frames",
        "inputs": [
          "frameImages"
        ],
        "frameCount": {
          "minimum": 3,
          "maximum": 10
        }
      },
      {
        "id": "video",
        "inputs": [
          "video"
        ]
      },
      {
        "id": "reference-videos",
        "inputs": [
          "referenceVideos"
        ]
      },
      {
        "id": "elements",
        "inputs": [
          "elements"
        ]
      },
      {
        "id": "reference-images+first-frame",
        "inputs": [
          "referenceImages",
          "frameImages"
        ],
        "frames": [
          "first"
        ]
      },
      {
        "id": "reference-images+first-last-frames",
        "inputs": [
          "referenceImages",
          "frameImages"
        ],
        "frames": [
          "first",
          "last"
        ]
      },
      {
        "id": "reference-images+multiple-frames",
        "inputs": [
          "referenceImages",
          "frameImages"
        ],
        "frameCount": {
          "minimum": 3,
          "maximum": 10
        }
      },
      {
        "id": "reference-images+video",
        "inputs": [
          "referenceImages",
          "video"
        ]
      },
      {
        "id": "first-frame+video",
        "inputs": [
          "frameImages",
          "video"
        ],
        "frames": [
          "first"
        ]
      },
      {
        "id": "first-last-frames+video",
        "inputs": [
          "frameImages",
          "video"
        ],
        "frames": [
          "first",
          "last"
        ]
      },
      {
        "id": "multiple-frames+video",
        "inputs": [
          "frameImages",
          "video"
        ],
        "frameCount": {
          "minimum": 3,
          "maximum": 10
        }
      },
      {
        "id": "reference-images+reference-videos",
        "inputs": [
          "referenceImages",
          "referenceVideos"
        ]
      },
      {
        "id": "first-frame+reference-videos",
        "inputs": [
          "frameImages",
          "referenceVideos"
        ],
        "frames": [
          "first"
        ]
      },
      {
        "id": "first-last-frames+reference-videos",
        "inputs": [
          "frameImages",
          "referenceVideos"
        ],
        "frames": [
          "first",
          "last"
        ]
      },
      {
        "id": "multiple-frames+reference-videos",
        "inputs": [
          "frameImages",
          "referenceVideos"
        ],
        "frameCount": {
          "minimum": 3,
          "maximum": 10
        }
      },
      {
        "id": "video+reference-videos",
        "inputs": [
          "video",
          "referenceVideos"
        ]
      },
      {
        "id": "reference-images+elements",
        "inputs": [
          "referenceImages",
          "elements"
        ]
      },
      {
        "id": "first-frame+elements",
        "inputs": [
          "frameImages",
          "elements"
        ],
        "frames": [
          "first"
        ]
      },
      {
        "id": "first-last-frames+elements",
        "inputs": [
          "frameImages",
          "elements"
        ],
        "frames": [
          "first",
          "last"
        ]
      },
      {
        "id": "multiple-frames+elements",
        "inputs": [
          "frameImages",
          "elements"
        ],
        "frameCount": {
          "minimum": 3,
          "maximum": 10
        }
      },
      {
        "id": "video+elements",
        "inputs": [
          "video",
          "elements"
        ]
      },
      {
        "id": "reference-videos+elements",
        "inputs": [
          "referenceVideos",
          "elements"
        ]
      },
      {
        "id": "reference-images+first-frame+video",
        "inputs": [
          "referenceImages",
          "frameImages",
          "video"
        ],
        "frames": [
          "first"
        ]
      },
      {
        "id": "reference-images+first-last-frames+video",
        "inputs": [
          "referenceImages",
          "frameImages",
          "video"
        ],
        "frames": [
          "first",
          "last"
        ]
      },
      {
        "id": "reference-images+multiple-frames+video",
        "inputs": [
          "referenceImages",
          "frameImages",
          "video"
        ],
        "frameCount": {
          "minimum": 3,
          "maximum": 10
        }
      },
      {
        "id": "reference-images+first-frame+reference-videos",
        "inputs": [
          "referenceImages",
          "frameImages",
          "referenceVideos"
        ],
        "frames": [
          "first"
        ]
      },
      {
        "id": "reference-images+first-last-frames+reference-videos",
        "inputs": [
          "referenceImages",
          "frameImages",
          "referenceVideos"
        ],
        "frames": [
          "first",
          "last"
        ]
      },
      {
        "id": "reference-images+multiple-frames+reference-videos",
        "inputs": [
          "referenceImages",
          "frameImages",
          "referenceVideos"
        ],
        "frameCount": {
          "minimum": 3,
          "maximum": 10
        }
      },
      {
        "id": "reference-images+video+reference-videos",
        "inputs": [
          "referenceImages",
          "video",
          "referenceVideos"
        ]
      },
      {
        "id": "first-frame+video+reference-videos",
        "inputs": [
          "frameImages",
          "video",
          "referenceVideos"
        ],
        "frames": [
          "first"
        ]
      },
      {
        "id": "first-last-frames+video+reference-videos",
        "inputs": [
          "frameImages",
          "video",
          "referenceVideos"
        ],
        "frames": [
          "first",
          "last"
        ]
      },
      {
        "id": "multiple-frames+video+reference-videos",
        "inputs": [
          "frameImages",
          "video",
          "referenceVideos"
        ],
        "frameCount": {
          "minimum": 3,
          "maximum": 10
        }
      },
      {
        "id": "reference-images+first-frame+elements",
        "inputs": [
          "referenceImages",
          "frameImages",
          "elements"
        ],
        "frames": [
          "first"
        ]
      },
      {
        "id": "reference-images+first-last-frames+elements",
        "inputs": [
          "referenceImages",
          "frameImages",
          "elements"
        ],
        "frames": [
          "first",
          "last"
        ]
      },
      {
        "id": "reference-images+multiple-frames+elements",
        "inputs": [
          "referenceImages",
          "frameImages",
          "elements"
        ],
        "frameCount": {
          "minimum": 3,
          "maximum": 10
        }
      },
      {
        "id": "reference-images+video+elements",
        "inputs": [
          "referenceImages",
          "video",
          "elements"
        ]
      },
      {
        "id": "first-frame+video+elements",
        "inputs": [
          "frameImages",
          "video",
          "elements"
        ],
        "frames": [
          "first"
        ]
      },
      {
        "id": "first-last-frames+video+elements",
        "inputs": [
          "frameImages",
          "video",
          "elements"
        ],
        "frames": [
          "first",
          "last"
        ]
      },
      {
        "id": "multiple-frames+video+elements",
        "inputs": [
          "frameImages",
          "video",
          "elements"
        ],
        "frameCount": {
          "minimum": 3,
          "maximum": 10
        }
      },
      {
        "id": "reference-images+reference-videos+elements",
        "inputs": [
          "referenceImages",
          "referenceVideos",
          "elements"
        ]
      },
      {
        "id": "first-frame+reference-videos+elements",
        "inputs": [
          "frameImages",
          "referenceVideos",
          "elements"
        ],
        "frames": [
          "first"
        ]
      },
      {
        "id": "first-last-frames+reference-videos+elements",
        "inputs": [
          "frameImages",
          "referenceVideos",
          "elements"
        ],
        "frames": [
          "first",
          "last"
        ]
      },
      {
        "id": "multiple-frames+reference-videos+elements",
        "inputs": [
          "frameImages",
          "referenceVideos",
          "elements"
        ],
        "frameCount": {
          "minimum": 3,
          "maximum": 10
        }
      },
      {
        "id": "video+reference-videos+elements",
        "inputs": [
          "video",
          "referenceVideos",
          "elements"
        ]
      },
      {
        "id": "reference-images+first-frame+video+reference-videos",
        "inputs": [
          "referenceImages",
          "frameImages",
          "video",
          "referenceVideos"
        ],
        "frames": [
          "first"
        ]
      },
      {
        "id": "reference-images+first-last-frames+video+reference-videos",
        "inputs": [
          "referenceImages",
          "frameImages",
          "video",
          "referenceVideos"
        ],
        "frames": [
          "first",
          "last"
        ]
      },
      {
        "id": "reference-images+multiple-frames+video+reference-videos",
        "inputs": [
          "referenceImages",
          "frameImages",
          "video",
          "referenceVideos"
        ],
        "frameCount": {
          "minimum": 3,
          "maximum": 10
        }
      },
      {
        "id": "reference-images+first-frame+video+elements",
        "inputs": [
          "referenceImages",
          "frameImages",
          "video",
          "elements"
        ],
        "frames": [
          "first"
        ]
      },
      {
        "id": "reference-images+first-last-frames+video+elements",
        "inputs": [
          "referenceImages",
          "frameImages",
          "video",
          "elements"
        ],
        "frames": [
          "first",
          "last"
        ]
      },
      {
        "id": "reference-images+multiple-frames+video+elements",
        "inputs": [
          "referenceImages",
          "frameImages",
          "video",
          "elements"
        ],
        "frameCount": {
          "minimum": 3,
          "maximum": 10
        }
      },
      {
        "id": "reference-images+first-frame+reference-videos+elements",
        "inputs": [
          "referenceImages",
          "frameImages",
          "referenceVideos",
          "elements"
        ],
        "frames": [
          "first"
        ]
      },
      {
        "id": "reference-images+first-last-frames+reference-videos+elements",
        "inputs": [
          "referenceImages",
          "frameImages",
          "referenceVideos",
          "elements"
        ],
        "frames": [
          "first",
          "last"
        ]
      },
      {
        "id": "reference-images+multiple-frames+reference-videos+elements",
        "inputs": [
          "referenceImages",
          "frameImages",
          "referenceVideos",
          "elements"
        ],
        "frameCount": {
          "minimum": 3,
          "maximum": 10
        }
      },
      {
        "id": "reference-images+video+reference-videos+elements",
        "inputs": [
          "referenceImages",
          "video",
          "referenceVideos",
          "elements"
        ]
      },
      {
        "id": "first-frame+video+reference-videos+elements",
        "inputs": [
          "frameImages",
          "video",
          "referenceVideos",
          "elements"
        ],
        "frames": [
          "first"
        ]
      },
      {
        "id": "first-last-frames+video+reference-videos+elements",
        "inputs": [
          "frameImages",
          "video",
          "referenceVideos",
          "elements"
        ],
        "frames": [
          "first",
          "last"
        ]
      },
      {
        "id": "multiple-frames+video+reference-videos+elements",
        "inputs": [
          "frameImages",
          "video",
          "referenceVideos",
          "elements"
        ],
        "frameCount": {
          "minimum": 3,
          "maximum": 10
        }
      },
      {
        "id": "reference-images+first-frame+video+reference-videos+elements",
        "inputs": [
          "referenceImages",
          "frameImages",
          "video",
          "referenceVideos",
          "elements"
        ],
        "frames": [
          "first"
        ]
      },
      {
        "id": "reference-images+first-last-frames+video+reference-videos+elements",
        "inputs": [
          "referenceImages",
          "frameImages",
          "video",
          "referenceVideos",
          "elements"
        ],
        "frames": [
          "first",
          "last"
        ]
      },
      {
        "id": "reference-images+multiple-frames+video+reference-videos+elements",
        "inputs": [
          "referenceImages",
          "frameImages",
          "video",
          "referenceVideos",
          "elements"
        ],
        "frameCount": {
          "minimum": 3,
          "maximum": 10
        }
      }
    ],
    "x-released-at": "2026-10-23T00:00:00Z",
    "x-cover-image": "https://assets.runware.ai/covers/klingai-video-4-0.jpg",
    "x-examples": "https://runware.ai/docs/models/klingai-video-4-0/examples.json",
    "x-pricing": {
      "currency": "USD",
      "docs": "https://runware.ai/docs/models-api/pricing",
      "rates": [
        {
          "amount": 0.157,
          "unit": "durationSecond",
          "label": "720p · No video input",
          "display": "$0.157 per second"
        },
        {
          "amount": 0.235,
          "unit": "durationSecond",
          "label": "1080p · No video input",
          "display": "$0.235 per second"
        },
        {
          "amount": 0.188,
          "unit": "durationSecond",
          "label": "720p · Video input",
          "display": "$0.188 per second"
        },
        {
          "amount": 0.282,
          "unit": "durationSecond",
          "label": "1080p · Video input",
          "display": "$0.282 per second"
        }
      ],
      "examples": [
        {
          "id": "adaptive-prosthetic-fashion-showcase",
          "configuration": "video-edit",
          "price": 1.7,
          "latencyMs": 140209
        },
        {
          "id": "whale-skeleton-rig-cleanup-plate",
          "configuration": "text-to-video",
          "price": 2.35,
          "latencyMs": 616355
        },
        {
          "id": "technical-apiary-suit-product-reel",
          "configuration": "first-frame",
          "price": 2.35,
          "latencyMs": 1655405
        },
        {
          "id": "subsea-monitoring-logo-animation",
          "configuration": "multiple-keyframes",
          "price": 2.35,
          "latencyMs": 212322
        },
        {
          "id": "seed-vault-film-stock-portrait",
          "configuration": "elements",
          "price": 2.35,
          "latencyMs": 164764
        },
        {
          "id": "urban-tree-pathology-presenter-clip",
          "configuration": "first-last-frame",
          "price": 2.35,
          "latencyMs": 476551
        },
        {
          "id": "glacial-handpan-performance-visualizer",
          "configuration": "reference-to-video",
          "price": 2.82,
          "latencyMs": 192369
        }
      ]
    }
  },
  "externalDocs": {
    "description": "Kling VIDEO 4.0 on Runware",
    "url": "https://runware.ai/docs/models/klingai-video-4-0"
  },
  "servers": [
    {
      "url": "https://api.runware.ai/v1",
      "description": "Runware REST API"
    }
  ],
  "components": {
    "securitySchemes": {
      "apiKeyAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "Runware API Key (e.g., Bearer <your-key>)"
      }
    },
    "schemas": {
      "AuthenticationTask": {
        "title": "Authentication",
        "description": "Authenticates a connection using an API key. Can be sent as the first element of the request array as an alternative to using the Authorization header.",
        "type": "object",
        "x-response-schema": "https://schemas.runware.ai/responses/utilities/authentication.json",
        "properties": {
          "taskType": {
            "title": "Task Type",
            "description": "Identifier for the type of task being performed.",
            "type": "string",
            "const": "authentication"
          },
          "apiKey": {
            "title": "API Key",
            "description": "Your Runware API key.",
            "type": "string"
          },
          "connectionSessionUUID": {
            "title": "Connection Session UUID",
            "description": "Optional session UUID to resume a previous connection and receive any buffered results.",
            "type": "string",
            "format": "uuid"
          }
        },
        "required": [
          "taskType",
          "apiKey"
        ],
        "additionalProperties": false
      },
      "RequestBody": {
        "type": "array",
        "items": {
          "type": "object",
          "x-constraints": [
            {
              "operation": "width",
              "parameters": [
                "inputs.frameImages",
                "inputs.referenceImages"
              ],
              "minimum": 300,
              "scope": "each"
            },
            {
              "operation": "height",
              "parameters": [
                "inputs.frameImages",
                "inputs.referenceImages"
              ],
              "minimum": 300,
              "scope": "each"
            },
            {
              "operation": "fileSize",
              "parameters": [
                "inputs.frameImages",
                "inputs.referenceImages"
              ],
              "maximum": 31457280,
              "scope": "each"
            },
            {
              "operation": "fileCount",
              "parameters": [
                "inputs.frameImages",
                "inputs.referenceImages"
              ],
              "maximum": 10
            },
            {
              "operation": "width",
              "parameters": [
                "inputs.video",
                "inputs.referenceVideos",
                "inputs.elements.videos"
              ],
              "minimum": 700,
              "maximum": 4553,
              "scope": "each"
            },
            {
              "operation": "height",
              "parameters": [
                "inputs.video",
                "inputs.referenceVideos",
                "inputs.elements.videos"
              ],
              "minimum": 700,
              "maximum": 4553,
              "scope": "each"
            },
            {
              "operation": "area",
              "parameters": [
                "inputs.video",
                "inputs.referenceVideos",
                "inputs.elements.videos"
              ],
              "maximum": 8294400,
              "scope": "each"
            },
            {
              "operation": "frameRate",
              "parameters": [
                "inputs.video",
                "inputs.referenceVideos",
                "inputs.elements.videos"
              ],
              "minimum": 24,
              "maximum": 60,
              "scope": "each"
            },
            {
              "operation": "duration",
              "parameters": [
                "inputs.video",
                "inputs.referenceVideos"
              ],
              "minimum": 3,
              "maximum": 30,
              "scope": "each"
            },
            {
              "operation": "duration",
              "parameters": [
                "inputs.video",
                "inputs.referenceVideos"
              ],
              "maximum": 30
            },
            {
              "operation": "fileSize",
              "parameters": [
                "inputs.video",
                "inputs.referenceVideos"
              ],
              "maximum": 314572800,
              "scope": "each"
            },
            {
              "operation": "fileCount",
              "parameters": [
                "inputs.video",
                "inputs.referenceVideos"
              ],
              "maximum": 5
            },
            {
              "operation": "ratio",
              "parameters": [
                "inputs.frameImages",
                "inputs.referenceImages",
                "inputs.video",
                "inputs.referenceVideos",
                "inputs.elements.videos"
              ],
              "minimum": 0.4,
              "maximum": 2.5,
              "scope": "each"
            },
            {
              "operation": "fileCount",
              "parameters": [
                "inputs.frameImages",
                "inputs.referenceImages",
                "inputs.video",
                "inputs.referenceVideos",
                "inputs.elements"
              ],
              "maximum": 15
            },
            {
              "operation": "duration",
              "parameters": [
                "inputs.elements.videos"
              ],
              "minimum": 3,
              "maximum": 8,
              "scope": "each"
            },
            {
              "operation": "fileSize",
              "parameters": [
                "inputs.elements.videos"
              ],
              "maximum": 209715200,
              "scope": "each"
            }
          ],
          "properties": {
            "model": {
              "title": "Model",
              "description": "Send `auto` instead of an AIR identifier to have the model router choose the model for this task. The rest of the request is unchanged, every value you send is kept, and only the parameters you leave out are filled in. See [Model Router](https://runware.ai/docs/models-api/model-router).\n\n[Read full documentation](https://runware.ai/docs/models/klingai-video-4-0#model)",
              "type": "string",
              "const": "klingai:kling-video@4.0"
            },
            "inputs": {
              "title": "Inputs",
              "description": "Input assets for the task.",
              "type": "object",
              "properties": {
                "referenceImages": {
                  "title": "Reference Images",
                  "description": "List of reference images (UUID, URL, Data URI, or Base64).",
                  "type": "array",
                  "minItems": 1,
                  "items": {
                    "title": "Image",
                    "description": "Image input (UUID, URL, Data URI, or Base64).",
                    "type": "string",
                    "anyOf": [
                      {
                        "format": "uuid"
                      },
                      {
                        "format": "uri"
                      },
                      {
                        "pattern": "^data:image\\/[a-zA-Z]+;base64,[a-zA-Z0-9+/=]+$"
                      },
                      {
                        "pattern": "^[a-zA-Z0-9+/=]+$"
                      }
                    ]
                  },
                  "maxItems": 10
                },
                "frameImages": {
                  "title": "Frame Images",
                  "description": "An array of frame-specific image inputs to guide video generation. Each item can be either a plain image input (UUID, URL, Data URI, or Base64) or an object that pairs an image with a target position in the video.\n\nThe `frameImages` parameter allows you to constrain specific frames within the video sequence, ensuring that particular visual content appears at designated points. Position can be specified using `frame` (named positions or frame indices) or `timestamp` (seconds), depending on model support. This is different from `referenceImages`, which provide overall visual guidance without constraining specific timeline positions.\n\nWhen the `frame` parameter is omitted, automatic distribution rules apply:\n\n- **1 image**: Used as the first frame.\n- **2 images**: First and last frames.\n- **3+ images**: First and last frames, with intermediate images evenly spaced between.\n\n**Examples**:\n\n**Shorthand format:** When you don't need to specify a frame position, you can pass a plain image input directly.\n\n```json\n\"frameImages\": [\n  \"aac49721-1964-481a-ae78-8a4e29b91402\"\n]\n```\n\n**Object format:** When you need to specify a position, use an object with `image` and either `frame` or `timestamp` (model-dependent).\n\n```json\n\"frameImages\": [\n  {\n    \"image\": \"aac49721-1964-481a-ae78-8a4e29b91402\",\n    \"frame\": \"first\"\n  }\n]\n```\n\n**First and last frames:** With two images, they automatically become the first and last frames of the video sequence. You can mix shorthand and object formats.\n\n```json\n\"frameImages\": [\n  \"aac49721-1964-481a-ae78-8a4e29b91402\",\n  {\n    \"image\": \"3ad204c3-a9de-4963-8a1a-c3911e3afafe\",\n    \"frame\": \"last\"\n  }\n]\n```\n\n**Multiple frames:** With three or more images, the first and last are anchored while intermediate frames are evenly distributed across the timeline.\n\n```json\n\"frameImages\": [\n  {\n    \"image\": \"aac49721-1964-481a-ae78-8a4e29b91402\",\n    \"frame\": \"first\"\n  },\n  \"c00abf5f-6cdb-4642-a01d-1bfff7bc3cf7\",\n  {\n    \"image\": \"3ad204c3-a9de-4963-8a1a-c3911e3afafe\",\n    \"frame\": \"last\"\n  }\n]\n```\n\n[Read full documentation](https://runware.ai/docs/models/klingai-video-4-0#frameImages)",
                  "type": "array",
                  "minItems": 1,
                  "contains": {
                    "not": {
                      "type": "object",
                      "properties": {
                        "frame": {
                          "enum": [
                            "last",
                            -1
                          ]
                        }
                      },
                      "required": [
                        "frame"
                      ],
                      "additionalProperties": true
                    }
                  },
                  "items": {
                    "anyOf": [
                      {
                        "title": "Image",
                        "description": "Image input (UUID, URL, Data URI, or Base64).",
                        "type": "string",
                        "anyOf": [
                          {
                            "format": "uuid"
                          },
                          {
                            "format": "uri"
                          },
                          {
                            "pattern": "^data:image\\/[a-zA-Z]+;base64,[a-zA-Z0-9+/=]+$"
                          },
                          {
                            "pattern": "^[a-zA-Z0-9+/=]+$"
                          }
                        ]
                      },
                      {
                        "type": "object",
                        "properties": {
                          "image": {
                            "title": "Image",
                            "description": "Image input (UUID, URL, Data URI, or Base64).",
                            "type": "string",
                            "anyOf": [
                              {
                                "format": "uuid"
                              },
                              {
                                "format": "uri"
                              },
                              {
                                "pattern": "^data:image\\/[a-zA-Z]+;base64,[a-zA-Z0-9+/=]+$"
                              },
                              {
                                "pattern": "^[a-zA-Z0-9+/=]+$"
                              }
                            ]
                          },
                          "frame": {
                            "title": "Frame",
                            "description": "Target frame position for the image. Supports first and last frame.",
                            "oneOf": [
                              {
                                "const": "first",
                                "description": "First frame of the video."
                              },
                              {
                                "const": "last",
                                "description": "Last frame of the video."
                              },
                              {
                                "const": 0,
                                "description": "Frame index 0 (first frame)."
                              },
                              {
                                "const": -1,
                                "description": "Frame index -1 (last frame)."
                              }
                            ]
                          }
                        },
                        "required": [
                          "image"
                        ],
                        "additionalProperties": false
                      }
                    ]
                  },
                  "maxItems": 10
                },
                "video": {
                  "title": "Video",
                  "description": "Video input (UUID or URL). Source video for prompt-based editing.",
                  "type": "string",
                  "anyOf": [
                    {
                      "format": "uuid"
                    },
                    {
                      "format": "uri"
                    }
                  ]
                },
                "referenceVideos": {
                  "title": "Reference Videos",
                  "description": "List of reference videos (UUID or URL). Videos inside `elements` count toward the limit of 5 input videos and toward the combined duration limit.",
                  "type": "array",
                  "minItems": 1,
                  "items": {
                    "title": "Video",
                    "description": "Video input (UUID or URL).",
                    "type": "string",
                    "anyOf": [
                      {
                        "format": "uuid"
                      },
                      {
                        "format": "uri"
                      }
                    ]
                  },
                  "maxItems": 5
                },
                "elements": {
                  "title": "Elements",
                  "description": "Elements allow you to include reusable assets (images, videos, or voices) in your video generation. Each element is identified by an `id` and can be referenced in the prompt using `<<<element_1>>>`, `<<<element_2>>>`, etc. in order of appearance.\n\nAn element can contain:\n\n- **Images** via `frontalImage` and optionally `images` (up to 3 additional angles).\n- **Videos** via `videos` (cannot be combined with images).\n- **Voices** via `voices` (can only be combined with images, not videos).\n\n**Examples**:\n\n**Create a new element with an image:**\n\n```json\n\"positivePrompt\": \"A video of <<<element_1>>> walking through a futuristic city\",\n\"inputs\": {\n  \"elements\": [\n    {\n      \"id\": \"my-character-id\",\n      \"description\": \"A young woman with red hair\",\n      \"frontalImage\": \"c64351d5-4c59-42f7-95e1-eace013eddab\",\n      \"tags\": [\"Character\"]\n    }\n  ]\n}\n```\n\n**Reuse a previously created element by ID:**\n\n```json\n\"positivePrompt\": \"A video of <<<element_1>>> sitting in a coffee shop, reading a book\",\n\"inputs\": {\n  \"elements\": [\n    {\n      \"id\": \"my-character-id\"\n    }\n  ]\n}\n```\n\n[Read full documentation](https://runware.ai/docs/models/klingai-video-4-0#elements)",
                  "type": "array",
                  "minItems": 1,
                  "maxItems": 7,
                  "items": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string",
                        "title": "ID",
                        "description": "Unique identifier for this element. Use to create a new element or reference a previously created one.",
                        "pattern": "^[A-Za-z0-9_-]+$",
                        "minLength": 1,
                        "maxLength": 20
                      },
                      "description": {
                        "type": "string",
                        "title": "Description",
                        "description": "Description of the element.",
                        "minLength": 1,
                        "maxLength": 100
                      },
                      "frontalImage": {
                        "type": "string",
                        "title": "Frontal Image",
                        "description": "Frontal reference image for the element. Required when using image-based elements."
                      },
                      "images": {
                        "type": "array",
                        "title": "Images",
                        "description": "Reference images for the element. Up to 3 images. Requires frontalImage.",
                        "items": {
                          "type": "string"
                        },
                        "minItems": 1,
                        "maxItems": 3
                      },
                      "videos": {
                        "type": "array",
                        "title": "Videos",
                        "description": "Reference video for the element. Cannot be combined with images or voices.",
                        "items": {
                          "type": "string"
                        },
                        "minItems": 1,
                        "maxItems": 1
                      },
                      "voices": {
                        "type": "array",
                        "title": "Voices",
                        "description": "Voice audio for the element. Can only be combined with images, not videos.",
                        "items": {
                          "type": "string"
                        },
                        "minItems": 1,
                        "maxItems": 1
                      },
                      "tags": {
                        "type": "array",
                        "title": "Tags",
                        "description": "Classification tags for the element.",
                        "items": {
                          "type": "string",
                          "enum": [
                            "Animal",
                            "Character",
                            "Hottest",
                            "Item",
                            "Costume",
                            "Scene",
                            "Effect",
                            "Others"
                          ]
                        },
                        "minItems": 1
                      }
                    },
                    "required": [
                      "id",
                      "description"
                    ],
                    "not": {
                      "required": [
                        "frontalImage",
                        "videos"
                      ]
                    },
                    "dependencies": {
                      "images": [
                        "frontalImage"
                      ],
                      "voices": [
                        "frontalImage"
                      ]
                    },
                    "allOf": [
                      {
                        "if": {
                          "anyOf": [
                            {
                              "required": [
                                "frontalImage"
                              ]
                            },
                            {
                              "required": [
                                "images"
                              ]
                            }
                          ]
                        },
                        "then": {
                          "required": [
                            "frontalImage",
                            "images"
                          ]
                        }
                      }
                    ],
                    "additionalProperties": false
                  },
                  "contains": {
                    "required": [
                      "videos"
                    ]
                  },
                  "maxContains": 3,
                  "minContains": 0
                }
              },
              "additionalProperties": false
            },
            "positivePrompt": {
              "title": "Positive Prompt",
              "description": "Text prompt describing elements to include in the generated output. Images are referenced as `<<<image_1>>>` and videos as `<<<video_1>>>`. Images are numbered across `frameImages` then `referenceImages`, and videos across `video` then `referenceVideos`. Must satisfy `E / 26000 + N / 11000 <= 1`, where `N` counts the non-ASCII characters and `E` the rest.",
              "type": "string",
              "minLength": 1,
              "maxLength": 26000
            },
            "width": {
              "title": "Width",
              "description": "Width of the generated media in pixels.",
              "type": "integer"
            },
            "height": {
              "title": "Height",
              "description": "Height of the generated media in pixels.",
              "type": "integer"
            },
            "resolution": {
              "title": "Resolution",
              "description": "Resolution preset for the output. When used with input media, automatically matches the aspect ratio from the input.",
              "type": "string",
              "enum": [
                "720p",
                "1080p"
              ],
              "default": "1080p"
            },
            "duration": {
              "title": "Duration",
              "description": "Length of the generated video in seconds. The total number of frames produced is determined by duration multiplied by the model's frame rate (fps).",
              "type": "integer",
              "default": 10,
              "minimum": 3,
              "maximum": 30
            },
            "taskType": {
              "title": "Task Type",
              "description": "Identifier for the type of task being performed.",
              "type": "string",
              "const": "videoInference"
            },
            "taskUUID": {
              "title": "Task UUID",
              "description": "UUID v4 identifier for tracking tasks and matching async responses. Must be unique per task.",
              "type": "string",
              "format": "uuid"
            },
            "webhookURL": {
              "title": "Webhook URL",
              "description": "Webhook URL that receives JSON responses via HTTP POST when generation tasks complete. For batch requests with multiple results, each completed item triggers a separate webhook call as it becomes available.",
              "type": "string",
              "format": "uri"
            },
            "includeCost": {
              "title": "Include Cost",
              "description": "Include task cost in the response.",
              "type": "boolean"
            },
            "routing": {
              "title": "Routing",
              "description": "Model router options. Only read when `model` is `auto`, and never sent to the model.",
              "type": "object",
              "properties": {
                "preferences": {
                  "title": "Preferences",
                  "description": "Relative importance of each dimension when models are compared. Weights, not thresholds.",
                  "type": "object",
                  "properties": {
                    "quality": {
                      "title": "Weight",
                      "description": "Importance of one dimension. `0` leaves it out of the decision.",
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 5
                    },
                    "speed": {
                      "title": "Weight",
                      "description": "Importance of one dimension. `0` leaves it out of the decision.",
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 5
                    },
                    "cost": {
                      "title": "Weight",
                      "description": "Importance of one dimension. `0` leaves it out of the decision.",
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 5
                    }
                  },
                  "additionalProperties": false
                },
                "maxPrice": {
                  "title": "Max Price",
                  "description": "Upper bound on what this request may cost, in USD. A model whose cost cannot be bounded is not chosen.",
                  "type": "number",
                  "minimum": 0
                },
                "requirements": {
                  "title": "Requirements",
                  "description": "Conditions the result has to meet, in plain words, such as a style or a feature. A model that cannot meet them is not chosen. Output size is set with width and height rather than described here.",
                  "type": "string",
                  "maxLength": 3000
                }
              },
              "additionalProperties": false
            },
            "numberResults": {
              "title": "Number of Results",
              "description": "Number of results to generate. Each result uses a different seed, producing variations of the same parameters.",
              "type": "integer",
              "minimum": 1,
              "default": 1,
              "maximum": 4
            },
            "uploadEndpoint": {
              "title": "Upload Endpoint",
              "description": "Specifies a URL where the generated content will be automatically uploaded using the HTTP PUT method. The raw binary data of the media file is sent directly as the request body. For secure uploads to cloud storage, use presigned URLs that include temporary authentication credentials.\n\n**Common use cases:**\n\n- **Cloud storage**: Upload directly to S3 buckets, Google Cloud Storage, or Azure Blob Storage using presigned URLs.\n- **CDN integration**: Upload to content delivery networks for immediate distribution.\n\n```text\n// S3 presigned URL for secure upload\nhttps://your-bucket.s3.amazonaws.com/generated/content.mp4?X-Amz-Signature=abc123&X-Amz-Expires=3600\n\n// Google Cloud Storage presigned URL\nhttps://storage.googleapis.com/your-bucket/content.jpg?X-Goog-Signature=xyz789\n\n// Custom storage endpoint\nhttps://storage.example.com/uploads/generated-image.jpg\n```\n\nThe content data will be sent as the request body to the specified URL when generation is complete.\n\n[Read full documentation](https://runware.ai/docs/models/klingai-video-4-0#uploadEndpoint)",
              "type": "string",
              "format": "uri"
            },
            "ttl": {
              "title": "TTL",
              "description": "Time-to-live (TTL) in seconds for generated content. Only applies when `outputType` is `URL`.",
              "type": "integer",
              "minimum": 60
            },
            "outputType": {
              "title": "Output Type",
              "description": "Video output type.",
              "type": "string",
              "enum": [
                "URL"
              ],
              "default": "URL"
            },
            "outputFormat": {
              "title": "Output Format",
              "description": "Specifies the file format of the generated output. The available values depend on the task type and the specific model's capabilities.\n\n- \\`JPG\\`: Best for photorealistic images with smaller file sizes (no transparency).\n- \\`PNG\\`: Lossless compression, supports high quality and transparency (alpha channel).\n- \\`WEBP\\`: Modern format providing superior compression and transparency support.\n- \\`MP4\\`: Widely supported video container (H.264), recommended for general use.\n- \\`WEBM\\`: Optimized for web delivery.\n- \\`MOV\\`: QuickTime format, common in professional workflows (Apple ecosystem).\n- \\`GIF\\`: Animated image format (no audio), suitable for short loops or previews.\n- \\`MP3\\`: Compressed audio, smaller file size.\n- \\`WAV\\`: Uncompressed, high-quality audio.\n- \\`FLAC\\`: Lossless compression.\n- \\`OGG\\`: Open-source compressed audio format (Vorbis codec).\n- \\`SVG\\`: Scalable Vector Graphics.\n- \\`TIFF\\`: High-quality output supporting layers.\n- \\`GLB\\`: Binary glTF format for 3D models, including geometry, textures, and PBR materials.\n\n> [!NOTE]\n> \\*\\*Transparency\\*\\*: If you are using features like background removal or LayerDiffuse that require transparency, you must select a format that supports an alpha channel (e.g., \\`PNG\\`, \\`WEBP\\`, \\`TIFF\\`). \\`JPG\\` does not support transparency.\n\n[Read full documentation](https://runware.ai/docs/models/klingai-video-4-0#outputFormat)",
              "type": "string",
              "enum": [
                "MP4",
                "WEBM",
                "MOV"
              ],
              "default": "MP4"
            },
            "outputQuality": {
              "title": "Output Quality",
              "description": "Compression quality of the output. Higher values preserve quality but increase file size.",
              "type": "integer",
              "minimum": 20,
              "maximum": 99,
              "default": 95
            },
            "deliveryMethod": {
              "title": "Delivery Method",
              "description": "Determines how the API delivers task results.",
              "type": "string",
              "oneOf": [
                {
                  "const": "async",
                  "description": "Returns an immediate acknowledgment with the task UUID. Poll for results using getResponse. Required for long-running tasks like video generation."
                }
              ],
              "default": "async"
            },
            "safety": {
              "type": "object",
              "title": "Safety Settings",
              "description": "Content safety checking configuration for video generation.",
              "properties": {
                "checkContent": {
                  "title": "Check Content",
                  "description": "Enable or disable content safety checking. Increases total generation time.",
                  "type": "boolean"
                },
                "mode": {
                  "title": "Safety Mode",
                  "description": "Safety checking mode for video generation.",
                  "type": "string",
                  "oneOf": [
                    {
                      "const": "fast",
                      "title": "Fast",
                      "description": "Checks key frames."
                    },
                    {
                      "const": "full",
                      "title": "Full",
                      "description": "Checks all frames."
                    }
                  ],
                  "default": "fast"
                }
              },
              "additionalProperties": false
            }
          },
          "allOf": [
            {
              "dependentRequired": {
                "width": [
                  "height"
                ],
                "height": [
                  "width"
                ]
              }
            },
            {
              "if": {
                "not": {
                  "properties": {
                    "inputs": {
                      "anyOf": [
                        {
                          "required": [
                            "frameImages"
                          ]
                        },
                        {
                          "required": [
                            "referenceImages"
                          ]
                        },
                        {
                          "required": [
                            "video"
                          ]
                        },
                        {
                          "required": [
                            "referenceVideos"
                          ]
                        },
                        {
                          "required": [
                            "elements"
                          ]
                        }
                      ]
                    }
                  },
                  "required": [
                    "inputs"
                  ]
                }
              },
              "then": {
                "required": [
                  "width",
                  "height"
                ]
              }
            },
            {
              "not": {
                "allOf": [
                  {
                    "required": [
                      "resolution"
                    ]
                  },
                  {
                    "anyOf": [
                      {
                        "required": [
                          "width"
                        ]
                      },
                      {
                        "required": [
                          "height"
                        ]
                      }
                    ]
                  }
                ]
              }
            },
            {
              "if": {
                "anyOf": [
                  {
                    "required": [
                      "width"
                    ]
                  },
                  {
                    "required": [
                      "height"
                    ]
                  }
                ]
              },
              "then": {
                "oneOf": [
                  {
                    "title": "720p (16:9)",
                    "properties": {
                      "width": {
                        "const": 1280
                      },
                      "height": {
                        "const": 720
                      }
                    }
                  },
                  {
                    "title": "720p (1:1)",
                    "properties": {
                      "width": {
                        "const": 940
                      },
                      "height": {
                        "const": 940
                      }
                    }
                  },
                  {
                    "title": "720p (9:16)",
                    "properties": {
                      "width": {
                        "const": 720
                      },
                      "height": {
                        "const": 1280
                      }
                    }
                  },
                  {
                    "title": "720p (~21:9)",
                    "properties": {
                      "width": {
                        "const": 1460
                      },
                      "height": {
                        "const": 624
                      }
                    }
                  },
                  {
                    "title": "1080p (16:9)",
                    "properties": {
                      "width": {
                        "const": 1920
                      },
                      "height": {
                        "const": 1080
                      }
                    }
                  },
                  {
                    "title": "1080p (1:1)",
                    "properties": {
                      "width": {
                        "const": 1440
                      },
                      "height": {
                        "const": 1440
                      }
                    }
                  },
                  {
                    "title": "1080p (9:16)",
                    "properties": {
                      "width": {
                        "const": 1080
                      },
                      "height": {
                        "const": 1920
                      }
                    }
                  },
                  {
                    "title": "1080p (~21:9)",
                    "properties": {
                      "width": {
                        "const": 2200
                      },
                      "height": {
                        "const": 940
                      }
                    }
                  }
                ]
              }
            },
            {
              "if": {
                "required": [
                  "resolution"
                ]
              },
              "then": {
                "properties": {
                  "inputs": {
                    "anyOf": [
                      {
                        "required": [
                          "frameImages"
                        ]
                      },
                      {
                        "required": [
                          "referenceImages"
                        ]
                      },
                      {
                        "required": [
                          "video"
                        ]
                      },
                      {
                        "required": [
                          "referenceVideos"
                        ]
                      },
                      {
                        "required": [
                          "elements"
                        ]
                      }
                    ]
                  }
                },
                "required": [
                  "inputs"
                ]
              }
            },
            {
              "if": {
                "not": {
                  "properties": {
                    "inputs": {
                      "required": [
                        "frameImages"
                      ]
                    }
                  },
                  "required": [
                    "inputs"
                  ]
                }
              },
              "then": {
                "required": [
                  "positivePrompt"
                ]
              }
            },
            {
              "if": {
                "properties": {
                  "inputs": {
                    "anyOf": [
                      {
                        "required": [
                          "referenceImages"
                        ]
                      },
                      {
                        "required": [
                          "video"
                        ]
                      },
                      {
                        "required": [
                          "referenceVideos"
                        ]
                      },
                      {
                        "required": [
                          "elements"
                        ]
                      }
                    ]
                  }
                },
                "required": [
                  "inputs"
                ]
              },
              "then": {
                "required": [
                  "positivePrompt"
                ]
              }
            }
          ],
          "additionalProperties": false,
          "required": [
            "taskType",
            "taskUUID",
            "model"
          ]
        },
        "description": "You must always POST an array of task objects."
      },
      "ResponseBody": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "title": "Video Response",
              "type": "object",
              "additionalProperties": false,
              "properties": {
                "taskType": {
                  "title": "Task Type",
                  "description": "Identifier for the type of task this response belongs to.",
                  "type": "string",
                  "const": "videoInference"
                },
                "taskUUID": {
                  "title": "Task UUID",
                  "description": "UUID v4 identifier echoed from the original request, used to match async responses to their tasks.",
                  "type": "string",
                  "format": "uuid"
                },
                "cost": {
                  "title": "Cost",
                  "description": "Task cost in USD. Present when `includeCost` is set to `true` in the request.",
                  "type": "number"
                },
                "videoUUID": {
                  "title": "Video UUID",
                  "description": "UUID of the output video.",
                  "type": "string",
                  "format": "uuid"
                },
                "videoURL": {
                  "title": "Video URL",
                  "description": "URL of the output video.",
                  "type": "string",
                  "format": "uri"
                },
                "videoBase64Data": {
                  "title": "Video Base64 Data",
                  "description": "Base64-encoded video data.",
                  "type": "string"
                },
                "videoDataURI": {
                  "title": "Video Data URI",
                  "description": "Data URI of the output video.",
                  "type": "string",
                  "format": "uri"
                },
                "seed": {
                  "title": "Seed",
                  "description": "The seed used for generation. If none was provided, shows the randomly generated seed.",
                  "type": "integer"
                },
                "NSFWContent": {
                  "title": "NSFW Content",
                  "description": "Flag indicating if NSFW content was detected.",
                  "type": "boolean"
                }
              },
              "required": [
                "taskType",
                "taskUUID",
                "videoUUID"
              ]
            }
          }
        }
      },
      "ErrorResponse": {
        "title": "Error Response",
        "description": "Standard error response returned by the Runware API.",
        "type": "object",
        "properties": {
          "errors": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "code",
                "message"
              ],
              "additionalProperties": true,
              "properties": {
                "code": {
                  "type": "string",
                  "description": "A short identifier for the error (e.g., invalidApiKey, timeoutProvider)."
                },
                "message": {
                  "type": "string",
                  "description": "A human-readable explanation of what went wrong."
                },
                "parameter": {
                  "type": "string",
                  "description": "The request parameter related to the error, if applicable."
                },
                "taskType": {
                  "type": "string",
                  "description": "The task type of the request that failed."
                },
                "taskUUID": {
                  "type": "string",
                  "description": "The unique identifier of the failed request."
                },
                "documentation": {
                  "type": "string",
                  "description": "A link to relevant documentation."
                }
              }
            }
          }
        },
        "required": [
          "errors"
        ],
        "additionalProperties": false
      }
    }
  },
  "paths": {
    "/": {
      "post": {
        "summary": "Run Kling VIDEO 4.0",
        "description": "Kling VIDEO 4.0 is a unified video model that generates 1080p clips of up to 30 seconds from text, images, reference videos, and reusable elements. It follows up to 10 keyframes per clip, including first, middle, and last frames, and combines reference images, reference videos, and elements in a single request to hold subjects, style, and motion. It also edits an existing video from a prompt, which suits long narrative shots, storyboard-driven sequences, and reference-driven production work.",
        "operationId": "run_klingai_video_4_0",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RequestBody"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ResponseBody"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request — Missing or invalid parameters.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized — No valid API key provided.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "402": {
            "description": "Payment Required — Insufficient account balance.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden — The API key lacks permissions for this request.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Too Many Requests — Rate limit exceeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Server Error — Something went wrong on Runware's end.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "503": {
            "description": "Service Unavailable — Temporarily unavailable (maintenance or capacity).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    }
  },
  "security": [
    {
      "apiKeyAuth": []
    }
  ]
}