| Version | Quality | Duration | Price |
|---|---|---|---|
| v1 | std | 5s | $0.13 |
| v1 | std | 10s | $0.26 |
| v1 | pro | 5s | $0.46 |
| v1 | pro | 10s | $0.92 |
| v1.5/v1.6 | std | 5s | $0.26 |
| v1.5/v1.6 | std | 10s | $0.53 |
| v1.5/v1.6 | pro | 5s | $0.46 |
| v1.5/v1.6 | pro | 10s | $0.92 |
| v2-master | - | 5s | $1.32 |
| v2-master | - | 10s | $2.64 |
| v2-1 | std | 5s | $0.26 |
| v2-1 | std | 10s | $0.53 |
| v2-1 | pro | 5s | $0.46 |
| v2-1 | pro | 10s | $0.92 |
| v2-1-master | - | 5s | $1.32 |
| v2-1-master | - | 10s | $2.64 |
| v2-5-turbo | pro | 5s | $0.33 |
| v2-5-turbo | pro | 10s | $0.66 |
| v2-6 (no native audio) | pro | 5s | $0.33 |
| v2-6 (no native audio) | pro | 10s | $0.67 |
| v2-6 (native audio, no voice control) | pro | 5s | $0.67 |
| v2-6 (native audio, no voice control) | pro | 10s | $1.33 |
| v2-6 (native audio, with voice control) | pro | 5s | $0.80 |
| v2-6 (native audio, with voice control) | pro | 10s | $1.60 |
import requests
import os
# Get your CometAPI key from https://api.cometapi.com/console/token, and paste it here
COMETAPI_KEY = os.environ.get("COMETAPI_KEY") or "<YOUR_COMETAPI_KEY>"
BASE_URL = "https://api.cometapi.com/kling/v1"
headers = {
"Authorization": f"Bearer {COMETAPI_KEY}",
"Content-Type": "application/json",
}
# ============================================================
# Step 1: Create Video Task
# ============================================================
print("Step 1: Creating video task...")
create_payload = {
"prompt": "A happy scene of a vacation on the beach.",
"model_name": "kling-v2-6",
}
create_response = requests.post(
f"{BASE_URL}/videos/text2video", headers=headers, json=create_payload
)
create_result = create_response.json()
print(f"Create response: {create_result}")
# Extract task ID from the response
task_id = create_result.get("data", {}).get("task_id")
if not task_id:
print("Error: Failed to get task_id from response")
exit(1)
print(f"Task ID: {task_id}")
# ============================================================
# Step 2: Query Task Status
# ============================================================
print("
Step 2: Querying task status...")
query_response = requests.get(
f"{BASE_URL}/videos/text2video/{task_id}", headers=headers
)
query_result = query_response.json()
print(f"Query response: {query_result}")
# Check task status
task_status = query_result.get("data", {}).get("status") or query_result.get(
"data", {}
).get("task_status")
print(f"Task status: {task_status}")