# 获取 Grok 视频

通过 UnifyLLM 公开任务 ID 轮询 Grok 视频任务，检查状态和错误后再下载已完成的视频。

- 原文: https://www.unifyllm.com/zh/docs/api-reference/get-grok-video/
- 语言: zh-CN

## 接口

```http
GET https://api.unifyllm.top/v1/videos/{task_id}
```

认证与请求头以本页调用示例为准。 

## 轮询与终态

- 排队或处理期间建议每隔 5–10 秒查询一次，不要通过重复提交创建请求检查进度。

- 请求超时或网络异常不代表创建失败；结果未知时，不要自动重发可能计费的 POST。

- 即使 status=completed 也要检查 error；moderation_blocked 可能表示没有可播放的视频。

| 状态 | 处理方式 |
| --- | --- |
| queued | 任务已排队，继续查询 |
| in_progress | 任务处理中，继续查询 |
| completed | 停止轮询，检查 error 后下载内容 |
| failed | 停止轮询，读取 error.code 和 error.message |

## 下载结果

查询结果不保证包含上游视频 URL。使用创建接口返回的完整公开任务 id 调用 /v1/videos/{task_id}/content 下载。创建、查询和下载都使用你的 UnifyLLM API Key，不需要供应商密钥。

## 参数

| 参数 | 位置 | 类型 | 必填 | 说明 | 可选值 | 示例 |
| --- | --- | --- | --- | --- | --- | --- |
| task_id | path | string | 是 | 创建接口返回的完整公开 id，保留 task_ 前缀。不要替换成供应商内部 ID。 |  | task_example |

## 默认

```json
{}
```

### cURL

```bash
curl --request GET \
  --url 'https://api.unifyllm.top/v1/videos/task_example' \
  --header 'Authorization: Bearer <YOUR_API_KEY>'
```

### JavaScript

```javascript
const response = await fetch("https://api.unifyllm.top/v1/videos/task_example", {
  method: "GET",
  headers: {
    "Authorization": "Bearer <YOUR_API_KEY>"
  },
});

const data = await response.json();
console.log(data);
```

### Python

```python
import requests

response = requests.get(
    "https://api.unifyllm.top/v1/videos/task_example",
    headers={"Authorization": "Bearer <YOUR_API_KEY>"}
)
response.raise_for_status()
print(response.json())
```

## 响应示例

### 任务进行中 — HTTP 200

```json
{
  "id": "task_example",
  "object": "video",
  "model": "grok-imagine-video-1.5",
  "status": "in_progress",
  "progress": 40
}
```

### 任务已完成 — HTTP 200

```json
{
  "id": "task_example",
  "object": "video",
  "model": "grok-imagine-video-1.5",
  "status": "completed",
  "progress": 100,
  "seconds": "3"
}
```

### 任务失败 — HTTP 200

```json
{
  "id": "task_example",
  "object": "video",
  "model": "grok-imagine-video-1.5",
  "status": "failed",
  "error": {
    "code": "video_generation_failed",
    "message": "Video generation failed."
  }
}
```

## 相关接口

- [创建 Grok 视频](https://www.unifyllm.com/zh/docs/api-reference/create-grok-video/)
- [下载 Grok 视频](https://www.unifyllm.com/zh/docs/api-reference/download-grok-video/)
