Appearance
查询视频任务(原生接口)
查询 predictLongRunning 提交的视频任务状态
查询任务状态
bash
curl "https://aiapi.fhddos.com/v1beta/operations/{operation_id}" \
-H "Authorization: Bearer $TOKEN"operation_id 来自创建任务时返回的 name 字段(如 operations/abc123xyz 中的 abc123xyz)。
响应示例
进行中
json
{
"name": "operations/abc123xyz",
"done": false
}已完成
json
{
"name": "operations/abc123xyz",
"done": true,
"response": {
"generateVideoResponse": {
"generatedSamples": [{
"video": {"uri": "https://.../video.mp4"},
"metadata": {
"durationSeconds": 6,
"size": "1280x720"
}
}]
}
}
}轮询建议
- 间隔 6-10 秒
- 超时设置 5-10 分钟
- 使用指数退避避免频繁请求
python
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")