import org.openapitools.client.ApiClient;
import org.openapitools.client.api.VideoApi;
import org.openapitools.client.ApiException;
import java.util.HashMap;
import java.util.Map;
public class VideoGenerationExample {
public static void main(String[] args) {
ApiClient apiClient = new ApiClient();
apiClient.setBasePath("https://api.legnext.ai");
VideoApi videoApi = new VideoApi(apiClient);
String apiKey = System.getenv("LEGNEXT_API_KEY");
try {
// Step 1: Generate initial video
Map<String, Object> body = new HashMap<>();
body.put("prompt", "a sunset over ocean waves");
body.put("videoType", 1);
var initialResponse = videoApi.apiV1VideoDiffusionPost(apiKey, body);
String jobId = initialResponse.getJobId();
System.out.println("Initial video job: " + jobId);
// Wait for completion (see task-management.mdx)
// ...
// Step 2: Extend the video
Map<String, Object> extendBody = new HashMap<>();
extendBody.put("jobId", jobId);
extendBody.put("videoNo", 0);
extendBody.put("prompt", "zoom in on the waves");
var extendResponse = videoApi.apiV1ExtendVideoPost(apiKey, extendBody);
System.out.println("Extended video job: " + extendResponse.getJobId());
} catch (ApiException e) {
System.err.println("Error: " + e.getResponseBody());
e.printStackTrace();
}
}
}