Create music using a simple text prompt
February 17, 2025
Table of contents
https://api.useapi.net/v1/riffusion/music/create-prompt
Request Headers
Authorization: Bearer {API token}
Content-Type: application/json
# Alternatively you can use multipart/form-data
# Content-Type: multipart/form-data
API token
is required, see Setup useapi.net for details.
Request Body
{
"prompt": "jazzy k-pop song about a distant lover",
"instrumental": false,
"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. -
prompt
is required, describe a song or instrumental music. How to prompt tutorial. -
instrumental
is optional.
Supported values:true
,false
(default). model
is optional.
Supported values:FUZZ-0.8
(default)
-
replyUrl
is optional, place here your callback URL. API will call the providedreplyUrl
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
-
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 providedreplyUrl
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" }
-
{ "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.
There are two possible cases for API response 429:
- API query is full and can not accept new music/create-prompt 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 }
- 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-prompt 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
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-prompt \ -d '{"prompt": "…"}'
-
const apiUrl = `https://api.useapi.net/v1/riffusion/create-prompt`; const api_token = "API token"; const prompt = "Your prompt goes here"; const data = { method: 'POST', headers: { 'Authorization': `Bearer ${api_token}`, 'Content-Type': 'application/json' } }; data.body = JSON.stringify({ prompt }); 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-prompt" api_token = "API token" prompt = "Your prompt goes here" headers = { "Content-Type": "application/json", "Authorization" : f"Bearer {api_token}" } body = { "prompt": f"{prompt}" } response = requests.post(apiUrl, headers=headers, json=body) print(response, response.json())