使用 Kling 扩展图像
通过 CometAPI 使用 Kling 图像扩展 API,在原始边界之外扩展图像,并实现可控的外绘。
扩展比例的工作方式
- 每个比例都相对于原始宽度或高度来计算
- 扩展后的组合画布仍必须保持在 Kling 文档规定的面积限制内
- 在尝试更大范围的扩展之前,先从每一侧使用
0.1这类较小的值开始
请求流程
- 发送全部四个比例字段,对于不希望扩展的任意一侧使用
0 - 保存返回的
task_id - 轮询对应的 Kling 图像查询路径,直到任务进入终态
授权
Bearer token authentication. Use your CometAPI key.
请求头
Must be application/json.
请求体
Source image to expand. Image URL or raw Base64 string without a data: prefix. Supported formats: JPG, JPEG, PNG. Maximum 10 MB, minimum 300x300 px, aspect ratio between 1:2.5 and 2.5:1.
Upward expansion ratio as a multiple of the original image dimension. Range: 0-2. Send 0 for sides you do not want to expand.
0 <= x <= 2Downward expansion ratio as a multiple of the original image dimension. Range: 0-2. Send 0 for sides you do not want to expand.
0 <= x <= 2Leftward expansion ratio as a multiple of the original image dimension. Range: 0-2. Send 0 for sides you do not want to expand.
0 <= x <= 2Rightward expansion ratio as a multiple of the original image dimension. Range: 0-2. Send 0 for sides you do not want to expand.
0 <= x <= 2Optional text prompt to guide the expanded area content. Maximum 2500 characters.
Number of expanded images to generate. Range: 1-9.
1 <= x <= 9Watermark options.
Webhook URL for task status notifications.
Optional user-defined task ID for your own tracking. Must be unique per account.