Bearer token authentication. Use your CometAPI key.
请求头
Content-Type
string
Must be application/json.
请求体
application/json
prompt
string
必填
Text prompt describing the video to generate. Maximum 500 characters.
negative_prompt
string
Elements to exclude from the video. Maximum 200 characters.
aspect_ratio
enum<string>
Aspect ratio request. Typical rendered sizes are 1280x720 for 16:9, 720x1280 for 9:16, and 960x960 for 1:1. This endpoint does not expose an exact size field.
可用选项:
16:9,
9:16,
1:1
callback_url
string
Webhook URL to receive task status updates when the task completes.
model_name
enum<string>
默认值:kling-v1
Model ID for this text-to-video request. Use an ordinary Kling video model ID; use Omni model IDs only with the Omni Video endpoint.
可用选项:
kling-v1,
kling-v1-6,
kling-v2-master,
kling-v2-1-master,
kling-v2-5-turbo,
kling-v2-6,
kling-v3
cfg_scale
number
Prompt adherence strength. Higher values follow the prompt more closely. Range: 0–1.
mode
enum<string>
默认值:std
Generation mode. std for standard (faster), pro for professional (higher quality). The default is std.
可用选项:
std,
pro
duration
string
默认值:5
Output video length in seconds. Use 5 or 10; omit to use 5.
camera_control
object
Camera motion preset or manual configuration. Omit for automatic camera movement.
Show child attributes
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.
sound
enum<string>
Optional generated-audio switch for models that support video sound. Use on or off, or omit the field for the model default.
可用选项:
on,
off
响应
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
Show child attributes
最后修改于 2026年7月3日
⌘I
cURL
curl https://api.cometapi.com/kling/v1/videos/text2video \
-H "Authorization: Bearer $COMETAPI_KEY" \
-H "Content-Type: application/json" \
-d '{
"prompt": "A small ceramic cup on a wooden table, steam rising in soft morning light",
"model_name": "kling-v3",
"mode": "std",
"duration": "5",
"sound": "off"
}'
import os
import requests
response = requests.post(
"https://api.cometapi.com/kling/v1/videos/text2video",
headers={"Authorization": "Bearer " + os.environ["COMETAPI_KEY"]},
json={
"prompt": "A small ceramic cup on a wooden table, steam rising in soft morning light",
"model_name": "kling-v3",
"mode": "std",
"duration": "5",
"sound": "off"
},
)
result = response.json()
print(result.get("code"), result.get("data", {}).get("task_id"))
const response = await fetch("https://api.cometapi.com/kling/v1/videos/text2video", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.COMETAPI_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"prompt": "A small ceramic cup on a wooden table, steam rising in soft morning light",
"model_name": "kling-v3",
"mode": "std",
"duration": "5",
"sound": "off"
}),
});
const result = await response.json();
console.log(result.code, result.data?.task_id);