Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.lemondata.cc/llms.txt

Use this file to discover all available pages before exploring further.

Path Parameters

id
string
required
The task ID returned from the initial image generation request.
If the create response included poll_url, prefer calling that exact URL for polling. Some image tasks may surface a poll_url under /v1/tasks/{id} instead of the image-specific status path.You can also poll public image task IDs such as ldtask_... at /v1/images/{id}. This compatibility alias uses the same authorization, ownership checks, billing headers, terminal snapshots, and response shape as /v1/images/generations/{id}.If the task no longer exists or can no longer be resolved through the public async-task contract, LemonData returns async_task_not_found with the message Task not found or no longer available.

Response

created
integer
Unix timestamp of creation.
task_id
string
The task identifier.
status
string
Task status: pending, processing, completed, or failed.
data
array
Array of generated images (populated when status is completed).Each object contains:
  • url (string): URL of the generated image
  • revised_prompt (string): The prompt used for generation
error
string
Error message (only present when status is failed).
curl "https://api.lemondata.cc/v1/tasks/ldtask_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
  -H "Authorization: Bearer sk-your-api-key"
{
  "created": 1706000000,
  "id": "ldtask_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "task_id": "ldtask_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "poll_url": "/v1/tasks/ldtask_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "status": "pending",
  "data": [
    {
      "url": "",
      "revised_prompt": "a beautiful sunset over mountains"
    }
  ]
}

Polling Best Practices

Recommended polling interval: 3-5 seconds. Most image generation tasks complete within 30-120 seconds depending on the model and routed provider path.
import requests
import time

def poll_image_task(task_id, api_key, max_wait=300, interval=3):
    """Poll for image generation result with timeout."""
    url = f"https://api.lemondata.cc/v1/tasks/{task_id}"
    headers = {"Authorization": f"Bearer {api_key}"}

    start_time = time.time()
    while time.time() - start_time < max_wait:
        response = requests.get(url, headers=headers)
        data = response.json()

        if data["status"] == "completed":
            return data["data"][0]["url"]
        elif data["status"] == "failed":
            raise Exception(data.get("error", "Generation failed"))

        time.sleep(interval)

    raise TimeoutError(f"Task {task_id} did not complete within {max_wait}s")

# Usage
image_url = poll_image_task("ldtask_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "sk-your-api-key")
print(f"Generated image: {image_url}")