Music quickstart
This guide will show you how to generate music with Eleven Music.
Using the Eleven 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 a environment variable via an .env
file, or directly in your app’s configuration depending on your preference.
Composition plans
A composition plan is a JSON object that describes the music you want to generate in finer detail. It can then be used to generate music with Eleven Music.
Using a plan is optional, but it can be used to generate more complex music by giving you more granular control over each section of the generation.
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.
Next steps
Explore the API reference for more information on the Music API and its options.