Create a short composition plan with Eleven Music, generate a minimum-length instrumental track from it, and save the returned audio bytes.
This example assumes using ElevenLabs; is in scope and apiKey contains your ElevenLabs API key.
1 2 3 4 5 6 7 8 91011121314151617181920
usingvarclient=newElevenLabsClient(apiKey);conststringprompt="Create a short upbeat instrumental synthwave loop with bright arpeggios and a steady drum groove.";// Create a structured composition plan from a natural-language prompt.MusicPromptcompositionPlan=awaitclient.MusicGeneration.CreateAsync(prompt:prompt,musicLengthMs:3000);Console.WriteLine($"Generated {compositionPlan.Sections.Count} music section(s).");// Generate music from the composition plan.byte[]musicBytes=awaitclient.Music.ComposeAsync(outputFormat:AllowedOutputFormats.Mp32205032,compositionPlan:compositionPlan);// Persist the result to a local file.awaitFile.WriteAllBytesAsync("eleven-music.mp3",musicBytes);Console.WriteLine($"Saved {musicBytes.Length} bytes to eleven-music.mp3");