> ## Documentation Index
> Fetch the complete documentation index at: https://platform.minimax.io/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Music Generation

> Use the prompt parameter to define the music's style, mood, and scenario, and the lyrics parameter to provide the vocal content. This feature is ideal for quickly generating unique theme songs for videos, games, or applications.

## Music 2.6: Cover Reborn. Bass Redefined.

Cover Reborn. Bass Redefined.

## Music Generation Example

Let's walk through how to create a soulful blues track from scratch in two simple steps: first, use the Lyrics Generation API to write lyrics based on a theme; then, feed those lyrics into the Music Generation API to compose and produce a complete song.

<Steps>
  <Step title="Call the Lyrics Generation API to generate lyrics from a theme (optional)">
    Simply tell the model what you're looking for — for example, "a soulful blues song about a rainy night" — and the Lyrics Generation API will automatically write complete lyrics with proper song structure (Verse, Chorus, Bridge, etc.). If you already have your own lyrics, feel free to skip this step. Additionally, even without lyrics you can go straight to the second step: call the music generation API to compose and generate a full song.

    <CodeGroup>
      ```python Lyrics Generation theme={null}
      import requests
      import os

      url = "https://api.minimax.io/v1/lyrics_generation"
      api_key = os.environ.get("MINIMAX_API_KEY")

      payload = {
          "mode": "write_full_song",
          "prompt": "A soulful blues song about a rainy night"
      }
      headers = {
          "Content-Type": "application/json",
          "Authorization": f"Bearer {api_key}"
      }

      response = requests.post(url, json=payload, headers=headers)

      print(response.text)
      ```
    </CodeGroup>
  </Step>

  <Step title="Call the Music Generation API to compose and produce the full song">
    Once you have your lyrics, set the music style via the `prompt` parameter (e.g., "Blues, Soulful, Rainy Night, Electric Guitar"), pass the lyrics into the `lyrics` parameter, and the Music Generation API will arrange, perform, and output a complete song. If you don't have lyrics, you can set the [lyrics\_optimizer](https://platform.minimax.io/docs/api-reference/music-generation#body-lyrics-optimizer) parameter to true to generate a song directly. In addition, Music 2.6 supports instrumental-only generation; see the [is\_instrumental](https://platform.minimax.io/docs/api-reference/music-generation#body-is-instrumental) parameter.

    <CodeGroup>
      ```python Music Generation theme={null}
      import requests
      import json
      import os

      url = "https://api.minimax.io/v1/music_generation"
      api_key = os.environ.get("MINIMAX_API_KEY")

      headers = {
          "Content-Type": "application/json",
          "Authorization": f"Bearer {api_key}"
      }

      payload = {
          "model": "music-2.6",
          "prompt": "Soulful Blues, Rainy Night, Melancholy, Male Vocals, Slow Tempo",
          "lyrics": "[Intro]\n(Ooh, yeah)\n(Listen to that rain)\nOh, Lord...\nIt's fallin' down so hard tonight...\n\n[Verse 1]\nThe sky is cryin', Lord, I can hear it on the roof\n(Hear it on the roof)\nEach drop a memory, ain't that the mournful truth?\nThis old guitar is my only friend in this lonely room\nSingin' the midnight rain blues, lost in the gloom\nStreetlights paintin' shadows, dancin' on the wall\nWishin' I could wash away this feelin' with it all\n(Wash it all away)\n\n[Chorus]\nMidnight rain, fallin' down on me\n(Fallin' on me)\nLike tears I can't cry, for all the world to see\nThis ain't just water, baby, it's a soulful sound\nWashin' over my heart, nowhere to be found\n(Nowhere to be found)\nJust the rhythm of the rain, and the blues in my soul\nTryna make me feel whole, but it's takin' its toll\n\n[Verse 2]\nRemember when we danced in the summer shower?\n(Summer shower)\nLaughin' like fools, in that golden hour\nNow the cold, hard rain, it chills me to the bone\nReminds me that I'm standin' here, all alone\nEvery rumble of thunder, shakes me deep inside\nGot nowhere to run, baby, nowhere left to hide\n(Nowhere to hide)\n\n[Pre-Chorus]\nThis lonely melody, it keeps playin' on\n(On and on)\nEver since you been gone\n(You been gone)\nOh, this rainy night, it just won't let me be\n\n[Chorus]\nMidnight rain, fallin' down on me\n(Fallin' on me)\nLike tears I can't cry, for all the world to see\nThis ain't just water, baby, it's a soulful sound\nWashin' over my heart, nowhere to be found\n(Nowhere to be found)\nJust the rhythm of the rain, and the blues in my soul\nTryna make me feel whole, but it's takin' its toll\n\n[Bridge]\n(Oh, the rain...)\nIs it washin' away the good times?\nOr just remindin' me of all the past crimes?\nThis emptiness inside, it cuts me like a knife\nJust me and this rain, livin' this lonely life\n(Lonely life)\nI need a little sunshine, Lord, to dry these tears\nChase away these lonely, rainy night fears\n\n[Solo]\n(Guitar solo - slow, mournful, bluesy)\n(Yeah... play it, boy)\n(Feel that rain)\n(Mmm-hmm)\n\n[Chorus]\nMidnight rain, fallin' down on me\n(Fallin' on me)\nLike tears I can't cry, for all the world to see\nThis ain't just water, baby, it's a soulful sound\nWashin' over my heart, nowhere to be found\n(Nowhere to be found)\nJust the rhythm of the rain, and the blues in my soul\nTryna make me feel whole, but it's takin' its toll\n\n[Outro]\n(Midnight rain...)\nOh, the rain...\n(Fallin' down)\nJust keep fallin'...\n(Wash me clean)\nLord, wash me clean...\n(Yeah...)\n(Blues...\nFade out...)",
          "audio_setting": {
              "sample_rate": 44100,
              "bitrate": 256000,
              "format": "mp3"
          },
          "output_format": "url"
      }

      response = requests.post(url, headers=headers, json=payload)
      result = response.json()

      print(json.dumps(result, ensure_ascii=False, indent=2))
      ```
    </CodeGroup>
  </Step>

  <Step title="Listen to the result">
    After completing the steps above, you'll have a complete song:

    <video controls className="w-full aspect-video rounded-xl audio-container" src="https://file.cdn.minimax.io/public/71fa0e3f-6ea2-4ecf-b2e7-89ee3815fdc3.mp3" />
  </Step>
