Path Parameters
The task ID returned from the create video request.
Response
Task status: pending, processing, completed, failed.
Progress percentage (0-100).
URL of the generated video (when completed).
Error message (if failed).
Completion timestamp (when done).
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 Best Practices
- Poll every 5-10 seconds
- Implement exponential backoff for long tasks
- Set a maximum timeout (e.g., 10 minutes)
- Handle
failed status gracefully
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")