> ## Documentation Index
> Fetch the complete documentation index at: https://docs.apimart.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Wan2.7-VideoEdit 동영상 편집

>  - 알리바바 클라우드 완상 2.7 동영상 편집 모델
- 기존 동영상에 대한 AI 편집: 스타일 전송, 콘텐츠 교체, 요소 추가
- 참조 이미지를 선택적으로 전달하여 목표 스타일 또는 외관을 지정 가능
- 원본 동영상 길이 유지 또는 출력 길이 사용자 지정 지원 

<RequestExample>
  ```bash cURL theme={null}
  curl --request POST \
    --url https://api.apimart.ai/v1/videos/generations \
    --header 'Authorization: Bearer <token>' \
    --header 'Content-Type: application/json' \
    --data '{
      "model": "wan2.7-videoedit",
      "video_urls": ["https://cdn.example.com/original.mp4"],
      "prompt": "배경을 설산 장면으로 교체",
      "resolution": "1080P"
    }'
  ```

  ```python Python theme={null}
  import requests

  url = "https://api.apimart.ai/v1/videos/generations"

  payload = {
      "model": "wan2.7-videoedit",
      "video_urls": ["https://cdn.example.com/original.mp4"],
      "prompt": "배경을 설산 장면으로 교체",
      "resolution": "1080P"
  }

  headers = {
      "Authorization": "Bearer <token>",
      "Content-Type": "application/json"
  }

  response = requests.post(url, json=payload, headers=headers)

  print(response.json())
  ```

  ```javascript JavaScript theme={null}
  const url = "https://api.apimart.ai/v1/videos/generations";

  const payload = {
    model: "wan2.7-videoedit",
    video_urls: ["https://cdn.example.com/original.mp4"],
    prompt: "배경을 설산 장면으로 교체",
    resolution: "1080P"
  };

  const headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
  };

  fetch(url, {
    method: "POST",
    headers: headers,
    body: JSON.stringify(payload)
  })
    .then(response => response.json())
    .then(data => console.log(data))
    .catch(error => console.error('Error:', error));
  ```

  ```go Go theme={null}
  package main

  import (
      "bytes"
      "encoding/json"
      "fmt"
      "io/ioutil"
      "net/http"
  )

  func main() {
      url := "https://api.apimart.ai/v1/videos/generations"

      payload := map[string]interface{}{
          "model":      "wan2.7-videoedit",
          "video_urls": []string{"https://cdn.example.com/original.mp4"},
          "prompt":     "배경을 설산 장면으로 교체",
          "resolution": "1080P",
      }

      jsonData, _ := json.Marshal(payload)

      req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
      req.Header.Set("Authorization", "Bearer <token>")
      req.Header.Set("Content-Type", "application/json")

      client := &http.Client{}
      resp, err := client.Do(req)
      if err != nil {
          panic(err)
      }
      defer resp.Body.Close()

      body, _ := ioutil.ReadAll(resp.Body)
      fmt.Println(string(body))
  }
  ```

  ```java Java theme={null}
  import java.net.http.HttpClient;
  import java.net.http.HttpRequest;
  import java.net.http.HttpResponse;
  import java.net.URI;

  public class Main {
      public static void main(String[] args) throws Exception {
          String url = "https://api.apimart.ai/v1/videos/generations";

          String payload = """
          {
            "model": "wan2.7-videoedit",
            "video_urls": ["https://cdn.example.com/original.mp4"],
            "prompt": "배경을 설산 장면으로 교체",
            "resolution": "1080P"
          }
          """;

          HttpClient client = HttpClient.newHttpClient();
          HttpRequest request = HttpRequest.newBuilder()
              .uri(URI.create(url))
              .header("Authorization", "Bearer <token>")
              .header("Content-Type", "application/json")
              .POST(HttpRequest.BodyPublishers.ofString(payload))
              .build();

          HttpResponse<String> response = client.send(request,
              HttpResponse.BodyHandlers.ofString());

          System.out.println(response.body());
      }
  }
  ```

  ```php PHP theme={null}
  <?php

  $url = "https://api.apimart.ai/v1/videos/generations";

  $payload = [
      "model" => "wan2.7-videoedit",
      "video_urls" => ["https://cdn.example.com/original.mp4"],
      "prompt" => "배경을 설산 장면으로 교체",
      "resolution" => "1080P"
  ];

  $ch = curl_init($url);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_POST, true);
  curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
  curl_setopt($ch, CURLOPT_HTTPHEADER, [
      "Authorization: Bearer <token>",
      "Content-Type: application/json"
  ]);

  $response = curl_exec($ch);
  curl_close($ch);

  echo $response;
  ?>
  ```

  ```ruby Ruby theme={null}
  require 'net/http'
  require 'json'
  require 'uri'

  url = URI("https://api.apimart.ai/v1/videos/generations")

  payload = {
    model: "wan2.7-videoedit",
    video_urls: ["https://cdn.example.com/original.mp4"],
    prompt: "배경을 설산 장면으로 교체",
    resolution: "1080P"
  }

  http = Net::HTTP.new(url.host, url.port)
  http.use_ssl = true

  request = Net::HTTP::Post.new(url)
  request["Authorization"] = "Bearer <token>"
  request["Content-Type"] = "application/json"
  request.body = payload.to_json

  response = http.request(request)
  puts response.body
  ```

  ```swift Swift theme={null}
  import Foundation

  let url = URL(string: "https://api.apimart.ai/v1/videos/generations")!

  let payload: [String: Any] = [
      "model": "wan2.7-videoedit",
      "video_urls": ["https://cdn.example.com/original.mp4"],
      "prompt": "배경을 설산 장면으로 교체",
      "resolution": "1080P"
  ]

  var request = URLRequest(url: url)
  request.httpMethod = "POST"
  request.setValue("Bearer <token>", forHTTPHeaderField: "Authorization")
  request.setValue("application/json", forHTTPHeaderField: "Content-Type")
  request.httpBody = try? JSONSerialization.data(withJSONObject: payload)

  let task = URLSession.shared.dataTask(with: request) { data, response, error in
      if let error = error {
          print("Error: \(error)")
          return
      }

      if let data = data, let responseString = String(data: data, encoding: .utf8) {
          print(responseString)
      }
  }

  task.resume()
  ```

  ```csharp C# theme={null}
  using System;
  using System.Net.Http;
  using System.Text;
  using System.Threading.Tasks;

  class Program
  {
      static async Task Main(string[] args)
      {
          var url = "https://api.apimart.ai/v1/videos/generations";

          var payload = @"{
              ""model"": ""wan2.7-videoedit"",
              ""video_urls"": [""https://cdn.example.com/original.mp4""],
              ""prompt"": ""배경을 설산 장면으로 교체"",
              ""resolution"": ""1080P""
          }";

          using var client = new HttpClient();
          client.DefaultRequestHeaders.Add("Authorization", "Bearer <token>");

          var content = new StringContent(payload, Encoding.UTF8, "application/json");
          var response = await client.PostAsync(url, content);
          var result = await response.Content.ReadAsStringAsync();

          Console.WriteLine(result);
      }
  }
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "code": 200,
    "data": [
      {
        "status": "submitted",
        "task_id": "task_01J9HA7JPQ9A0Z6JZ3V8M9W6PZ"
      }
    ]
  }
  ```

  ```json 400 theme={null}
  {
    "error": {
      "code": 400,
      "message": "요청 매개변수가 유효하지 않습니다",
      "type": "invalid_request_error"
    }
  }
  ```

  ```json 401 theme={null}
  {
    "error": {
      "code": 401,
      "message": "인증에 실패했습니다. API 키를 확인해 주세요",
      "type": "authentication_error"
    }
  }
  ```

  ```json 402 theme={null}
  {
    "error": {
      "code": 402,
      "message": "잔액이 부족합니다. 충전해 주세요",
      "type": "payment_required"
    }
  }
  ```

  ```json 429 theme={null}
  {
    "error": {
      "code": 429,
      "message": "요청이 너무 많습니다. 잠시 후 다시 시도해 주세요",
      "type": "rate_limit_error"
    }
  }
  ```

  ```json 500 theme={null}
  {
    "error": {
      "code": 500,
      "message": "서버 내부 오류. 잠시 후 다시 시도해 주세요",
      "type": "server_error"
    }
  }
  ```
