Skip to content

CancelTask

This example assumes using Runway; is in scope and apiKey contains your Runway API key.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
using var client = new RunwayClient(apiKey);

// Start a generation task.

var response = await client.StartGenerating.CreateImageToVideoAsync(
    xRunwayVersion: "2024-11-06",
    request: new CreateImageToVideoRequestGen3aTurbo
    {
        PromptImage = "https://example.com/photo.jpg",
        PromptText = "A slow zoom out revealing the landscape",
        Model = "gen3a_turbo",
        Duration = 5,
        Ratio = CreateImageToVideoRequestGen3aTurboRatio.x1280_768,
    });

Console.WriteLine($"Task ID: {response.Id}");

// Cancel the task before it finishes.

await client.TaskManagement.DeleteTasksByIdAsync(
    id: response.Id,
    xRunwayVersion: "2024-11-06");

Console.WriteLine("Task cancelled successfully.");

// Verify the task is no longer running.

var taskDetail = await client.TaskManagement.GetTasksByIdAsync(
    id: response.Id,
    xRunwayVersion: "2024-11-06");