## Basic model info - Model name: sand/sand magi-2 - Model description: Generate a 1080p video from text, a starting image with an optional last frame, or image, video and audio references. Choose 4 to 30 whole seconds (default 5). Synchronized audio is enabled by default. - Endpoint name: reference-to-video ## Model schema The model schema is defined in the OpenAPI schema: [OpenAPI Schema](https://oapi.sunra.ai/main/sand/magi-2/f7272257989e3667a506280e314063a1f31e31fb.json) ### Model input schema The model input schema is: ```json { "additionalProperties": false, "anyOf": [ { "properties": { "reference_images": { "minItems": 1, "type": "array" } }, "required": [ "reference_images" ] }, { "properties": { "reference_videos": { "minItems": 1, "type": "array" } }, "required": [ "reference_videos" ] }, { "properties": { "reference_audios": { "minItems": 1, "type": "array" } }, "required": [ "reference_audios" ] } ], "description": "Supply at least one reference image, video, or audio clip.", "properties": { "prompt": { "description": "Describe the visuals and sounds.", "maxLength": 15000, "minLength": 1, "title": "Prompt", "type": "string", "x-sr-order": 201 }, "aspect_ratio": { "default": "16:9", "enum": [ "16:9", "9:16", "1:1", "4:3", "3:4", "21:9" ], "title": "Aspect Ratio", "type": "string", "x-sr-order": 402 }, "duration": { "default": 5, "description": "Requested duration in whole seconds. WaveSpeed prices the selected duration.", "maximum": 30, "minimum": 4, "title": "Duration", "type": "integer", "x-sr-order": 401 }, "generate_audio": { "default": true, "title": "Generate Audio", "type": "boolean", "x-sr-order": 501 }, "reference_audios": { "description": "Up to 5 public HTTPS audio clips, 2–30 seconds each and at most 30 seconds combined.", "items": { "format": "uri", "maxLength": 8192, "pattern": "^https://[^/\\\\\\s?#]+[^\\\\\\s#]*$", "type": "string" }, "maxItems": 5, "title": "Reference Audios", "type": "array", "x-sr-order": 303 }, "reference_images": { "description": "Public HTTPS URLs of up to 10 reference images, in order.", "items": { "format": "uri", "maxLength": 8192, "pattern": "^https://[^/\\\\\\s?#]+[^\\\\\\s#]*$", "type": "string" }, "maxItems": 10, "title": "Reference Images", "type": "array", "x-sr-order": 301 }, "reference_videos": { "description": "Up to 5 public HTTPS reference videos, 2–30 seconds each and at most 30 seconds combined.", "items": { "format": "uri", "maxLength": 8192, "pattern": "^https://[^/\\\\\\s?#]+[^\\\\\\s#]*$", "type": "string" }, "maxItems": 5, "title": "Reference Videos", "type": "array", "x-sr-order": 302 }, "resolution": { "const": "1080p", "default": "1080p", "title": "Resolution", "type": "string", "x-sr-order": 403 } }, "required": [ "prompt" ], "title": "ReferenceToVideoInput", "type": "object" } ``` ### Model output schema The model output schema is: ```json { "properties": { "output_video_dur": { "description": "Measured output duration in seconds.", "exclusiveMinimum": 0, "title": "Output Video Dur", "type": "number" }, "video": { "properties": { "content_type": { "description": "The mime type of the file.", "title": "Content Type", "type": "string" }, "file_name": { "description": "The name of the file. It will be auto-generated if not provided.", "title": "File Name", "type": "string" }, "file_size": { "description": "The size of the file in bytes.", "title": "File Size", "type": "integer" }, "url": { "description": "The URL where the file can be downloaded from.", "title": "Url", "type": "string" } }, "required": [ "content_type", "file_name", "file_size", "url" ], "title": "SunraFile", "type": "object" } }, "required": [ "video", "output_video_dur" ], "title": "MagiVideoOutput", "type": "object" } ``` ## Example inputs and outputs Use the following example inputs and outputs to understand the model. ### Input example ```json { "prompt": "", "aspect_ratio": "16:9", "duration": 5, "generate_audio": true, "reference_audios": [ ], "reference_images": [ ], "reference_videos": [ ], "resolution": "1080p" } ``` ### Output example ```json { } ``` ## Model code examples ### JavaScript ```javascript import { sunra } from "@sunra/client"; const result = await sunra.subscribe("sand/magi-2/reference-to-video", { input: { prompt: '', duration: 5, aspect_ratio: '16:9', resolution: '1080p', generate_audio: true, reference_images: [], reference_videos: [], reference_audios: [] }, logs: true, onQueueUpdate: (update) => { console.log(`Status Update: ${update.status}, Request ID: ${update.request_id}`); }, }); console.log(result.data); console.log(result.requestId); ``` ### Python ```python import sunra_client result = sunra_client.subscribe( "sand/magi-2/reference-to-video", arguments={ "prompt": "", "duration": 5, "aspect_ratio": "16:9", "resolution": "1080p", "generate_audio": True, "reference_images": [], "reference_videos": [], "reference_audios": [] }, with_logs=True, on_enqueue=print, on_queue_update=print, ) print(result) ``` ### Java ```java import ai.sunra.client.*; import java.util.Map; import com.google.gson.JsonObject; var client = SunraClient.withEnvCredentials(); var response = client.subscribe( "sand/magi-2/reference-to-video", SubscribeOptions.builder() .input(Map.of( "prompt", "", "duration", 5, "aspect_ratio", "16:9", "resolution", "1080p", "generate_audio", true, "reference_images", , "reference_videos", , "reference_audios", )) .resultType(JsonObject.class) .onQueueUpdate(update -> System.out.printf( "\nStatus Update: %s, Request ID: %s%n", update.getStatus(), update.getRequestId() )) .logs(true) .build() ); System.out.println("Completed!"); System.out.println(response.getData()); ``` ### Kotlin ```kotlin import ai.sunra.client.kt.* import com.google.gson.JsonObject val client = createSunraClient() val response = client.subscribe( endpointId = "sand/magi-2/reference-to-video", input = mapOf( "prompt" to "", "duration" to 5, "aspect_ratio" to "16:9", "resolution" to "1080p", "generate_audio" to true, "reference_images" to , "reference_videos" to , "reference_audios" to ), options = ai.sunra.client.kt.SubscribeOptions(logs = true), onUpdate = { update -> println("\nStatus Update: ${update.status}, Request ID: ${update.requestId}") } ) println("Completed!") println(response.data) ``` ### Curl ```bash curl --request POST \ --url https://api.sunra.ai/v1/queue/sand/magi-2/reference-to-video \ --header "Authorization: Key $SUNRA_KEY" \ --header "Content-Type: application/json" \ --data '{"prompt":"","duration":5,"aspect_ratio":"16:9","resolution":"1080p","generate_audio":true,"reference_images":[],"reference_videos":[],"reference_audios":[]}' ``` ## Model readme undefined