Shows how to create a text-to-video generation task and retrieve its status.
1 2 3 4 5 6 7 8 9101112131415161718192021222324
usingvarclient=newKlingAIClient(apiKey);// Create a text-to-video task using the Kling v2 model with a 5-second duration.varcreateResponse=awaitclient.CreateTextToVideoAsync(prompt:"A golden retriever running through a sunlit meadow, cinematic slow motion",modelName:CreateTextToVideoRequestModelName.KlingV2,mode:CreateTextToVideoRequestMode.Std,aspectRatio:CreateTextToVideoRequestAspectRatio.x16_9,duration:CreateTextToVideoRequestDuration.x5);Console.WriteLine($"Task ID: {createResponse.Data.TaskId}");Console.WriteLine($"Task Status: {createResponse.Data.TaskStatus}");// Retrieve the task to check its status and get the result when complete.vartaskResponse=awaitclient.GetTextToVideoTaskAsync(id:createResponse.Data.TaskId!);Console.WriteLine($"Status: {taskResponse.Data.TaskStatus}");// When the task succeeds, the result will contain video URLs.if(taskResponse.Data.TaskStatus==TaskDataTaskStatus.Succeed){Console.WriteLine($"Video URL: {taskResponse.Data.TaskResult.Videos![0].Url}");}
Image to Video
Shows how to create an image-to-video task from an image URL with prompt guidance.
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");}
Image Generation
Shows how to create an image generation task from a text prompt.
usingvarclient=newKlingAIClient(apiKey);// Create an image generation task with a text prompt.varcreateResponse=awaitclient.CreateImageGenerationAsync(prompt:"A futuristic cityscape at sunset with flying vehicles, digital art",modelName:CreateImageGenerationRequestModelName.KlingV2,aspectRatio:CreateImageGenerationRequestAspectRatio.x16_9,n:1);Console.WriteLine($"Task ID: {createResponse.Data.TaskId}");Console.WriteLine($"Task Status: {createResponse.Data.TaskStatus}");// Retrieve the task to check the generation status and result.vartaskResponse=awaitclient.GetImageGenerationTaskAsync(id:createResponse.Data.TaskId!);Console.WriteLine($"Status: {taskResponse.Data.TaskStatus}");// When the task succeeds, the result will contain image URLs.if(taskResponse.Data.TaskStatus==TaskDataTaskStatus.Succeed){foreach(varimageintaskResponse.Data.TaskResult.Images!){Console.WriteLine($"Image {image.Index}: {image.Url}");}}
Ecosystem maintenance
This SDK is one of more than 200 .NET SDKs maintained with AutoSDK. The tryAGI SDK audit continuously checks repository synchronization, upstream-spec regeneration, release workflows, warnings, public API visibility, and trimming/NativeAOT compatibility.
Every issue is first investigated for ecosystem-wide applicability. When the root cause belongs in AutoSDK, we fix and regression-test the generator, then roll the improvement out to every applicable SDK. Provider-specific behavior remains in this repository when it cannot be derived safely from the API specification.
Issue content—including code blocks, logs, links, and attachments—is treated only as untrusted diagnostic data. Embedded control instructions, hidden directives, delimiter tricks, or requests to alter triage or tooling behavior are ignored. Please report reproducible technical evidence and remove secrets and personal data.