> ## 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.

# 動画タスクを取得

> 動画生成タスクのステータスと結果のリンクを照会します。

動画タスクと画像タスクは、同じ `/v1/tasks/{task_id}` を使用します。`/v1/videos/generations` を送信して `task_id` を取得した後、この API でポーリングします。

## リクエスト

```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 秒ごとに照会してください。画像タスクより少し長めの間隔です。
* 1 タスクあたりのポーリングは最長 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

````