进阶 docs.leonardo.ai 2026-11-22 15:11:20 · 0 阅读

第45章 Leonardo.AI API 调用指南:使用 Kling O1 生成与编辑视频

Kling O1 本指南演示如何调用 Leonardo.AI REST API,使用 Kling O1 模型生成视频。 示例请求 curl --request POST \ --url https://cloud.leonardo.ai/api/rest/v2/generations \ --header 'accept: application/json' \ --header 'authorization: Bearer ' \ --header 'content-type: application/json' \ --data ' { "model": "kling-video-o-1", "public": false, "parameters": { "prompt": "The woman plays with the cat", "guidances": { "start_frame": [ { "image": { "id": "", "type": "UPLOADED" } } ], "end_frame": [ { "image": { "id": "", "type": "UPLOADED" } } ] }, "duration": 5, "width": 1080, "height": 1920 } } ' 示例请求 - 视频编辑 curl --request POST \ --url https://cloud.leonardo.ai/api/rest/v2/generations \ --header 'accept: application/json' \ --header 'authorization: Bearer ' \ --header 'content-type: application/json' \ --data ' { "model": "kling-video-o-1", "public": false, "parameters": { "prompt": "add @image1 to the background", "mode": "RESOLUTION_1080", "prompt_enhance": "OFF", "quantity": 1, "duration": 5, "seed": YOUR_SEED, "width": 1920, "height": 1080, "guidances": { "image_reference": [ { "image": { "id": "YOUR_UPLOADED_IMAGE_ID", "type": "UPLOADED" } } ], "video_reference_base": [ { "video": { "id": "YOUR_GENERATED_VIDEO_ID", "type": "GENERATED" } } ] } } } '
调用示例
API 请求端点、请求头与参数 端点 https://cloud.leonardo.ai/api/rest/v2/generations 请求头 --header "accept: application/json" \ --header "authorization: Bearer " \ --header "content-type: application/json" Body 参数 参数 类型 说明 duration number 生成视频的时长,可设为 5 或 10。 guidances.endframe array 最多 1 项,每项包含 image.id 和 image.type(GENERATED 或 UPLOADED)。仅在提供了 start_frame 且未提供 image_reference 时可用。 guidances.image_reference array 最多四个参考图片组成的数组,用于引导生成的视觉风格或内容。每项包含 image.id 和 image.type(GENERATED 或 UPLOADED)。仅在未提供 start_frame 或 end_frame 时可用。 guidances.start_frame array 最多 1 项,每项包含 image.id 和 image.type(GENERATED 或 UPLOADED)。仅在未提供 image_reference 时可用。 guidances.video_reference_base array 参考视频时长需为 3-10 秒;高度/宽度至少 720 像素,宽度不能超过 2160 像素。目前参考视频仅支持 GENERATED 类型。视频 ID 即对应图片的 image ID,也就是 generated_images 中该视频的 ID。 motion MP4 URL height number 设置输出视频的高度(像素)。 model string 指定用于生成的模型,需设为 kling-video-o-1。 prompt string 描述要生成的视频内容的文本,最长 2500 字符。 public boolean 控制生成的视频是公开(true)还是私有(false)。 width number 设置输出视频的宽度(像素)。 高度与宽度组合 API 支持以下宽高比组合的 width 和 height 参数: 宽高比 宽度 高度 16:9(横屏) 1920 1080 1:1(方形) 1440 1440 9:16(竖屏) 1080 1920 更新于 19 天前。此页面对你有帮助吗?

评论 (0)