Deploy Dedicated GPU server to run AI models

Deploy Model
Skip to main content
Imagen

AI Music API - Generate Music from Text

Create original music tracks, sound effects, and audio content programmatically with ModelsLab's AI music API. Generate royalty-free music from text descriptions for any project.

What Is the ModelsLab AI Music API?

Generate Original Music from Text Descriptions

The ModelsLab AI Music API generates original music compositions from natural language descriptions. Describe the genre, mood, tempo, instrumentation, and duration — the API returns a royalty-free audio file within seconds. Generated tracks are original compositions, not samples or loops, and are cleared for commercial use without licensing fees.

The API supports text-to-music generation for full tracks and text-to-SFX for sound effects. Both endpoints accept detailed text prompts and return downloadable audio files in WAV or MP3 format.

  • Text-to-music: generate full compositions from natural language prompts
  • Text-to-SFX: create custom sound effects from text descriptions
  • Multiple genres — electronic, classical, ambient, hip-hop, jazz, cinematic, rock
  • Configurable parameters: BPM (60-200), duration (5-300 seconds), key, instruments
  • Royalty-free output — commercial use included, no licensing required
  • Audio output in WAV (uncompressed) and MP3 (compressed) formats

How Does AI Music Generation Compare to Stock Music Libraries?

Traditional stock music libraries charge per-track licensing fees ($15-$200 per track) and often have usage restrictions. AI music generation produces unlimited original tracks at pay-per-generation pricing — typically $0.02-$0.10 per track depending on duration. Each generated track is unique, eliminating the risk of another creator using the same music in a competing project.

Unlike stock libraries, the ModelsLab Music API can generate variations programmatically — produce 10 different versions of a "upbeat corporate intro" and pick the best one, all through API calls. This makes it particularly efficient for A/B testing audio in advertising and for procedural game audio.

Trusted by

Google logo
Salesforce logo
Amazon logo
IBM logo
Adobe logo
Sony logo
Google logo
Salesforce logo
Amazon logo
IBM logo
Adobe logo
Sony logo
Google logo
Salesforce logo
Amazon logo
IBM logo
Adobe logo
Sony logo
Google logo
Salesforce logo
Amazon logo
IBM logo
Adobe logo
Sony logo
1B+

Images Processed Monthly

500K+

Active Developers

5K+

Discord Community Members

300+

Available AI APIs

How Do You Generate Music from Text?

Create original music tracks and sound effects in a single API call. Describe the mood, genre, and instruments — the API handles the rest.

cURL — Generate a Music Track

bash
1curl -X POST https://modelslab.com/api/v6/audio/text_to_music \
2 -H "Content-Type: application/json" \
3 -d '{
4 "key": "your_api_key",
5 "prompt": "upbeat electronic track, 120 BPM, synthesizers and drums, energetic and positive mood, 30 seconds",
6 "duration": 30,
7 "format": "mp3"
8 }'

Python — Generate Sound Effects

python
1import requests
2
3# Generate a sound effect from text
4response = requests.post(
5 "https://modelslab.com/api/v6/audio/text_to_sfx",
6 json={
7 "key": "your_api_key",
8 "prompt": "thunderstorm with heavy rain and distant thunder",
9 "duration": 10,
10 "format": "wav"
11 }
12)
13
14data = response.json()
15audio_url = data["output"][0]
16print(f"Sound effect: {audio_url}")

JavaScript — Batch Music Generation

javascript
1// Generate multiple music variations for A/B testing
2const moods = ["energetic", "calm", "dramatic", "playful"];
3
4const results = await Promise.all(
5 moods.map(mood =>
6 fetch("https://modelslab.com/api/v6/audio/text_to_music", {
7 method: "POST",
8 headers: { "Content-Type": "application/json" },
9 body: JSON.stringify({
10 key: "your_api_key",
11 prompt: `corporate intro music, ${mood} mood, piano and strings, 15 seconds`,
12 duration: 15,
13 format: "mp3"
14 })
15 }).then(r => r.json())
16 )
17);
18
19results.forEach((data, i) => {
20 console.log(`${moods[i]}: ${data.output[0]}`);
21});

