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

# 画像タスクを取得

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

非同期画像タスクを送信した後、`task_id` を使用してタスクのステータスを照会します。新規実装では `/v1/tasks/{task_id}` を優先して使用してください。

## リクエスト

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

## 処理中のレスポンス

```json theme={null}
{
  "id": "img_xxx",
  "task_id": "img_xxx",
  "object": "image.task",
  "status": "in_progress",
  "progress": 50,
  "created_at": 1777080000
}
```

## 成功時のレスポンス

```json theme={null}
{
  "id": "img_xxx",
  "task_id": "img_xxx",
  "object": "image.task",
  "status": "succeeded",
  "progress": 100,
  "created_at": 1777080000,
  "completed_at": 1777080060,
  "result": {
    "created": 1777080000,
    "data": [
      {
        "url": "/p/img/img_xxx/0?exp=1777166400000&sig=...",
        "file_id": "file_xxx"
      }
    ]
  }
}
```

## 画像 URL の形式

タスクが成功したら `result.data[].url` を読み取ります。このフィールドには、相対パス、完全な HTTP(S) URL、または `data:image/...;base64,...` 形式の Data URL が入る場合があります。

Data URL はエラーでもログ内容でもなく、画像データそのものです。Web ページではそのまま表示できます。スクリプトでファイルとして保存する場合は、先に base64 をデコードしてください。

## 失敗時のレスポンス

```json theme={null}
{
  "id": "img_xxx",
  "task_id": "img_xxx",
  "object": "image.task",
  "status": "failed",
  "progress": 100,
  "created_at": 1777080000,
  "completed_at": 1777080060,
  "error": {
    "code": "upstream_error",
    "message": "アップストリームからエラーが返されました"
  }
}
```

## ステータス

| ステータス         | 意味   | 呼び出し元での推奨対応                  |
| ------------- | ---- | ---------------------------- |
| `queued`      | 処理待ち | ポーリングを続けます。                  |
| `in_progress` | 生成中  | ポーリングを続けます。                  |
| `succeeded`   | 完了   | `result.data[].url` を表示します。  |
| `failed`      | 失敗   | エラー情報を表示し、ユーザーが再試行できるようにします。 |

## 旧エンドポイント

`GET /v1/images/tasks/{task_id}` は旧クライアント向けに維持されています。新規実装では 2 種類の照会構造を混在させないでください。

旧エンドポイントのレスポンス例：

```json theme={null}
{
  "task_id": "img_xxx",
  "status": "success",
  "conversation_id": "conv_xxx",
  "created": 1777080000,
  "finished_at": 1777080060,
  "error": "",
  "credit_cost": 123,
  "data": [
    {
      "url": "/p/img/img_xxx/0?exp=1777166400000&sig=...",
      "file_id": "file_xxx"
    }
  ]
}
```


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

````