> ## 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-R2V 참조 동영상 생성

>  - 알리바바 클라우드 완상 2.7 참조 동영상 생성 모델
- 하나 이상의 참조 이미지/동영상을 기반으로 스타일, 캐릭터, 장면이 일관된 새로운 동영상 생성
- 캐릭터 일관성, 스타일 전송, 다중 소재 조합 지원
- 참조 음성(reference_voice)을 통한 캐릭터 목소리 제어 지원 

<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-r2v",
      "prompt": "이 사람이 차가 붐비는 거리를 걸어간다",
      "image_with_roles": [{"url": "https://cdn.example.com/character.jpg", "role": "reference_image"}],
      "resolution": "1080P",
      "duration": 8
    }'
  ```

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

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

  payload = {
      "model": "wan2.7-r2v",
      "prompt": "이 사람이 차가 붐비는 거리를 걸어간다",
      "image_with_roles": [{"url": "https://cdn.example.com/character.jpg", "role": "reference_image"}],
      "resolution": "1080P",
      "duration": 8
  }

  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-r2v",
    prompt: "이 사람이 차가 붐비는 거리를 걸어간다",
    image_with_roles: [{ url: "https://cdn.example.com/character.jpg", role: "reference_image" }],
    resolution: "1080P",
    duration: 8
  };

  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-r2v",
          "prompt": "이 사람이 차가 붐비는 거리를 걸어간다",
          "image_with_roles": []map[string]string{
              {"url": "https://cdn.example.com/character.jpg", "role": "reference_image"},
          },
          "resolution": "1080P",
          "duration":   8,
      }

      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-r2v",
            "prompt": "이 사람이 차가 붐비는 거리를 걸어간다",
            "image_with_roles": [{"url": "https://cdn.example.com/character.jpg", "role": "reference_image"}],
            "resolution": "1080P",
            "duration": 8
          }
          """;

          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-r2v",
      "prompt" => "이 사람이 차가 붐비는 거리를 걸어간다",
      "image_with_roles" => [["url" => "https://cdn.example.com/character.jpg", "role" => "reference_image"]],
      "resolution" => "1080P",
      "duration" => 8
  ];

  $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-r2v",
    prompt: "이 사람이 차가 붐비는 거리를 걸어간다",
    image_with_roles: [{ url: "https://cdn.example.com/character.jpg", role: "reference_image" }],
    resolution: "1080P",
    duration: 8
  }

  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-r2v",
      "prompt": "이 사람이 차가 붐비는 거리를 걸어간다",
      "image_with_roles": [["url": "https://cdn.example.com/character.jpg", "role": "reference_image"]],
      "resolution": "1080P",
      "duration": 8
  ]

  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-r2v"",
              ""prompt"": ""이 사람이 차가 붐비는 거리를 걸어간다"",
              ""image_with_roles"": [{""url"": ""https://cdn.example.com/character.jpg"", ""role"": ""reference_image""}],
              ""resolution"": ""1080P"",
              ""duration"": 8
          }";

          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-r2v`로 고정
</ParamField>

<ParamField body="prompt" type="string" required>
  동영상 내용 설명, 최대 5000자

  여러 이미지/동영상의 경우 "이미지1", "이미지2", "동영상1" 등의 번호로 참조 소재를 지정 (입력 순서대로)

  예: `"이미지1의 인물이 이미지2의 장면으로 들어와 주위를 둘러본다"`
</ParamField>

<ParamField body="image_with_roles" type="array<object>">
  역할이 지정된 이미지 배열. `video_urls`와 최소 하나는 전달 필요

  각 객체 필드:

  * `url` (string): 이미지 URL
  * `role` (string): 이미지 역할
    * `reference_image` - 참조 이미지 (기본값)
    * `first_frame` - 첫 프레임 지정 (전달 시 `size` 매개변수는 무효, 첫 프레임 이미지의 비율 적용)
  * `reference_voice` (string, 선택): 해당 참조 캐릭터의 음성 샘플 오디오 URL. 생성된 동영상 내 캐릭터 목소리 제어에 사용

  예:

  ```json theme={null}
  [
    {
      "url": "https://cdn.example.com/character.jpg",
      "role": "reference_image",
      "reference_voice": "https://cdn.example.com/voice_sample.mp3"
    },
    { "url": "https://cdn.example.com/start.jpg", "role": "first_frame" }
  ]
  ```
