查询生成任务
查询任务状态和生成结果。使用 Bearer 鉴权,仅可访问当前组织的任务。
http
GET /v2/generations/{id}
路径参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
id | string | 是 | 创建接口返回的任务 ID;正 int64 十进制字符串,无前导零 |
请求示例
将 SAND_GENERATION_ID 设为已保存的任务 ID;查询中断后仍使用同一 ID。
bash
export SAND_GENERATION_ID='123456789'
curl "https://api.sandai.cn/v2/generations/$SAND_GENERATION_ID" \
-H "Authorization: Bearer $SAND_API_KEY"
响应
查询成功返回 HTTP 200 OK 和 Cache-Control: no-store,任务执行结果由 status 表示。
json
{
"id": "123456789",
"status": "succeeded",
"output": {
"videoUrl": "https://files.example.com/video.mp4?signature=example",
"urlExpiresAt": "2026-11-02T03:00:00.000Z"
},
"error": null,
"createdAt": "2026-11-02T01:55:00.000Z"
}
以下五个顶层字段始终存在,时间使用 UTC RFC 3339 毫秒格式。
| 字段 | 类型 | 说明 |
|---|---|---|
id | string | 任务 ID |
status | string | 任务状态,见下表 |
output | object | null | succeeded 时返回结果对象;其他状态为 null |
output.videoUrl | string | null | 视频下载地址 |
output.urlExpiresAt | string | null | 下载地址过期时间 |
error | object | null | failed 时返回失败原因,其他状态为 null |
error.code | string | 任务失败码,见任务执行失败 |
error.message | string | 失败说明 |
createdAt | string | 任务创建时间 |
任务状态
| 状态 | 含义 | 处理方式 |
|---|---|---|
queued | 等待处理 | 继续查询 |
processing | 正在准备、生成或审核 | 继续查询 |
succeeded | 生成成功 | 检查下载地址后获取视频 |
failed | 生成或审核失败 | 停止查询,检查 error |
canceled | 任务已取消 | 停止查询 |
单个任务建议每 10 秒查询一次。多个任务请错开查询,并按组织查询配额延长间隔,详见限流、轮询与重试。
获取视频
检查 output 和 output.videoUrl 非空后下载,无需携带 API Key。链接有效期为 60 分钟,以 urlExpiresAt 为准;过期后重新查询获取新链接。
成功任务的产物不可用时,output.videoUrl 与 output.urlExpiresAt 可为 null。后续审核可能影响结果访问,请以最新查询为准。
任务不存在、已删除或属于其他组织时,返回 404 generation_not_found。其他请求错误见错误。
模型停用或模型访问权限被收回后,原组织仍可在任务保留期内按 ID 查询。