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();