</ParamField>

<ParamField body="video_urls" type="array<string>">
  참조 동영상 URL 배열, 최대 5개 (이미지+동영상 총합 ≤ 5)

  `image_with_roles`와 최소 하나는 전달 필요

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

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

<ParamField body="negative_prompt" type="string">
  원하지 않는 내용을 설명하는 네거티브 프롬프트, 최대 500자
</ParamField>

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

  옵션:

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

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

  지원 범위: `2` \~ `15`초

  기본값: `5`

  <Warning>
    참조 소재에 동영상이 포함된 경우: \[2, 10] 범위의 정수

    참조 소재에 동영상이 포함되지 않은 경우: \[2, 15] 범위의 정수
  </Warning>
</ParamField>

<ParamField body="size" type="string" default="16:9">
  화면 비율

  지원 형식:

  * `16:9` - 가로 와이드 (기본값)
  * `9:16` - 세로
  * `1:1` - 정사각형
  * `4:3` - 가로
  * `3:4` - 세로

  <Warning>
    `image_with_roles`를 통해 `first_frame`이 전달되면 이 매개변수는 무시되며, 비율은 첫 프레임 이미지 기준으로 설정됩니다
  </Warning>
</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>

## 응답

<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-r2v",
  "prompt": "이 사람이 차가 붐비는 거리를 걸어간다",
  "image_with_roles": [
    { "url": "https://cdn.example.com/character.jpg", "role": "reference_image" }
  ]
}
```

### 사례 2: 다중 참조 이미지 생성

```json theme={null}
{
  "model": "wan2.7-r2v",
  "prompt": "이미지1의 인물이 이미지2의 장면으로 들어와 이미지3의 동작을 따라한다",
  "image_with_roles": [
    { "url": "https://cdn.example.com/person.jpg", "role": "reference_image" },
    { "url": "https://cdn.example.com/background.jpg", "role": "reference_image" },
    { "url": "https://cdn.example.com/pose.jpg", "role": "reference_image" }
  ],
  "resolution": "1080P",
  "duration": 8,
  "size": "16:9"
}
```

### 사례 3: 참조 동영상 기반 생성

```json theme={null}
{
  "model": "wan2.7-r2v",
  "prompt": "참조 동영상의 스타일로 해변 일몰 장면을 생성",
  "video_urls": ["https://cdn.example.com/style_reference.mp4"],
  "resolution": "720P",
  "duration": 8
}
```

### 사례 4: 첫 프레임 지정 + 참조 이미지

```json theme={null}
{
  "model": "wan2.7-r2v",
  "prompt": "참조 인물이 이 위치에서 앞으로 걸어나간다",
  "image_with_roles": [
    { "url": "https://cdn.example.com/character.jpg", "role": "reference_image" },
    { "url": "https://cdn.example.com/start.jpg", "role": "first_frame" }
  ],
  "resolution": "1080P",
  "duration": 8
}
```

### 사례 5: 참조 이미지 + 참조 음성 (정밀한 방법)

```json theme={null}
{
  "model": "wan2.7-r2v",
  "prompt": "이 사람이 거리를 걸으면서 말한다",
  "image_with_roles": [
    {
      "url": "https://cdn.example.com/character.jpg",
      "role": "reference_image",
      "reference_voice": "https://cdn.example.com/voice_sample.mp3"
    }
  ],
  "resolution": "1080P",
  "duration": 10
}
```

## 이미지 참조 규칙

여러 참조 이미지가 있는 경우 `prompt` 내에서 번호로 참조합니다:

* 1번째 이미지 → "이미지1" 또는 "첫 번째 이미지"
* 1번째 동영상 → "동영상1" 또는 "첫 번째 동영상"

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

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