Shows how to create an image-to-video task from an image URL with prompt guidance.
This example assumes using KlingAI; is in scope and apiKey contains your KlingAI API key.
1 2 3 4 5 6 7 8 9101112131415161718192021222324
usingvarclient=newKlingAIClient(apiKey);// Create an image-to-video task by providing an image URL and a motion prompt.varcreateResponse=awaitclient.CreateImageToVideoAsync(image:"https://example.com/landscape.jpg",prompt:"Camera slowly pans across the landscape with gentle wind blowing through the trees",modelName:CreateImageToVideoRequestModelName.KlingV2,mode:CreateImageToVideoRequestMode.Std,duration:CreateImageToVideoRequestDuration.x5);Console.WriteLine($"Task ID: {createResponse.Data.TaskId}");// Query the task status using the returned task ID.vartaskResponse=awaitclient.GetImageToVideoTaskAsync(id:createResponse.Data.TaskId!);Console.WriteLine($"Status: {taskResponse.Data.TaskStatus}");// When complete, the result contains generated video URLs.if(taskResponse.Data.TaskStatus==TaskDataTaskStatus.Succeed){Console.WriteLine($"Video URL: {taskResponse.Data.TaskResult.Videos![0].Url}");Console.WriteLine($"Duration: {taskResponse.Data.TaskResult.Videos[0].Duration}s");}