메인 콘텐츠로 건너뛰기
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
}

경로 파라미터

task_id
string
필수
비디오 생성 요청에서 반환된 작업 ID입니다.

응답

task_id
string
작업 식별자.
status
string
작업 상태: pending, processing, completed, failed.
progress
number
진행률 백분율 (0-100).
video_url
string
생성된 비디오의 URL (완료 시).
error
string
에러 메시지 (실패 시).
created_at
integer
생성 타임스탬프.
completed_at
integer
완료 타임스탬프 (완료 시).
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
}

폴링 권장 사항

  • 5-10초마다 폴링을 수행하세요.
  • 시간이 오래 걸리는 작업의 경우 지수 백오프(exponential backoff)를 구현하세요.
  • 최대 타임아웃을 설정하세요 (예: 10분).
  • failed 상태를 적절하게 처리하세요.
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")