建立 Kling Omni 圖像任務
使用 CometAPI POST /kling/v1/images/omni-image,透過 prompt 與參考圖片輸入建立 Kling Omni Image 任務。
task_id;請使用 取得 Kling Omni 圖像任務 輪詢任務,直到產生的圖片 URL 可用為止。
選擇請求格式
- 單張圖片生成:傳送
prompt、image_list、resolution、result_type: single、n與aspect_ratio - 含浮水印輸出:當你需要在查詢回應中取得含浮水印的結果 URL 時,加入
watermark_info.enabled: true - model ID:省略
model_name以使用路由預設值,或傳送經測試的 Omni Image model ID,例如kling-image-o1或kling-v3-omni
image 欄位的 image_list 項目。Prompt 可以用索引引用它們,例如第一個項目使用 <<<image_1>>>,第二個項目使用 <<<image_2>>>。
任務流程
建立任務
POST /kling/v1/images/omni-image 並儲存回傳的 data.task_id。查詢任務
data.task_status 為 succeed 或 failed。保存圖片
data.task_result.images[].url 複製到你自己的儲存空間。結果欄位
成功的查詢回應會在data.task_result.images 下回傳生成的圖片。每個項目可能包含:
授權
Bearer token authentication. Use your CometAPI API key.
標頭
Must be application/json.
主體
Text prompt for the generated image. The prompt can reference images with <<<image_1>>>, <<<image_2>>>, and matching indexes from image_list. Maximum length is 2,500 characters.
Optional model ID for this Omni Image request. Omit this field to use the route default.
Reference images that the prompt can cite with <<<image_1>>>, <<<image_2>>>, and so on. Keep the total number of reference images within the provider limits for the selected model.
Requested output resolution. Use 1k, 2k, or 4k; omitted requests use 1k.
1k, 2k, 4k Use single for a single-image task.
single Number of single-image results to generate. Range: 1 to 9.
1 <= x <= 9Requested output aspect ratio in width:height format. Use auto to let the provider choose from the prompt and references.
16:9, 9:16, 1:1, 4:3, 3:4, 3:2, 2:3, 21:9, auto Watermark options. When enabled is true, the task can return watermarked result URLs in addition to the original result URLs.
Webhook URL that receives task status notifications when the task status changes. Omit this field to poll manually.
User-defined task ID for your own tracking. It does not replace the system-generated task_id and must be unique per account.