メインコンテンツへスキップ
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
タスクのステータス: pendingprocessingcompletedfailed
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秒ごとにポーリングを行う
  • 長時間のタスクにはエクスポネンシャルバックオフを実装する
  • 最大タイムアウト(例: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")