Music Generation
Generate original music tracks from text prompts
Music Generation
Generate original music tracks from text descriptions using Stable Audio and other music models.
Music generation can take 30-60 seconds. We recommend using async mode for production applications.
Try it Now
Test the Music Generation API directly in your browser:
Endpoint
POST /music/generations
POST /music/generations?async=trueRequired scope: music
Request Body
{
"prompt": "Upbeat electronic dance music with pulsing synths, 128 BPM",
"model": "fal-ai/stable-audio",
"duration_seconds": 30,
"mode": "text_to_music",
"output_format": "mp3",
"negative_prompt": null
}Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
prompt | string | Yes | - | Description of the music to generate |
model | string | No | fal-ai/stable-audio | Music model to use |
duration_seconds | number | No | 30 | Duration (max 47 seconds) |
mode | string | No | text_to_music | Generation mode |
source_audio | string | No | - | Audio URL for audio-to-audio mode |
output_format | string | No | mp3 | mp3 or wav |
negative_prompt | string | No | - | What to avoid in the generation |
model_inputs | object | No | - | Additional model-specific parameters |
Generation Modes
| Mode | Description |
|---|---|
text_to_music | Generate from text prompt only |
audio_to_audio | Transform existing audio based on prompt |
Available Models
| Model ID | Max Duration | Notes |
|---|---|---|
fal-ai/stable-audio | 47s | High quality, diverse styles (default) |
fal-ai/stable-audio-25/text-to-audio | 60s | Stable Audio 2.5 |
fal-ai/minimax-music/v2 | 60s | MiniMax Music v2 |
fal-ai/minimax-music/v1.5 | 60s | MiniMax Music v1.5 |
beatoven/music-generation | 60s | Beatoven AI |
sonauto/v2/text-to-music | 60s | Sonauto V2 |
Response
{
"created": 1703123456,
"data": {
"audio_url": "https://fal.media/files/music123.mp3",
"duration_seconds": 30
},
"model": "fal-ai/stable-audio",
"model_tier": "standard",
"usage": {
"tracks_used": 1,
"quota_multiplier": 1.25,
"tracks_remaining": 19
}
}Quota & Pricing
Music generation uses the music_tracks quota bucket:
| Plan | Music Tracks/Month |
|---|---|
| Free | - |
| Pro | 20 |
| Business | 80 |
Top-up pricing: $0.50 per track
Examples
curl -X POST https://www.novakit.ai/api/v1/music/generations \
-H "Authorization: Bearer sk_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"prompt": "Relaxing lo-fi hip hop beat with vinyl crackle and mellow piano",
"duration_seconds": 30
}'import requests
response = requests.post(
"https://www.novakit.ai/api/v1/music/generations",
headers={
"Authorization": "Bearer sk_your_api_key",
"Content-Type": "application/json"
},
json={
"prompt": "Epic orchestral trailer music with dramatic drums and strings",
"duration_seconds": 45
}
)
audio_url = response.json()["data"]["audio_url"]
print(f"Music: {audio_url}")
# Download the audio file
audio = requests.get(audio_url)
with open("music.mp3", "wb") as f:
f.write(audio.content)const response = await fetch(
"https://www.novakit.ai/api/v1/music/generations",
{
method: "POST",
headers: {
"Authorization": "Bearer sk_your_api_key",
"Content-Type": "application/json",
},
body: JSON.stringify({
prompt: "Ambient electronic soundscape with ethereal pads",
duration_seconds: 30,
}),
}
);
const data = await response.json();
console.log(`Music URL: ${data.data.audio_url}`);Prompt Writing Tips
Writing effective music prompts:
- Specify genre and style (e.g., "jazz", "electronic", "classical")
- Include tempo/BPM when relevant
- Describe instruments and sounds
- Mention mood and atmosphere
Example Prompts by Genre
| Genre | Example Prompt |
|---|---|
| Lo-fi | "Chill lo-fi hip hop beat, vinyl crackling, soft piano chords, rain sounds, 75 BPM" |
| Electronic | "Energetic EDM drop with pulsing bass, synth leads, and build-up, 128 BPM" |
| Cinematic | "Epic orchestral score with soaring strings, brass fanfare, and timpani drums" |
| Jazz | "Smooth jazz trio with walking bass, brush drums, and warm piano improvisation" |
| Ambient | "Peaceful ambient soundscape with gentle pads, nature sounds, and soft drones" |
| Rock | "Classic rock guitar riff with driving drums and electric bass, 120 BPM" |
| Classical | "Solo piano piece in the style of Chopin, romantic and melancholic" |
| Hip Hop | "Boom bap beat with heavy 808s, crispy snares, and soulful vocal samples, 90 BPM" |
Using Negative Prompts
Exclude unwanted elements from your generation:
{
"prompt": "Peaceful acoustic guitar melody",
"negative_prompt": "drums, electronic, distortion, loud, vocals"
}Audio-to-Audio Mode
Transform existing audio based on a text prompt:
response = requests.post(
"https://www.novakit.ai/api/v1/music/generations",
headers={"Authorization": "Bearer sk_your_api_key"},
json={
"prompt": "Make this more energetic with electronic beats",
"mode": "audio_to_audio",
"source_audio": "https://example.com/original-track.mp3",
"duration_seconds": 30
}
)Async Mode
For production use, always use async mode:
import requests
import time
# Start async generation
response = requests.post(
"https://www.novakit.ai/api/v1/music/generations?async=true",
headers={"Authorization": "Bearer sk_your_api_key"},
json={
"prompt": "Upbeat pop song with catchy melody",
"duration_seconds": 45
}
)
job_id = response.json()["id"]
print(f"Job started: {job_id}")
# Poll for completion with long-polling
while True:
status = requests.get(
f"https://www.novakit.ai/api/v1/jobs/{job_id}?poll=true",
headers={"Authorization": "Bearer sk_your_api_key"}
).json()
print(f"Status: {status['status']}, Progress: {status.get('progress', 0)}%")
if status["status"] == "completed":
print(f"Music URL: {status['outputData']['audio']['url']}")
break
elif status["status"] == "failed":
print(f"Failed: {status.get('errorMessage')}")
break
time.sleep(2)Output Formats
| Format | Description | Best For |
|---|---|---|
mp3 | Compressed, smaller files | Web, streaming |
wav | Uncompressed, higher quality | Production, editing |
Error Handling
| Status | Error | Solution |
|---|---|---|
| 400 | prompt is required | Provide a music description |
| 400 | duration_seconds exceeds maximum | Keep under 47 seconds |
| 402 | Music track limit exceeded | Upgrade plan or purchase top-up |
| 403 | Model tier not allowed | Check plan permissions |
Best Practices
1. Be Specific with Prompts
Instead of:
"Happy music"
Try:
"Uplifting acoustic folk song with strumming guitar, warm vocals, and light percussion, 110 BPM, major key"
2. Include Musical Details
- Tempo: "120 BPM", "fast tempo", "slow and relaxed"
- Key/Mode: "major key", "minor key", "modal"
- Instruments: List specific instruments you want
- Style references: "in the style of [artist/genre]"
3. Use Negative Prompts
Remove unwanted elements:
{
"prompt": "Calm meditation music",
"negative_prompt": "drums, percussion, fast, intense, vocals"
}4. Iterate and Refine
Music generation has inherent randomness. Generate multiple versions and pick the best one:
results = []
for i in range(3):
response = generate_music({
"prompt": "Jazz piano solo",
"duration_seconds": 30
})
results.append(response["data"]["audio_url"])