Langsung ke konten utama
GET
/
v1
/
videos
/
generations
/
{id}
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
}

Parameter Path

task_id
string
wajib
ID tugas yang dikembalikan dari permintaan pembuatan video.

Respons

task_id
string
Pengidentifikasi tugas.
status
string
Status tugas: pending, processing, completed, failed.
progress
number
Persentase progres (0-100).
video_url
string
URL dari video yang dihasilkan (saat selesai).
error
string
Pesan kesalahan (jika gagal).
created_at
integer
Timestamp pembuatan.
completed_at
integer
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")