Shows how to poll the status of a composition task until the track is composed
and the download URLs for the full track and individual stems are available.
This example assumes using Beatoven; is in scope and apiKey contains your Beatoven API key.
1 2 3 4 5 6 7 8 91011121314151617181920212223
// Compose a short track and poll until it finishes, then read the track + stem URLs// from the response metadata.usingvarclient=newBeatovenClient(apiKey);varcomposeResponse=awaitclient.Tracks.ComposeTrackAsync(prompt:newComposeTrackPrompt{Text="15 seconds calm piano melody"});usingvartimeoutCts=newCancellationTokenSource(TimeSpan.FromMinutes(5));TaskStatusResponse?status=null;while(!timeoutCts.IsCancellationRequested){status=awaitclient.Tasks.GetTaskStatusAsync(taskId:composeResponse.TaskId,cancellationToken:timeoutCts.Token);if(status.StatusisBeatoven.TaskStatus.ComposedorBeatoven.TaskStatus.Failed){break;}awaitTask.Delay(TimeSpan.FromSeconds(5),timeoutCts.Token);}