## Basic model info - Model name: elevenlabs/elevenlabs music-v2 - Model description: ElevenLabs Music v2: studio-quality songs and instrumentals from a text prompt or a chunk-by-chunk composition plan with per-section styles, lyrics and optional audio references, 3 seconds to 10 minutes. - Endpoint name: text-to-music ## Model schema The model schema is defined in the OpenAPI schema: [OpenAPI Schema](https://oapi.sunra.ai/main/elevenlabs/music-v2/latest.json) ### Model input schema The model input schema is: ```json { "description": "Input schema for ElevenLabs Music v2 and v2.5 generation.", "properties": { "prompt": { "anyOf": [ { "maxLength": 4100, "type": "string" }, { "type": "null" } ], "description": "The text prompt describing the music to generate. Cannot be used in conjunction with composition_plan.", "title": "Prompt", "x-sr-order": 200 }, "seed": { "anyOf": [ { "type": "integer" }, { "type": "null" } ], "description": "Random seed to initialize the music generation process. Can only be used with composition_plan. The same seed with the same parameters gives more consistent results, but exact reproducibility is not guaranteed.", "title": "Seed", "x-sr-order": 402 }, "composition_plan": { "anyOf": [ { "description": "Chunk-based composition plan shared by Music v2 and v2.5.", "properties": { "chunks": { "description": "The chunks that make up the generation, in order. At most 30 chunks, totalling between 3000ms and 600000ms.", "items": { "description": "One generation chunk in a Music v2 composition plan.", "properties": { "audio_reference": { "anyOf": [ { "description": "Audio clip used to condition the style of a composition-plan chunk.", "properties": { "audio_url": { "description": "URL of the audio clip to use as the style reference.", "title": "Audio Url", "type": "string" }, "end_ms": { "anyOf": [ { "exclusiveMinimum": 0, "type": "integer" }, { "type": "null" } ], "description": "Offset into the clip where the referenced window ends, in milliseconds. Defaults to 30000ms after start_ms, or the end of the clip if it is shorter. The window must be at most 30000ms long.", "title": "End Ms" }, "start_ms": { "default": 0, "description": "Offset into the clip where the referenced window starts, in milliseconds.", "minimum": 0, "title": "Start Ms", "type": "integer" }, "strength": { "anyOf": [ { "enum": [ "low", "medium", "high", "xhigh" ], "type": "string" }, { "type": "null" } ], "description": "How strongly the model follows the reference. Low lets it deviate and be more creative, high keeps it close to the reference.", "title": "Strength" } }, "required": [ "audio_url" ], "title": "MusicAudioReference", "type": "object" }, { "type": "null" } ], "description": "An audio clip whose style conditions this chunk. The reference on the first chunk matters most: it influences every later chunk, so condition from the first chunk to style the whole song." }, "context_adherence": { "anyOf": [ { "enum": [ "low", "medium", "high" ], "type": "string" }, { "type": "null" } ], "description": "How closely this chunk follows the context of its surrounding chunks. Low adherence lets the model deviate and be more creative, high adherence keeps it consistent with the surrounding context.", "title": "Context Adherence" }, "duration_ms": { "description": "The duration of the chunk in milliseconds. Must be between 3000ms and 120000ms.", "maximum": 120000, "minimum": 3000, "title": "Duration Ms", "type": "integer" }, "negative_styles": { "anyOf": [ { "items": { "type": "string" }, "type": "array" }, { "type": "null" } ], "description": "The styles and musical directions that should not be present in this chunk. Leaving this empty is a good default; only set it to explicitly avoid a particular style or direction.", "title": "Negative Styles" }, "positive_styles": { "description": "The styles and musical directions that should be present in this chunk. Use English for best results. The styles of the first chunk matter most as they set the overall tone and genre; later chunks can add nuance, progression or change direction.", "items": { "type": "string" }, "title": "Positive Styles", "type": "array" }, "text": { "description": "The text to generate for this chunk. Can start with an optional section name in square brackets, e.g. [Verse 1], followed by lyric lines, plus inline directions in curly braces, e.g. {scratching}. Section names must be between 1 and 100 characters. At most 30 lines are allowed, each at most 200 characters.", "title": "Text", "type": "string" } }, "required": [ "text", "duration_ms", "positive_styles" ], "title": "MusicGenerationChunk", "type": "object" }, "maxItems": 30, "minItems": 1, "title": "Chunks", "type": "array" } }, "required": [ "chunks" ], "title": "MusicV2CompositionPlan", "type": "object" }, { "type": "null" } ], "description": "The chunk-based composition plan for the music. Cannot be used in conjunction with prompt.", "x-sr-order": 300 }, "force_instrumental": { "default": false, "description": "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.", "title": "Force Instrumental", "type": "boolean", "x-sr-order": 401 }, "music_length_ms": { "anyOf": [ { "maximum": 600000, "minimum": 3000, "type": "integer" }, { "type": "null" } ], "description": "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. Billing is per started minute of the actual output; because the model renders a few tens of milliseconds more than requested, a length on or within 500ms below a whole minute (e.g. 60000) is sent as that minute minus 500ms (59500) so the result stays inside the minute you asked for.", "title": "Music Length Ms", "x-sr-order": 400 }, "output_format": { "default": "mp3_48000_192", "description": "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. 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", "mp3_44100_96", "mp3_44100_128", "mp3_44100_192", "mp3_48000_128", "mp3_48000_192", "mp3_48000_240", "mp3_48000_320", "pcm_8000", "pcm_16000", "pcm_22050", "pcm_24000", "pcm_32000", "pcm_44100", "pcm_48000", "ulaw_8000", "alaw_8000", "opus_48000_32", "opus_48000_64", "opus_48000_96", "opus_48000_128", "opus_48000_192" ], "title": "Output Format", "type": "string", "x-sr-order": 500 } }, "title": "TextToMusicInput", "type": "object" } ``` ### Model output schema The model output schema is: ```json { "description": "Output schema for ElevenLabs Music generation.", "properties": { "audio": { "properties": { "content_type": { "description": "The mime type of the file.", "title": "Content Type", "type": "string" }, "file_name": { "description": "The name of the file. It will be auto-generated if not provided.", "title": "File Name", "type": "string" }, "file_size": { "description": "The size of the file in bytes.", "title": "File Size", "type": "integer" }, "url": { "description": "The URL where the file can be downloaded from.", "title": "Url", "type": "string" } }, "required": [ "content_type", "file_name", "file_size", "url" ], "title": "SunraFile", "type": "object" }, "output_audio_duration": { "title": "Output Audio Duration", "type": "integer" }, "output_audio_minutes": { "title": "Output Audio Minutes", "type": "integer" } }, "required": [ "audio", "output_audio_duration", "output_audio_minutes" ], "title": "MusicOutput", "type": "object" } ``` ## Example inputs and outputs Use the following example inputs and outputs to understand the model. ### Input example ```json { "prompt": null, "seed": null, "composition_plan": null, "force_instrumental": false, "music_length_ms": null, "output_format": "mp3_48000_192" } ``` ### Output example ```json { } ``` ## Model code examples ### JavaScript ```javascript import { sunra } from "@sunra/client"; const result = await sunra.subscribe("elevenlabs/music-v2/text-to-music", { input: { prompt: null, composition_plan: null, music_length_ms: null, force_instrumental: false, seed: null, output_format: 'mp3_48000_192' }, logs: true, onQueueUpdate: (update) => { console.log(`Status Update: ${update.status}, Request ID: ${update.request_id}`); }, }); console.log(result.data); console.log(result.requestId); ``` ### Python ```python import sunra_client result = sunra_client.subscribe( "elevenlabs/music-v2/text-to-music", arguments={ "prompt": None, "composition_plan": None, "music_length_ms": None, "force_instrumental": False, "seed": None, "output_format": "mp3_48000_192" }, with_logs=True, on_enqueue=print, on_queue_update=print, ) print(result) ``` ### Java ```java import ai.sunra.client.*; import java.util.Map; import com.google.gson.JsonObject; var client = SunraClient.withEnvCredentials(); var response = client.subscribe( "elevenlabs/music-v2/text-to-music", SubscribeOptions.builder() .input(Map.of( "prompt", null, "composition_plan", null, "music_length_ms", null, "force_instrumental", false, "seed", null, "output_format", "mp3_48000_192")) .resultType(JsonObject.class) .onQueueUpdate(update -> System.out.printf( "\nStatus Update: %s, Request ID: %s%n", update.getStatus(), update.getRequestId() )) .logs(true) .build() ); System.out.println("Completed!"); System.out.println(response.getData()); ``` ### Kotlin ```kotlin import ai.sunra.client.kt.* import com.google.gson.JsonObject val client = createSunraClient() val response = client.subscribe( endpointId = "elevenlabs/music-v2/text-to-music", input = mapOf( "prompt" to null, "composition_plan" to null, "music_length_ms" to null, "force_instrumental" to false, "seed" to null, "output_format" to "mp3_48000_192"), options = ai.sunra.client.kt.SubscribeOptions(logs = true), onUpdate = { update -> println("\nStatus Update: ${update.status}, Request ID: ${update.requestId}") } ) println("Completed!") println(response.data) ``` ### Curl ```bash curl --request POST \ --url https://api.sunra.ai/v1/queue/elevenlabs/music-v2/text-to-music \ --header "Authorization: Key $SUNRA_KEY" \ --header "Content-Type: application/json" \ --data '{"prompt":null,"composition_plan":null,"music_length_ms":null,"force_instrumental":false,"seed":null,"output_format":"mp3_48000_192"}' ``` ## Model readme undefined