查询 predictLongRunning 提交的视频任务状态
curl "$BASE_URL/v1beta/operations/{operation_id}" \ -H "Authorization: Bearer $TOKEN"
operation_id
name
operations/abc123xyz
abc123xyz
{ "name": "operations/abc123xyz", "done": false }
{ "name": "operations/abc123xyz", "done": true, "response": { "generateVideoResponse": { "generatedSamples": [{ "video": {"uri": "https://.../video.mp4"}, "metadata": { "durationSeconds": 6, "size": "1280x720" } }] } } }
import time def poll_operation(op_id, timeout=600): start = time.time() interval = 6 while time.time() - start < timeout: resp = get_operation(op_id) if resp.get("done"): return resp time.sleep(interval) interval = min(interval * 1.5, 30) raise TimeoutError("Operation timed out")