Przejdź do głównej treści
POST
/
kling
/
v1
/
videos
/
text2video
Text to Video
curl --request POST \
  --url https://api.cometapi.com/kling/v1/videos/text2video \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "prompt": "A happy scene of a vacation on the beach."
}
'
{
  "code": 123,
  "message": "<string>",
  "request_id": "<string>",
  "data": {
    "task_id": "<string>",
    "task_status": "<string>",
    "created_at": 123,
    "updated_at": 123
  }
}
Użyj tego endpointu, aby utworzyć zadanie Kling text-to-video na podstawie promptu. Uruchamia ono zadanie asynchroniczne zamiast od razu zwracać gotowe wideo.

Pierwsze działające żądanie

  • Najpierw wyślij krótki prompt
  • Dodaj aspect_ratio, duration lub mode dopiero wtedy, gdy podstawowy przepływ zacznie działać
  • Ustaw callback_url, jeśli chcesz dostarczanie typu push zamiast samego odpytywania

Przepływ zadania

1

Prześlij żądanie generowania

Utwórz zadanie za pomocą tego endpointu i zapisz zwrócony identyfikator zadania Kling.
2

Sprawdzaj stan zadania

Monitoruj postęp przez Pojedyncze zapytania, aż zadanie osiągnie stan końcowy.
3

Zapisz wynik

Gdy Kling zwróci metadane gotowego zasobu, przenieś wynik do własnego magazynu danych, jeśli potrzebujesz długiego okresu przechowywania.
Pełną macierz parametrów i szczegóły dotyczące ścieżek modeli znajdziesz w oficjalnej dokumentacji Kling.

Autoryzacje

Authorization
string
header
wymagane

Bearer token authentication. Use your CometAPI key.

Nagłówki

Content-Type
string

Must be application/json.

Treść

application/json
prompt
string
domyślnie:Hello
wymagane

Text prompt describing the video to generate. Maximum 500 characters.

negative_prompt
string

Elements to exclude from the video. Maximum 200 characters.

aspect_ratio
string

Output aspect ratio (width:height). Options: 16:9, 9:16, 1:1, 4:3, 3:4, 3:2, 2:3.

callback_url
string

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

model_name
string

Kling model variant to use. See the Models page for current options.

cfg_scale
number

Prompt adherence strength. Higher values follow the prompt more closely. Range: 0–1.

mode
enum<string>

Generation mode. std for standard (faster), pro for professional (higher quality).

Dostępne opcje:
std,
pro
duration
string

Output video length in seconds. Options: 5, 10.

camera_control
object

Camera motion preset or manual configuration. Omit for automatic camera movement.

external_task_id
string

Custom task id for your own tracking. Does not replace the system-generated task id but can be used to query tasks. Must be unique per user.

Odpowiedź

200 - application/json

Successful Response

code
integer

Error code; specifically define the error code

message
string

error message

request_id
string

Request ID, system-generated, for tracking requests, troubleshooting issues

data
object