Skip to main content

Image to Video Endpoint

Overview

Image to Video endpoint generates video from image.

Text to video endpoint result

Request

--request POST 'https://modelslab.com/api/v6/video/img2video' \

Make a POST request to https://modelslab.com/api/v6/video/img2video endpoint and pass the required parameters in the request body.

Body Attributes

ParameterDescriptionValues
keyYour API Key used for request authorization.key
model_idThe ID of the model to use. Can be svdAllowed values: svd
promptA text prompt describing the specific elements you'd like to see in the videostring
negative_promptItems you don't want in the video.string
enhance_promptEnhance prompts for better results; options: yes/no.string
init_imageLink equivalent of a valid PNG, JPEG, or other valid image format file to use as initial image conditioning.URL
heightMax height: 512px.The maximum is 512 pixels.
widthMax width: 512px.The maximum is 512 pixels.
num_framesNumber of frames in generated video. Max: 25. Defaults to 16.The maximum is 25. The default is 16.
num_inference_stepsNumber of denoising steps. Max: 50. Defaults to 20.The maximum is 50. The default is 20.
min_guidance_scaleStart value of guidance scale for video generation when using svd as model. Defaults to 1.0.1.0-8.0
max_guidance_scaleEnd value of guidance scale for video generation when using svd as model. Defaults to 3.0.1.0-8.0
motion_bucket_idHigher values lead to more motion in generated videos. Defaults to 127.Integral value (default: 127)
noise_aug_strengthStrength for noise initialization when using svd as model.min: 0, max: 1
fpsFrames per second rate of generated video.Max: 16
output_typeThe output type could be mp4, gif.mp4 or gif
latent_interpolation_methodInterpolation method, default is lerp. Other options: slerp.lerp, slerp
clip_skipClip skips - default is null.The default is null. (max: 2)
instant_responsetrue if you'd like a response with future links for queued requests instantly instead of waiting for a fixed amount of time. Defaults to false.TRUE or FALSE (default: FALSE)
temptrue if you want to store your generations on our temporary storage. Temporary files are cleaned every 24 hours. Defaults to false.TRUE or FALSE (default: FALSE)
webhookSet a URL to get a POST API call once the video generation is complete.URL
track_idThis ID is returned in the response to the webhook API call. This will be used to identify the webhook request.Integral value

Example

Body

Body
{
"key":"",
"model_id":"svd",
"init_image": "https://imagedelivery.net/PP4qZJxMlvGLHJQBm3ErNg/e2f9cb8e-cb87-4143-dd81-a9e77e3bb800/768",
"height":512,
"width":512,
"num_frames":25,
"num_inference_steps":20,
"min_guidance_scale":1,
"max_guidance_scale":3,
"motion_bucket_id":20,
"noise_aug_strength":0.02,
"webhook":null,
"track_id":null
}

Request

var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");

var raw = JSON.stringify({
"key":"",
"model_id":"svd",
"init_image": "https://imagedelivery.net/PP4qZJxMlvGLHJQBm3ErNg/e2f9cb8e-cb87-4143-dd81-a9e77e3bb800/768",
"height":512,
"width":512,
"num_frames":25,
"num_inference_steps":20,
"min_guidance_scale":1,
"max_guidance_scale":3,
"motion_bucket_id":20,
"noise_aug_strength":0.02,
"webhook":null,
"track_id":null
});

var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};

fetch("https://modelslab.com/api/v6/video/img2video", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));

Response

Example Response

{
"status": "success",
"generationTime": 8.49,
"id": 146,
"output": [
"https://pub-3626123a908346a7a8be8d9295f44e26.r2.dev/video_generations/ddde786a-a9cb-499f-83d9-f4fa45664404.gif"
],
"proxy_links": [
"https://pub-3626123a908346a7a8be8d9295f44e26.r2.dev/video_generations/ddde786a-a9cb-499f-83d9-f4fa45664404.gif"
],
"meta": {
"file_prefix": "c9173348-fbeb-4da2-9f86-e157763be54b",
"fps": 7,
"height": 512,
"init_image": "https://imagedelivery.net/PP4qZJxMlvGLHJQBm3ErNg/e2f9cb8e-cb87-4143-dd81-a9e77e3bb800/768",
"instant_response": "no",
"max_guidance_scale": 3,
"min_guidance_scale": 1,
"model_id": "svd",
"motion_bucket_id": 20,
"noise_aug_strength": 0.02,
"num_frames": 25,
"num_inference_steps": 20,
"seed": 3811131349,
"temp": "no",
"width": 512
}
}