Compose music up to 60 seconds long using a text prompt

September 25, 2024 (October 11, 2024)

Table of contents

  1. Request Headers
  2. Query Parameters
  3. Responses
  4. Model
  5. Examples
  6. Try It

Equivalent of hailuoai.com/music.

Generate music in under 60 seconds. Add a new line to separate sentences. Add two empty lines for a pause.

Use hailuoai.com/music account to generate music, see Setup MiniMax for details.

https://api.useapi.net/v1/minimax/music/create?…

Request Headers
Authorization: Bearer {API token}
Content-Type: application/json
Query Parameters
  • account is optional when only one account configured. However, if you have multiple accounts configured, this parameter becomes required.

  • prompt is required. Provide your lyrics.

  • styleId is required. Specify desired music style.

  • title is optional.

Responses
  • Use the returned musicId to retrieve full music results, such as coverURL, style, lyrics and moderation status by using GET /music/musicId.

    Sometimes, MiniMax will apply post-moderation to an already generated song. In such cases, attempting to retrieve and play audioURL will fail, and the status of the generation will be set to 4. Those songs will not appear under GET /music and can only be retrieved by the GET /music/musicId endpoint.

    {
        "musicId": "user:1234-minimax:987654321-music:998877665544332211",
        "audioURL": "https://cdn.hailuoai.com/prod/2024-10-05-08/music/123456789-music_998877665544332211.mp3",
        "duration": 55,
    }
    
  • 400 Bad Request

    {
      "error": "<Error message>",
      "code": 400
    }
    
  • 401 Unauthorized

    {
      "error": "Unauthorized",
      "code": 401
    }
    
  • 422 Unprocessable Content

    Moderated prompt.

    {
        "error": "Moderated prompt"
    }
    
  • 429 Too Many Requests

    Only one concurrent music generation is supported per account.

    {
        "error": "The previous request has not been completed yet. Please try again later."
    }
    
Model
{ // TypeScript, all fields are optional
  musicId: string
  audioURL: string
  duration: number
  error: string
  code: number
}
Examples
  • curl "https://api.useapi.net/v1/minimax/music/create?styleId=…&prompt=…" \
         -H "Accept: application/json" \
         -H "Authorization: Bearer …" 
    
  • const styleId = "abcdef";      
    const prompt = "lyrics";      
    const apiUrl = `https://api.useapi.net/v1/minimax/music/create?styleId=${styleId}&prompt=${prompt}`; 
    const token = "API token";
    const response = await fetch(apiUrl, {
      headers: {
        "Authorization": `Bearer ${token}`,
      },
    });
    const result = await response.json();
    console.log("response", {response, result});
    
  • import requests
    styleId = "abcdef";      
    prompt = "lyrics";      
    apiUrl = f"https://api.useapi.net/v1/minimax/music/create?styleId={styleId}&prompt={prompt}";  
    token = "API token"
    headers = {
        "Content-Type": "application/json", 
        "Authorization" : f"Bearer {token}"
    }
    response = requests.get(apiUrl, headers=headers)
    print(response, response.json())
    
Try It