Use case
AI Music Generator API
Builders adding a generate-a-song button to an existing app who need a generator behind an API rather than a consumer tool.
The problem
A consumer music generator on a website does not help when you need the same capability inside your own product, with your own auth, your own UI, and your own usage tracking. Screen-scraping a web app is fragile and breaks without notice. You need a stable programmatic generator you can build on.
Why MusicAPI fits this
A documented REST generator: create a job, poll for the result, get a finished track. No browser automation.
Multiple model versions selectable per request via the mv field, so you control the quality and speed tradeoff.
Per-credit rate is the same across packs and subscriptions, so generator costs scale predictably with usage.
Code sample
A real request against the live API: start a job, then poll the task endpoint until the audio is ready.
# Generate a song from a style and a prompt
# 1. Start a generation job
curl -X POST https://api.musicapi.ai/api/v1/sonic/create \
-H "Authorization: Bearer $MUSICAPI_KEY" \
-H "Content-Type: application/json" \
-d '{
"custom_mode": true,
"mv": "sonic-v5",
"prompt": "[Verse] Neon mile markers blur as we go [Chorus] Hold the line, we are almost home",
"tags": "synthwave, driving, retro",
"title": "Almost Home",
"make_instrumental": false
}'
# Response: { "message": "success", "task_id": "a1b2c3d4-..." }
# 2. Poll until the audio is ready (state: "succeeded")
curl https://api.musicapi.ai/api/v1/sonic/task/a1b2c3d4-... \
-H "Authorization: Bearer $MUSICAPI_KEY"
# Response data[].audio_url is a ready-to-stream MP3 once state is "succeeded".Pricing
MusicAPI is pay-as-you-go with credit packs, plus predictable monthly subscriptions. The per-credit rate is the same across packs and subscriptions. See the pricing page for current rates, free credits, and volume options.
FAQ
Can I pick which model generates the song?
Yes. The mv field selects the model version per request, from sonic-v3-5 through sonic-v5-5. Newer versions allow longer prompts and tags and support extra controls like vocal_gender.
Is there a free way to test the generator?
Yes. New accounts get free credits to run real generations before any payment. See the pricing page for current free-credit and pack details.
Can I generate instrumental-only tracks?
Yes. Set make_instrumental to true and the generator returns a track with no vocals, which is useful for backing music and beds.
Build it in 5 minutes
Get free credits on signup and run real generations before any payment. No credit card required to start.
API details verified 2026-05-16. The API surface evolves; the pricing page always has current rates.