package main
import (
"context"
"fmt"
"os"
legnext "github.com/legnext-ai/sdks/sdks/go"
)
func main() {
// Configure API client
config := legnext.NewConfiguration()
config.Servers = legnext.ServerConfigurations{
{
URL: "https://api.legnext.ai",
},
}
apiKey := os.Getenv("LEGNEXT_API_KEY")
if apiKey == "" {
fmt.Println("LEGNEXT_API_KEY environment variable not set")
return
}
config.AddDefaultHeader("x-api-key", apiKey)
client := legnext.NewAPIClient(config)
ctx := context.Background()
// Step 1: Generate video
prompt := "a beautiful sunset over the ocean"
videoType := int32(1)
request := legnext.VideoDiffusionRequest{
Prompt: &prompt,
VideoType: &videoType,
}
response, _, err := client.VideoGenerationAPI.GenerateVideo(ctx).
VideoDiffusionRequest(request).
Execute()
if err != nil {
fmt.Printf("Error generating video: %v\n", err)
return
}
jobId := *response.JobId
fmt.Printf("Video generation started: %s\n", jobId)
// Step 2: Wait for completion (see Task Management docs)
// ...
// Step 3: Extend the video
videoNo := int32(0)
extendPrompt := "continue with dramatic clouds"
extendRequest := legnext.ExtendVideoRequest{
JobId: &jobId,
VideoNo: &videoNo,
Prompt: &extendPrompt,
}
extendResponse, _, err := client.VideoGenerationAPI.ExtendVideo(ctx).
ExtendVideoRequest(extendRequest).
Execute()
if err != nil {
fmt.Printf("Error extending video: %v\n", err)
return
}
fmt.Printf("Video extension started: %s\n", *extendResponse.JobId)
// Step 4: Upscale the extended video
upscaleRequest := legnext.VideoUpscaleRequest{
JobId: extendResponse.JobId,
VideoNo: &videoNo,
}
upscaleResponse, _, err := client.VideoGenerationAPI.UpscaleVideo(ctx).
VideoUpscaleRequest(upscaleRequest).
Execute()
if err != nil {
fmt.Printf("Error upscaling video: %v\n", err)
return
}
fmt.Printf("Video upscale started: %s\n", *upscaleResponse.JobId)
}