Image to Video Endpoint
Overview
Text to Video endpoint generates video from image.
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
Parameter | Description | Values |
---|---|---|
key | Your API Key used for request authorization. | key |
model_id | The ID of the model to use. Can be svd | Allowed values: svd |
prompt | A text prompt describing the specific elements you'd like to see in the video, works only for the models dark-sushi-mix-vid , epicrealismnaturalsi-vid , and hellonijicute25d-vid . | string |
negative_prompt | Items you don't want in the video. | string |
init_image | Link equivalent of a valid PNG, JPEG, or other valid image format file to use as initial image conditioning. | URL |
height | Max height: 512px. | The maximum is 512 pixels. |
width | Max width: 512px. | The maximum is 512 pixels. |
num_frames | Number of frames in generated video. Max: 25. Defaults to 16. | The maximum is 25. The default is 16. |
num_inference_steps | Number of denoising steps. Max: 50. Defaults to 20. | The maximum is 50. The default is 20. |
min_guidance_scale | Start value of guidance scale for video generation when using svd as model. Defaults to 1.0. | 1.0-8.0 |
max_guidance_scale | End value of guidance scale for video generation when using svd as model. Defaults to 3.0. | 1.0-8.0 |
motion_bucket_id | Higher values lead to more motion in generated videos. Defaults to 127. | Integral value (default: 127) |
noise_aug_strength | Strength for noise initialization when using svd as model. | min: 0, max: 1 |
fps | Frames per second rate of generated video. | Max: 16 |
output_type | The output type could be mp4 , gif . | mp4 or gif |
latent_interpolation_method | Interpolation method, default is lerp . Other options: slerp . | lerp , slerp |
clip_skip | Clip skips - default is null. | The default is null. (max: 2) |
instant_response | true 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 ) |
temp | true 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 ) |
webhook | Set a URL to get a POST API call once the video generation is complete. | URL |
track_id | This 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":200,
"noise_aug_strength":0.02,
"webhook":null,
"track_id":null
}
Request
- JS
- PHP
- NODE
- PYTHON
- JAVA
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":200,
"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));
<?php
$payload = [
"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" => 200,
"noise_aug_strength" => 0.02,
"webhook" => null,
"track_id" => null
];
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://modelslab.com/api/v6/video/img2video',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => json_encode($payload),
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
var request = require('request');
var options = {
'method': 'POST',
'url': 'https://modelslab.com/api/v6/video/img2video',
'headers': {
'Content-Type': 'application/json'
},
body: 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":200,
"noise_aug_strength":0.02,
"webhook":null,
"track_id":null
})
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
import requests
import json
url = "https://modelslab.com/api/v6/video/img2video"
payload = json.dumps({
"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":200,
"noise_aug_strength":0.02,
"webhook":None,
"track_id":None
})
headers = {
'Content-Type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n \"key\":\"\",\n \"model_id\":\"svd\",\n \"init_image\": \"https://imagedelivery.net/PP4qZJxMlvGLHJQBm3ErNg/e2f9cb8e-cb87-4143-dd81-a9e77e3bb800/768\",\n \"height\":512,\n \"width\":512,\n \"num_frames\":25,\n \"num_inference_steps\":20,\n \"min_guidance_scale\":1,\n \"max_guidance_scale\":3,\n \"motion_bucket_id\":200,\n \"noise_aug_strength\":0.02,\n \"strength\":0.7,\n \"webhook\":null,\n \"track_id\":null\n}");
Request request = new Request.Builder()
.url("https://modelslab.com/api/v6/video/img2video")
.method("POST", body)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
Response
Example Response
{
"status": "success",
"generationTime": 8.49,
"id": 146,
"output": [
"https://d9jy2smsrdjcq.cloudfront.net/video_generations/59fbb932-2233-4119-ab1b-80403f4f135a.gif"
],
"proxy_links": [
"https://d9jy2smsrdjcq.cloudfront.net/video_generations/59fbb932-2233-4119-ab1b-80403f4f135a.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": 200,
"noise_aug_strength": 0.02,
"num_frames": 25,
"num_inference_steps": 20,
"seed": 3811131349,
"temp": "no",
"width": 512
}
}