Yol Parametreleri
Video oluşturma isteğinden dönen görev ID’si.
Yanıt
Görev durumu: pending, processing, completed, failed.
İlerleme yüzdesi (0-100).
Oluşturulan videonun URL’i (tamamlandığında).
Hata mesajı (başarısız olursa).
Oluşturulma zaman damgası.
Tamamlanma zaman damgası (tamamlandığında).
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
}
Polling En İyi Uygulamaları
- Her 5-10 saniyede bir sorgulama yapın
- Uzun süreli görevler için üstel geri çekilme (exponential backoff) uygulayın
- Maksimum bir zaman aşımı süresi belirleyin (örneğin 10 dakika)
failed durumunu uygun şekilde ele alın
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")