# Grok Imagine 视频任务状态

> 视频生成

查询异步视频生成任务状态。任务完成后，响应中会包含视频结果 URL、用量信息或错误信息。

## 请求地址

`GET https://api.modelverse.cn/v1/tasks/status`

## 请求参数

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| task_id | query | string | Yes | 异步任务标识符，由 `/v1/tasks/submit` 返回。 |

## 响应

- **200** — 任务状态响应。
- **400** — 请求参数无效。
- **default** — 错误响应。

## OpenAPI 定义

```json
{
  "openapi": "3.1.0",
  "x-language": "zh-CN",
  "info": {
    "title": "Grok Imagine Video 接口文档",
    "version": "1.0.0",
    "description": "这是 ModelVerse 上 `grok-imagine-video` 的视频接口文档，说明如何提交图生视频任务、参考生视频任务、查询任务状态、读取视频结果以及处理错误。\n接口路径包括 `POST /v1/tasks/submit`、`GET /v1/tasks/status`。\n"
  },
  "servers": [
    {
      "url": "https://api.modelverse.cn",
      "description": "ModelVerse API endpoint for Grok Imagine Video model."
    }
  ],
  "tags": [
    {
      "name": "GrokImagineVideo",
      "description": "Grok Imagine Video asynchronous task operations."
    }
  ],
  "paths": {
    "/v1/tasks/submit": {
      "post": {
        "tags": [
          "GrokImagineVideo"
        ],
        "operationId": "submitGrokImagineVideoTask",
        "summary": "Grok Imagine 视频生成",
        "description": "提交异步视频生成任务。支持图生视频和参考生视频两种模式。\n- 图生视频：使用 `img_url` 参数传入单张图片 URL\n- 参考生视频：使用 `reference_urls` 参数传入多张参考图片 URL 数组\n支持模型：`grok-imagine-video`\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/GrokImagineVideoSubmitRequest"
              },
              "examples": {
                "imageToVideo": {
                  "summary": "图生视频",
                  "value": {
                    "model": "grok-imagine-video",
                    "input": {
                      "img_url": "https://xxxxx/xxxx.png",
                      "prompt": "一个宁静的日出湖泊，薄雾在水面翻滚弥漫"
                    },
                    "parameters": {
                      "resolution": "720p",
                      "aspect_ratio": "16:9",
                      "duration": 8
                    }
                  }
                },
                "referenceToVideo": {
                  "summary": "参考生视频",
                  "value": {
                    "model": "grok-imagine-video",
                    "input": {
                      "reference_urls": [
                        "https://xxxxx/xxxx.png",
                        "https://xxxxx/xxxx.jpg",
                        "https://xxxxx/xxxx.jpeg"
                      ],
                      "prompt": "一个宁静的日出湖泊，薄雾在水面翻滚弥漫，两只动物在嬉闹"
                    },
                    "parameters": {
                      "resolution": "720p",
                      "aspect_ratio": "16:9",
                      "duration": 7
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "任务提交成功。",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GrokImagineVideoSubmitResponse"
                },
                "examples": {
                  "submitted": {
                    "summary": "已提交任务",
                    "value": {
                      "output": {
                        "task_id": "6a3179a0-d86a-99bf-acc4-144636e0b1f6"
                      },
                      "request_id": "6c6ade6b-3b81-4d01-9731-002cfd5381c1"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "请求参数无效。",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GrokImagineVideoErrorResponse"
                }
              }
            }
          },
          "default": {
            "description": "错误响应。",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GrokImagineVideoErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/v1/tasks/status": {
      "get": {
        "tags": [
          "GrokImagineVideo"
        ],
        "operationId": "getGrokImagineVideoTaskStatus",
        "summary": "Grok Imagine 视频任务状态",
        "description": "查询异步视频生成任务状态。任务完成后，响应中会包含视频结果 URL、用量信息或错误信息。\n",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "task_id",
            "in": "query",
            "required": true,
            "description": "异步任务标识符，由 `/v1/tasks/submit` 返回。",
            "schema": {
              "type": "string"
            },
            "examples": {
              "placeholder": {
                "summary": "任务 ID 示例",
                "value": "27f25fe6-f3b6-9ad3-9ce1-93aed4912505"
              }
            }
          }
        ],
        "responses": {
          "200": {
            "description": "任务状态响应。",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GrokImagineVideoStatusResponse"
                },
                "examples": {
                  "success": {
                    "summary": "成功任务",
                    "value": {
                      "output": {
                        "task_id": "df83b536-32d3-95d8-8c99-c54224a604b2",
                        "task_status": "Success",
                        "urls": [
                          "https://vidgen.x.ai/xai-vidgen-bucket/xai-video-df83b536-32d3-95d8-8c99-c54224a604b2.mp4"
                        ],
                        "submit_time": 1782892133,
                        "finish_time": 1782892255
                      },
                      "usage": {
                        "prompt_tokens": 0,
                        "completion_tokens": 0,
                        "total_tokens": 0,
                        "duration": 8,
                        "output_video_duration": 8
                      },
                      "request_id": ""
                    }
                  },
                  "failure": {
                    "summary": "失败任务",
                    "value": {
                      "output": {
                        "task_id": "task_id",
                        "task_status": "Failure",
                        "submit_time": 1782892133,
                        "finish_time": 1782892255,
                        "error_message": "error_message"
                      },
                      "usage": {
                        "duration": 8
                      },
                      "request_id": ""
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "请求参数无效。",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GrokImagineVideoErrorResponse"
                }
              }
            }
          },
          "default": {
            "description": "错误响应。",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GrokImagineVideoErrorResponse"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "API key",
        "description": "API 密钥认证，格式为 `Bearer {API_KEY}`"
      }
    },
    "schemas": {
      "GrokImagineVideoSubmitRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "model",
          "input",
          "parameters"
        ],
        "properties": {
          "model": {
            "type": "string",
            "const": "grok-imagine-video",
            "description": "模型名称。仅支持 `grok-imagine-video`。"
          },
          "input": {
            "$ref": "#/components/schemas/GrokImagineVideoInput"
          },
          "parameters": {
            "$ref": "#/components/schemas/GrokImagineVideoParameters"
          }
        }
      },
      "GrokImagineVideoInput": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "prompt"
        ],
        "properties": {
          "img_url": {
            "type": "string",
            "format": "uri",
            "description": "单张图片的 URL 地址，用于图生视频模式。与 `reference_urls` 参数互斥。\n"
          },
          "reference_urls": {
            "type": "array",
            "description": "多张参考图片的 URL 地址数组，用于参考生视频模式。与 `img_url` 参数互斥。\n",
            "items": {
              "type": "string",
              "format": "uri"
            }
          },
          "prompt": {
            "type": "string",
            "description": "描述视频生成内容的文本提示词。"
          }
        }
      },
      "GrokImagineVideoParameters": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "resolution",
          "aspect_ratio",
          "duration"
        ],
        "properties": {
          "resolution": {
            "type": "string",
            "enum": [
              "480p",
              "720p"
            ],
            "default": "480p",
            "description": "输出视频分辨率。"
          },
          "aspect_ratio": {
            "type": "string",
            "enum": [
              "1:1",
              "16:9",
              "9:16",
              "4:3",
              "3:4",
              "3:2",
              "2:3"
            ],
            "default": "16:9",
            "description": "输出视频的宽高比。"
          },
          "duration": {
            "type": "integer",
            "minimum": 1,
            "maximum": 15,
            "default": 8,
            "description": "视频时长，单位为秒。"
          }
        }
      },
      "GrokImagineVideoSubmitResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "output",
          "request_id"
        ],
        "properties": {
          "output": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "task_id"
            ],
            "properties": {
              "task_id": {
                "type": "string",
                "description": "异步任务唯一标识。"
              }
            }
          },
          "request_id": {
            "type": "string",
            "description": "唯一请求标识。"
          }
        }
      },
      "GrokImagineVideoStatusResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "output",
          "request_id"
        ],
        "properties": {
          "output": {
            "$ref": "#/components/schemas/GrokImagineVideoStatusOutput"
          },
          "usage": {
            "$ref": "#/components/schemas/GrokImagineVideoUsage"
          },
          "request_id": {
            "type": "string",
            "description": "唯一请求标识。"
          }
        }
      },
      "GrokImagineVideoStatusOutput": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "task_id",
          "task_status"
        ],
        "properties": {
          "task_id": {
            "type": "string",
            "description": "异步任务唯一标识。"
          },
          "task_status": {
            "$ref": "#/components/schemas/GrokImagineVideoTaskStatus"
          },
          "urls": {
            "type": "array",
            "description": "视频结果 URL 列表。",
            "items": {
              "type": "string",
              "format": "uri"
            }
          },
          "submit_time": {
            "type": "integer",
            "format": "int64",
            "description": "任务提交时间戳（Unix 时间戳，秒）。"
          },
          "finish_time": {
            "type": "integer",
            "format": "int64",
            "description": "任务完成时间戳（Unix 时间戳，秒）。"
          },
          "error_message": {
            "type": "string",
            "description": "任务失败时返回的错误信息。"
          }
        }
      },
      "GrokImagineVideoTaskStatus": {
        "type": "string",
        "description": "异步任务状态。",
        "enum": [
          "Pending",
          "Running",
          "Success",
          "Failure"
        ]
      },
      "GrokImagineVideoUsage": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "prompt_tokens": {
            "type": "integer",
            "description": "提示词 Token 数量。"
          },
          "completion_tokens": {
            "type": "integer",
            "description": "完成 Token 数量。"
          },
          "total_tokens": {
            "type": "integer",
            "description": "总 Token 数量。"
          },
          "duration": {
            "type": "integer",
            "description": "视频时长，单位为秒。"
          },
          "output_video_duration": {
            "type": "integer",
            "description": "输出视频时长，单位为秒。"
          }
        }
      },
      "GrokImagineVideoErrorResponse": {
        "type": "object",
        "additionalProperties": true,
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "$ref": "#/components/schemas/GrokImagineVideoErrorObject"
          }
        }
      },
      "GrokImagineVideoErrorObject": {
        "type": "object",
        "additionalProperties": true,
        "required": [
          "message",
          "type"
        ],
        "properties": {
          "message": {
            "type": "string",
            "description": "错误信息。"
          },
          "type": {
            "type": "string",
            "description": "错误类型。",
            "examples": [
              "invalid_request_error"
            ]
          },
          "code": {
            "type": [
              "string",
              "null"
            ],
            "description": "错误码。",
            "examples": [
              "param_error"
            ]
          },
          "param": {
            "type": [
              "string",
              "null"
            ],
            "description": "相关请求参数，如有。"
          }
        }
      }
    }
  }
}
```
