Compose music
February 17, 2025 (March 28, 2025)
Riffussion API has been decommissioned. Currently we do not have plans to re-release it and recommend switching to Mureka API for music generation.
Table of contents
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
API tokenis required, see Setup useapi.net for details.
Request Body
{
"title": "Optional song title",
"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_idis optional, if not specified API will randomly select account from available accounts. -
titleis optional. Provide title for your song. -
lyricsis optional. Provide lyrics for your song. If this parameter omitted instrumental music will be generated. -
lyrics_strengthis 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_weirdnessis optional. Indicates how experimental and chaotic your song will be. Advanced Settings tutorial.
Supported values: 0…100. -
prompt_1is required. Enter the type of genres, sounds, and vibe you want the song to have. How to prompt tutorial. -
prompt_1_strengthis optional. Specify how much the song adheres to sound prompt.
Supported values: 20…100, default 50. -
prompt_1_startis 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_endis 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_2is optional, seeprompt_1. Same forprompt_2_strength,prompt_2_startandprompt_2_end. -
prompt_3is optional, seeprompt_1. Same forprompt_3_strength,prompt_3_startandprompt_3_end. -
instrumentalis optional.
Supported values:true,false(default). modelis optional.
Supported values:FUZZ-0.8(default)
-
image_idis optional. Upload cover for your song via POST music/upload-image or generate one via POST music/generate-image. -
riff_idis optional. Specify the existing song you want to transform using theidprovided by GET music. -
audio_upload_idis optional. Use thejob_idfrom POST music/upload-audio to specify the track you want to transform. transformis optional. You can transform an existing song obtained via GET music or an uploaded track via POST music/upload-audio.
Supported values:-
cover_variationis optional and used when thetransformvalue is set tocover.
Supported values: 0…100, default 50. -
extend_after_secondsis required when thetransformvalue is set toextend. Specify in seconds the point in the song from which you want the audio to extend. -
replace_start_secondsis required when thetransformvalue is set toreplace. Specify in seconds the point in the song from which you want the audio to start replacing. -
replace_end_secondsis required when thetransformvalue is set toreplace. Specify in seconds the point in the song at which you want the audio to end replacing. trim_start_secondsis required when thetransformvalue is set totrim. Specify in seconds the point in the song from which you want the audio to start.-
trim_end_secondsis required when thetransformvalue is set totrim. Specify in seconds the point in the song at which you want the audio to end. -
seedis optional.
Valid range 0…2147483647. -
replyUrlis optional, place here your callback URL. API will call the providedreplyUrlonce generation completed or failed.
Maximum length 1024 characters.
We recommend using sites like webhook.site to test callback URL functionality. -
replyRefis optional, place here your reference id which will be stored and returned along with the response / result.
Maximum length 1024 characters. maxJobsis optional, if not specified value from accounts will be used.
Valid range: 1…10.
Responses
-
Use the returned
idvalues to retrieve generation status and results using GET music.If you specify the optional parameter
replyUrl, the API will call the providedreplyUrlwith generation progress updates until the generation is complete or fails.{ "jobs": [ { "id": "a5d2d4a3-5bca-401a-8c53-2f18a7a4eb00" }, { "id": "a05-ad4c1-a8f-52b3a7-a14e0d24b0c583a" } ], "user_id": "5f72c91e-2b3d-42a4-9fb1-0b8c2e293b2c" } -
{ "error": "<Error message>", "code": 400 } -
{ "error": "Unauthorized", "code": 401 } -
Moderated prompt.
{ "is_flagged": true, "reason": "moderation", "musician_replacement_data": null } -
Wait in a loop for at least 10..30 seconds and retry again.
If you get a
429directly from Riffusion (see case 2. below), you MUST wait at least 60 seconds before trying again. Ideally, you’d want to place this account on hold for 15+ minutes before trying again. Riffusion currently operates in free mode and limits the number of generations per account per hour. This restriction will likely be lifted once they switch to a paid model.There are two possible cases for API response 429:
- API query is full and can not accept new music/create-compose requests. Size of query defined by
maxJobsoptional 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 } - The API received an HTTP response status 429 from Riffusion.
{ "detail": "Too Many Requests" }
- API query is full and can not accept new music/create-compose requests. Size of query defined by
-
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
jobs: { 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())