Compose music

February 17, 2025

Table of contents

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

Compose tutorial. Advanced settings tutorial.

https://api.useapi.net/v1/riffusion/music/create-compose

Request Headers
Authorization: Bearer {API token}
Content-Type: application/json
# Alternatively you can use multipart/form-data
# Content-Type: multipart/form-data
Request Body
{
    "lyrics": "Song lyrics goes here",
    "prompt_1": "Drum & bass with some acid techno",
    "prompt_1_strength": 70,
    "prompt_1_start": 0,
    "prompt_1_end": 30,
    "prompt_2": "Melodic 80's new wave",
    "prompt_2_strength": 90,
    "prompt_2_start": 30,
    "prompt_2_end": 60,
    "prompt_3": "R&B with saxophone solo",
    "prompt_3_strength": 100,
    "prompt_3_start": 60,
    "prompt_3_end": 100,
    "model": "FUZZ-0.8",
    "replyUrl": "Place your call back URL here",
    "replyRef": "Place your reference id here",
    "maxJobs": 1-10
}
  • user_id is optional, if not specified API will randomly select account from available accounts.

  • lyrics is optional. Provide lyrics for your song. If this parameter omitted instrumental music will be generated.

  • lyrics_strength is optional. Gives you the ability to set how closely you want the model to follow the lyrics you added in the Lyrics section. Advanced Settings tutorial.
    Supported values: 0…100.

  • lyrics_weirdness is optional. Indicates how experimental and chaotic your song will be. Advanced Settings tutorial.
    Supported values: 0…100.

  • prompt_1 is required. Enter the type of genres, sounds, and vibe you want the song to have. How to prompt tutorial.

  • prompt_1_strength is optional. Specify how much the song adheres to sound prompt.
    Supported values: 20…100, default 50.

  • prompt_1_start is optional. Specify a percentage value between 0 and 100 indicating when the prompt should start being applied to the generated song.
    Supported values: 0…100, default 0.

  • prompt_1_end is optional. Specify a percentage value between 0 and 100 indicating when the prompt should stop being applied to the generated song.
    Supported values: 0…100, default 100.

  • prompt_2 is optional, see prompt_1. Same for prompt_2_strength, prompt_2_start and prompt_2_end.

  • prompt_3 is optional, see prompt_1. Same for prompt_3_strength, prompt_3_start and prompt_3_end.

  • instrumental is optional.
    Supported values: true, false (default).

  • model is optional.
    Supported values:
    • FUZZ-0.8 (default)
  • riff_id is optional. Specify the existing song you want to transform using the id provided by GET music.

  • audio_upload_id is optional. Use the job_id from POST music/upload-audio to specify the track you want to transform.

  • transform is optional. You can transform an existing song obtained via GET music or an uploaded track via POST music/upload-audio.
    Supported values:
    • cover - create a cover. Cover tutorial.
    • extend - extend existing audio. Extend tutorial.
    • inpaint - replace a portion of the song. Replace tutorial.
  • cover_variation is optional and used when the transform value is set to cover.
    Supported values: 0…100, default 50.

  • extend_after_seconds is required when the transform value is set to extend. Specify in seconds the point in the song from which you want the audio to extend.

  • replace_start_seconds is required when the transform value is set to replace. Specify in seconds the point in the song from which you want the audio to start replacing.

  • replace_end_seconds is required when the transform value is set to replace. Specify in seconds the point in the song at which you want the audio to end replacing.

  • seed is optional.
    Valid range 0…2147483647.

  • replyUrl is optional, place here your callback URL. API will call the provided replyUrl once generation completed or failed.
    Maximum length 1024 characters.
    We recommend using sites like webhook.site to test callback URL functionality.

  • replyRef is optional, place here your reference id which will be stored and returned along with the response / result.
    Maximum length 1024 characters.

  • maxJobs is optional, if not specified value from accounts will be used.
    Valid range: 1…10.
Responses
  • 200 OK

    Use the returned job_id to retrieve generation status and results using GET music.

    If you specify the optional parameter replyUrl, the API will call the provided replyUrl with generation progress updates until the generation is complete or fails.

    {
        "job_id": "a5d2d4a3-5bca-401a-8c53-2f18a7a4eb00",
        "user_id": "5f72c91e-2b3d-42a4-9fb1-0b8c2e293b2c"
    }
    
  • 400 Bad Request

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

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

    Moderated prompt.

    {
        "is_flagged": true,
        "reason": "moderation",
        "musician_replacement_data": null
    }
    
  • 429 Too Many Requests

    Wait in a loop for at least 10..30 seconds and retry again.

    There are two possible cases for API response 429:

    1. API query is full and can not accept new music/create-compose requests. Size of query defined by maxJobs optional parameter.
      {
       "error": "Account <user_id> is busy executing X jobs",
       "runningJobs": {
           "<user_id>": [
               {
                   "user_id": "<user_id>",
                   "job_id": "<job_id>",
                   "started": 1739763152345,
                   "replyUrl": "call back URL here, if provided",
                   "replyRef": "reference id here, if provided"
               }
           ]
       },
       "code": 429
      }
      
    2. The API received an HTTP response status 429 from Riffusion.
      {
       "detail": "Too Many Requests"
      }
      
  • 596 Pending error

    API was unable to refresh your cookie. Please resolve this issue by using the POST accounts endpoint before making any new API calls.

    {
      "error": "Your Riffusion account has pending error. Please address this issue at https://useapi.net/docs/api-riffusion-v1/post-riffusion-accounts before making any new API calls."
    }
    
Model
{   // TypeScript, all fields are optional
    job_id: string
    user_id: string
    detail: string
    is_flagged: boolean
    reason: string
}
Examples
  • curl -H "Accept: application/json" \
         -H "Content-Type: application/json" \
         -H "Authorization: Bearer …" \
         -X POST https://api.useapi.net/v1/riffusion/create-compose \
         -d '{"prompt_1": "…", "lyrics": "…"}'
    
  • const apiUrl = `https://api.useapi.net/v1/riffusion/create-compose`; 
    const api_token = "API token";
    const prompt_1 = "Your prompt goes here";      
    const lyrics = "Your lyrics goes here";     
    const data = { 
      method: 'POST',
      headers: {
        'Authorization': `Bearer ${api_token}`,
        'Content-Type': 'application/json' }
    };
    data.body = JSON.stringify({ 
      prompt_1, lyrics
    });
    const response = await fetch(apiUrl, data);
    const result = await response.json();
    console.log("response", {response, result});
    
  • import requests
    apiUrl = f"https://api.useapi.net/v1/riffusion/create-compose" 
    api_token = "API token"
    prompt_1 = "Your prompt goes here"      
    lyrics = "Your lyrics goes here"
    headers = {
        "Content-Type": "application/json", 
        "Authorization" : f"Bearer {api_token}"
    }
    body = {
        "prompt_1": f"{prompt_1}",
        "lyrics": f"{lyrics}"
    }
    response = requests.post(apiUrl, headers=headers, json=body)
    print(response, response.json())
    
Try It