---
title: AI Music API - Generate Music from Text | ModelsLab
description: Generate original music and sound effects from text with our AI music API. Royalty-free output, multiple genres, fast generation. Try free.
url: https://modelslab-frontend-v2-927501783998.us-east4.run.app/ai-music-api
canonical: https://modelslab-frontend-v2-927501783998.us-east4.run.app/ai-music-api
type: website
component: Seo/AiMusicApi
generated_at: 2026-04-06T13:00:31.049205Z
---

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.

[Generate Music with API](https://modelslab-frontend-v2-927501783998.us-east4.run.app/register) [API Documentation](https://docs.modelslab.com)

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](https://imagedelivery.net/PP4qZJxMlvGLHJQBm3ErNg/669b27bc-f881-4e16-569d-4ce02f1bc000/768)

![Salesforce logo](https://imagedelivery.net/PP4qZJxMlvGLHJQBm3ErNg/8f7d9952-1dee-4108-f1e5-96ff77108e00/768)

![Amazon logo](https://imagedelivery.net/PP4qZJxMlvGLHJQBm3ErNg/b4d3bc1b-8c2b-4d98-7c87-ed162ccbf400/768)

![IBM logo](https://imagedelivery.net/PP4qZJxMlvGLHJQBm3ErNg/41bf250b-c933-4d8a-6355-07cf4a2fda00/768)

![Adobe logo](https://imagedelivery.net/PP4qZJxMlvGLHJQBm3ErNg/9eb124dd-95c4-4889-c838-faa0f6317000/768)

![Sony logo](https://imagedelivery.net/PP4qZJxMlvGLHJQBm3ErNg/2d67a30b-a490-4b96-ce1d-28d8371da300/768)

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

```
<code>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  }'</code>
```

### Python — Generate Sound Effects

python

```
<code>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}")</code>
```

### JavaScript — Batch Music Generation

javascript

```
<code>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});</code>
```

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](https://imagedelivery.net/PP4qZJxMlvGLHJQBm3ErNg/8741a716-a81d-419a-c14f-88155af00c00/768)

![Example of AI outpainting result](https://images.stablediffusionapi.com/?image=https://assets.modelslab.ai/generations/09738200-f1fc-442c-9852-7d6a9cd56d34.png&quality=25)

![Example of AI outpainting result](https://images.stablediffusionapi.com/?image=https://assets.modelslab.ai/generations/851c5561-3239-4915-a66b-46d58d6c377c.png&quality=25)

![Example of AI outpainting result](https://images.stablediffusionapi.com/?image=https://assets.modelslab.ai/generations/70d56252-0444-431d-82b9-ad15c260263e.png&quality=25)

![Example of AI outpainting result](https://images.stablediffusionapi.com/?image=https://assets.modelslab.ai/generations/7b9995d6-68e1-48ba-bc0c-8e3a8f824faf.png&quality=25)

![Example of AI outpainting result](https://images.stablediffusionapi.com/?image=https://assets.modelslab.ai/generations/878fc33a-be9d-4fef-a8a5-f2f9931cd1d3.jpg&quality=25)

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

[Start Free Trial](https://modelslab-frontend-v2-927501783998.us-east4.run.app/register)

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.

[Start Creating Music ](https://modelslab-frontend-v2-927501783998.us-east4.run.app/register)

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:

Video ProductionGame DevelopmentPodcasts and Audio ContentAdvertisingApp and UX Sound DesignFilm and Animation

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

![Video Production](https://imagedelivery.net/PP4qZJxMlvGLHJQBm3ErNg/0fbacb1a-6e34-4254-0a9d-5e75178cf200/768)

Your Data is Secure: GDPR Compliant AI Services
---

![ModelsLab GDPR Compliance Certification Badge](https://imagedelivery.net/PP4qZJxMlvGLHJQBm3ErNg/28133112-07fe-4c1c-44eb-36948d51ae00/768)

AI Image API Pricing Starting at $0.0047 Per Image
---

ModelsLab offers a free tier with pay-as-you-go pricing, a Standard plan at $47/month for 10,000 API calls, and a Premium plan at $199/month with unlimited calls. All plans include access to Flux, SDXL, Stable Diffusion 3, and 10,000+ community models. Cancel anytime.

Coming Soon
---

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

AI Music API — Frequently Asked Questions
---

### What genres can the AI Music API generate?

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.

### Is the generated music royalty-free?

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.

### How long can generated tracks be?

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.

### How much does AI music generation cost?

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.

### Can I generate sound effects too?

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.

### What audio formats are supported?

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>

Chat with support[View Docs](https://docs.modelslab.com)

Explore Our Other Solutions
---

Unlock your creative potential and scale your business with ModelsLab's comprehensive suite of AI-powered solutions.

[Imagen

### AI Image Generation & Tools

Generate, edit, upscale, and transform images with state-of-the-art AI models.

Explore Imagen](https://modelslab-frontend-v2-927501783998.us-east4.run.app/imagen) [Audio Gen

### AI Audio Generation

Text-to-speech, voice cloning, music generation, and audio processing APIs.

Explore Audio Gen](https://modelslab-frontend-v2-927501783998.us-east4.run.app/audio-gen) [Video Fusion

### AI Video Generation & Tools

Create, edit, and enhance videos with AI-powered generation and transformation tools.

Explore Video Fusion](https://modelslab-frontend-v2-927501783998.us-east4.run.app/video-fusion) [Chat

### Engage Seamlessly with LLM

Access powerful language models for chatbots, content generation, and AI assistants.

Explore Chat](https://modelslab-frontend-v2-927501783998.us-east4.run.app/custom-llm) [3D Verse

### Create Stunning 3D Models

Transform images and text into 3D models with advanced AI-powered generation.

Explore 3D Verse](https://modelslab-frontend-v2-927501783998.us-east4.run.app/3d-verse)

Plugins

Explore Plugins for Pro
---

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

[Explore Plugins](https://modelslab-frontend-v2-927501783998.us-east4.run.app/pro#plugins) [Learn More](https://modelslab-frontend-v2-927501783998.us-east4.run.app/pro)

API

Build Apps with ModelsLab

ML

 API
---

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

[API Documentation](https://docs.modelslab.com) [Playground](https://modelslab-frontend-v2-927501783998.us-east4.run.app/models)

---

*This markdown version is optimized for AI agents and LLMs.*

**Links:**
- [Website](https://modelslab.com)
- [API Documentation](https://docs.modelslab.com)
- [Blog](https://modelslab.com/blog)

---
*Generated by ModelsLab - 2026-04-06*