You are developing a content creation app — reels, clips, presentations — and realize that each track needs to be licensed separately. This is expensive and slows down the release. The solution is to embed AI music generation right into the app. The user enters a text prompt, selects a genre and mood, and within 15–40 seconds gets a unique track with no copyright fees. We have already implemented such integrations for clients in fitness, fashion, and edutainment. Our experience: 5+ years in mobile development and 20+ projects with AI features. By generating your own music, you save up to $500 per commercial track compared to licensing from stock libraries.
Available APIs
Suno does not officially provide a public REST API — it is in closed beta. Direct integration is possible via unofficial API wrappers (unstable) or through Replicate, where open-source alternatives like MusicGen by Meta and AudioCraft are deployed.
For production, we recommend using proven solutions. Below is a comparison of three main options:
| Provider | Quality | Generation Time | Licensing | Commercial Use |
|---|---|---|---|---|
| ElevenLabs AI Music | High (with vocals) | 15–40 s | Rights transfer with paid plan | Yes |
| Replicate + MusicGen | Medium (instrumental) | 10–30 s | MIT (implicit) | Risky |
| Udio API (early access) | High (style + vocals) | 20–50 s | Per ToS user ownership with paid | Yes |
Example request to ElevenLabs Music:
POST https://api.elevenlabs.io/v1/sound-generation
xi-api-key: <key>
{
"text": "Upbeat electronic music for a fitness app, 120 BPM, energetic",
"duration_seconds": 30,
"prompt_influence": 0.5
}
Response after 15–40 seconds — binary mp3 or JSON with URL.
Guide for AI Music Generation Integration
-
Choose a provider based on your budget and quality needs. ElevenLabs is 2x faster than Udio for short tracks (15s vs 30s average) and offers clearer licensing for commercial use.
-
Set up API keys securely on your backend. Never expose them in the client.
-
Build the generation request with prompt, duration, and optional parameters like prompt_influence.
-
Handle async response via polling with backoff delays or webhooks. Show a progress indicator with ETA (e.g., 25s for a 30s track).
-
Save and play back the audio. On iOS, configure AVAudioSession for playback. On Android, use ExoPlayer with crossfade.
Async Flow on iOS
class MusicGenerationService {
func generate(prompt: String, duration: Int) async throws -> URL {
let jobId = try await elevenLabsClient.createMusicJob(
prompt: prompt,
duration: duration
)
for delay in [5.0, 8.0, 10.0, 15.0, 20.0, 30.0] {
try await Task.sleep(nanoseconds: UInt64(delay * 1e9))
let status = try await elevenLabsClient.getJobStatus(id: jobId)
if status.state == "complete", let url = status.audioURL {
return try await downloadAudio(from: url)
}
if status.state == "error" { throw MusicGenError.failed }
}
throw MusicGenError.timeout
}
}
Generation time for a 30-second track is 15–30 seconds. A spinner with progress is enough; push is not required.
Playback and Audio Management
On iOS, audio generation must be properly integrated with AVAudioSession:
// Session setup: playback even in silent mode
try AVAudioSession.sharedInstance().setCategory(
.playback,
mode: .default,
options: [.mixWithOthers]
)
try AVAudioSession.sharedInstance().setActive(true)
If you do not configure the .playback category, the music will mute when the screen locks. This is a common mistake in MVP implementations. For iOS audio playback, ensure proper session handling.
On Android: MediaPlayer for simple playback, ExoPlayer for a queue of tracks with smooth transitions (DefaultCrossfadeHandler). This handles Android audio generation results efficiently.
Licensing and Copyright
The main legal question: who owns the rights to the generated track? ElevenLabs: with a paid plan — the user. MusicGen: MIT license for the model, but the commercial use status of tracks is not explicitly regulated. Suno: according to ToS, tracks belong to the user with a paid subscription. AI music licensing terms vary by provider.
In the app: clearly inform users about the licensing terms of the chosen AI service. If the track will be used in commercial videos — recommend the provider's paid plan.
Integration with Video
A common case is to select or generate music for a video clip. Need: match the beat to the video length (loop/trim), overlay via FFmpeg, save the result.
Simple loop with FFmpeg:
ffmpeg -stream_loop -1 -i music.mp3 -i video.mp4 \
-shortest -map 0:a -map 1:v \
-c:v copy -c:a aac output.mp4
If the track is longer than the video — trim with fade out: add -af "afade=t=out:st={fade_start}:d=2".
What's Included in the Work
| Stage | Description | Result |
|---|---|---|
| Analysis | Provider selection, load estimation, legal check | Specification with cost estimates |
| Design | Generation flow architecture, licensing scheme | Diagram, API contracts, UI mockups |
| Implementation | Integration code, style selection UI, progress, playback | Working prototype |
| Testing | Speed, stability, edge case coverage | Test report (100+ scenarios) |
| Deployment | CI/CD, monitoring, documentation | App Store/Google Play access, admin guide |
Deliverables:
- Full source code with inline comments
- API documentation and licensing cheat sheet
- User training (1 hour session)
- 30-day post-launch support
- Access to our custom monitoring dashboard (track errors, generation times)
Pricing: Basic integration (generation → playback → save) starts at $2,500. Full cycle with video editor and track history: $8,000–$12,000. Contact us for a detailed quote.
Why Trust Us with the Integration?
We are a team with 5+ years of experience in mobile development and over 20 projects with AI features. Our solutions run in production with loads up to 10,000 generations per day. We use a proven stack: Swift 5.9, Kotlin, Flutter 3.x. We guarantee code transparency and compliance with App Store Review Guidelines.
How to Order the Integration?
Contact us — we will assess your project, select the optimal provider, and propose timelines. Basic integration takes from 4 days. A full cycle with a video editor and track history takes up to 2 weeks. The cost is calculated individually. For a consultation on AI music generation, write to us. Our AI integration mobile app expertise ensures seamless implementation of prompt-based track generation and async generation flow.







