ToAPIs ToAPIs
MAGI-2

MAGI-2 동영상 생성

텍스트, 첫/마지막 프레임 이미지 또는 이미지/동영상/오디오 멀티모달 참조로 1080p 동기화 음성 포함 MP4 동영상 생성, 길이 4-30초

POST
/v1/videos/generations

중국 본토 사용자 참고: 중국 본토에서는 https://toapis.cn을 API 엔드포인트(Base URL)로 사용하고 예시의 https://toapis.com을 https://toapis.cn으로 교체하세요. CN 사이트의 상태 조회 및 Webhook 응답에서는 미디어 파일 URL이 CN 파일 도메인으로 자동 변환됩니다.

  • 플랫폼 모델명: magi-2 (세 가지 모드 모두 단일 모델명을 사용하며 최상위 video_generation_mode로 구분)
  • 출력 사양: 동기화된 네이티브 오디오(대사, 효과음, 환경음)가 포함된 1080p MP4 동영상, 4-30초 사이의 임의 정수 초
  • 과금 방식: 성공적으로 출력된 동영상의 초 단위 길이를 기준으로 과금합니다. 세 가지 모드에 동일한 과금 규칙이 적용되며, 무음(generate_audio: false)도 동일한 과금 규칙을 사용하고, 참조 미디어는 별도 입력 항목으로 과금되지 않으며, 작업 실패 시에는 과금되지 않습니다
  • 지원 리전: 글로벌(https://toapis.com) 및 CN(https://toapis.cn) 양쪽 모두 지원
  • 비동기 작업 API: 제출 시 통일된 generation.task를 반환하며 GET /v1/videos/generations/{task_id} 또는 GET /v1/tasks/{task_id}로 상태와 결과를 조회합니다

이 모델은 엄격한 최상위 플랫 JSON 파라미터 화이트리스트를 적용합니다. 이미지-비디오를 포함한 모든 모드에서 prompt는 필수이며 공백일 수 없습니다. 미디어 입력만으로 모드를 자동 추론하지 않으며, 중첩 래퍼 객체(input, options, config, metadata), 구 별칭, 미정의 파라미터, Base64/Data URI, multipart 파일 업로드는 HTTP 400으로 거부됩니다.

입력 모드

video_generation_mode 모드 미디어 요구사항 aspect_ratio
text_to_video (기본값) 텍스트-비디오 image_urls, last_frame_url, video_urls, audio_urls 전달 불가 선택, 6가지 비율, 기본값 16:9
first_frame_image_to_video 첫/마지막 프레임 이미지-비디오 image_urls 필수(첫 프레임 정확히 1장); last_frame_url 선택; video_urls 및 audio_urls 전달 불가 선택, 6가지 비율; 생략 시 첫 프레임을 따름
reference_to_video 멀티모달 참조-비디오 image_urls(1-10장), video_urls(1-5개), audio_urls(1-5개) 중 최소 한 배열 이상 필수(혼합 가능); last_frame_url 전달 불가 선택, 6가지 비율, 기본값 16:9

인증

Authorizationstring헤더필수

모든 엔드포인트는 Bearer Token 인증이 필요합니다.

Authorization: Bearer <token>

요청 파라미터

modelstring본문필수기본값: magi-2

플랫폼 동영상 생성 모델명. 세 가지 모드 모두 magi-2로 고정됩니다.

video_generation_modestring본문기본값: text_to_video

동영상 생성 모드. 기본값은 text_to_video입니다.

  • text_to_video: 텍스트-비디오(미디어 필드 불가)
  • first_frame_image_to_video: 첫 프레임(선택적 마지막 프레임) 이미지-비디오
  • reference_to_video: 이미지/동영상/오디오 멀티모달 참조-비디오

미디어 입력을 전달할 때는 반드시 모드를 명시해야 하며 image_urls 존재 여부로 모드를 추론하지 않습니다.

promptstring본문필수

동영상 설명. 앞뒤 공백 제거 후 1-8000 Unicode 문자. 이미지-비디오를 포함한 모든 모드에서 필수(비어 있을 수 없음)입니다. 피사체, 동작, 카메라 움직임, 대사(따옴표로 표기), 효과음, 환경음을 구체적으로 작성하세요.

durationinteger본문기본값: 5

출력 동영상 길이(초). 4부터 30까지의 정수이며 기본값은 5입니다. 생성 초 단위로 과금됩니다.

aspect_ratiostring본문기본값: 16:9

출력 화면 비율. 지원 값: 21:9, 16:9, 4:3, 1:1, 3:4, 9:16.

  • text_to_video 및 reference_to_video: 기본값 16:9
  • first_frame_image_to_video: 선택 사항; 생략 시 출력 비율은 첫 프레임 이미지를 따릅니다
resolutionstring본문기본값: 1080p

출력 해상도. 1080p만 지원하며 다른 값은 거부됩니다.

generate_audioboolean본문기본값: true

동기화된 네이티브 오디오(대사, 효과음, 환경음) 생성 여부. 기본값 true. false로 설정하면 무음 동영상이 생성되며 과금 규칙은 동일합니다.

seedinteger본문

선택적 난수 시드(0~2147483647 정수, 양 끝값 포함). 생략 시 랜덤 시드 사용, 명시적 0은 그대로 보존되며 음수는 거부됩니다.

image_urlsstring[]본문

공개 접근 가능한 HTTP(S) 이미지 URL 배열(JPG / PNG / WEBP). 로컬 이미지는 먼저 이미지 업로드로 URL을 발급받으세요.

  • text_to_video: 전달 불가
  • first_frame_image_to_video: 필수, 첫 프레임으로 정확히 1장
  • reference_to_video: 선택, 주체/스타일 참조용 1-10장(첫 프레임으로 해석되지 않음)

사용하지 않을 때는 필드를 생략하세요. 빈 배열 []이나 null은 HTTP 400 오류를 반환합니다.

last_frame_urlstring본문

종료 장면을 지정하는 단일 공개 HTTP(S) 이미지 URL(JPG / PNG / WEBP).

first_frame_image_to_video 모드에서 image_urls와 함께 사용할 때만 허용되며 text_to_video 및 reference_to_video에서는 전달 불가합니다.

video_urlsstring[]본문

참조 동영상 공개 HTTP(S) URL 배열(MP4 / MOV), 1-5개. 로컬 동영상은 먼저 동영상 업로드로 URL을 발급받으세요.

  • reference_to_video에서만 허용되며 text_to_video 및 first_frame_image_to_video에서는 전달 불가
  • 각 클립은 2-30초, 참조 동영상 총 길이는 <= 30초여야 합니다(제출 시 URL 형식과 개수 상한을 검증하며 길이 제약은 생성 단계에서 검증됨)
audio_urlsstring[]본문

참조 오디오 공개 HTTP(S) URL 배열(MP3 / WAV), 1-5개. 로컬 오디오는 먼저 오디오 업로드로 URL을 발급받으세요.

  • reference_to_video에서만 허용되며 text_to_video 및 first_frame_image_to_video에서는 전달 불가
  • 각 클립은 2-30초, 참조 오디오 총 길이는 <= 30초여야 합니다(제출 시 URL 형식과 개수 상한을 검증하며 길이 제약은 생성 단계에서 검증됨)
client_business_idstring본문

주문 번호나 거래 ID 같은 선택적 비즈니스 식별자. 동일한 상태 조회 엔드포인트에서 이 값으로 작업을 조회할 수 있습니다.

webhookstring본문

선택적 ToAPIs 작업 완료 콜백 URL(callback_url도 호환 지원). 플랫폼이 HMAC-SHA256 서명으로 관리 및 전달하며 자세한 내용은 작업 Webhook을 참조하세요.

미디어 규칙 및 검증 경계

  • 모든 미디어 입력은 공개 접근 가능한 http:// 또는 https:// URL만 허용합니다. 사설/루프백 주소, 자격 증명이 포함된 URL, Data URI, Base64, multipart 파일 업로드는 거부됩니다.
  • reference_to_video 모드에서는 image_urls, video_urls, audio_urls 중 최소 한 배열 이상을 비어 있지 않게 전달해야 하며 세 유형을 자유롭게 조합할 수 있습니다.
  • 사용하지 않는 선택적 미디어 필드는 빈 배열 []이나 null 대신 생략하세요.
  • 중첩 래퍼 객체(input, options, config, metadata), 구 별칭(seconds, size, ratio, audio, audio_setting, image, images, reference_images), stream, n, fps, watermark, return_last_frame, negative_prompt, 범위 밖의 seed / duration, 미지원 resolution / aspect_ratio, 모드 충돌 조합은 HTTP 400으로 거부됩니다.

과금 규칙

항목 설명
과금 방식 성공 출력 동영상 초당 과금 (per_second, 4-30 정수 초)
모드 적용 text_to_video, first_frame_image_to_video, reference_to_video 세 모드에 동일한 과금 규칙 적용
오디오 및 참조 미디어 generate_audio: false(무음)도 동일한 과금 규칙을 사용하며, 참조 이미지/동영상/오디오는 별도 입력 항목으로 과금되지 않음
실패 및 정산 작업 실패 시 미과금(사전 예약 크레딧 환불); 최종 정산은 종료 상태 응답의 billing(status: "settled" / "refunded") 및 usage(charge_type: "per_second", output_seconds) 기준

제출 응답에는 작업 핸들만 포함되며 최종 비용은 포함되지 않습니다. 실제 제공 여부와 계정 과금 세부 사항은 해당 사이트 콘솔 및 최종 작업 상태의 billing / usage를 기준으로 합니다.

요청 예시

텍스트-비디오 (명시적 seed: 0)

{
  "model": "magi-2",
  "video_generation_mode": "text_to_video",
  "prompt": "A small boat crosses a quiet lake at sunrise, with gentle water sounds and distant birds.",
  "duration": 5,
  "aspect_ratio": "16:9",
  "resolution": "1080p",
  "generate_audio": true,
  "seed": 0
}

첫/마지막 프레임 이미지-비디오 (무음, aspect_ratio 미포함)

{
  "model": "magi-2",
  "video_generation_mode": "first_frame_image_to_video",
  "prompt": "The camera slowly pushes toward the subject and transitions smoothly into the ending composition.",
  "image_urls": [
    "https://example.com/first-frame.jpg"
  ],
  "last_frame_url": "https://example.com/last-frame.jpg",
  "duration": 5,
  "resolution": "1080p",
  "generate_audio": false
}

멀티모달 참조-비디오 (이미지 + 동영상 + 오디오)

{
  "model": "magi-2",
  "video_generation_mode": "reference_to_video",
  "prompt": "Keep the subject from the reference image, follow the camera movement from the reference video, and match the mood of the reference audio.",
  "image_urls": [
    "https://example.com/reference-subject.jpg"
  ],
  "video_urls": [
    "https://example.com/reference-motion.mp4"
  ],
  "audio_urls": [
    "https://example.com/reference-ambience.wav"
  ],
  "duration": 5,
  "aspect_ratio": "16:9",
  "resolution": "1080p",
  "generate_audio": true
}

응답

idstring

작업 상태 조회에 사용하는 ToAPIs 플랫폼 작업 ID.

objectstring

객체 유형, 항상 generation.task.

modelstring

이 요청에 사용된 플랫폼 모델명, 항상 magi-2.

statusstring

작업 상태: queued, in_progress, completed, failed 중 하나.

progressinteger

작업 진행률(0부터 100까지의 백분율).

created_atinteger

작업 생성 시각(Unix 초 타임스탬프).

제출 후 동영상 작업 상태 조회(GET /v1/videos/generations/{task_id}, GET /v1/tasks/{task_id} 호환)를 폴링하거나 작업 Webhook을 설정하세요. 완료되면 MP4 동영상 URL이 result.data[0].url에 반환됩니다. 폴링 간격은 지터를 포함해 5-10초 이상으로 설정하고 HTTP 429 응답 시 Retry-After를 따르세요.

요청 예시

curl --request POST \
  --url https://toapis.com/v1/videos/generations \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "model": "magi-2",
    "video_generation_mode": "text_to_video",
    "prompt": "A small boat crosses a quiet lake at sunrise, with gentle water sounds.",
    "duration": 5,
    "aspect_ratio": "16:9",
    "resolution": "1080p",
    "generate_audio": true,
    "seed": 0
  }'
