Important Notice: This is an unofficial API implementation of Riffusion. We are not affiliated with or endorsed by the original Riffusion project. Any changes to the underlying Riffusion model or technology may temporarily affect our API's functionality without notice. Use at your own discretion.
Welcome to the Riffusion API documentation. Our API allows you to generate music from text descriptions using state-of-the-art AI technology. Riffusion is a powerful tool that transforms text prompts into high-quality music snippets across various genres and styles.
Generate unique music in seconds with simple text prompts
Use custom cookies to optimize requests and improve performance
Fine-tune your music generation with advanced parameters
https://riffusionapi.com/api
All API requests require authentication using an API key. Include your API key in the request headers:
x-api-key: YOUR_API_KEY
Security Warning
Never share your API key or commit it to version control. Store it securely as an environment variable in production environments.
You can manage your API keys from your dashboard. We recommend rotating your keys periodically for enhanced security.
Manage API Keys/status
Get current API usage and limits for your account
{
"status": "active",
"plan": "pro",
"monthly_calls": 150,
"remaining_calls": 9850,
"rate_limit_remaining": 9
}
/generate-music
Submit a music generation request (asynchronous processing)
{
"prompt": "jazz piano with drums",
"custom_cookies": [
{
"domain": "www.riffusion.com",
"name": "sb-api-auth-token.0",
"value": "base64-eyJhY2Nlc3NfdG9rZW4iOiJleUpoYkdja..."
},
{
"domain": "www.riffusion.com",
"name": "sb-api-auth-token.1",
"value": "mlkZW50aXR5X2RhdGEiOnsiYXZhdGFyX3..."
},
{
"domain": ".riffusion.com",
"name": "ph_phc_AQw23OVpatMbQV6oPTq1Lf6yJOOM415JjJSn1vtRnFC_posthog",
"value": "%7B%22distinct_id%22%3A%228a7c1cd2..."
}
]
}
prompt
Text description of the music to generate
Required
custom_cookies
Array of cookies to use with the request
Optional
seed
Random seed for generation
Optional
{
"status": "pending",
"request_id": "550e8400-e29b-41d4-a716-446655440000",
"message": "Your request has been submitted. Check /check-generation/{request_id} for results."
}
/check-generation/{request_id}
Check the status of a music generation request
request_id
: The ID returned from the generation request{
"status": "processing",
"message": "Your request is still processing"
}
{
"status": "success",
"urls": [
"https://storage.riffusion.com/123.wav",
"https://storage.riffusion.com/456.wav"
],
"plan": "pro"
}
{
"status": "failed",
"details": {
"detail": "Error generating music: WebDriver error occurred"
}
}
Our API includes rate limit information in response headers:
X-RateLimit-Limit
: Maximum requests per minuteX-RateLimit-Remaining
: Remaining requests in the current windowX-RateLimit-Reset
: Time when the rate limit resets (Unix timestamp)Rate Limit Exceeded
When rate limits are exceeded, the API will return a 429 Too Many Requests
status code. Please implement appropriate backoff and retry mechanisms in your application.
curl -X GET "https://riffusionapi.com/api/status" \
-H "accept: application/json" \
-H "x-api-key: YOUR_API_KEY"
Stability Warning
Using the API without custom cookies may result in reduced reliability, higher failure rates, and slower response times. For production environments, we strongly recommend using custom cookies as shown in the next example.
curl -X POST "https://riffusionapi.com/api/generate-music" \
-H "accept: application/json" \
-H "x-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"prompt": "jazz piano with drums"
}'
Check the status with the request_id you received:
curl -X GET "https://riffusionapi.com/api/check-generation/550e8400-e29b-41d4-a716-446655440000" \
-H "accept: application/json" \
-H "x-api-key: YOUR_API_KEY"
Recommended Approach
This method provides the most stable and reliable experience. Custom cookies help maintain session continuity with the Riffusion service.
curl -X POST "https://riffusionapi.com/api/generate-music" \
-H "accept: application/json" \
-H "x-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"prompt": "Summer hit",
"custom_cookies": [
{
"domain": "www.riffusion.com",
"name": "sb-api-auth-token.0",
"value": "base64-eyJhY2Nlc3NfdG9rZW4iOiJleUpoYkdja..."
},
{
"domain": "www.riffusion.com",
"name": "sb-api-auth-token.1",
"value": "mlkZW50aXR5X2RhdGEiOnsiYXZhdGFyX3..."
},
{
"domain": ".riffusion.com",
"name": "ph_phc_AQw23OVpatMbQV6oPTq1Lf6yJOOM415JjJSn1vtRnFC_posthog",
"value": "%7B%22distinct_id%22%3A%228a7c1cd2..."
}
]
}'
{
"detail": "Rate limit exceeded (10 requests per minute)"
}
{
"detail": "Invalid API key"
}
{
"detail": "Monthly API calls limit exceeded (10000 calls)"
}
{
"detail": "Request not found"
}
{
"status": "failed",
"details": {
"detail": "Error generating music: Timeout occurred"
}
}