图生视频

POST /kling/image-to-video/kling-3.0-turbo

MethodPOST
Path/kling/image-to-video/kling-3.0-turbo
Typehttp
Status-2
Module2102810
Folder89080955

概览

MethodPOST
Path/kling/image-to-video/kling-3.0-turbo
Typehttp
Status-2
Module2102810
Folder89080955

请求体

{
  "type": "application/json",
  "parameters": [],
  "jsonSchema": {
    "type": "object",
    "description": "可灵 3.0 Turbo 图生视频请求体。contents 为必填,至少包含一个 type=first_frame 的首帧图片项。body 原样透传上游,settings 无默认值补全(建议显式填写)。",
    "required": [
      "contents"
    ],
    "additionalProperties": true,
    "properties": {
      "contents": {
        "type": "array",
        "description": "内容数组,必填。规则:① 至少一个 type=first_frame 项(必须有 url);② 可附加 type=prompt 项(text 最多 2500 字符);③ type 仅支持 prompt / first_frame,其他值报 400。",
        "minItems": 1,
        "items": {
          "oneOf": [
            {
              "type": "object",
              "description": "首帧图片(必须至少一个)",
              "required": [
                "type",
                "url"
              ],
              "additionalProperties": false,
              "properties": {
                "type": {
                  "type": "string",
                  "const": "first_frame"
                },
                "url": {
                  "type": "string",
                  "format": "uri",
                  "description": "首帧图片的公网可访问 URL。上游约束:格式 jpg/jpeg/png(不支持 webp);大小 ≤ 50MB;宽/高各 ≥ 300px;图片宽高比须在 1:2.5 ~ 2.5:1 范围内,否则上游返回错误。"
                }
              },
              "x-apifox-orders": [
                "type",
                "url"
              ]
            },
            {
              "type": "object",
              "description": "文本提示词(可选,最多一个)",
              "required": [
                "type",
                "text"
              ],
              "additionalProperties": false,
              "properties": {
                "type": {
                  "type": "string",
                  "const": "prompt"
                },
                "text": {
                  "type": "string",
                  "description": "提示词文本,最多 2500 字符(图生限制,低于文生的 3072)。",
                  "minLength": 1,
                  "maxLength": 2500
                }
              },
              "x-apifox-orders": [
                "type",
                "text"
              ]
            }
          ]
        }
      },
      "settings": {
        "type": "object",
        "description": "生成参数,全部可选。⚠️ 图生视频 body 原样透传上游,缺失 settings 时不补默认值,建议显式填写。",
        "additionalProperties": false,
        "properties": {
          "resolution": {
            "type": "string",
            "description": "输出分辨率。1080p 计费约 1.5×。",
            "enum": [
              "720p",
              "1080p"
            ],
            "x-apifox-enum": [
              {
                "value": "720p",
                "name": "标清 720p",
                "description": "基准计费倍率"
              },
              {
                "value": "1080p",
                "name": "高清 1080p",
                "description": "计费倍率约 1.5×"
              }
            ]
          },
          "aspect_ratio": {
            "type": "string",
            "description": "画面宽高比。⚠️ 官方说明:图生视频的宽高比由首帧图片决定,此字段对上游实际无效;但网关仍用它计算计费,建议与首帧图片的实际比例保持一致(或不传)。",
            "enum": [
              "16:9",
              "9:16",
              "1:1"
            ],
            "x-apifox-enum": [
              {
                "value": "16:9",
                "name": "横屏 16:9",
                "description": "上游忽略,计费参考用"
              },
              {
                "value": "9:16",
                "name": "竖屏 9:16",
                "description": "上游忽略,计费参考用"
              },
              {
                "value": "1:1",
                "name": "方形 1:1",
                "description": "上游忽略,计费参考用"
              }
            ]
          },
          "duration": {
            "type": "integer",
            "description": "视频时长(秒),范围 3–15。计费金额与时长线性正相关。",
            "minimum": 3,
            "maximum": 15
          }
        },
        "x-apifox-orders": [
          "resolution",
          "aspect_ratio",
          "duration"
        ]
      },
      "options": {
        "type": "object",
        "description": "任务控制参数,全部可选。",
        "additionalProperties": false,
        "properties": {
          "callback_url": {
            "type": "string",
            "format": "uri",
            "description": "任务完成后上游回调的 URL。"
          },
          "external_task_id": {
            "type": "string",
            "description": "业务侧自定义任务 ID,便于幂等查询。"
          },
          "watermark_info": {
            "type": "object",
            "description": "水印配置,原样透传。",
            "properties": {},
            "x-apifox-orders": []
          }
        },
        "x-apifox-orders": [
          "callback_url",
          "external_task_id",
          "watermark_info"
        ]
      }
    },
    "$comment": "contents 中至少一个 type=first_frame 项,否则返回 400: contents must include at least one first_frame item。",
    "x-apifox-orders": [
      "contents",
      "settings",
      "options"
    ]
  },
  "required": true,
  "mediaType": "",
  "examples": [
    {
      "mediaType": "application/json",
      "value": "{\r\n  \"contents\": [\r\n    {\r\n      \"type\": \"first_frame\",\r\n      \"url\": \"{{first_frame_url}}\"\r\n    }\r\n  ],\r\n  \"settings\": {\r\n    \"resolution\": \"720p\",\r\n    \"aspect_ratio\": \"16:9\",\r\n    \"duration\": 5\r\n  }\r\n}",
      "name": "新手推荐:图生视频 · 最简请求(仅首帧)"
    },
    {
      "name": "新手推荐:图生视频 · 首帧 + 提示词",
      "value": "{\r\n    \"contents\": [\r\n        {\r\n            \"type\": \"first_frame\",\r\n            \"url\": \"{{first_frame_url}}\"\r\n        },\r\n        {\r\n            \"type\": \"prompt\",\r\n            \"text\": \"The character slowly turns around and waves, soft natural lighting, smooth camera movement\"\r\n        }\r\n    ],\r\n    \"settings\": {\r\n        \"resolution\": \"720p\",\r\n        \"aspect_ratio\": \"16:9\",\r\n        \"duration\": 5\r\n    }\r\n}",
      "mediaType": "application/json"
    },
    {
      "name": "新手推荐:图生视频 · 竖屏首帧",
      "value": "{\r\n  \"contents\": [\r\n    {\r\n      \"type\": \"first_frame\",\r\n      \"url\": \"{{first_frame_url}}\"\r\n    }\r\n  ],\r\n  \"settings\": {\r\n    \"resolution\": \"720p\",\r\n    \"aspect_ratio\": \"9:16\",\r\n    \"duration\": 5\r\n  }\r\n}",
      "mediaType": "application/json"
    },
    {
      "name": "进阶推荐:图生视频 · 1080p 高清 + 提示词引导",
      "value": "{\r\n  \"contents\": [\r\n    {\r\n      \"type\": \"first_frame\",\r\n      \"url\": \"{{first_frame_url}}\"\r\n    },\r\n    {\r\n      \"type\": \"prompt\",\r\n      \"text\": \"Camera slowly zooms in, subject smiles gently, wind blows hair slightly\"\r\n    }\r\n  ],\r\n  \"settings\": {\r\n    \"resolution\": \"1080p\",\r\n    \"aspect_ratio\": \"16:9\",\r\n    \"duration\": 5\r\n  }\r\n}",
      "mediaType": "application/json"
    },
    {
      "name": "进阶推荐:图生视频 · 1080p 竖屏长视频 + 回调",
      "value": "{\r\n  \"contents\": [\r\n    {\r\n      \"type\": \"first_frame\",\r\n      \"url\": \"{{first_frame_url}}\"\r\n    },\r\n    {\r\n      \"type\": \"prompt\",\r\n      \"text\": \"Subject walks forward confidently, dynamic background blur, cinematic style\"\r\n    }\r\n  ],\r\n  \"settings\": {\r\n    \"resolution\": \"1080p\",\r\n    \"aspect_ratio\": \"9:16\",\r\n    \"duration\": 10\r\n  },\r\n  \"options\": {\r\n    \"external_task_id\": \"biz-img2v-20240623-001\",\r\n    \"callback_url\": \"https://your-server.com/webhook/kling\"\r\n  }\r\n}",
      "mediaType": "application/json"
    },
    {
      "name": "进阶推荐:图生视频 · 方形 1:1 社交媒体",
      "value": "{\r\n    \"contents\": [\r\n        {\r\n            \"type\": \"first_frame\",\r\n            \"url\": \"{{first_frame_url}}\"\r\n        },\r\n        {\r\n            \"type\": \"prompt\",\r\n            \"text\": \"Flower petals gently swaying, bokeh background shimmers, dreamy atmosphere\"\r\n        }\r\n    ],\r\n    \"settings\": {\r\n        \"resolution\": \"720p\",\r\n        \"aspect_ratio\": \"1:1\",\r\n        \"duration\": 5\r\n    }\r\n}",
      "mediaType": "application/json"
    }
  ],
  "oasExtensions": ""
}

