Documentation Index
Fetch the complete documentation index at: https://docs.legnext.ai/llms.txt
Use this file to discover all available pages before exploring further.
apiV1VideoDiffusionPost()
Generate a video from text prompt or animate an existing image.
const { Configuration, VideoApi } = require('@legnext-api/js-sdk');
const apiClient = new Configuration();
apiClient.basePath = 'https://api.legnext.ai';
const videoApi = new VideoApi(apiClient);
const apiKey = 'your-api-key-here';
// Text-to-video
const body = {
prompt: 'a flowing river through mountains',
videoType: 1, // 0=480p (faster), 1=720p (higher quality)
callback: 'https://your-domain.com/webhook'
};
const response = await videoApi.apiV1VideoDiffusionPost(apiKey, body);
console.log('Job ID:', response.jobId);
Image-to-video animation (from generated image):
// Animate a specific image from a generation task
const body = {
jobId: 'original-job-id',
imageNo: 0, // Image number (0-3)
prompt: 'flowing water animation',
videoType: 1,
callback: 'https://your-domain.com/webhook'
};
const response = await videoApi.apiV1VideoDiffusionPost(apiKey, body);
Image-to-video animation (from image URL):
// Animate an existing image by URL
const body = {
prompt: 'https://example.com/image.png a flowing river through mountains',
videoType: 1,
callback: 'https://your-domain.com/webhook'
};
const response = await videoApi.apiV1VideoDiffusionPost(apiKey, body);
Parameters:
prompt (String): Video prompt or “[image_url] prompt text” (1-8192 characters)
videoType (Number): Quality (0=480p, 1=720p)
jobId (String, optional): For animating from existing generation task
imageNo (Number, optional): Image number (0-3) when using jobId
callback (String): Webhook URL
Returns: Promise resolving to response with job_id and status
apiV1ExtendVideoPost()
Extend an existing video.
const body = {
jobId: 'original-video-job-id',
videoNo: 0, // Video number (0-3)
prompt: 'continue with dramatic lighting', // Optional
callback: 'https://your-domain.com/webhook'
};
const response = await videoApi.apiV1ExtendVideoPost(apiKey, body);
console.log('Extended video Job ID:', response.jobId);
Parameters:
jobId (String): Original video task ID
videoNo (Number): Video number (0-3)
prompt (String, optional): Extension prompt (1-8192 characters)
callback (String): Webhook URL
apiV1VideoUpscalePost()
Upscale video to higher resolution.
const body = {
jobId: 'original-video-job-id',
videoNo: 0, // Video number (0-3)
callback: 'https://your-domain.com/webhook'
};
const response = await videoApi.apiV1VideoUpscalePost(apiKey, body);
console.log('Upscaled video Job ID:', response.jobId);
Parameters:
jobId (String): Original video task ID
videoNo (Number): Video number (0-3)
callback (String): Webhook URL
Complete Example
const { Configuration, VideoApi } = require('@legnext-api/js-sdk');
async function generateAndExtendVideo() {
const apiClient = new Configuration();
apiClient.basePath = 'https://api.legnext.ai';
const videoApi = new VideoApi(apiClient);
const apiKey = process.env.LEGNEXT_API_KEY;
try {
// Step 1: Generate initial video
const body = {
prompt: 'a sunset over ocean waves',
videoType: 1
};
const initialResponse = await videoApi.apiV1VideoDiffusionPost(apiKey, body);
const jobId = initialResponse.jobId;
console.log('Initial video job:', jobId);
// Wait for completion (see task-management.mdx)
// await waitForCompletion(jobId);
// Step 2: Extend the video
const extendBody = {
jobId: jobId,
videoNo: 0,
prompt: 'zoom in on the waves'
};
const extendResponse = await videoApi.apiV1ExtendVideoPost(apiKey, extendBody);
console.log('Extended video job:', extendResponse.jobId);
} catch (error) {
console.error('Error:', error);
}
}
generateAndExtendVideo();
Next Steps