{
  "openapi": "3.1.0",
  "info": {
    "title": "SeedRouter Kling 4.0 Flash",
    "version": "1.0.0",
    "description": "Kling 4.0 Flash 720p video with sound from text, reference images, reference videos and elements. Asynchronous task delivery; media by URL only; callbacks are not offered; tasks cannot be cancelled."
  },
  "servers": [
    {
      "url": "https://api.seedrouter.ai/v1"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "paths": {
    "/videos/generations": {
      "post": {
        "summary": "Create a video generation task",
        "operationId": "createVideoTask",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/VideoRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Accepted. Poll the returned id; no video is returned by this call.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TaskAccepted"
                }
              }
            }
          },
          "400": {
            "description": "Public error; no infrastructure details.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Public error; no infrastructure details.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "402": {
            "description": "Public error; no infrastructure details.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Public error; no infrastructure details.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Public error; no infrastructure details.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "503": {
            "description": "Public error; no infrastructure details.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/tasks/{task_id}": {
      "get": {
        "summary": "Read an owned image task",
        "operationId": "getImageTask",
        "parameters": [
          {
            "name": "task_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^task_[A-Za-z0-9]{1,64}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Processing, completed or failed task. Polling timeout is not a task failure.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Task"
                }
              }
            }
          },
          "401": {
            "description": "Public error; no infrastructure details.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Public error; no infrastructure details.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Public error; no infrastructure details.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer"
      }
    },
    "schemas": {
      "VideoRequest": {
        "$schema": "https://json-schema.org/draft/2020-12/schema",
        "type": "object",
        "properties": {
          "model": {
            "type": "string",
            "const": "kling-4-0-flash"
          },
          "prompt": {
            "type": "string",
            "maxLength": 8000,
            "description": "Up to 8000 characters. Mention materials as @image_1, @video_1 (numbered from 1 in each list) or @<element name>; every @ followed by a name character must name a material of this request."
          },
          "duration": {
            "type": "integer",
            "minimum": 3,
            "maximum": 20,
            "default": 5,
            "description": "3–20 seconds of output."
          },
          "resolution": {
            "type": "string",
            "enum": [
              "720p"
            ],
            "default": "720p",
            "description": "720p is the only output."
          },
          "aspect_ratio": {
            "type": "string",
            "enum": [
              "auto",
              "16:9",
              "9:16",
              "1:1",
              "21:9"
            ],
            "description": "Left out: auto when any reference material is given, 16:9 otherwise."
          },
          "image_urls": {
            "maxItems": 10,
            "type": "array",
            "items": {
              "type": "string",
              "format": "uri"
            },
            "description": "Reference images, up to 10, mentioned as @image_N in order."
          },
          "video_urls": {
            "maxItems": 5,
            "type": "array",
            "items": {
              "type": "string",
              "format": "uri"
            },
            "description": "Reference videos, up to 5 together with video elements, mentioned as @video_N. Reference videos and video elements together must be 2–20 seconds long; they are billed at the video-input rate."
          },
          "keep_original_sound": {
            "type": "boolean",
            "default": false,
            "description": "Keep the reference videos' own audio. Only with video_urls; otherwise the clip always gets new sound."
          },
          "elements": {
            "maxItems": 7,
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string",
                  "pattern": "^[一-龥A-Za-z0-9_]{1,20}$"
                },
                "type": {
                  "type": "string",
                  "enum": [
                    "image",
                    "video"
                  ]
                },
                "image_urls": {
                  "minItems": 2,
                  "maxItems": 4,
                  "type": "array",
                  "items": {
                    "type": "string",
                    "format": "uri"
                  }
                },
                "video_url": {
                  "type": "string",
                  "format": "uri"
                },
                "tag": {
                  "type": "string",
                  "enum": [
                    "character",
                    "animal",
                    "prop",
                    "costume",
                    "scene",
                    "effect",
                    "others"
                  ]
                },
                "description": {
                  "type": "string",
                  "maxLength": 100
                },
                "voice_url": {
                  "type": "string",
                  "format": "uri"
                }
              },
              "required": [
                "name"
              ],
              "additionalProperties": false
            },
            "description": "Subjects for this request, up to 7 (at most 3 video subjects), mentioned as @name. An image subject has 2–4 image_urls, the first being the main view; a video subject (type video) has one 3–8 second single-shot character video_url. voice_url binds reference audio to a character. image_urls, video_urls and elements together are at most 15 items."
          }
        },
        "required": [
          "model",
          "prompt"
        ],
        "additionalProperties": false
      },
      "TaskAccepted": {
        "type": "object",
        "required": [
          "id",
          "model",
          "status",
          "created_at"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "model": {
            "enum": [
              "kling-4-0-flash"
            ]
          },
          "status": {
            "const": "processing"
          },
          "created_at": {
            "type": "integer"
          }
        }
      },
      "Task": {
        "type": "object",
        "required": [
          "id",
          "model",
          "status",
          "created_at"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "model": {
            "enum": [
              "kling-4-0-flash"
            ]
          },
          "status": {
            "enum": [
              "processing",
              "completed",
              "failed"
            ]
          },
          "created_at": {
            "type": "integer"
          },
          "finished_at": {
            "type": "integer"
          },
          "output": {
            "type": "object",
            "properties": {
              "video_url": {
                "type": "string",
                "format": "uri"
              }
            }
          },
          "error": {
            "$ref": "#/components/schemas/Error"
          }
        }
      },
      "Error": {
        "type": "object",
        "required": [
          "code",
          "message"
        ],
        "properties": {
          "code": {
            "type": "integer",
            "enum": [
              10001,
              10002,
              20001,
              20002,
              30001,
              30002,
              50001,
              50002,
              50003,
              60001,
              60002,
              60003,
              60004,
              90001
            ]
          },
          "message": {
            "type": "string"
          }
        }
      },
      "ErrorResponse": {
        "type": "object",
        "properties": {
          "error": {
            "$ref": "#/components/schemas/Error"
          }
        }
      }
    }
  }
}