响应

[
  {
    "id": 140353437,
    "name": "成功",
    "code": 200,
    "contentType": "json",
    "jsonSchema": {
      "type": "object",
      "required": [
        "code",
        "message",
        "data"
      ],
      "properties": {
        "code": {
          "type": "integer",
          "description": "0 = 成功;非 0 = 失败,详见 message 字段"
        },
        "message": {
          "type": "string"
        },
        "request_id": {
          "type": "string",
          "description": "上游请求 ID,排查问题时提供给上游支持"
        },
        "data": {
          "type": "object",
          "description": "任务信息。id 与 task_id 均可能携带任务 ID,优先取 id。",
          "properties": {
            "id": {
              "type": "string",
              "description": "任务 ID(优先)"
            },
            "task_id": {
              "type": "string",
              "description": "任务 ID(备用,部分上游返回此字段)"
            },
            "status": {
              "type": "string",
              "description": "初始任务状态,如 submitted / queued"
            },
            "task_status": {
              "type": "string",
              "description": "同 status,字段名因上游而异"
            }
          },
          "x-apifox-orders": [
            "id",
            "task_id",
            "status",
            "task_status"
          ]
        }
      },
      "x-apifox-orders": [
        "code",
        "message",
        "request_id",
        "data"
      ]
    },
    "itemSchema": {},
    "description": "",
    "mediaType": "",
    "headers": []
  }
]