{
  "openapi": "3.1.0",
  "info": {
    "title": "mj-v7-inpaint 인터페이스",
    "version": "1.0.0",
    "description": "- 이미지의 특정 영역을 지정하여 재생성하고, 나머지 부분은 변경하지 않음\n- 두 가지 마스크 방식 지원: 다각형 좌표 또는 흑백 마스크 이미지\n- 비동기 처리 모드, 반환된 작업 ID로 [조회](/ko/api-manual/task-management/get-task-detail)"
  },
  "servers": [
    {
      "url": "https://api.evolink.ai"
    }
  ],
  "paths": {
    "/v1/images/generations": {
      "post": {
        "operationId": "mjV7Inpaint",
        "summary": "Midjourney V7 인페인트",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MjV7InpaintRequest"
              },
              "examples": {
                "polygon_mask": {
                  "summary": "다각형 좌표 인페인트",
                  "value": {
                    "model": "mj-v7-inpaint",
                    "prompt": "벚꽃나무 추가",
                    "model_params": {
                      "task_id": "task-unified-xxx",
                      "image_number": 0,
                      "mask": {
                        "areas": [
                          {
                            "width": 200,
                            "height": 200,
                            "points": [
                              50,
                              50,
                              50,
                              250,
                              250,
                              250,
                              250,
                              50
                            ]
                          }
                        ]
                      }
                    }
                  }
                },
                "image_mask": {
                  "summary": "마스크 이미지 인페인트",
                  "value": {
                    "model": "mj-v7-inpaint",
                    "model_params": {
                      "task_id": "task-unified-xxx",
                      "image_number": 0,
                      "mask": {
                        "url": "https://example.com/mask.png"
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "작업 생성 성공",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ImageGenerationResponse"
                }
              }
            }
          },
          "400": {
            "description": "잘못된 요청 매개변수",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "미인증",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "402": {
            "description": "쿼터 부족",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "접근 거부",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "속도 제한 초과",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "내부 서버 오류",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "##모든 인터페이스는 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```"
      }
    },
    "schemas": {
      "MjV7InpaintRequest": {
        "type": "object",
        "required": [
          "model",
          "model_params"
        ],
        "properties": {
          "model": {
            "type": "string",
            "enum": [
              "mj-v7-inpaint"
            ],
            "default": "mj-v7-inpaint",
            "description": "모델 이름"
          },
          "prompt": {
            "type": "string",
            "description": "재도색 영역에 생성할 내용 설명",
            "example": "벚꽃나무 추가"
          },
          "model_params": {
            "type": "object",
            "required": [
              "task_id",
              "mask"
            ],
            "description": "모델 매개변수",
            "properties": {
              "task_id": {
                "type": "string",
                "description": "소스 작업 ID",
                "example": "task-unified-xxx"
              },
              "image_number": {
                "type": "integer",
                "enum": [
                  0,
                  1,
                  2,
                  3
                ],
                "default": 0,
                "description": "이미지 선택 (0-3)"
              },
              "mask": {
                "type": "object",
                "description": "재도색 영역 정의, 두 가지 방법 지원",
                "oneOf": [
                  {
                    "type": "object",
                    "description": "다각형 좌표 방식",
                    "required": [
                      "areas"
                    ],
                    "properties": {
                      "areas": {
                        "type": "array",
                        "description": "다각형 좌표 방식, 여러 인페인트 영역 지원",
                        "items": {
                          "type": "object",
                          "properties": {
                            "width": {
                              "type": "integer",
                              "description": "다각형 바운딩 박스 너비"
                            },
                            "height": {
                              "type": "integer",
                              "description": "다각형 바운딩 박스 높이"
                            },
                            "points": {
                              "type": "array",
                              "items": {
                                "type": "integer"
                              },
                              "description": "플랫 좌표 쌍 [x1,y1,x2,y2,...] 폐합 다각형 형성"
                            }
                          }
                        }
                      }
                    }
                  },
                  {
                    "type": "object",
                    "description": "흑백 마스크 이미지 URL, 흰색 영역=인페인트 영역, 검은색 영역=보존 영역",
                    "required": [
                      "url"
                    ],
                    "properties": {
                      "url": {
                        "type": "string",
                        "format": "uri",
                        "description": "흑백 마스크 이미지 URL, 흰색 영역=인페인트 영역, 검은색 영역=보존 영역"
                      }
                    }
                  }
                ]
              },
              "speed": {
                "type": "string",
                "enum": [
                  "fast",
                  "turbo"
                ],
                "default": "fast",
                "description": "속도 모드 (prompt 입력 시에만 적용)\n\n**비용 안내:** turbo 모드는 비용이 더 높습니다"
              }
            }
          },
          "callback_url": {
            "type": "string",
            "format": "uri",
            "description": "작업 완료 후 콜백 URL"
          }
        }
      },
      "ImageGenerationResponse": {
        "type": "object",
        "properties": {
          "created": {
            "type": "integer",
            "description": "작업 생성 타임스탬프",
            "example": 1757165031
          },
          "id": {
            "type": "string",
            "description": "작업 ID",
            "example": "task-unified-1757165031-mjv7"
          },
          "model": {
            "type": "string",
            "description": "실제 사용된 모델 이름"
          },
          "object": {
            "type": "string",
            "enum": [
              "image.generation.task"
            ],
            "description": "작업 유형"
          },
          "progress": {
            "type": "integer",
            "description": "작업 진행률 (0-100)",
            "minimum": 0,
            "maximum": 100,
            "example": 0
          },
          "status": {
            "type": "string",
            "description": "작업 상태",
            "enum": [
              "pending",
              "processing",
              "completed",
              "failed"
            ],
            "example": "pending"
          },
          "task_info": {
            "$ref": "#/components/schemas/TaskInfo"
          },
          "type": {
            "type": "string",
            "enum": [
              "text",
              "image",
              "audio",
              "video"
            ],
            "example": "image"
          },
          "usage": {
            "$ref": "#/components/schemas/Usage"
          }
        }
      },
      "TaskInfo": {
        "type": "object",
        "properties": {
          "can_cancel": {
            "type": "boolean",
            "description": "작업 취소 가능 여부",
            "example": true
          },
          "estimated_time": {
            "type": "integer",
            "description": "예상 완료 시간(초)",
            "minimum": 0,
            "example": 45
          }
        }
      },
      "Usage": {
        "type": "object",
        "properties": {
          "billing_rule": {
            "type": "string",
            "enum": [
              "per_call",
              "per_token",
              "per_second"
            ],
            "example": "per_call"
          },
          "credits_reserved": {
            "type": "number",
            "description": "예상 소비 크레딧",
            "minimum": 0,
            "example": 1.8
          },
          "user_group": {
            "type": "string",
            "example": "default"
          }
        }
      },
      "ErrorResponse": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              },
              "type": {
                "type": "string"
              }
            }
          }
        }
      }
    }
  }
}