Parameter Path
ID tugas yang dikembalikan dari permintaan pembuatan video.
Respons
Status tugas: pending, processing, completed, failed.
Persentase progres (0-100).
URL dari video yang dihasilkan (saat selesai).
Pesan kesalahan (jika gagal).
Timestamp penyelesaian (saat selesai).
curl "https://api.lemondata.cc/v1/videos/generations/video_abc123" \
-H "Authorization: Bearer sk-your-api-key"
{
"task_id": "video_abc123",
"status": "pending",
"progress": 0,
"model": "kling-v2.6-pro",
"created_at": 1706000000
}
Praktik Terbaik Polling
- Lakukan polling setiap 5-10 detik
- Terapkan exponential backoff untuk tugas yang lama
- Atur batas waktu maksimum (misalnya, 10 menit)
- Tangani status
failed dengan baik
import time
def wait_for_video(task_id, max_wait=600, interval=5):
"""Wait for video with timeout."""
start = time.time()
while time.time() - start < max_wait:
response = requests.get(
f"https://api.lemondata.cc/v1/videos/generations/{task_id}",
headers={"Authorization": "Bearer sk-your-api-key"}
)
data = response.json()
if data["status"] == "completed":
return data["video_url"]
elif data["status"] == "failed":
raise Exception(data.get("error", "Video generation failed"))
time.sleep(interval)
raise TimeoutError("Video generation timed out")