Skip to main content
POST
cURL

Generowanie obrazów

Pełne informacje o parametrach znajdziesz w oficjalnej dokumentacji Kling.
Użyj tego endpointu, aby tworzyć statyczne obrazy za pomocą API generowania obrazów Kling. Obsługuje on zarówno żądania tekstowe, jak i żądania z obrazami referencyjnymi w ramach tego samego asynchronicznego przepływu zadań.

Pierwsze żądanie

Zacznij od model_name: kling-v3, prompt, n oraz aspect_ratio. Dodawaj obrazy referencyjne, ustawienia zgodności lub pola zaawansowane dopiero wtedy, gdy pierwsze żądanie zwróci użyteczne zadanie. Pominięcie model_name powoduje użycie starszej domyślnej wartości zgodności, dlatego w nowych integracjach wysyłaj jawnie kling-v3.

Odczytywanie odpowiedzi

Zapisz zwrócone task_id, a następnie odpytyj odpowiadającą trasę zapytania obrazu Kling, aż task_status osiągnie stan końcowy. Jeśli Twój workflow wymaga trwałego przechowywania, skopiuj końcowy zasób do własnej warstwy pamięci po zakończeniu generowania.

Autoryzacje

Authorization
string
header
wymagane

Bearer token authentication. Use your CometAPI key.

Nagłówki

Content-Type
string
domyślnie:application/json

Must be application/json.

Treść

application/json
prompt
string
wymagane

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

model_name
enum<string>
domyślnie:kling-v1

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

Dostępne opcje:
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.

Dostępne opcje:
subject,
face
image_fidelity
number
domyślnie:0.5

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

Wymagany zakres: 0 <= x <= 1
human_fidelity
number
domyślnie:0.45

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

Wymagany zakres: 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>
domyślnie:1k

Output resolution. Defaults to 1k.

Dostępne opcje:
1k,
2k
n
integer
domyślnie:1

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

Wymagany zakres: 1 <= x <= 9
aspect_ratio
enum<string>
domyślnie:16:9

Output aspect ratio (width:height).

Dostępne opcje:
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.

Odpowiedź

200 - application/json

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

code
wymagane

Response code. 0 means the task request was accepted.

message
string
wymagane

Response message.

data
object
wymagane
request_id
string

Request identifier returned when present.