Skip to main content
POST
cURL

Geração de imagens

Para a referência completa de parâmetros, consulte a documentação oficial do Kling.
Use este endpoint para criar imagens estáticas por meio da API de geração de imagens do Kling. Ele oferece suporte a solicitações somente com texto e a solicitações com referência de imagem por meio do mesmo fluxo de tarefa assíncrona.

Primeira solicitação

Comece com model_name: kling-v3, prompt, n e aspect_ratio. Adicione imagens de referência, controles de fidelidade ou campos avançados somente depois que a primeira solicitação retornar uma tarefa utilizável. Omitir model_name usa um padrão legado de compatibilidade, então envie kling-v3 explicitamente em novas integrações.

Leia a resposta

Salve o task_id retornado e, em seguida, faça polling da rota de consulta de imagens Kling correspondente até que task_status atinja um estado terminal. Se o seu fluxo de trabalho precisar de armazenamento persistente, copie o asset final para sua própria camada de armazenamento após a conclusão da geração.

Autorizações

Authorization
string
header
obrigatório

Bearer token authentication. Use your CometAPI key.

Cabeçalhos

Content-Type
string
padrão:application/json

Must be application/json.

Corpo

application/json
prompt
string
obrigatório

Text prompt describing the image to generate. Maximum 2500 characters.

model_name
enum<string>
padrão:kling-v1

Kling image model variant. Use kling-v3 for new requests. Omitting model_name uses the legacy CometAPI route default.

Opções disponíveis:
kling-v1,
kling-v1-5,
kling-v2,
kling-v2-1,
kling-v3
negative_prompt
string

Elements to exclude from the image. Maximum 2500 characters. Not supported when image is provided.

image
string

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.

image_reference
enum<string>

Reference mode for legacy image-to-image requests when image is provided.

Opções disponíveis:
subject,
face
image_fidelity
number
padrão:0.5

How closely the output follows the reference image. Range: 0-1. Used by legacy image-reference models.

Intervalo necessário: 0 <= x <= 1
human_fidelity
number
padrão:0.45

Human-subject fidelity control. Range: 0-1. Used only by legacy subject-reference requests.

Intervalo necessário: 0 <= x <= 1
element_list
object[]

Optional Kling element references. The total count of element references and input images must not exceed 10.

resolution
enum<string>
padrão:1k

Output resolution. Defaults to 1k.

Opções disponíveis:
1k,
2k
n
integer
padrão:1

Number of images to generate. Range: 1-9.

Intervalo necessário: 1 <= x <= 9
aspect_ratio
enum<string>
padrão:16:9

Output aspect ratio (width:height).

Opções disponíveis:
16:9,
9:16,
1:1,
4:3,
3:4,
3:2,
2:3,
21:9
watermark_info
object

Watermark options.

callback_url
string

Webhook URL to receive task status updates when the task completes.

external_task_id
string

Optional user-defined task ID for your own tracking. Must be unique per account.

Resposta

200 - application/json

Task request accepted or an error response returned by the API.

code
obrigatório

Response code. 0 means the task request was accepted.

message
string
obrigatório

Response message.

data
object
obrigatório
request_id
string

Request identifier returned when present.