> ## Documentation Index
> Fetch the complete documentation index at: https://docs.geeknow.top/llms.txt
> Use this file to discover all available pages before exploring further.

# Grok 任务查询

> 使用 `GET /v1/videos/{task_id}` 查询 Grok 视频任务进度、结果与错误信息。

# Grok 任务查询

Grok Imagine 系列任务提交后，通过 `GET /v1/videos/{task_id}` 轮询状态，并共用同一组查询与下载接口。

* 接口路径是 `GET /v1/videos/{task_id}`。
* 任务完成后，优先从响应中的视频 URL 字段读取结果地址。
* 如果响应没有公开 URL，或直接下载公开 URL 失败，可回退到 `GET /v1/videos/{task_id}/content`。
* `/content` 端点需要携带同一个 `Authorization: Bearer YOUR_API_KEY`。

## 方法与路径

```http theme={null}
GET /v1/videos/{task_id}
```

## 请求示例

<CodeGroup>
  ```bash theme={null}
  curl https://www.geeknow.top/v1/videos/video_abc123 \
    -H "Authorization: Bearer YOUR_API_KEY"
  ```

  ```python theme={null}
  import requests

  resp = requests.get(
      "https://www.geeknow.top/v1/videos/video_abc123",
      headers={"Authorization": "Bearer YOUR_API_KEY"},
      timeout=30,
  )
  print(resp.json())
  ```

  ```javascript theme={null}
  const response = await fetch("https://www.geeknow.top/v1/videos/video_abc123", {
    headers: {
      Authorization: "Bearer YOUR_API_KEY",
    },
  });

  console.log(await response.json());
  ```
</CodeGroup>

## 响应示例

<ResponseExample>
  ```json 200 - 处理中 theme={null}
  {
    "id": "video_abc123",
    "object": "video",
    "model": "grok-imagine-video",
    "status": "processing",
    "progress": 42,
    "created_at": 1735689600,
    "completed_at": 0,
    "expires_at": 1735776000,
    "seconds": "10",
    "size": "720P",
    "remixed_from_video_id": "",
    "error": {
      "message": "",
      "code": ""
    },
    "video_url": ""
  }
  ```

  ```json 200 - 已完成 theme={null}
  {
    "id": "task_abc123",
    "object": "video",
    "model": "grok-imagine-video-1.5",
    "status": "completed",
    "progress": 100,
    "created_at": 1735689600,
    "completed_at": 1735689900,
    "expires_at": 1735776000,
    "seconds": "10",
    "size": "720P",
    "remixed_from_video_id": "",
    "error": {
      "message": "",
      "code": ""
    },
    "video_url": "https://example.com/video.mp4"
  }
  ```

  ```json 200 - 失败 theme={null}
  {
    "id": "video_abc123",
    "object": "video",
    "model": "grok-imagine-video-1.5-preview",
    "status": "failed",
    "progress": 100,
    "created_at": 1735689600,
    "completed_at": 1735689700,
    "expires_at": 1735776000,
    "seconds": "10",
    "size": "720P",
    "remixed_from_video_id": "",
    "error": {
      "message": "Content policy violation",
      "code": "content_policy"
    },
    "video_url": ""
  }
  ```
</ResponseExample>

## 认证

```http theme={null}
Authorization: Bearer YOUR_API_KEY
```

## Path Parameters

<ParamField body="task_id" type="string" required>
  视频任务 ID。
</ParamField>

## Response

<ResponseField name="id" type="string">
  任务 ID。
</ResponseField>

<ResponseField name="status" type="string">
  任务状态。常见值有 `processing`、`failed`、`completed`。
</ResponseField>

<ResponseField name="model" type="string">
  任务对应的模型名。该字段用于展示和排查，不应用作任务 ID。
</ResponseField>

<ResponseField name="progress" type="integer">
  进度百分比。
</ResponseField>

<ResponseField name="completed_at" type="integer">
  完成时间戳。
</ResponseField>

<ResponseField name="expires_at" type="integer">
  结果过期时间戳。
</ResponseField>

<ResponseField name="seconds" type="string">
  输出时长。
</ResponseField>

<ResponseField name="size" type="string">
  输出清晰度档位。
</ResponseField>

<ResponseField name="video_url" type="string">
  视频地址。完成时通常可直接下载；如果为空或不可下载，按下方兼容顺序读取其他字段，或回退到 `/content`。
</ResponseField>

<ResponseField name="error" type="object">
  失败原因对象。
</ResponseField>

## 轮询建议

建议客户端将以下状态视为处理中并继续轮询：`queued`、`pending`、`processing`、`in_progress`、`running`、`generating`。

建议将以下状态视为完成：`completed`、`succeeded`、`success`。

建议将以下状态视为失败或终止：`failed`、`fail`、`error`、`cancelled`、`canceled`、`expired`、`deleted`。

任务完成后，结果地址可按以下兼容顺序读取：

1. `content.video_url`
2. `content.url`
3. `output.url`
4. `video_url`
5. `url`
6. `detail.url`
7. `data[0].url`

如果这些字段都为空，或下载返回的地址失败，再回退请求：

```http theme={null}
GET /v1/videos/{task_id}/content
```

下载 `/content` 时需要继续携带鉴权头：

```bash theme={null}
curl https://www.geeknow.top/v1/videos/video_abc123/content \
  -H "Authorization: Bearer YOUR_API_KEY" \
  --output result.mp4
```

## 相关接口

* [Grok 视频概览](./overview)
* [Grok Imagine Video](./grok-imagine-video)
* [Grok Imagine 1.5 Preview](./grok-imagine-video-1-5-preview)
