Skip to main content

Path Parameters

id
string
required
The task ID returned from the create video request. Treat id and task_id as the same async identity.
If a create response returns poll_url, call that exact URL. When it points to /v1/tasks/{id}, treat that as the canonical fixed status endpoint.

Response

id
string
Canonical async task identifier.
task_id
string
Async task identifier alias.
poll_url
string
Preferred polling URL when the create response supplies one.
status
string
Task status: pending, processing, completed, failed.
progress
number
Progress percentage (0-100).
video_url
string
URL of the generated video (when completed).
video
object
Single video payload with url, duration, width, and height when available.
videos
array
Multiple video payloads when the upstream returns more than one output.
error
string
Error message (if failed).
created
integer
Creation timestamp.
updated
integer
Last update timestamp.
model
string
Model used for the task.
curl "https://api.lemondata.cc/v1/tasks/video_abc123" \
  -H "Authorization: Bearer sk-your-api-key"
{
  "id": "video_abc123",
  "task_id": "video_abc123",
  "poll_url": "/v1/tasks/video_abc123",
  "status": "pending",
  "progress": 0,
  "model": "sora-2",
  "created": 1706000000,
  "updated": 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/tasks/{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")