Skip to main content

Text to Video Endpoint

Overview

Text to Video endpoint generates and returns a video based on a text description.

Text to video endpoint result

Request

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

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

Body Attributes

ParameterDescription
keyYour API Key used for request authorization.
model_idThe ID of the model to use. The allowed model_id are zeroscope, dark-sushi-mix-vid ,epicrealismnaturalsi-vid,hellonijicute25d-vid
promptText prompt with description of the things you want in the video to be generated.
negative_promptItems you don't want in the video.
seedSeed is used to reproduce results, same seed will give you same image in return again. Pass null for a random number.
heightMax height: 1024px.
widthMax width: 1024px.
num_framesNumber of frames in generated video. Max: 25. Defaults to 16.
num_inference_stepsNumber of denoising steps. Max: 50. Defaults to 20.
guidance_scaleScale for classifier-free guidance.
clip_skipNumber of CLIP layers to skip. 2 leads to more aesthetic defaults. Defauls to null.
upscale_heightCan be specified to upscale height of video generated by zeroscope model.
upscale_widthCan be specified to upscale width of video generated by zeroscope model.
upscale_strengthHigher strength can lead to more differences between generated video and upscaled video when using zeroscope model.
upscale_guidance_scaleGuidance scale to be used for upscaling video when using zeroscope model.
upscale_num_inference_stepsNumber of denoising steps for upscaling video when using zeroscope model.
use_improved_samplingWhether or not you want to use improved sampling technique. Leads to better results with higher temporal consistency at the cost of being slow.
improved_sampling_seedSeed for consistent video generation when using improved sampling technique.
fpsFrames per second rate of generated video.
output_typeThe output type could be mp4,gif.
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.
temptrue if you want to store your generations on our temporary storage. Temporary files are cleaned every 24 hours. Defaults to false.
webhookSet an URL to get a POST API call once the image generation is complete.
ip_adapter_idIp adpater id. The supported ids are ip-adapter_sdxl, ip-adapter_sd15,ip-adapter-plus-face_sd15
ip_adapter_scalescale should be between 0 to 1
ip_adapter_imageValid image url for ip adapter
lora_modelslora models to be used with the model id - default=null
lora_strengthcomma separated lora strengths - default=1.0
motion_lorasmotion lora models to be used with the model id - default=null
motion_lora_strengthcomma separated motion lora strengths - default=1.0
domain_lora_scaleanimate diff v3 scale - default=1.0
adapter_loramotion model lora for v3 - default is v2_sd15_adapter
motion_modulemotion models - default is v2_sd15_mm. Other options include animatelcm,v2_sd15_mm,animateDiff-lightning
track_idThis ID is returned in the response to the webhook API call. This will be used to identify the webhook request.

Example

Body

When the model_id is zeroscope, the request json looks like so,

Body
{
"key":"",
"model_id":"zeroscope",
"prompt":"An astronaut riding a horse",
"negative_prompt":"low quality",
"height":320,
"width":576,
"num_frames":16,
"num_inference_steps":20,
"guidance_scale":7,
"upscale_height":640,
"upscale_width":1024,
"upscale_strength":0.6,
"upscale_guidance_scale":12,
"upscale_num_inference_steps":20,
"output_type":"gif",
"webhook":null,
"track_id":null
}

When the model_id is either dark-sushi-mix-vid ,epicrealismnaturalsi-vid orhellonijicute25d-vid , the request json looks like so,

Body
{
"key":"",
"model_id":"epicrealismnaturalsi",
"prompt":"An astronaut riding a horse",
"negative_prompt":"low quality",
"height":320,
"fps":7
"width":576,
"num_frames":18,
"num_inference_steps":30,
"guidance_scale":7.5,
"output_type":"gif",
"webhook":null,
"track_id":null
}

Request

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

var raw = JSON.stringify({
"key":"",
"model_id":"zeroscope",
"prompt":"An astronaut riding a horse",
"negative_prompt":"low quality",
"height":320,
"width":576,
"num_frames":16,
"num_inference_steps":20,
"guidance_scale":7,
"upscale_height":640,
"upscale_width":1024,
"upscale_strength":0.6,
"upscale_guidance_scale":12,
"upscale_num_inference_steps":20,
"output_type":"gif",
"webhook":null,
"track_id":null
});

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

fetch("https://modelslab.com/api/v6/video/text2video", 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": 147,
"output": [
"https://pub-3626123a908346a7a8be8d9295f44e26.r2.dev/generations/2be1702e-3a1f-46ee-811c-350cee84b66e.gif"
],
"proxy_links": [
"https://cdn2.stablediffusionapi.com/generations/2be1702e-3a1f-46ee-811c-350cee84b66e.gif"
],
"meta": {
"clip_skip": null,
"file_prefix": "2be1702e-3a1f-46ee-811c-350cee84b66e",
"fps": 7,
"guidance_scale": 7,
"height": 320,
"improved_sampling_seed": 42,
"instant_response": "no",
"model_id": "zeroscope",
"negative_prompt": "low quality",
"num_frames": 16,
"num_inference_steps": 20,
"output_type": "gif",
"prompt": "An astronaut riding a horse",
"seed": 3848624113,
"temp": "no",
"upscale_guidance_scale": 15,
"upscale_height": null,
"upscale_num_inference_steps": 20,
"upscale_strength": 0.6,
"upscale_width": null,
"use_improved_sampling": "no",
"width": 576
}
}