AI Song Generator API
Give your users a song generator without building one. Send a prompt or lyrics, receive finished songs, and pay only for the requests you make.
Keys, billing and docs live on APIstable, a developer platform we point builders to. API calls aren't included in Nafy subscriptions.
One endpoint, three ways to make a song
Pick the mode that matches how much control your users need. All three use the same create-task request.
Prompt mode
Your user types one sentence and gets a complete song. The fastest way to add a "make me a song" button.
{
"model": "<MUSIC_MODEL_ID>",
"input": {
"custom_mode": false,
"instrumental": false,
"prompt": "a cheerful pop song about a dog who loves the beach"
}
}Lyrics mode
Send your own lyrics, title and style tags for full control over words and structure.
{
"model": "<MUSIC_MODEL_ID>",
"input": {
"custom_mode": true,
"instrumental": false,
"title": "Late Train Home",
"style": "dream pop, airy female vocals, 95 bpm",
"lyrics": "[Verse]\nWindow seat and city glow\n[Chorus]\nTake me home"
}
}Instrumental mode
Skip vocals for background music, game loops, intros and ad beds.
{
"model": "<MUSIC_MODEL_ID>",
"input": {
"custom_mode": true,
"instrumental": true,
"title": "Level 3 Theme",
"style": "chiptune, upbeat, driving bass, loopable"
}
}POST these bodies to /api/v1/tasks/create_task with your Bearer key, then read the task by ID. Replace <MUSIC_MODEL_ID> with the ID from the model page.
Before you go live
Teams that launch smoothly tend to get these six things right from day one.
- 1
Call the API from your backend
Never ship the API key in a browser or mobile app. Proxy requests through your own server.
- 2
Use a callback URL
Generation is asynchronous. A webhook is cheaper and simpler than polling every task.
- 3
Store audio yourself
Result links expire after a while. In your success handler, move each track to S3, R2 or your CDN.
- 4
Show every take
Requests often come back with two takes. A side-by-side picker turns that into a feature.
- 5
Filter user prompts
If end users type prompts, screen them for abusive content and copyrighted lyrics before sending.
- 6
Plan for failures
Failed tasks aren't charged. Retry once with a simpler prompt and show a friendly message if it still fails.
Why build on an API instead of your own models
Launch in days
No GPUs, model hosting or audio pipeline to maintain. A few HTTP calls and you're live.
Costs that follow usage
Pay per request from a prepaid balance. Quiet month, small bill; busy month, it scales with you.
Works with any stack
Plain REST and JSON, so it fits Node, Python, PHP, Go, serverless functions and no-code tools.
AI Song Generator API: common questions
- What can I build with an AI song generator API?
- Anything where users should get a custom song: music and karaoke apps, personalized gift songs, social and video tools, games with generated soundtracks, chatbots that can sing, and marketing tools that produce jingles.
- What's the difference between prompt mode and lyrics mode?
- Prompt mode writes the lyrics for you from a single description. Lyrics mode uses exactly the words, title and style you send, which is better when your app already has lyrics or users want control.
- Does Nafy offer this API?
- Song generation for developers runs on APIstable, a platform we recommend. Sign up there for a key, then top up and track spending from its dashboard.
- Can I use my Nafy subscription or credits?
- No. Nafy plans and credits are for the Nafy web app. API requests are paid from the balance on your API account.
- Can I connect it to n8n, Make or Zapier?
- Yes. Any tool that can send HTTP requests with a Bearer header can create tasks and read results, so no-code automations work without extra plugins.
- How is pricing calculated?
- Each create-task request is charged once, regardless of how many takes it returns, and failed tasks are free. Check the model page for the current per-request price.
Add a song generator to your product
Sign up, send a single JSON body, and play back a track generated by your own code.
Get API access