> ## 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 3.0: Experience the New Music Generation Capabilities

* Better creative-intent understanding: the upgraded semantic model reduces the usual AI-generated drift.
* A major leap in sound quality: no more cramped or muddy mixes, with support for specific instruments and real playing techniques such as slides and legato for commercial-recording-grade listening.
* More natural vocal synthesis: the new vocal engine removes high-frequency "digital hiss" and gives you control over melody, pronunciation, breathing, and layered harmonies for a more studio-like result.

## Music Generation Example

Let's walk through how to create a modern melodic trap and dark R\&B track 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. This demo highlights overall control and realism in Music 3.0.

<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 modern melodic trap and dark R\&B track featuring a male vocalist with heavy autotune." — 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 modern melodic trap and dark R&B track featuring a male vocalist with heavy autotune. The production is driven by a deep bouncy 808 sub-bass, fast rolling triplet hi-hats, and moody ambient synths. The vocal style is a rhythmic sing-rap flow with cynical, nocturnal energy. The track has a steady groove, clean modern mixing, and a highly catchy, laid-back yet edgy urban vibe."
      }
      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., "A modern melodic trap and dark R\&B track with heavy autotune, deep bouncy 808 sub-bass, rolling triplet hi-hats, and moody ambient synths"), 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 3.0 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-3.0",
          "prompt": "A modern melodic trap and dark R&B track featuring a male vocalist with heavy autotune. The production is driven by a deep bouncy 808 sub-bass, fast rolling triplet hi-hats, and moody ambient synths. The vocal style is a rhythmic sing-rap flow with cynical, nocturnal energy. The track has a steady groove, clean modern mixing, and a highly catchy, laid-back yet edgy urban vibe.",
          "lyrics": "[Intro]\nShe so typical typical\n(typ-typ-typical) (typ-typ-typical)\n(typ-typ-typical)\n(typ-typ-typical)\n\n\n[verse]\nTold her save it\nI’ll show her how it really goes\nShe tell me she crave it\nYou don’t gotta hide that you fake it\nyou chase every trend you can take\nAnything I touch, I break\nDon’t care that you’re empty\nyou get naked, then vacant\nYour style outdated\n\n\n[pre-chorus]\nshort on sense and payment\nobsessed with famous\nrunning aimless\n\n\n[chorus]\nI swear I’ve seen your face\nin every single town\nChasing clout and praise\nyou just a clown don’t switch up now\nif you live for comments, say it loud\nBore me once, that’s all you get\nWon’t listen twice pipe it down\n\n\n[verse]\nI don’t want average\nyour whole vibe’s baggage\nyou post, then panic\nMy love? You couldn’t damage\nMy last girl had magic\nYou? Just tragic\nGet your weight up\nyou’re a habit I’m trying to break\n\n\n[hook]\nPlastic\nPlastic\nPlastic\nAll dayplastic\nShe say she get it, do it, get it\nPlastic\nPlastic\nPlastic\nShe so typical typical\n\n\n[bridge]\nShe basic told her face it\nI tell her where to go\nshe say erase it\nShe basic told her face it\nSay she want the truth\nshe can’t take it\n\n\n[pre-chorus]\nThis ain’t a game\nYou never change the flow\nIf you want something real\nyou gotta let it go\nYou love me\nYou love a ghost I know\nYou froze\nYou act like a drone\nwhile I sit on my throne\nNo friends just a phone\nTalent you don’t have it\nYour vibe’s all graphic\nWith me it’s an adventure\nwith you it’s plastic acting\nIf you talk, be honest\nIf you leave, I’m solid\nyour love’s mechanic\nI don’t feel the panic\n\n\n[chorus]\nShe basic told her face it\nI tell her where to go\nshe say erase it\nShe basic told her face it\nSay she want the truth\nshe can’t take it\nShe so typical typical\n\n\n[outro]\nI swear I’ve seen your face\nin every single town\nChasing clout and praise\nyou just a clown don’t switch up now\nif you live for comments, say it loud\nBore me once, that’s all you get\nWon’t listen twice pipe it down",
          "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/5b520c07-e2e9-49af-8815-e225ab8fb98a.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](/docs/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](/docs/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="/docs/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="/docs/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="/docs/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="/docs/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="/docs/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>