</ResponseExample>

## 인증

<ParamField header="Authorization" type="string" required>
  모든 API 엔드포인트는 Bearer Token 인증이 필요합니다

  API 키 받기:

  [API 키 관리 페이지](https://apimart.ai/keys)에서 API 키를 받으세요

  요청 헤더에 추가:

  ```
  Authorization: Bearer YOUR_API_KEY
  ```
</ParamField>

## 요청 매개변수

<ParamField body="model" type="string" required>
  동영상 생성 모델 이름. `wan2.7-videoedit`로 고정
</ParamField>

<ParamField body="video_urls" type="array<string>" required>
  편집 대상 원본 동영상 URL 배열

  <Warning>
    **첫 번째 동영상만 사용됩니다**
  </Warning>

  <Note>
    **동영상 제한:**

    * 형식: mp4, mov
    * 길이: 2\~10초
    * 해상도: 너비와 높이 모두 \[240, 4096] 픽셀 범위
    * 가로세로 비율: 1:8 \~ 8:1
    * 파일 크기: 100MB 이하
  </Note>
</ParamField>

<ParamField body="prompt" type="string">
  편집 지시. 동영상에 어떤 변경을 가하고 싶은지 설명, 최대 5000자

  <Note>
    전달하지 않으면 모델은 기본 스타일 전송을 수행합니다
  </Note>

  예: `"인물의 의상을 빨간 드레스로 변경"`, `"배경을 설산 장면으로 교체"`
</ParamField>

<ParamField body="negative_prompt" type="string">
  생성 결과에 포함하고 싶지 않은 내용을 나타내는 네거티브 프롬프트. 최대 500자까지.
</ParamField>

<ParamField body="image_urls" type="array<string>">
  참조 이미지 URL 배열, 최대 4장

  목표 스타일 또는 외관 지정에 사용 (스타일 전송의 목표 스타일 참조 등)
</ParamField>

<ParamField body="resolution" type="string" default="1080P">
  출력 동영상 해상도

  옵션:

  * `720P` - 표준
  * `1080P` - 고화질 (기본값)
</ParamField>

<ParamField body="duration" type="integer" default="0">
  출력 동영상 길이 (초)

  * `0` (기본값): 원본 동영상의 전체 길이 유지
  * `2-10` 사이의 정수: 처음부터 지정된 길이 만큼 잘라내기

  <Note>
    `duration=0`일 때 출력 동영상의 실제 길이로 과금됩니다

    지정한 길이는 `video_urls` 원본 동영상의 길이를 초과할 수 없습니다
  </Note>
</ParamField>

<ParamField body="size" type="string">
  출력 화면 비율

  지원 형식:

  * `16:9` - 가로 와이드
  * `9:16` - 세로
  * `1:1` - 정사각형
  * `4:3` - 가로
  * `3:4` - 세로

  <Note>
    전달하지 않으면 입력 동영상의 비율을 유지합니다
  </Note>
</ParamField>

<ParamField body="prompt_extend" type="boolean" default="true">
  프롬프트 지능 재작성 활성화 여부

  짧은 프롬프트에서 효과가 크지만 처리 시간이 증가합니다

  기본값: `true`
</ParamField>

<ParamField body="watermark" type="boolean" default="false">
  생성된 동영상에 "AI 생성" 워터마크 추가 여부

  * `true`: 워터마크 추가
  * `false`: 추가 안 함 (기본값)
</ParamField>

<ParamField body="seed" type="integer">
  생성 내용의 무작위성을 제어하는 시드 정수

  범위: `≥0`의 정수

  <Note>
    * 동일한 요청에서 다른 seed 값을 받으면 (예: seed를 지정하지 않음) 다른 결과가 생성됩니다
    * 동일한 요청에서 동일한 seed 값을 받으면 유사한 결과가 생성되지만 완전한 일치는 보장되지 않습니다
  </Note>
</ParamField>

<ParamField body="metadata" type="object">
  추가 매개변수 객체

  <Expandable title="metadata 필드">
    <ParamField body="audio_setting" type="string" default="auto">
      오디오 처리 방식:

      * `auto` (기본값): 편집된 동영상 내용에 따라 AI가 일치하는 오디오를 자동 재생성
      * `origin`: 원본 동영상 오디오를 강제 유지. 중요한 배경음/대화가 있는 동영상에 적합
    </ParamField>
  </Expandable>
</ParamField>

## 응답

<ResponseField name="code" type="integer">
  응답 상태 코드. 성공 시 200
</ResponseField>

<ResponseField name="data" type="array">
  응답 데이터 배열

  <Expandable title="배열 요소">
    <ResponseField name="status" type="string">
      작업 상태. 최초 제출 시 `submitted`
    </ResponseField>

    <ResponseField name="task_id" type="string">
      작업 고유 식별자
    </ResponseField>
  </Expandable>
</ResponseField>

## 사용 사례

### 사례 1: 기본 동영상 편집 (최소)

```json theme={null}
{
  "model": "wan2.7-videoedit",
  "video_urls": ["https://cdn.example.com/original.mp4"],
  "prompt": "배경을 설산 장면으로 교체"
}
```

### 사례 2: 스타일 전송 (참조 이미지 포함)

```json theme={null}
{
  "model": "wan2.7-videoedit",
  "prompt": "참조 이미지의 애니메 스타일에 맞게 동영상 스타일을 변경",
  "video_urls": ["https://cdn.example.com/original.mp4"],
  "image_urls": [
    "https://cdn.example.com/anime_style.jpg"
  ],
  "resolution": "1080P",
  "watermark": false
}
```

### 사례 3: 원본 동영상 오디오 유지

중요한 배경음이나 인물 대화가 있는 동영상에 적합:

```json theme={null}
{
  "model": "wan2.7-videoedit",
  "video_urls": ["https://cdn.example.com/speech.mp4"],
  "prompt": "배경을 산길로 교체",
  "metadata": { "audio_setting": "origin" }
}
```

### 사례 4: 전체 매개변수

```json theme={null}
{
  "model": "wan2.7-videoedit",
  "prompt": "인물의 의상을 빨간 드레스로 변경",
  "negative_prompt": "흐림, 왜곡",
  "video_urls": ["https://cdn.example.com/original.mp4"],
  "image_urls": ["https://cdn.example.com/reference.jpg"],
  "resolution": "1080P",
  "duration": 0,
  "size": "16:9",
  "prompt_extend": true,
  "watermark": false,
  "seed": 888,
  "metadata": {
    "audio_setting": "origin"
  }
}
```

## 오디오 처리 설명

| audio\_setting | 설명                               | 적용 시나리오                                |
| -------------- | -------------------------------- | -------------------------------------- |
| `auto` (기본값)   | 편집된 동영상 내용에 따라 AI가 일치하는 오디오를 재생성 | 시각 스타일이 크게 변하고 오디오도 동기화하여 업데이트하고 싶은 경우 |
| `origin`       | 원본 동영상 오디오 트랙을 강제 유지             | 중요한 배경음악, 인물 대화가 있는 동영상                |

<Note>
  **작업 결과 조회**

  동영상 생성은 비동기 작업으로, 제출 후 `task_id`가 반환됩니다. [작업 상태 조회](/ko/api-reference/tasks/status) 엔드포인트를 사용하여 생성 진행 상황과 결과를 조회하세요.
</Note>
