{
  "openapi": "3.1.0",
  "info": {
    "title": "작업 상세 정보 조회 API",
    "description": "작업 ID로 비동기 작업의 상태, 진행률 및 결과 정보를 조회합니다",
    "license": {
      "name": "MIT"
    },
    "version": "1.0.0"
  },
  "servers": [
    {
      "url": "https://api.evolink.ai",
      "description": "프로덕션 환경"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "paths": {
    "/v1/tasks/{task_id}": {
      "get": {
        "summary": "작업 상태 조회",
        "description": "작업 ID로 비동기 작업의 상태, 진행률 및 결과 정보를 조회합니다",
        "operationId": "getTaskDetail",
        "tags": [
          "작업 관리"
        ],
        "parameters": [
          {
            "name": "task_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "작업 ID, 조회 시 {}를 무시하고 비동기 작업 응답 본문의 id를 경로 끝에 추가하세요",
            "example": "task-unified-1756817821-4x3rx6ny"
          }
        ],
        "responses": {
          "200": {
            "description": "작업 상태 세부 정보",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TaskDetailResponse"
                },
                "example": {
                  "created": 1788436500,
                  "duration": 30,
                  "id": "task-unified-1788436500-yscib7uw",
                  "model": "gemini-3-pro-image-preview",
                  "object": "image.generation.task",
                  "progress": 100,
                  "result_data": [
                    {
                      "url": "http://example.com/image.jpg"
                    }
                  ],
                  "results": [
                    "http://example.com/image.jpg"
                  ],
                  "status": "completed",
                  "task_info": {
                    "can_cancel": false
                  },
                  "type": "image",
                  "usage": {
                    "cost": {
                      "credits": 10,
                      "usd": 0.148,
                      "cny": 1
                    },
                    "credits_used": 10
                  }
                }
              }
            }
          },
          "401": {
            "description": "인증되지 않음: API 키가 없거나 유효하지 않거나 만료되었거나 비활성화됨",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "Invalid API key (request id: 20260908103000123456789abcdef)",
                    "param": null,
                    "type": "authentication_error"
                  }
                }
              }
            }
          },
          "403": {
            "description": "계정이 비활성화됨",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "user_disabled",
                    "message": "Your account has been disabled (request id: 20260908103000123456789abcdef)",
                    "param": null,
                    "type": "invalid_request_error"
                  }
                }
              }
            }
          },
          "404": {
            "description": "작업이 존재하지 않거나 현재 API 키에 속하지 않음 (작업 ID 형식이 잘못된 경우에도 반환)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "message": "Task not found",
                    "type": "invalid_request_error",
                    "param": "",
                    "code": "task_not_found"
                  }
                }
              }
            }
          },
          "429": {
            "description": "요청 속도 제한 초과 (Retry-After 헤더도 함께 반환)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "rate_limit_exceeded",
                    "message": "You have reached the request limit: max 60 requests per 1 minutes. Retry after 30 seconds. (request id: 20260908103000123456789abcdef)",
                    "param": null,
                    "retry_after": 30,
                    "retryable": true,
                    "type": "rate_limit_error"
                  }
                }
              }
            }
          },
          "500": {
            "description": "내부 서버 오류",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "message": "Failed to get task status",
                    "type": "api_error",
                    "param": "",
                    "code": "internal_error"
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "TaskDetailResponse": {
        "type": "object",
        "properties": {
          "created": {
            "type": "integer",
            "description": "작업 생성 타임스탬프",
            "example": 1756817821
          },
          "id": {
            "type": "string",
            "description": "작업 ID",
            "example": "task-unified-1756817821-4x3rx6ny"
          },
          "model": {
            "type": "string",
            "description": "사용된 모델",
            "example": "gemini-3-pro-image-preview"
          },
          "object": {
            "type": "string",
            "description": "작업 유형",
            "enum": [
              "image.generation.task",
              "video.generation.task",
              "audio.generation.task"
            ],
            "example": "image.generation.task"
          },
          "progress": {
            "type": "integer",
            "minimum": 0,
            "maximum": 100,
            "description": "작업 진행률 백분율",
            "example": 100
          },
          "status": {
            "type": "string",
            "description": "작업 상태. 참고: 작업이 업스트림에서 아직 대기 중이어도 조회 API는 이미 \"processing\"을 반환하므로, 클라이언트는 보통 processing / completed / failed만 보게 됩니다.",
            "enum": [
              "pending",
              "processing",
              "completed",
              "failed"
            ],
            "example": "completed"
          },
          "type": {
            "type": "string",
            "description": "작업 유형",
            "enum": [
              "image",
              "video",
              "audio",
              "text"
            ],
            "example": "image"
          },
          "duration": {
            "type": "integer",
            "description": "작업 소요 시간(초). status가 \"completed\" 또는 \"failed\"일 때만 반환됩니다.",
            "example": 30
          },
          "video_duration": {
            "type": "number",
            "description": "실제 생성된 영상 길이(초). 일부 영상 모델(예: Kling)의 최종 상태에서만 반환됩니다.",
            "example": 5.0
          },
          "draft_expires_at": {
            "type": "string",
            "format": "date-time",
            "description": "최종 비디오로 변환할 수 있는 기한(UTC, RFC 3339). 생성 시 `draft: true`를 전달한 Seedance 2.5 초안이 `completed` 상태일 때만 반환됩니다. 이 시각이 지나면 Seedance 2.5 Draft-to-Video로 변환할 수 없습니다",
            "example": "2026-09-23T17:19:36Z"
          },
          "source_task_id": {
            "type": "string",
            "description": "이 최종 비디오의 변환 원본인 초안 작업의 ID. Seedance 2.5 Draft-to-Video 작업에서만 반환됩니다",
            "example": "task-unified-1774857405-abc123"
          },
          "results": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uri"
            },
            "description": "결과 URL 목록. status가 \"completed\"이고 모델이 URL 결과를 생성하는 경우에만 반환되며, 그 외에는 필드 자체가 없습니다.",
            "example": [
              "http://example.com/image.jpg"
            ]
          },
          "result_data": {
            "description": "모델별 전체 결과 객체. 이미지 모델은 [{\"url\": ...}] 형태의 객체 배열(results와 동일한 URL)이며, 일부 모델은 더 풍부한 객체를 반환합니다(예: Suno는 곡 객체). 구조화된 결과가 없는 모델에서는 반환되지 않습니다.",
            "example": [
              {
                "url": "http://example.com/image.jpg"
              }
            ]
          },
          "usage": {
            "type": "object",
            "description": "사용량 및 과금 정보. status가 \"completed\"일 때만 반환됩니다. credits_used와 cost는 항상 포함되며, 토큰 필드는 토큰 과금 모델(예: gpt-image-2)에서만 반환됩니다. 일부 모델은 모델별 과금 필드를 추가로 반환합니다.",
            "properties": {
              "credits_used": {
                "type": "number",
                "description": "이 작업에서 실제로 차감된 Credits. 과금이 아직 정산되지 않은 경우에만 생략됩니다.",
                "example": 10
              },
              "cost": {
                "type": "object",
                "description": "이 작업의 비용을 세 가지 통화로 표시. credits_used에서 환산(올림).",
                "properties": {
                  "credits": {
                    "type": "number",
                    "description": "차감된 Credits (credits_used와 동일)",
                    "example": 10
                  },
                  "usd": {
                    "type": "number",
                    "description": "미국 달러 환산 금액",
                    "example": 0.148
                  },
                  "cny": {
                    "type": "number",
                    "description": "위안화 환산 금액",
                    "example": 1
                  }
                }
              },
              "image_input_tokens": {
                "type": "integer",
                "description": "이미지 입력 토큰 (토큰 과금 이미지 모델만, 예: gpt-image-2)",
                "example": 1032
              },
              "image_cached_input_tokens": {
                "type": "integer",
                "description": "캐시된 이미지 입력 토큰 (토큰 과금 이미지 모델만)"
              },
              "image_output_tokens": {
                "type": "integer",
                "description": "이미지 출력 토큰 (토큰 과금 이미지 모델만)",
                "example": 987
              },
              "text_input_tokens": {
                "type": "integer",
                "description": "텍스트 입력 토큰 (토큰 과금 모델만)",
                "example": 13
              },
              "text_cached_input_tokens": {
                "type": "integer",
                "description": "캐시된 텍스트 입력 토큰 (토큰 과금 이미지 모델만)"
              },
              "text_output_tokens": {
                "type": "integer",
                "description": "텍스트 출력 토큰 (0보다 클 때만 반환)"
              },
              "total_tokens": {
                "type": "integer",
                "description": "총 토큰 수(토큰 단위 과금 모델만 해당). GPT Image 2.6의 SVG 작성 모델 사용량은 이 필드에 포함되지 않습니다. svg_input_tokens 및 svg_output_tokens를 참조하세요.",
                "example": 2032
              },
              "svg_model": {
                "type": "string",
                "description": "실제로 사용한 SVG 작성 모델 이름. GPT Image 2.6의 SVG 작업에서 업스트림이 작성 모델 사용량을 반환한 경우에만 표시됩니다. 작성 모델 사용량은 이 모델의 해당 단가로 과금됩니다.",
                "example": "gpt-6.1-terra"
              },
              "svg_input_tokens": {
                "type": "integer",
                "minimum": 0,
                "description": "SVG 작성 모델의 입력 토큰 수. svg_model과 함께 반환되며 total_tokens에는 포함되지 않습니다.",
                "example": 1095
              },
              "svg_output_tokens": {
                "type": "integer",
                "minimum": 0,
                "description": "SVG 작성 모델의 출력 토큰 수. 추론 토큰이 이미 포함되어 있으므로 추론 사용량을 다시 더하지 마세요. svg_model과 함께 반환되며 total_tokens에는 포함되지 않습니다.",
                "example": 1887
              }
            }
          },
          "error": {
            "type": "object",
            "nullable": true,
            "description": "작업 실패 시 오류 정보 (status가 failed일 때만 표시). 참고: 여기의 error.code는 문자열 유형의 비즈니스 오류 코드로 HTTP 상태 코드와 다릅니다. 전체 목록은 오류 코드 참조 문서를 확인하세요.",
            "properties": {
              "code": {
                "type": "string",
                "description": "비즈니스 오류 코드 (문자열 유형)",
                "example": "content_policy_violation"
              },
              "message": {
                "type": "string",
                "description": "사용자 친화적인 오류 설명 및 문제 해결 팁",
                "example": "Content policy violation.\nYour request was blocked by safety filters. Please adjust your prompt or input images and try again."
              },
              "details": {
                "type": "string",
                "description": "추가 오류 세부 정보, 값이 있을 때만 반환"
              },
              "suggestion": {
                "type": "string",
                "description": "권장 조치, 일부 beta/별칭 모델에서만 반환"
              }
            }
          },
          "task_info": {
            "type": "object",
            "description": "작업 상세 정보",
            "properties": {
              "can_cancel": {
                "type": "boolean",
                "description": "작업 취소 가능 여부",
                "example": false
              }
            }
          },
          "effective_speed": {
            "type": "string",
            "enum": [
              "draft",
              "fast",
              "turbo"
            ],
            "description": "Midjourney V7 variation / pan / outpaint: prompt는 선택 사항입니다. 생략, 빈 문자열, 공백만 있거나 제어 대상 속도·버전 매개변수를 제거한 뒤 비어 있으면 speed=turbo여도 Fast로 실행하고 Fast 요금을 적용합니다. 유효한 본문이 있으면 속도 생략 또는 fast는 Fast, turbo는 Turbo로 실행하며 Fast 요금의 2배입니다. Playground는 Fast만 제공합니다. 원본 작업은 현재 사용자의 완료된 작업이어야 합니다. prompt가 없을 때는 이미지 생성 및 지원되는 variation, pan, outpaint 결과를 사용할 수 있습니다. Historical tasks retain their recorded execution speed and billing."
          }
        }
      },
      "ErrorResponse": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "description": "오류 코드 (문자열 유형)",
                "example": "task_not_found"
              },
              "message": {
                "type": "string",
                "description": "오류 설명 메시지. 미들웨어에서 발생한 오류(401, 429)는 끝에 \" (request id: ...)\"가 붙습니다",
                "example": "Task not found"
              },
              "type": {
                "type": "string",
                "description": "오류 유형",
                "example": "invalid_request_error"
              },
              "param": {
                "type": "string",
                "nullable": true,
                "description": "관련 매개변수 이름. 이 엔드포인트에서는 null 또는 빈 문자열"
              },
              "retry_after": {
                "type": "integer",
                "description": "재시도 전 대기 시간(초) (429만)",
                "example": 30
              },
              "retryable": {
                "type": "boolean",
                "description": "요청 재시도 가능 여부 (429만)",
                "example": true
              }
            }
          }
        }
      }
    },
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "##모든 API는 Bearer Token 인증이 필요합니다##\n\n**API Key 받기:**\n\n[API Key 관리 페이지](https://evolink.ai/dashboard/keys)를 방문하여 API Key를 받으세요\n\n**요청 헤더에 추가:**\n```\nAuthorization: Bearer YOUR_API_KEY\n```"
      }
    }
  },
  "tags": [
    {
      "name": "작업 관리",
      "description": "비동기 작업 관리 관련 API"
    }
  ]
}
