Sand AI의 Magi 2 동영상 생성 모델에 대한 전체 API 레퍼런스입니다.
모델 종류
이 API는 다음 세 가지 모델을 지원합니다.
Magi 2 Text to Video
엔드포인트 {#}
POST /api/v1/video/task
요청 매개변수
필수 매개변수
선택 매개변수
요청 예시
const response = await fetch('https://api.flaq.ai/api/v1/video/task', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
model_name: 'magi-2-text-to-video',
prompt: 'The camera glides toward a lighthouse at dusk as waves crash against the rocks',
duration: 8,
aspect_ratio: '16:9',
sound: true
})
});
const { data } = await response.json();
const taskId = data.task_id;
Magi 2 Image to Video
요청 매개변수
필수 매개변수
선택 매개변수
요청 예시
{
model_name: 'magi-2-image-to-video',
image_url: 'https://example.com/first-frame.jpg',
image_end_url: 'https://example.com/last-frame.jpg',
prompt: 'The camera slowly pulls back to reveal a waterfall and the forest around it',
duration: 8,
aspect_ratio: '16:9',
sound: false
}
Magi 2 Reference to Video
요청 매개변수
필수 매개변수
참조 미디어
모든 참조 미디어는 선택 사항이며 하나의 요청에 함께 사용할 수 있습니다. 세 배열을 모두 생략하면 모델이 프롬프트만으로 동영상을 생성합니다.
@ (AT) 참조 자리표시자
@ (AT) 참조 기능은 프롬프트에 번호가 붙은 <<<...>>> 자리표시자를 사용합니다. 번호는 미디어 유형별로 1부터 시작하며 해당 배열의 순서를 따릅니다.
선택 매개변수
요청 예시
{
model_name: 'magi-2-reference-to-video',
prompt: 'Use the reference image for the subject, the reference video for the camera movement, and the reference audio for the ambience',
duration: 8,
aspect_ratio: '16:9',
sound: true,
images: ['https://example.com/subject-reference.jpg'],
videos: ['https://example.com/camera-movement-reference.mp4'],
audios: ['https://example.com/ambience-reference.mp3']
}
@ (AT) 참조로 동영상을 생성하는 요청 예시
{
model_name: 'magi-2-reference-to-video',
prompt: 'Show the cyclist from <<<image_1>>> on the trail in <<<image_2>>>. Follow the camera movement in <<<video_1>>> and use <<<audio_1>>> as a reference for the forest ambience',
duration: 10,
aspect_ratio: '16:9',
sound: true,
images: [
'https://example.com/cyclist-reference.jpg',
'https://example.com/forest-trail-reference.png'
],
videos: ['https://example.com/camera-movement-reference.mp4'],
audios: ['https://example.com/forest-ambience-reference.mp3']
}
응답 형식
초기 응답
모든 모델은 폴링에 사용할 task_id를 반환합니다.
{
"code": 0,
"message": "success",
"data": {
"task_id": "{task_id}",
"response_url": "https://api.flaq.ai/api/v1/video/{task_id}",
"task_status": "submitted"
}
}
폴링 응답
GET /api/v1/video/{taskId}를 주기적으로 호출하여 상태를 확인합니다.
{
"code": 0,
"message": "success",
"data": {
"task_id": "{task_id}",
"response_url": "https://api.flaq.ai/api/v1/video/{task_id}",
"task_status": "succeed",
"task_status_msg": null,
"task_result": {
"videos": [
{
"url": "https://example.com/generated-video.mp4"
}
]
}
}
}
상태 값
submitted: 작업이 접수되어 처리 대기 중
processing: 동영상 생성 중
succeed: 동영상 생성 완료
failed: 동영상 생성 실패
권장 사항
- 프롬프트: 장면, 동작, 카메라 연출 및 원하는 소리를 설명합니다
- 프레임 이미지: 이미지로 동영상을 생성할 때는
image_end_url을 제공하는 경우에도 항상 image_url을 지정합니다
- 참조 순서:
images, videos, audios의 항목을 prompt에서 참조할 순서대로 배치합니다
- 소리: 무음 동영상이 필요하면
sound를 false로 설정합니다