Music quickstart
This guide will show you how to generate music with our Music API.
Use the ElevenLabs music skill to generate music tracks from your AI coding assistant:
Using the Music API
Create an API key
Create an API key in the dashboard here, which you’ll use to securely access the API.
Store the key as a managed secret and pass it to the SDKs either as an environment variable via an .env file, or directly in your app’s configuration depending on your preference.
Install the SDK
SDK
CLI
Python and TypeScript also use dotenv to load your API key from a .env file. The other SDKs read ELEVENLABS_API_KEY from the environment.
Install the ElevenLabs CLI. Homebrew (macOS) and Scoop (Windows) are recommended.
Working with an AI coding assistant? Run elevenlabs generate-skills in your project to write a
SKILL.md for every command group into skills/, so your assistant knows the CLI’s full surface
without you pasting docs. Use --output-dir to put them elsewhere. This reads the CLI’s own
embedded API definition, so it needs no API key and works offline — and it stays in step with
whichever CLI version you have installed.
Then authenticate — this opens your browser to authorize the CLI:
Composition plans
A composition plan is a JSON object that describes the music you want to generate in finer detail. Use text prompts for quick prototyping and composition plans when you need specific chunk structure, precise lyrics timing, or complex arrangements.
Generating a composition plan
A composition plan can be generated from a prompt by using the API.
The above will generate a composition plan similar to the following:
Using a composition plan
A composition plan can be used to generate music by passing it to the compose method.
Generating music with details
For each music generation a composition plan is created from the prompt. You can opt to retrieve this plan by using the detailed response endpoint.
Copyrighted material
Attempting to generate music or a composition plan that contains copyrighted material will result in an error. This includes mentioning a band or musician by name or using copyrighted lyrics.
Prompts with copyrighted material
In these cases, the API will return a bad_prompt error that contains a suggestion of what prompt you could use instead.
Composition plans with copyrighted material
If styles using copyrighted material are used when generating a composition plan, a bad_composition_plan error will be returned. Similar to music prompts, a suggested composition plan composition_plan_suggestion will be returned within the error.
In the case of a composition plan or prompt that contains harmful material, no suggested prompt will be returned.