Skip to main content
GET
https://console.mixroute.io
/
v1
/
video
/
generations
/
{task_id}
curl --request GET \
  --url https://console.mixroute.io/v1/video/generations/video_xxx \
  --header 'Authorization: Bearer sk-xxxxxxxxxx'
{
  "task_id": "video_xxx",
  "status": "succeeded",
  "format": "mp4",
  "url": "https://example.com/video.mp4"
}

简介

查询视频任务接口用于根据任务ID查询视频生成任务的状态和结果。提交任务后,您需要定期轮询此接口来检查任务状态,直到任务完成或失败。
建议每 3-5 秒轮询一次任务状态,直到任务状态变为 succeededfailed

认证

Bearer Token,如 Bearer sk-xxxxxxxxxx

路径参数

task_id
string
required
视频生成任务ID,由提交任务接口返回

任务状态

状态说明建议操作
queued任务已排队,等待处理继续轮询
in_progress任务正在处理中继续轮询
succeeded任务成功完成下载视频或获取视频URL
failed任务失败查看失败原因

cURL 示例

curl -X GET "https://console.mixroute.io/v1/video/generations/video_69095b4ce0048190893a01510c0c98b0" \
  -H "Authorization: Bearer sk-xxxxxxxxxx"

轮询示例

Python 示例

import requests
import time

def poll_task_status(task_id, api_key, max_wait_time=300):
    """轮询任务状态直到完成"""
    url = f"https://console.mixroute.io/v1/video/generations/{task_id}"
    headers = {"Authorization": f"Bearer {api_key}"}
    
    start_time = time.time()
    while True:
        response = requests.get(url, headers=headers)
        data = response.json()
        status = data.get("status")
        
        print(f"当前状态: {status}")
        
        if status == "succeeded":
            video_url = data.get("url")
            print(f"✅ 任务完成!视频URL: {video_url}")
            return video_url
        elif status == "failed":
            error_msg = data.get("error", {}).get("message", "未知错误")
            print(f"❌ 任务失败: {error_msg}")
            return None
        
        # 检查超时
        if time.time() - start_time > max_wait_time:
            print("⏰ 等待超时")
            return None
        
        # 等待5秒后再次查询
        time.sleep(5)

JavaScript 示例

async function pollTaskStatus(taskId, apiKey, maxWaitTime = 300000) {
  const url = `https://console.mixroute.io/v1/video/generations/${taskId}`;
  const headers = { 'Authorization': `Bearer ${apiKey}` };
  
  const startTime = Date.now();
  
  while (true) {
    const response = await fetch(url, { headers });
    const data = await response.json();
    const status = data.status;
    
    console.log(`当前状态: ${status}`);
    
    if (status === 'succeeded') {
      const videoUrl = data.url;
      console.log(`✅ 任务完成!视频URL: ${videoUrl}`);
      return videoUrl;
    } else if (status === 'failed') {
      const errorMsg = data.error?.message || '未知错误';
      console.error(`❌ 任务失败: ${errorMsg}`);
      throw new Error(errorMsg);
    }
    
    // 检查超时
    if (Date.now() - startTime > maxWaitTime) {
      throw new Error('等待超时');
    }
    
    // 等待5秒后再次查询
    await new Promise(resolve => setTimeout(resolve, 5000));
  }
}

响应示例

任务排队中

{
  "task_id": "video_69095b4ce0048190893a01510c0c98b0",
  "status": "queued",
  "format": "mp4"
}

任务处理中

{
  "task_id": "video_69095b4ce0048190893a01510c0c98b0",
  "status": "in_progress",
  "format": "mp4"
}

任务成功(Veo/阿里万相/豆包 Seedance)

{
  "task_id": "video_69095b4ce0048190893a01510c0c98b0",
  "status": "succeeded",
  "format": "mp4",
  "url": "https://nebula-ads.oss-cn-guangzhou.aliyuncs.com/2025/11/18/abc123/video.mp4"
}
Veo 和阿里万相在任务成功后,视频URL直接包含在响应中。

任务成功(Sora 2)

{
  "task_id": "video_69095b4ce0048190893a01510c0c98b0",
  "status": "succeeded",
  "format": "mp4"
}
Sora 2 模型的视频不会直接返回 URL,需要调用下载视频接口获取视频数据。

任务失败

{
  "task_id": "video_69095b4ce0048190893a01510c0c98b0",
  "status": "failed",
  "format": "mp4",
  "error": {
    "code": 400,
    "message": "提示词包含不当内容"
  }
}

响应字段说明

字段名类型说明
task_idstring任务ID
statusstring任务状态
formatstring视频格式
urlstring视频下载URL(除 Sora 2 外的模型)
errorobject错误信息(失败时返回)

不同模型的差异

模型返回 URL备注
Sora 2需调用下载接口
Veo直接返回视频URL
阿里万相直接返回视频URL
豆包 Seedance直接返回视频URL

注意事项

  • 不同模型的响应字段可能略有差异
  • 建议实现指数退避策略,避免频繁请求
  • 视频生成通常需要 30 秒到数分钟不等,请耐心等待
curl --request GET \
  --url https://console.mixroute.io/v1/video/generations/video_xxx \
  --header 'Authorization: Bearer sk-xxxxxxxxxx'
{
  "task_id": "video_xxx",
  "status": "succeeded",
  "format": "mp4",
  "url": "https://example.com/video.mp4"
}