{
  "openapi": "3.1.0",
  "info": {
    "title": "Runware API - Kling IMAGE 4.0",
    "summary": "Native 8K images with dense legible text and consistent sets of up to 10",
    "description": "Kling IMAGE 4.0 is an image model for text-to-image and reference-guided generation at native 2K, 4K, and 8K, with natural lighting and skin and material detail close to a camera photo. It renders up to 2,000 characters of legible text in seven languages, combines up to 10 reference images and elements, and plans series of up to 10 images that keep subjects and style consistent. It also designs e-commerce product pages and websites as a single tall image, which suits storyboards, slide decks, product shoots, and campaign visuals.",
    "version": "1.0.0",
    "x-model-id": "klingai-image-4-0",
    "x-air-id": "klingai:kling-image@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-image",
      "image-to-image",
      "edit",
      "checkpoint"
    ],
    "x-modes": [
      {
        "id": "text",
        "inputs": []
      },
      {
        "id": "reference-images",
        "inputs": [
          "referenceImages"
        ]
      },
      {
        "id": "elements",
        "inputs": [
          "elements"
        ]
      },
      {
        "id": "style-image",
        "inputs": [
          "styleImage"
        ]
      },
      {
        "id": "subject-image",
        "inputs": [
          "subjectImage"
        ]
      },
      {
        "id": "reference-images+elements",
        "inputs": [
          "referenceImages",
          "elements"
        ]
      },
      {
        "id": "style-image+subject-image",
        "inputs": [
          "styleImage",
          "subjectImage"
        ]
      }
    ],
    "x-released-at": "2026-11-17T00:00:00Z",
    "x-cover-image": "https://assets.runware.ai/covers/klingai-image-4-0.jpg",
    "x-examples": "https://runware.ai/docs/models/klingai-image-4-0/examples.json",
    "x-pricing": {
      "currency": "USD",
      "docs": "https://runware.ai/docs/models-api/pricing",
      "rates": [
        {
          "amount": 0.063,
          "unit": "output",
          "label": "Image · 2K",
          "display": "$0.063 per image"
        },
        {
          "amount": 0.094,
          "unit": "output",
          "label": "Image · 4K",
          "display": "$0.094 per image"
        },
        {
          "amount": 0.157,
          "unit": "output",
          "label": "Image · 8K",
          "display": "$0.157 per image"
        },
        {
          "amount": 0.549,
          "unit": "output",
          "label": "Webpage · 1K",
          "display": "$0.549 per image"
        },
        {
          "amount": 0.596,
          "unit": "output",
          "label": "Webpage · 2K",
          "display": "$0.596 per image"
        },
        {
          "amount": 0.235,
          "unit": "output",
          "label": "E-commerce · Short · 1K",
          "display": "$0.235 per image"
        },
        {
          "amount": 0.282,
          "unit": "output",
          "label": "E-commerce · Short · 2K",
          "display": "$0.282 per image"
        },
        {
          "amount": 0.47,
          "unit": "output",
          "label": "E-commerce · Medium · 1K",
          "display": "$0.47 per image"
        },
        {
          "amount": 0.549,
          "unit": "output",
          "label": "E-commerce · Medium · 2K",
          "display": "$0.549 per image"
        },
        {
          "amount": 0.784,
          "unit": "output",
          "label": "E-commerce · Long · 1K",
          "display": "$0.784 per image"
        },
        {
          "amount": 0.862,
          "unit": "output",
          "label": "E-commerce · Long · 2K",
          "display": "$0.862 per image"
        },
        {
          "amount": 0.003,
          "unit": "inputImage",
          "display": "$0.003 per input image"
        }
      ],
      "examples": [
        {
          "id": "antarctic-field-safety-sticker-pack",
          "configuration": "text-to-image · 2496×1664",
          "price": 0.063,
          "latencyMs": 48180
        },
        {
          "id": "forensic-botanist-persona-portrait",
          "configuration": "elements · 1760×2336",
          "price": 0.069,
          "latencyMs": 70263
        },
        {
          "id": "typhoon-switchboard-series-poster",
          "configuration": "reference-to-image · 2K",
          "price": 0.069,
          "latencyMs": 70562
        },
        {
          "id": "coastal-forager-rainwear-lookbook",
          "configuration": "sequential-images · 4K",
          "price": 0.094,
          "latencyMs": 303801
        },
        {
          "id": "forensic-botanist-portrait-website",
          "configuration": "webpage-design",
          "price": 0.549,
          "latencyMs": 116621
        },
        {
          "id": "municipal-leak-listening-rod-page",
          "configuration": "ecommerce-page · 2K",
          "price": 0.552,
          "latencyMs": 167366
        }
      ]
    }
  },
  "externalDocs": {
    "description": "Kling IMAGE 4.0 on Runware",
    "url": "https://runware.ai/docs/models/klingai-image-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.referenceImages",
                "inputs.subjectImage",
                "inputs.styleImage"
              ],
              "minimum": 300,
              "scope": "each"
            },
            {
              "operation": "height",
              "parameters": [
                "inputs.referenceImages",
                "inputs.subjectImage",
                "inputs.styleImage"
              ],
              "minimum": 300,
              "scope": "each"
            },
            {
              "operation": "ratio",
              "parameters": [
                "inputs.referenceImages",
                "inputs.subjectImage",
                "inputs.styleImage"
              ],
              "minimum": 0.4,
              "maximum": 2.5,
              "scope": "each"
            },
            {
              "operation": "fileSize",
              "parameters": [
                "inputs.referenceImages",
                "inputs.subjectImage",
                "inputs.styleImage"
              ],
              "maximum": 31457280,
              "scope": "each"
            },
            {
              "operation": "fileCount",
              "parameters": [
                "inputs.referenceImages",
                "inputs.elements"
              ],
              "maximum": 10
            }
          ],
          "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-image-4-0#model)",
              "type": "string",
              "const": "klingai:kling-image@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
                },
                "elements": {
                  "title": "Elements",
                  "description": "Elements allow you to include reusable assets in your 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` plus `images` (1 to 3 additional angles).\n- **Videos** via `videos`, on video models only (cannot be combined with images).\n- **Voices** via `voices`, on video models only (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\": \"<<<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      \"images\": [\"8f2a9c3e-1b4d-4e6f-a7c8-9d0e1f2a3b4c\"],\n      \"tags\": [\"Character\"]\n    }\n  ]\n}\n```\n\n**Reuse a previously created element by ID:**\n\n```json\n\"positivePrompt\": \"<<<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-image-4-0#elements)",
                  "type": "array",
                  "minItems": 1,
                  "maxItems": 10,
                  "items": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "title": "ID",
                        "description": "Unique identifier for this element. Use to create a new element or reference a previously created one.",
                        "type": "string",
                        "pattern": "^[A-Za-z0-9_-]+$",
                        "minLength": 1,
                        "maxLength": 20
                      },
                      "description": {
                        "title": "Description",
                        "description": "Description of the element.",
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 100
                      },
                      "frontalImage": {
                        "title": "Frontal Image",
                        "description": "Frontal reference image for the element. Required when using image-based elements.",
                        "type": "string"
                      },
                      "images": {
                        "title": "Images",
                        "description": "Reference images for the element. Up to 3 images. Requires frontalImage.",
                        "type": "array",
                        "minItems": 1,
                        "maxItems": 3,
                        "items": {
                          "type": "string"
                        }
                      },
                      "tags": {
                        "title": "Tags",
                        "description": "Classification tags for the element.",
                        "type": "array",
                        "minItems": 1,
                        "items": {
                          "type": "string",
                          "enum": [
                            "Animal",
                            "Character",
                            "Hottest",
                            "Item",
                            "Costume",
                            "Scene",
                            "Effect",
                            "Others"
                          ]
                        }
                      }
                    },
                    "required": [
                      "id"
                    ],
                    "allOf": [
                      {
                        "if": {
                          "anyOf": [
                            {
                              "required": [
                                "frontalImage"
                              ]
                            },
                            {
                              "required": [
                                "images"
                              ]
                            }
                          ]
                        },
                        "then": {
                          "required": [
                            "frontalImage",
                            "images",
                            "description"
                          ]
                        }
                      }
                    ],
                    "additionalProperties": false
                  }
                },
                "styleImage": {
                  "title": "Image",
                  "description": "Image whose visual and layout style the page takes (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+/=]+$"
                    }
                  ]
                },
                "subjectImage": {
                  "title": "Image",
                  "description": "Image of the subject the page keeps as it appears and is designed around (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+/=]+$"
                    }
                  ]
                }
              },
              "additionalProperties": false
            },
            "positivePrompt": {
              "title": "Positive Prompt",
              "description": "Text prompt describing elements to include in the generated output. Reference images are referenced as `<<<image_1>>>` and elements as `<<<element_1>>>`, numbered in order. Must satisfy `E / 50000 + N / 21000 <= 1`, or `E / 166000 + N / 71000 <= 1` with `settings.pageType`, where `N` counts the non-ASCII characters and `E` the rest.",
              "type": "string",
              "minLength": 1,
              "maxLength": 166000
            },
            "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. Without reference images, the model picks the aspect ratio from the prompt.",
              "type": "string",
              "enum": [
                "1K",
                "2K",
                "4K",
                "8K"
              ]
            },
            "settings": {
              "title": "Settings",
              "description": "Global inference settings.",
              "type": "object",
              "properties": {
                "pageLength": {
                  "type": "string",
                  "title": "Page Length",
                  "description": "Length of the product page, in content sections.",
                  "oneOf": [
                    {
                      "description": "About 2 to 5 sections.",
                      "const": "short"
                    },
                    {
                      "description": "About 6 to 10 sections.",
                      "const": "medium"
                    },
                    {
                      "description": "About 11 to 18 sections.",
                      "const": "long"
                    }
                  ]
                },
                "pageType": {
                  "type": "string",
                  "title": "Page Type",
                  "description": "Long-form page design, returned as one tall image whose size the model picks.",
                  "oneOf": [
                    {
                      "description": "E-commerce product detail page for the product in `inputs.referenceImages`.",
                      "const": "ecommerce"
                    },
                    {
                      "description": "Website design.",
                      "const": "webpage"
                    }
                  ]
                },
                "seriesLength": {
                  "type": [
                    "integer",
                    "string"
                  ],
                  "title": "Series Length",
                  "description": "Number of images in an image series. The images are planned together, keep subjects and style consistent, and are returned in series order.",
                  "oneOf": [
                    {
                      "type": "integer",
                      "minimum": 2,
                      "maximum": 10
                    },
                    {
                      "description": "Picks between 2 and 10 images from the prompt.",
                      "const": "auto"
                    }
                  ]
                }
              },
              "additionalProperties": false
            },
            "taskType": {
              "title": "Task Type",
              "description": "Identifier for the type of task being performed.",
              "type": "string",
              "const": "imageInference"
            },
            "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"
            },
            "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": 20
            },
            "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-image-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": "Image output type.",
              "type": "string",
              "enum": [
                "URL",
                "base64Data",
                "dataURI"
              ],
              "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-image-4-0#outputFormat)",
              "type": "string",
              "enum": [
                "JPG",
                "PNG",
                "WEBP"
              ],
              "default": "JPG"
            },
            "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": "sync",
                  "description": "Returns results directly in the API response. Over HTTP, a task still running after 120 seconds continues as an async task and comes back with status 'processing'. Poll for its results using getResponse."
                },
                {
                  "const": "async",
                  "description": "Returns an immediate acknowledgment with the task UUID. Poll for results using getResponse."
                }
              ],
              "default": "sync"
            },
            "safety": {
              "type": "object",
              "title": "Safety Settings",
              "description": "Content safety checking configuration for image generation.",
              "properties": {
                "checkContent": {
                  "title": "Check Content",
                  "description": "Enable or disable content safety checking. Increases total generation time.",
                  "type": "boolean"
                }
              },
              "additionalProperties": false
            },
            "advancedFeatures": {
              "title": "Advanced Features",
              "description": "Model-specific advanced configuration options.",
              "type": "object",
              "properties": {
                "watermark": {
                  "title": "Watermark",
                  "description": "Configuration object for adding watermarks to generated videos. Watermarks can be applied using either text or image content with customizable positioning and appearance. You must provide either `text` or `image` content for the watermark, but not both.\n\n**Text watermark**:\n\n```json\n\"advancedFeatures\": {\n  \"watermark\": {\n    \"text\": \"© 2025 Company\",\n    \"displayPosition\": \"bottom-right\",\n    \"opacity\": 0.6,\n    \"fontColor\": \"#ffffff\",\n    \"bgColor\": \"#000000\"\n  }\n}\n```\n\n**Image watermark**:\n\n```json\n\"advancedFeatures\": {\n  \"watermark\": {\n    \"image\": \"c64351d5-4c59-42f7-95e1-eace013eddab\",\n    \"displayPosition\": \"top-left\",\n    \"opacity\": 0.6\n  }\n}\n```\n\n**Tiled watermark**:\n\n```json\n\"advancedFeatures\": {\n  \"watermark\": {\n    \"text\": \"PREVIEW\",\n    \"tiled\": true,\n    \"opacity\": 0.4,\n    \"fontColor\": \"#cccccc\"\n  }\n}\n```\n\n[Read full documentation](https://runware.ai/docs/models/klingai-image-4-0#watermark)",
                  "type": "object",
                  "properties": {
                    "text": {
                      "title": "Watermark Text",
                      "description": "Watermark text.",
                      "type": "string",
                      "minLength": 2,
                      "maxLength": 32
                    },
                    "image": {
                      "title": "Watermark Image",
                      "description": "Watermark image (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+/=]+$"
                        }
                      ]
                    },
                    "displayPosition": {
                      "title": "Display Position",
                      "description": "Watermark position.",
                      "type": "string",
                      "enum": [
                        "top-left",
                        "top-center",
                        "top-right",
                        "center-left",
                        "center-center",
                        "center-right",
                        "bottom-left",
                        "bottom-center",
                        "bottom-right",
                        "tiled"
                      ]
                    },
                    "opacity": {
                      "title": "Watermark Opacity",
                      "description": "Watermark opacity.",
                      "type": "number",
                      "multipleOf": 0.01,
                      "minimum": 0.1,
                      "maximum": 1
                    },
                    "fontColor": {
                      "title": "Font Color",
                      "description": "Text color in hex format.",
                      "type": "string",
                      "pattern": "^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$"
                    },
                    "bgColor": {
                      "title": "Background Color",
                      "description": "Background color in hex format.",
                      "type": "string",
                      "pattern": "^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$"
                    }
                  },
                  "oneOf": [
                    {
                      "required": [
                        "text"
                      ]
                    },
                    {
                      "required": [
                        "image"
                      ]
                    }
                  ],
                  "additionalProperties": false
                }
              },
              "additionalProperties": false
            }
          },
          "required": [
            "positivePrompt",
            "taskType",
            "taskUUID",
            "model"
          ],
          "allOf": [
            {
              "dependentRequired": {
                "width": [
                  "height"
                ],
                "height": [
                  "width"
                ]
              }
            },
            {
              "not": {
                "allOf": [
                  {
                    "required": [
                      "resolution"
                    ]
                  },
                  {
                    "anyOf": [
                      {
                        "required": [
                          "width"
                        ]
                      },
                      {
                        "required": [
                          "height"
                        ]
                      }
                    ]
                  }
                ]
              }
            },
            {
              "if": {
                "properties": {
                  "settings": {
                    "required": [
                      "pageType"
                    ]
                  }
                },
                "required": [
                  "settings"
                ]
              },
              "then": {
                "not": {
                  "anyOf": [
                    {
                      "required": [
                        "width"
                      ]
                    },
                    {
                      "required": [
                        "height"
                      ]
                    },
                    {
                      "properties": {
                        "inputs": {
                          "required": [
                            "elements"
                          ]
                        }
                      },
                      "required": [
                        "inputs"
                      ]
                    },
                    {
                      "properties": {
                        "settings": {
                          "required": [
                            "seriesLength"
                          ]
                        }
                      },
                      "required": [
                        "settings"
                      ]
                    }
                  ]
                }
              }
            },
            {
              "if": {
                "properties": {
                  "settings": {
                    "properties": {
                      "pageType": {
                        "const": "webpage"
                      }
                    },
                    "required": [
                      "pageType"
                    ]
                  }
                },
                "required": [
                  "settings"
                ]
              },
              "then": {
                "not": {
                  "properties": {
                    "inputs": {
                      "required": [
                        "referenceImages"
                      ]
                    }
                  },
                  "required": [
                    "inputs"
                  ]
                }
              }
            },
            {
              "if": {
                "not": {
                  "properties": {
                    "settings": {
                      "required": [
                        "pageType"
                      ]
                    }
                  },
                  "required": [
                    "settings"
                  ]
                }
              },
              "then": {
                "properties": {
                  "positivePrompt": {
                    "maxLength": 50000
                  },
                  "resolution": {
                    "enum": [
                      "2K",
                      "4K",
                      "8K"
                    ],
                    "default": "2K"
                  }
                }
              }
            },
            {
              "if": {
                "properties": {
                  "settings": {
                    "required": [
                      "pageType"
                    ]
                  }
                },
                "required": [
                  "settings"
                ]
              },
              "then": {
                "properties": {
                  "resolution": {
                    "enum": [
                      "1K",
                      "2K"
                    ],
                    "default": "1K"
                  }
                }
              }
            },
            {
              "if": {
                "properties": {
                  "settings": {
                    "properties": {
                      "pageType": {
                        "const": "ecommerce"
                      }
                    },
                    "required": [
                      "pageType"
                    ]
                  }
                },
                "required": [
                  "settings"
                ]
              },
              "then": {
                "properties": {
                  "inputs": {
                    "properties": {
                      "referenceImages": {
                        "maxItems": 3
                      }
                    },
                    "required": [
                      "referenceImages"
                    ]
                  },
                  "settings": {
                    "properties": {
                      "pageLength": {
                        "default": "medium"
                      }
                    }
                  }
                },
                "required": [
                  "inputs"
                ]
              }
            },
            {
              "if": {
                "properties": {
                  "settings": {
                    "required": [
                      "pageLength"
                    ]
                  }
                },
                "required": [
                  "settings"
                ]
              },
              "then": {
                "properties": {
                  "settings": {
                    "properties": {
                      "pageType": {
                        "const": "ecommerce"
                      }
                    },
                    "required": [
                      "pageType"
                    ]
                  }
                }
              }
            },
            {
              "if": {
                "properties": {
                  "inputs": {
                    "required": [
                      "styleImage"
                    ]
                  }
                },
                "required": [
                  "inputs"
                ]
              },
              "then": {
                "properties": {
                  "settings": {
                    "properties": {
                      "pageType": {
                        "const": "webpage"
                      }
                    },
                    "required": [
                      "pageType"
                    ]
                  }
                },
                "required": [
                  "settings"
                ]
              }
            },
            {
              "if": {
                "properties": {
                  "inputs": {
                    "required": [
                      "subjectImage"
                    ]
                  }
                },
                "required": [
                  "inputs"
                ]
              },
              "then": {
                "properties": {
                  "settings": {
                    "properties": {
                      "pageType": {
                        "const": "webpage"
                      }
                    },
                    "required": [
                      "pageType"
                    ]
                  }
                },
                "required": [
                  "settings"
                ]
              }
            },
            {
              "if": {
                "properties": {
                  "settings": {
                    "required": [
                      "seriesLength"
                    ]
                  }
                },
                "required": [
                  "settings"
                ]
              },
              "then": {
                "properties": {
                  "numberResults": {
                    "maximum": 1
                  }
                }
              }
            },
            {
              "if": {
                "anyOf": [
                  {
                    "required": [
                      "width"
                    ]
                  },
                  {
                    "required": [
                      "height"
                    ]
                  }
                ]
              },
              "then": {
                "oneOf": [
                  {
                    "title": "2K (1:1)",
                    "properties": {
                      "width": {
                        "const": 2048
                      },
                      "height": {
                        "const": 2048
                      }
                    }
                  },
                  {
                    "title": "2K (3:2)",
                    "properties": {
                      "width": {
                        "const": 2496
                      },
                      "height": {
                        "const": 1664
                      }
                    }
                  },
                  {
                    "title": "2K (2:3)",
                    "properties": {
                      "width": {
                        "const": 1664
                      },
                      "height": {
                        "const": 2496
                      }
                    }
                  },
                  {
                    "title": "2K (4:3)",
                    "properties": {
                      "width": {
                        "const": 2336
                      },
                      "height": {
                        "const": 1760
                      }
                    }
                  },
                  {
                    "title": "2K (3:4)",
                    "properties": {
                      "width": {
                        "const": 1760
                      },
                      "height": {
                        "const": 2336
                      }
                    }
                  },
                  {
                    "title": "2K (9:16)",
                    "properties": {
                      "width": {
                        "const": 1536
                      },
                      "height": {
                        "const": 2720
                      }
                    }
                  },
                  {
                    "title": "2K (16:9)",
                    "properties": {
                      "width": {
                        "const": 2720
                      },
                      "height": {
                        "const": 1536
                      }
                    }
                  },
                  {
                    "title": "2K (21:9)",
                    "properties": {
                      "width": {
                        "const": 3136
                      },
                      "height": {
                        "const": 1326
                      }
                    }
                  },
                  {
                    "title": "4K (1:1)",
                    "properties": {
                      "width": {
                        "const": 4096
                      },
                      "height": {
                        "const": 4096
                      }
                    }
                  },
                  {
                    "title": "4K (3:2)",
                    "properties": {
                      "width": {
                        "const": 4992
                      },
                      "height": {
                        "const": 3328
                      }
                    }
                  },
                  {
                    "title": "4K (2:3)",
                    "properties": {
                      "width": {
                        "const": 3328
                      },
                      "height": {
                        "const": 4992
                      }
                    }
                  },
                  {
                    "title": "4K (4:3)",
                    "properties": {
                      "width": {
                        "const": 4672
                      },
                      "height": {
                        "const": 3520
                      }
                    }
                  },
                  {
                    "title": "4K (3:4)",
                    "properties": {
                      "width": {
                        "const": 3520
                      },
                      "height": {
                        "const": 4672
                      }
                    }
                  },
                  {
                    "title": "4K (9:16)",
                    "properties": {
                      "width": {
                        "const": 3072
                      },
                      "height": {
                        "const": 5440
                      }
                    }
                  },
                  {
                    "title": "4K (16:9)",
                    "properties": {
                      "width": {
                        "const": 5440
                      },
                      "height": {
                        "const": 3072
                      }
                    }
                  },
                  {
                    "title": "4K (21:9)",
                    "properties": {
                      "width": {
                        "const": 6272
                      },
                      "height": {
                        "const": 2651
                      }
                    }
                  },
                  {
                    "title": "8K (1:1)",
                    "properties": {
                      "width": {
                        "const": 8192
                      },
                      "height": {
                        "const": 8192
                      }
                    }
                  },
                  {
                    "title": "8K (3:2)",
                    "properties": {
                      "width": {
                        "const": 9984
                      },
                      "height": {
                        "const": 6656
                      }
                    }
                  },
                  {
                    "title": "8K (2:3)",
                    "properties": {
                      "width": {
                        "const": 6656
                      },
                      "height": {
                        "const": 9984
                      }
                    }
                  },
                  {
                    "title": "8K (4:3)",
                    "properties": {
                      "width": {
                        "const": 9344
                      },
                      "height": {
                        "const": 7040
                      }
                    }
                  },
                  {
                    "title": "8K (3:4)",
                    "properties": {
                      "width": {
                        "const": 7040
                      },
                      "height": {
                        "const": 9344
                      }
                    }
                  },
                  {
                    "title": "8K (9:16)",
                    "properties": {
                      "width": {
                        "const": 6144
                      },
                      "height": {
                        "const": 10880
                      }
                    }
                  },
                  {
                    "title": "8K (16:9)",
                    "properties": {
                      "width": {
                        "const": 10880
                      },
                      "height": {
                        "const": 6144
                      }
                    }
                  },
                  {
                    "title": "8K (21:9)",
                    "properties": {
                      "width": {
                        "const": 12544
                      },
                      "height": {
                        "const": 5302
                      }
                    }
                  }
                ]
              }
            }
          ],
          "additionalProperties": false
        },
        "description": "You must always POST an array of task objects."
      },
      "ResponseBody": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "title": "Image Response",
              "type": "object",
              "additionalProperties": false,
              "properties": {
                "taskType": {
                  "title": "Task Type",
                  "description": "Identifier for the type of task this response belongs to.",
                  "type": "string",
                  "const": "imageInference"
                },
                "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"
                },
                "imageUUID": {
                  "title": "Image UUID",
                  "description": "UUID of the output image.",
                  "type": "string",
                  "format": "uuid"
                },
                "imageURL": {
                  "title": "Image URL",
                  "description": "URL of the output image.",
                  "type": "string",
                  "format": "uri"
                },
                "imageBase64Data": {
                  "title": "Image Base64 Data",
                  "description": "Base64-encoded image data.",
                  "type": "string"
                },
                "imageDataURI": {
                  "title": "Image Data URI",
                  "description": "Data URI of the output image.",
                  "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",
                "imageUUID"
              ]
            }
          }
        }
      },
      "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 IMAGE 4.0",
        "description": "Kling IMAGE 4.0 is an image model for text-to-image and reference-guided generation at native 2K, 4K, and 8K, with natural lighting and skin and material detail close to a camera photo. It renders up to 2,000 characters of legible text in seven languages, combines up to 10 reference images and elements, and plans series of up to 10 images that keep subjects and style consistent. It also designs e-commerce product pages and websites as a single tall image, which suits storyboards, slide decks, product shoots, and campaign visuals.",
        "operationId": "run_klingai_image_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": []
    }
  ]
}