</Steps>

## Cover Generation

Music Cover generates a new rendition of an existing song with a different style. There are two modes:

* **One-Step Cover**: Pass the reference audio directly — lyrics are auto-extracted via ASR.
* **Two-Step Cover**: Preprocess the audio first to extract and modify lyrics, then generate the cover.

### One-Step Cover (Quick Mode)

Pass the reference audio URL and a style prompt to the Music Generation API. Lyrics are automatically extracted from the audio.

<CodeGroup>
  ```python One-Step Cover theme={null}
  import requests
  import json
  import os

  url = "https://api.minimax.io/v1/music_generation"
  api_key = os.environ.get("MINIMAX_API_KEY")

  headers = {
      "Content-Type": "application/json",
      "Authorization": f"Bearer {api_key}"
  }

  payload = {
      "model": "music-cover",
      "audio_url": "https://example.com/original-song.mp3",
      "prompt": "Jazz, smooth, late night lounge, saxophone",
      "audio_setting": {
          "sample_rate": 44100,
          "bitrate": 256000,
          "format": "mp3"
      },
      "output_format": "url"
  }

  response = requests.post(url, headers=headers, json=payload)
  result = response.json()

  print(json.dumps(result, ensure_ascii=False, indent=2))
  ```
</CodeGroup>

### Two-Step Cover (Advanced Mode — with Lyrics Modification)

For more control, use the two-step workflow: first preprocess the audio to extract features and lyrics, then modify the lyrics and generate the cover.

