provider music-generation POST /v1/music
@utdk/elevenlabs /v1/music
Compose Music
Compose a song from a prompt or a composition plan.
output_format query
Output format of the generated audio. Formatted as codec_sample_rate_bitrate. So an mp3 with 22.05kHz sample rate at 32kbs is represented as mp3_22050_32. MP3 with 192kbps bitrate requires you to be subscribed to Creator tier or above. PCM with 44.1kHz sample rate requires you to be subscribed to Pro tier or above. Note that the μ-law format (sometimes written mu-law, often approximated as u-law) is commonly used for Twilio audio inputs.
enum: mp3_22050_32, mp3_24000_48, mp3_44100_32, mp3_44100_64…
xi-api-key header
Your API key. This is required by most endpoints to access our API programmatically. You can view your xi-api-key using the 'Profile' tab on the website.

Try it

Authentication
Configure credentials for ElevenLabs API Documentation
Gateway
The gateway proxies requests and injects credentials server-side. Configure credentials above, then enter your gateway URL.

Saved automatically to browser storage.

generate
POST/v1/music
Compose a song from a prompt or a composition plan.

Output format of the generated audio. Formatted as codec_sample_rate_bitrate. So an mp3 with 22.05kHz sample rate at 32kbs is represented as mp3_22050_32. MP3 with 192kbps bitrate requires you to be subscribed to Creator tier or above. PCM with 44.1kHz sample rate requires you to be subscribed to Pro tier or above. Note that the μ-law format (sometimes written mu-law, often approximated as u-law) is commonly used for Twilio audio inputs.

Input

A simple text prompt to generate a song from. Cannot be used in conjunction with `composition_plan`.

Optional generation mode hint for prompt-based music generation. Can only be used with `prompt`.

A music prompt. Deprecated. Use `composition_plan` instead.

The lyrics text to use for the generation.

A detailed composition plan to guide music generation. Cannot be used in conjunction with `prompt`.

The length of the song to generate in milliseconds. Used only in conjunction with `prompt`. Must be between 3000ms and 600000ms. Optional - if not provided, the model will choose a length based on the prompt.

The model to use for the generation.

Random seed to initialize the music generation process. Providing the same seed with the same parameters can help achieve more consistent results, but exact reproducibility is not guaranteed and outputs may change across system updates. Cannot be used in conjunction with prompt.

If true, guarantees that the generated song will be instrumental. If false, the song may or may not be instrumental depending on the `prompt`. Can only be used with `prompt`.

The ID of the finetune to use for the generation

How strongly the finetune influences the generation. Defaults to 1.0 (full strength). Lower values soften the influence of the finetune, leaving more room for prompt-level steering. Only meaningful when `finetune_id` is also provided.

If true, proper names in the prompt will be phonetically spelled in the lyrics for better pronunciation by the music model. The original names will be restored in word timestamps.

Controls how strictly section durations in the `composition_plan` are enforced. Only used with `composition_plan`. When set to true, the model will precisely respect each section's `duration_ms` from the plan. When set to false, the model may adjust individual section durations which will generally lead to better generation quality and improved latency, while always preserving the total song duration from the plan.

Whether to store the generated song for inpainting. Only available to enterprise clients with access to the inpainting feature.

Whether to sign the generated song with C2PA. Applicable only for mp3 files.

Enter a gateway URL above to enable sending.

Code snippet
Updates live as you fill in the form above.

TypeScript

import elevenlabs from '@utdk/elevenlabs';

await elevenlabs.generate({
  "model_id": "music_v1",
  "force_instrumental": false,
  "finetune_strength": 1,
  "use_phonetic_names": false,
  "respect_sections_durations": true,
  "store_for_inpainting": false,
  "sign_with_c2pa": false
})