Skip to main content

Text to Video Endpoint

Overview

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

Open in Playground 🚀

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

ParameterDescriptionValues
keyYour API Key used for request authorization.key
model_idThe ID of the model to use. The allowed model IDs are ltx .Allowed values:ltx .
promptText prompt with a description of the things you want in the video to be generated.String
negative_promptItems you don't want in the video.String
seedSeed is used to reproduce results. The same seed will give you the same image again. Pass null for a random number.Integer or null
heightThe height of the video.The maximum is 512 pixels.
widthThe width of the video.The maximum is 512 pixels.
num_framesThe number of frames in the generated video. Default is 16. Maximum is 25.Integer (Default: 16, Max: 25).
num_inference_stepsNumber of denoising steps. Default is 20. Maximum is 50.Integer (Default: 20, Max: 50).
guidance_scaleScale for classifier-free guidance. Minimum is 0, maximum is 8.min: 0, max: 8
clip_skipNumber of CLIP layers to skip. Skipping 2 layers often gives more aesthetic results. Default is null.Integer or null
upscale_heightThe upscaled height for videos generated.1024
upscale_widthThe upscaled width for videos generated.1024
upscale_strengthStrength of upscaling. Higher values can result in more noticeable differences.0-1
upscale_guidance_scaleGuidance scale for upscaling videos.0-8
upscale_num_inference_stepsNumber of denoising steps for upscaling. Default is 20. Maximum is 50.The maximum is 50. The default is 20.
use_improved_samplingWhether to use an improved sampling technique for better temporal consistency. Defaults to false.TRUE or FALSE
improved_sampling_seedSeed for consistent video generation with improved sampling.INTEGER
fpsFrames per second rate of the generated video.Max 16
output_typeThe type of output format.mp4 or gif
instant_responseIf true, returns future links for queued requests instantly instead of waiting. Default is false.The default is false. (TRUE or FALSE)
tempIf true, stores the video in temporary storage (cleaned every 24 hours). Default is false.The default is false. (TRUE or FALSE)
webhookA URL to receive a POST API call once the video generation is complete.URL
track_idA unique ID used in the webhook response to identify the request.string
Open in Playground 🚀

Example

Body

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

Body
{
"key":"",
"model_id":"ltx",
"prompt":"An astronaut riding a horse",
"negative_prompt":"low quality",
"height":512,
"width":512,
"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
}

Request

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

var raw = JSON.stringify({
"key":"",
"model_id":"ltx",
"prompt":"An astronaut riding a horse",
"negative_prompt":"low quality",
"height":512,
"width":512,
"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/video_generations/3037887d-03d0-4dd8-bbcc-cc9a9b65d664.gif"
],
"proxy_links": [
"https://pub-3626123a908346a7a8be8d9295f44e26.r2.dev/video_generations/3037887d-03d0-4dd8-bbcc-cc9a9b65d664.gif"
],
"meta": {
"clip_skip": null,
"file_prefix": "2be1702e-3a1f-46ee-811c-350cee84b66e",
"fps": 7,
"guidance_scale": 7,
"height": 512,
"improved_sampling_seed": 42,
"instant_response": "no",
"model_id": "ltx",
"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": 512
}
}