curl --request POST \
  --url https://toapis.com/v1/videos/generations \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "model": "magi-2",
    "video_generation_mode": "first_frame_image_to_video",
    "prompt": "The camera slowly pushes in and transitions smoothly to the ending frame.",
    "image_urls": [
      "https://example.com/first-frame.jpg"
    ],
    "last_frame_url": "https://example.com/last-frame.jpg",
    "duration": 5,
    "resolution": "1080p",
    "generate_audio": false
  }'
curl --request POST \
  --url https://toapis.com/v1/videos/generations \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "model": "magi-2",
    "video_generation_mode": "reference_to_video",
    "prompt": "Keep the subject from the reference image, use the camera motion from the video, and match the ambience from the audio.",
    "image_urls": [
      "https://example.com/reference-subject.jpg"
    ],
    "video_urls": [
      "https://example.com/reference-motion.mp4"
    ],
    "audio_urls": [
      "https://example.com/reference-ambience.wav"
    ],
    "duration": 5,
    "aspect_ratio": "16:9",
    "resolution": "1080p",
    "generate_audio": true
  }'
import requests

response = requests.post(
    "https://toapis.com/v1/videos/generations",
    headers={
        "Authorization": "Bearer <token>",
        "Content-Type": "application/json",
    },
    json={
        "model": "magi-2",
        "video_generation_mode": "reference_to_video",
        "prompt": "Keep the subject from the reference image and show it moving in a sunlit garden.",
        "image_urls": ["https://example.com/reference-subject.jpg"],
        "duration": 5,
        "aspect_ratio": "16:9",
        "resolution": "1080p",
        "generate_audio": True,
    },
)

print(response.json())
const response = await fetch("https://toapis.com/v1/videos/generations", {
  method: "POST",
  headers: {
    Authorization: "Bearer <token>",
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    model: "magi-2",
    video_generation_mode: "text_to_video",
    prompt: "A small boat crosses a quiet lake at sunrise, with gentle water sounds.",
    duration: 5,
    aspect_ratio: "16:9",
    resolution: "1080p",
    generate_audio: true
  })
});

console.log(await response.json());

응답 예시

{
  "id": "tsk_vid_01M840FXWTM23BKN1JR68C5XEM",
  "object": "generation.task",
  "model": "magi-2",
  "status": "queued",
  "progress": 0,
  "created_at": 1795575600
}