用户生图(视频)任务详情

查询当前登录用户提交的自定义生图或生视频任务状态。

请求URL:

  • /getGenerateTaskInfo

请求方式:

  • POST

header:

参数名 必选 类型 说明
Authorization string 授权Token,格式:Bearer {token}

参数:

参数名 必选 类型 说明
appId string App唯一标识
udid string 唯一设备ID
taskId uint 提交生成任务时返回的任务ID

请求示例:

{
    "appId": "com.example.app",
    "udid": "device-uuid",
    "taskId": 790110
}

执行中返回示例:

{
    "code": 200,
    "msg": "SUCCESS",
    "data": {
        "id": 790110,
        "type": 9,
        "state": 20,
        "path": "",
        "reason": "",
        "cost": 14,
        "startTime": 1785398400,
        "elapsedTime": 3
    }
}

成功返回示例:

{
    "code": 200,
    "msg": "SUCCESS",
    "data": {
        "id": 790110,
        "type": 9,
        "state": 30,
        "path": "https://cdn.example.com/aiChat/media/original/video.mp4",
        "reason": "",
        "cost": 14,
        "startTime": 1785398400,
        "elapsedTime": 38
    }
}

失败返回示例:

{
    "code": 200,
    "msg": "SUCCESS",
    "data": {
        "id": 790110,
        "type": 9,
        "state": 2,
        "path": "",
        "reason": "tensor.art job failed",
        "cost": 14,
        "startTime": 1785398400,
        "elapsedTime": 5
    }
}

返回参数说明:

参数名 类型 说明
code int 状态码
msg string 提示信息
data struct 任务数据
- id uint 任务ID
- type uint8 主动生成任务类型:8-生图;9-生视频
- state uint8 任务状态:2-失败;5-准备参数;10-等待执行;20-执行中;30-执行成功
- path string 生成成功后的图片或视频完整地址
- reason string 失败原因;非失败状态通常为空
- cost uint 本次实际消耗钻石数
- startTime int64 任务开始时间,Unix秒时间戳
- elapsedTime uint 任务耗时,单位秒

备注:

  • 只能查询当前登录用户通过 /submitGenerateMedia 创建的任务。
  • 建议在状态为5、10或20时继续轮询;状态为2或30时停止轮询。
  • 任务失败时系统会自动退还本次任务消耗的钻石。

1. SSE任务结果通知

任务成功或失败后,服务端会向当前用户推送任务结果。顶层 type 与任务状态一致:30表示成功,2表示失败。

成功通知示例:

{
    "type": 30,
    "msg": "task success",
    "data": {
        "taskId": 790110,
        "dialogueId": 0,
        "roleId": 0,
        "recordId": 0,
        "type": 9,
        "apiCode": 0,
        "state": 30,
        "thumbFileUrl": "",
        "fileUrl": "https://cdn.example.com/aiChat/media/original/video.mp4",
        "reason": ""
    }
}

失败通知示例:

{
    "type": 2,
    "msg": "task fail",
    "data": {
        "taskId": 790110,
        "dialogueId": 0,
        "roleId": 0,
        "recordId": 0,
        "type": 9,
        "apiCode": 0,
        "state": 2,
        "thumbFileUrl": "",
        "fileUrl": "",
        "reason": "tensor.art job failed"
    }
}
参数名 类型 说明
type uint8 消息类型,与任务状态一致:2-失败;30-成功
msg string 任务状态说明
data struct 任务结果
- taskId uint 任务ID,用于关联提交接口返回的任务
- dialogueId uint 会话ID;用户自定义生成任务固定为0
- roleId uint 角色ID;用户自定义生成任务固定为0
- recordId uint 聊天记录ID;用户自定义生成任务固定为0
- type uint8 主动生成任务类型:8-生图;9-生视频
- apiCode int 三方接口状态码;无特殊状态时为0
- state uint8 任务状态:2-失败;30-成功
- thumbFileUrl string 缩略文件地址;没有缩略文件时为空
- fileUrl string 生成成功后的图片或视频完整地址
- reason string 失败原因;成功时为空

错误码:

  • 510 系统异常
  • 670 登录失效
  • 800 参数错误
  • 900 任务不存在或不属于当前用户
2021 © Live all right reserved,powered by Gitbook该文件修订时间: 2026-08-10 18:19:52

results matching ""

    No results matching ""