<Steps>
  <Step title="Preprocess the reference audio">
    Call the [Music Cover Preprocess API](/api-reference/music-cover-preprocess) to extract audio features and structured lyrics. This step is **free** (no charge).

    The response includes:

    * `cover_feature_id`: A unique identifier for the audio features (valid for 24 hours)
    * `formatted_lyrics`: Structured lyrics with section tags (`[Verse]`, `[Chorus]`, etc.) that you can modify
    * `structure_result`: JSON string with segment types and timestamps
    * `audio_duration`: Duration of the reference audio in seconds

    <CodeGroup>
      ```python Preprocess theme={null}
      import requests
      import json
      import os

      url = "https://api.minimax.io/v1/music_cover_preprocess"
      api_key = os.environ.get("MINIMAX_API_KEY")

      headers = {
          "Content-Type": "application/json",
          "Authorization": f"Bearer {api_key}"
      }

      payload = {
          "model": "music-cover",
          "audio_url": "https://example.com/original-song.mp3"
      }

      response = requests.post(url, headers=headers, json=payload)
      result = response.json()

      # Save the cover_feature_id and review the lyrics
      cover_feature_id = result["cover_feature_id"]
      formatted_lyrics = result["formatted_lyrics"]

      print(f"Feature ID: {cover_feature_id}")
      print(f"Extracted Lyrics:\n{formatted_lyrics}")
      ```
    </CodeGroup>
  </Step>

  <Step title="Modify lyrics and generate the cover">
    Review and edit the `formatted_lyrics` from the previous step, then pass the `cover_feature_id` and modified lyrics to the [Music Generation API](/api-reference/music-generation).

    <Note>
      When using `cover_feature_id`, do not pass `audio_url` or `audio_base64` — they are mutually exclusive. The `lyrics` parameter is required (10–1000 characters).
    </Note>

    <CodeGroup>
      ```python Generate Cover theme={null}
      import requests
      import json
      import os

      url = "https://api.minimax.io/v1/music_generation"
      api_key = os.environ.get("MINIMAX_API_KEY")

      headers = {
          "Content-Type": "application/json",
          "Authorization": f"Bearer {api_key}"
      }

      # Use the cover_feature_id from the previous step
      # Modify the extracted lyrics as needed
      modified_lyrics = "[Verse 1]\nYour modified first verse here\nWith new words that tell your story\n\n[Chorus]\nA brand new chorus for the cover\nSinging with a different feel"

      payload = {
          "model": "music-cover",
          "cover_feature_id": cover_feature_id,
          "lyrics": modified_lyrics,
          "prompt": "Jazz, smooth, late night lounge, saxophone",
          "audio_setting": {
              "sample_rate": 44100,
              "bitrate": 256000,
              "format": "mp3"
          },
          "output_format": "url"
      }

      response = requests.post(url, headers=headers, json=payload)
      result = response.json()

      print(json.dumps(result, ensure_ascii=False, indent=2))
      ```
    </CodeGroup>
  </Step>
</Steps>

## Recommended Reading

<Columns cols={2}>
  <Card title="Music Generation API" icon="book-open" href="/api-reference/music-generation" arrow="true" cta="Click here">
    Use this API to generate a song from lyrics and a prompt.
  </Card>

  <Card title="Music Cover Preprocess API" icon="book-open" href="/api-reference/music-cover-preprocess" arrow="true" cta="Click here">
    Preprocess reference audio to extract features and lyrics for two-step cover generation.
  </Card>

  <Card title="Lyrics Generation API" icon="book-open" href="/api-reference/lyrics-generation" arrow="true" cta="Click here">
    Use this API to generate or edit lyrics from a song description.
  </Card>

  <Card title="Pricing" icon="book-open" href="/guides/pricing-paygo#music" arrow="true" cta="Click here">
    Detailed information on model pricing and API packages.
  </Card>

  <Card title="Rate Limits" icon="book-open" href="/guides/rate-limits#3-rate-limits-for-our-api" arrow="true" cta="Click here">
    Rate limits are restrictions that our API imposes on the number of times a user or client can access our services within a specified period of time.
  </Card>
</Columns>
