{
  "openapi": "3.1.0",
  "info": {
    "title": "kling-o3-video-edit API",
    "description": "AI 모델을 사용한 비디오 편집 작업 생성",
    "license": {
      "name": "MIT"
    },
    "version": "1.0.0"
  },
  "servers": [
    {
      "url": "https://api.evolink.ai",
      "description": "프로덕션 환경"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "paths": {
    "/v1/videos/generations": {
      "post": {
        "summary": "kling-o3-video-edit API",
        "description": "- Kling-O3 Video Edit (kling-o3-video-edit)는 원본 비디오를 편집 및 수정하며, Kling AI kling-v3-omni 모델을 기반으로 합니다\n- 출력 비디오의 길이와 종횡비는 입력 비디오와 동일하게 유지됩니다\n- 텍스트 지시, 참조 이미지 및 요소를 사용한 편집을 지원합니다\n- 비디오 입력이 제공된 경우 사운드 생성이 지원되지 않습니다(사운드가 강제로 꺼짐)\n- 비동기 처리 모드이며, 반환된 작업 ID를 사용하여 [상태 조회](/ko/api-manual/task-management/get-task-detail)\n- 생성된 비디오 링크는 24시간 동안 유효하며, 즉시 저장하시기 바랍니다",
        "operationId": "createVideoGeneration",
        "tags": [
          "비디오 생성"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/VideoGenerationRequest"
              },
              "examples": {
                "basic": {
                  "summary": "기본 비디오 편집",
                  "value": {
                    "model": "kling-o3-video-edit",
                    "prompt": "Adjust the color to warm tones and add a cinematic feel",
                    "video_url": "https://example.com/original.mp4",
                    "quality": "720p",
                    "keep_original_sound": true
                  }
                },
                "pro_no_sound": {
                  "summary": "고화질 + 원본 사운드 없음",
                  "value": {
                    "model": "kling-o3-video-edit",
                    "prompt": "Change the scene from daytime to nighttime and add neon light effects",
                    "video_url": "https://example.com/original.mp4",
                    "quality": "1080p",
                    "keep_original_sound": false
                  }
                },
                "style_reference": {
                  "summary": "스타일 참조 편집",
                  "value": {
                    "model": "kling-o3-video-edit",
                    "prompt": "Apply color grading based on the color tone and style of this reference image",
                    "video_url": "https://example.com/original.mp4",
                    "image_urls": [
                      "https://example.com/style_ref.jpg"
                    ],
                    "quality": "1080p",
                    "keep_original_sound": true
                  }
                },
                "element_replace": {
                  "summary": "요소 교체",
                  "value": {
                    "model": "kling-o3-video-edit",
                    "prompt": "Replace the person in the video with <<<element_1>>>",
                    "video_url": "https://example.com/original.mp4",
                    "quality": "1080p",
                    "model_params": {
                      "element_list": [
                        {
                          "element_id": "456789"
                        }
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "비디오 생성 작업이 성공적으로 생성되었습니다",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/VideoGenerationResponse"
                }
              }
            }
          },
          "400": {
            "description": "요청 매개변수가 잘못되었습니다",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "invalid_request",
                    "message": "Invalid request parameters",
                    "type": "invalid_request_error"
                  }
                }
              }
            }
          },
          "401": {
            "description": "인증되지 않았거나 토큰이 유효하지 않거나 만료되었습니다",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "Invalid or expired token",
                    "type": "authentication_error"
                  }
                }
              }
            }
          },
          "402": {
            "description": "할당량이 부족합니다. 충전이 필요합니다",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "insufficient_quota",
                    "message": "Insufficient quota. Please top up your account.",
                    "type": "insufficient_quota"
                  }
                }
              }
            }
          },
          "403": {
            "description": "접근이 거부되었습니다",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "model_access_denied",
                    "message": "Token does not have access to model: kling-o3-video-edit",
                    "type": "invalid_request_error"
                  }
                }
              }
            }
          },
          "429": {
            "description": "요청 한도를 초과했습니다",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "rate_limit_exceeded",
                    "message": "Too many requests, please try again later",
                    "type": "rate_limit_error"
                  }
                }
              }
            }
          },
          "500": {
            "description": "서버 내부 오류",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "internal_error",
                    "message": "Internal server error",
                    "type": "api_error"
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "VideoGenerationRequest": {
        "type": "object",
        "required": [
          "model"
        ],
        "properties": {
          "model": {
            "type": "string",
            "description": "비디오 생성 모델 이름",
            "enum": [
              "kling-o3-video-edit"
            ],
            "default": "kling-o3-video-edit",
            "example": "kling-o3-video-edit"
          },
          "prompt": {
            "type": "string",
            "description": "편집 지시, 최대 2500자\n\n**참조 구문:** 프롬프트에서 `<<<xxx>>>` 구문을 사용하여 요소, 이미지 및 비디오를 참조할 수 있습니다. 예: `Replace the person in the video with <<<element_1>>>`",
            "example": "Adjust the color to warm tones and add a cinematic feel",
            "maxLength": 2500
          },
          "video_url": {
            "type": "string",
            "description": "편집할 비디오 URL\n\n**비디오 형식 요구사항:**\n- 형식: MP4 / MOV\n- 크기: <= 200MB\n- 길이: >= 3초\n- 해상도: 너비 및 높이 720px ~ 2160px\n- 프레임 레이트: 24fps ~ 60fps\n\n**제약 조건:**\n- 첫/마지막 프레임 지원되지 않음\n- 비디오가 제공된 경우 참조 이미지 수 + 요소 수 <= 4\n- 비디오 캐릭터 요소는 지원되지 않습니다(멀티 이미지 요소만 지원)\n- 비디오 URL은 서버에서 직접 접근 가능해야 합니다",
            "format": "uri",
            "example": "https://example.com/original.mp4"
          },
          "keep_original_sound": {
            "type": "boolean",
            "description": "원본 비디오 사운드 유지 여부\n\n**참고:**\n- `true`: 원본 비디오 사운드 유지 (기본값)\n- `false`: 원본 비디오 사운드 유지하지 않음",
            "default": true,
            "example": true
          },
          "image_urls": {
            "type": "array",
            "description": "참조 이미지 URL 배열 (스타일 참조)\n\n**제약 조건:** 비디오가 제공된 경우 참조 이미지 수 + 요소 수 <= 4\n\n**참고:**\n- 이미지 URL은 서버에서 직접 접근 가능해야 하며, 접근 시 직접 다운로드되어야 합니다",
            "items": {
              "type": "string",
              "format": "uri"
            },
            "example": [
              "https://example.com/style_ref.jpg"
            ]
          },
          "quality": {
            "type": "string",
            "description": "해상도 품질\n\n**옵션:**\n- `720p`: 표준 720P\n- `1080p`: 고화질 1080P\n\n**요금:** 기본 단가 81,000 UC/초 x 입력 비디오 길이(올림). 1080p 배율 1.334",
            "enum": [
              "720p",
              "1080p"
            ],
            "default": "720p",
            "example": "720p"
          },
          "model_params": {
            "type": "object",
            "description": "고급 매개변수",
            "properties": {
              "element_list": {
                "type": "array",
                "description": "요소 라이브러리 목록. 비디오 캐릭터 요소는 지원되지 않습니다(멀티 이미지 요소만 지원)\n\n**제약 조건:** 비디오가 제공된 경우 참조 이미지 수 + 요소 수 <= 4",
                "items": {
                  "type": "object",
                  "properties": {
                    "element_id": {
                      "type": "string",
                      "description": "요소 ID"
                    }
                  }
                }
              },
              "watermark_info": {
                "type": "object",
                "description": "워터마크 설정",
                "properties": {
                  "enabled": {
                    "type": "boolean",
                    "description": "워터마크 활성화 여부"
                  }
                }
              }
            }
          },
          "callback_url": {
            "type": "string",
            "description": "작업 완료 시 HTTPS 콜백 URL\n\n**콜백 시점:**\n- 작업이 완료, 실패 또는 취소될 때 트리거됩니다\n- 과금 확인 후 전송됩니다\n\n**보안 제한:**\n- HTTPS 프로토콜만 지원\n- 내부 IP 주소 금지 (127.0.0.1, 10.x.x.x, 172.16-31.x.x, 192.168.x.x 등)\n- URL 길이는 `2048`자를 초과할 수 없습니다\n\n**콜백 메커니즘:**\n- 타임아웃: `10`초\n- 실패 후 최대 `3`회 재시도 (실패 후 `1`/`2`/`4`초)\n- 콜백 응답 형식은 작업 조회 API와 동일\n- 2xx 상태 코드는 성공으로 간주, 그 외 코드는 재시도 트리거",
            "format": "uri",
            "example": "https://your-domain.com/webhooks/video-task-completed"
          }
        }
      },
      "VideoGenerationResponse": {
        "type": "object",
        "properties": {
          "created": {
            "type": "integer",
            "description": "작업 생성 타임스탬프",
            "example": 1757169743
          },
          "id": {
            "type": "string",
            "description": "작업 ID",
            "example": "task-unified-1757169743-7cvnl5zw"
          },
          "model": {
            "type": "string",
            "description": "실제 사용된 모델 이름",
            "example": "kling-o3-video-edit"
          },
          "object": {
            "type": "string",
            "enum": [
              "video.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/VideoTaskInfo",
            "description": "비디오 작업 세부 정보"
          },
          "type": {
            "type": "string",
            "enum": [
              "text",
              "image",
              "audio",
              "video"
            ],
            "description": "작업 출력 유형",
            "example": "video"
          },
          "usage": {
            "$ref": "#/components/schemas/VideoUsage",
            "description": "사용량 및 과금 정보"
          }
        }
      },
      "VideoTaskInfo": {
        "type": "object",
        "properties": {
          "can_cancel": {
            "type": "boolean",
            "description": "작업 취소 가능 여부",
            "example": true
          },
          "estimated_time": {
            "type": "integer",
            "description": "예상 완료 시간 (초)",
            "minimum": 0,
            "example": 300
          },
          "video_duration": {
            "type": "integer",
            "description": "비디오 길이 (초)",
            "example": 9
          }
        }
      },
      "VideoUsage": {
        "type": "object",
        "description": "사용량 및 과금 정보",
        "properties": {
          "billing_rule": {
            "type": "string",
            "description": "과금 규칙",
            "enum": [
              "per_call",
              "per_token",
              "per_second"
            ],
            "example": "per_call"
          },
          "credits_reserved": {
            "type": "number",
            "description": "예상 소비 크레딧",
            "minimum": 0,
            "example": 7
          },
          "user_group": {
            "type": "string",
            "description": "사용자 그룹 카테고리",
            "example": "default"
          }
        }
      },
      "ErrorResponse": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "description": "오류 코드 식별자"
              },
              "message": {
                "type": "string",
                "description": "오류 설명"
              },
              "type": {
                "type": "string",
                "description": "오류 유형"
              }
            }
          }
        }
      }
    },
    "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": "AI 비디오 생성 API"
    }
  ]
}
