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

# Retrieve video task

> 查询视频生成任务的状态和结果链接。

视频与图片任务共用 `/v1/tasks/{task_id}`。提交 `/v1/videos/generations` 后拿到 `task_id`，再用本接口轮询。

## 请求

```bash theme={null}
curl "https://dimilinks.com/v1/tasks/video_xxx" \
  -H "Authorization: Bearer $DIMILINKS_API_KEY"
```

## 进行中响应

```json theme={null}
{
  "data": {
    "id": "video_xxx",
    "task_id": "video_xxx",
    "status": "processing",
    "progress": 35,
    "created_at": 1777080000
  }
}
```

## 成功响应

任务进入 `completed` 后，结果视频可通过 `/v1/videos/{task_id}/content` 拉取（需要带 Bearer 鉴权）。

```json theme={null}
{
  "data": {
    "id": "video_xxx",
    "task_id": "video_xxx",
    "status": "completed",
    "progress": 100,
    "created_at": 1777080000,
    "completed_at": 1777080300
  }
}
```

```bash theme={null}
curl -L "https://dimilinks.com/v1/videos/video_xxx/content" \
  -H "Authorization: Bearer $DIMILINKS_API_KEY" \
  -o video.mp4
```

如果你的产品要把视频展示给终端用户，建议在你的服务端代理这一次下载：先用密钥取到视频，再以你自己的鉴权下发，避免把 DimiLinks 密钥暴露到浏览器。

## 失败响应

```json theme={null}
{
  "data": {
    "id": "video_xxx",
    "task_id": "video_xxx",
    "status": "failed",
    "progress": 100,
    "created_at": 1777080000,
    "completed_at": 1777080300,
    "error": {
      "code": "upstream_error",
      "message": "视频生成失败，请稍后重试。"
    }
  }
}
```

## 状态

| 状态                                   | 含义   | 调用方建议                             |
| ------------------------------------ | ---- | --------------------------------- |
| `queued`、`pending`、`submitted`       | 等待处理 | 继续轮询                              |
| `processing`、`in_progress`、`running` | 生成中  | 继续轮询                              |
| `completed`、`success`                | 已完成  | 拉取 `/v1/videos/{task_id}/content` |
| `failed`、`error`、`cancelled`         | 已失败  | 展示错误提示，允许用户重试                     |

## 轮询建议

* 每 3 到 5 秒查询一次，比图片任务略宽松。
* 单条任务最长建议轮询 10 分钟；超时后直接告知用户失败并允许重试。
* 出现 `404` 立即停止轮询，多半是任务 ID 错或不属于当前密钥。


## OpenAPI

````yaml GET /tasks/{task_id}
openapi: 3.1.0
info:
  title: DimiLinks API
  description: >-
    DimiLinks unified API for chat (OpenAI-compatible and Anthropic native),
    image generation/editing, and video generation.
  version: 1.1.0
servers:
  - url: https://dimilinks.com/v1
    description: OpenAI 兼容入口：chat completions / images / videos / models / tasks
security:
  - bearerAuth: []
tags:
  - name: Models
  - name: Chat
  - name: Images
  - name: Videos
  - name: Tasks
paths:
  /tasks/{task_id}:
    get:
      tags:
        - Tasks
      summary: Retrieve task
      description: Retrieve image or video generation task by id.
      operationId: retrieveTask
      parameters:
        - name: task_id
          in: path
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Image or video task
          content:
            application/json:
              schema:
                oneOf:
                  - $ref: '#/components/schemas/ImageTask'
                  - $ref: '#/components/schemas/VideoTask'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
components:
  schemas:
    ImageTask:
      type: object
      properties:
        id:
          type: string
          example: img_xxx
        task_id:
          type: string
          example: img_xxx
        object:
          type: string
          example: image.task
        status:
          type: string
          enum:
            - queued
            - in_progress
            - succeeded
            - failed
        progress:
          type: integer
          minimum: 0
          maximum: 100
        created_at:
          type: integer
        completed_at:
          type: integer
        result:
          $ref: '#/components/schemas/ImageResponse'
        error:
          $ref: '#/components/schemas/ErrorObject'
    VideoTask:
      type: object
      properties:
        data:
          type: object
          properties:
            id:
              type: string
            task_id:
              type: string
            status:
              type: string
              enum:
                - queued
                - pending
                - submitted
                - processing
                - in_progress
                - running
                - completed
                - success
                - failed
                - error
                - cancelled
            progress:
              type: integer
              minimum: 0
              maximum: 100
            created_at:
              type: integer
            completed_at:
              type: integer
            error:
              $ref: '#/components/schemas/ErrorObject'
    ImageResponse:
      type: object
      properties:
        created:
          type: integer
          example: 1777080000
        task_id:
          type: string
          example: img_xxx
        data:
          type: array
          items:
            $ref: '#/components/schemas/ImageData'
    ErrorObject:
      type: object
      properties:
        message:
          type: string
        type:
          type: string
          example: invalid_request_error
        code:
          oneOf:
            - type: string
            - type: integer
    ErrorResponse:
      type: object
      properties:
        error:
          $ref: '#/components/schemas/ErrorObject'
    ImageData:
      type: object
      properties:
        url:
          type: string
          example: /p/img/img_xxx/0?exp=1777166400000&sig=...
        file_id:
          type: string
          example: file_xxx
  responses:
    Unauthorized:
      description: Missing or invalid API key
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    NotFound:
      description: Task not found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````