What Music Generation Capabilities Are Available?

Describe the mood, genre, tempo, and instruments — our music generation API produces original tracks in seconds.

Text-to-Music Generation

Describe the music you want in natural language — specify genre, mood, tempo, instruments, and duration. The API generates original compositions matching your description.

Sound Effects Generation

Create custom sound effects from text descriptions. Generate foley sounds, ambient audio, UI sounds, and environmental effects for games, films, and apps.

Multiple Genres and Styles

Generate music across genres — electronic, classical, hip-hop, ambient, jazz, rock, cinematic scores, and more. Control BPM, key, and instrumentation via API parameters.

Royalty-Free Output

All generated music is original and royalty-free for commercial use. Use tracks in videos, games, podcasts, and apps without licensing concerns.

Text-to-Music Generation
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result
Example of AI outpainting result

Create production-quality music, sound effects, and audio content through simple API calls.

How to Generate Music with Our API

Create original music in three steps.

STEP 01
STEP 01

Step 1: Describe Your Music

Send a text prompt describing the music you want. Specify genre, mood, instruments, tempo, and duration. For example: "upbeat electronic track, 120 BPM, synthesizers, 30 seconds."

STEP 02
STEP 02

Step 2: Generate and Preview

The API processes your request and generates an original music track. Receive the audio file URL within seconds, ready for download or streaming.

STEP 03
STEP 03

Step 3: Download and Use

Download the generated audio in WAV or MP3 format. Use it directly in your application, video, game, or any creative project.

Why Choose ModelsLab for AI Music Generation?

Key advantages that set us apart

Text-to-music generation from natural language
Multiple genre support — electronic, classical, ambient, and more
Sound effects generation from text descriptions
Royalty-free output for commercial use
Configurable BPM, key, and duration parameters
WAV and MP3 output formats
Batch generation for multiple tracks
RESTful API with Python and JavaScript SDKs
Sub-10-second generation for 30-second tracks
Pay-per-generation pricing with free tier
GDPR-compliant — audio not stored after delivery
24/7 developer support

Our Popular Use Cases

Where to use our AI music API:

Generate background music for YouTube videos, social media reels, and corporate presentations. Create unique soundtracks without licensing hassles.

Video Production

Your Data is Secure: GDPR Compliant AI Services

ModelsLab GDPR Compliance Certification Badge

GDPR Compliant

Flexible Pricing for Your AI Design & Visualization Needs

Choose the plan that fits your creative or development workflow. Cancel anytime.

Coming Soon

We are making some changes to our pricing, please check back later.

AI Music API — Frequently Asked Questions

The API supports a wide range of genres including electronic, classical, ambient, hip-hop, jazz, rock, cinematic scores, lo-fi, R&B, folk, and more. You specify the genre in your text prompt along with mood, tempo, and instrumentation preferences.

Yes. All music and sound effects generated through the ModelsLab AI Music API are original compositions that are royalty-free for commercial use. You can use them in videos, games, podcasts, advertisements, and applications without additional licensing fees.

Generated tracks can range from 5 seconds to 300 seconds (5 minutes). Duration is controlled via the duration parameter in your API request. Shorter tracks generate faster — a 30-second track typically generates in under 10 seconds.

Music generation is priced per generation, typically $0.02-$0.10 per track depending on duration and quality settings. A free tier is available for testing. Subscription plans include bundled generations at lower per-unit costs.

Yes. The API includes a dedicated text-to-SFX endpoint for generating sound effects from text descriptions. Create foley sounds, ambient audio, UI feedback sounds, environmental effects, and any other audio from natural language prompts.

The API outputs audio in WAV (uncompressed, highest quality) and MP3 (compressed, smaller file size) formats. Specify your preferred format via the format parameter in your request.

Get Expert Support in Seconds

We're Here to Help.

Want to know more? You can email us anytime at support@modelslab.com

View Docs
Plugins

Explore Plugins for Pro

Our plugins are designed to work with the most popular content creation software.

API

Build Apps with
ML
API

Use our API to build apps, generate AI art, create videos, and produce audio with ease.