Genera immagini con Kling
Genera immagini con Kling tramite CometAPI: POST /kling/v1/images/generations supporta la creazione di immagini guidata da prompt e la generazione con immagini di riferimento.
Generazione di immagini
Prima richiesta
Inizia conmodel_name: kling-v3, prompt, n e aspect_ratio. Aggiungi immagini di riferimento, controlli di fedeltà o campi avanzati solo dopo che la prima richiesta restituisce un task utilizzabile. Omettere model_name usa un valore predefinito legacy per la compatibilità, quindi invia esplicitamente kling-v3 per le nuove integrazioni.
Leggere la risposta
Salva iltask_id restituito, quindi interroga la route di query immagini Kling corrispondente finché task_status non raggiunge uno stato terminale. Se il tuo flusso di lavoro richiede uno storage persistente, copia l’asset finale nel tuo livello di storage dopo il completamento della generazione.Autorizzazioni
Bearer token authentication. Use your CometAPI key.
Intestazioni
Must be application/json.
Corpo
Text prompt describing the image to generate. Maximum 2500 characters.
Kling image model variant. Use kling-v3 for new requests. Omitting model_name uses the legacy CometAPI route default.
kling-v1, kling-v1-5, kling-v2, kling-v2-1, kling-v3 Elements to exclude from the image. Maximum 2500 characters. Not supported when image is provided.
Reference image as a raw Base64 string without a data: prefix, or a public URL. Accepted formats: JPG, JPEG, PNG. Maximum 10 MB, minimum 300x300 px, aspect ratio between 1:2.5 and 2.5:1.
Reference mode for legacy image-to-image requests when image is provided.
subject, face How closely the output follows the reference image. Range: 0-1. Used by legacy image-reference models.
0 <= x <= 1Human-subject fidelity control. Range: 0-1. Used only by legacy subject-reference requests.
0 <= x <= 1Optional Kling element references. The total count of element references and input images must not exceed 10.
Output resolution. Defaults to 1k.
1k, 2k Number of images to generate. Range: 1-9.
1 <= x <= 9Output aspect ratio (width:height).
16:9, 9:16, 1:1, 4:3, 3:4, 3:2, 2:3, 21:9 Watermark options.
Webhook URL to receive task status updates when the task completes.
Optional user-defined task ID for your own tracking. Must be unique per account.