Build a Personalized Song Service with an AI Music Generator API
Rachel
11/27/2026
Custom songs are one of the most loved gifts online: a birthday song with the person's name in the chorus, a wedding song that tells how the couple met, an anniversary track full of inside jokes. A few years ago each of these needed a songwriter and a studio. Today you can deliver them in minutes with an AI music generator API.
This post is a practical blueprint for building that kind of service. We focus on the parts that make or break quality: collecting the right details, turning them into singable lyrics, and handling generation reliably.
The Pipeline at a Glance
- Order form collects names, occasion, story details and preferred genre.
- Lyrics step turns those details into structured lyrics with [Verse] and [Chorus] sections.
- Generation step sends the lyrics to the music API and waits for the result.
- Review and delivery lets the customer pick their favorite take and download it.
Step 1: Ask for Details That Make Great Lyrics
Generic questions produce generic songs. The best order forms ask for:
- Who it's for and what they're called (nicknames sing better than full names).
- The occasion and the feeling you want: funny, emotional, nostalgic.
- Three specific memories, such as a trip, a habit or a phrase they always say.
- A genre or reference mood, offered as a short list (acoustic pop, country, R&B, rock, lullaby).
Store these as structured fields, not one big text box. You'll reuse them in both the lyrics and the style prompt.
Step 2: Write Lyrics the Model Can Sing
You can write lyrics with any text model, or let customers paste their own. Either way, normalize them before sending:
- Use clear section tags:
[Verse],[Chorus],[Verse],[Chorus],[Bridge],[Chorus]. - Put the name in the chorus. It repeats, so it's what people remember.
- Keep lines short, roughly 6 to 10 syllables, and avoid long lists of names or dates.
- Keep genre and instruments out of the lyrics. Everything in the lyrics gets sung.
Our guide on turning lyrics into songs covers more lyric-writing tips that apply directly here.
Step 3: Generate the Song
We use the AI Music Generator API offered through APIstable, the API platform we recommend for developers. Requests are plain JSON, billing is per request, and failed generations aren't charged. Copy the music model ID from the model page and keep your key in an environment variable on the server.
// server/generate-song.js (Node.js 18+)
const BASE = "https://apistable.ai/api/v1/tasks";
const headers = {
Authorization: `Bearer ${process.env.APISTABLE_API_KEY}`,
"Content-Type": "application/json",
};
export async function createSongTask(order, lyrics) {
const res = await fetch(`${BASE}/create_task`, {
method: "POST",
headers,
body: JSON.stringify({
model: process.env.MUSIC_MODEL_ID,
callback_url: `https://your-shop.com/webhooks/song?order=${order.id}`,
input: {
custom_mode: true,
instrumental: false,
title: `${order.occasion} Song for ${order.nickname}`,
style: `${order.genre}, warm, heartfelt, clear vocals`,
lyrics,
},
}),
});
const body = await res.json();
return body.data.task_id; // save this on the order
}
Using a callback_url is the right choice for a shop: you don't need a worker polling every order. When the webhook fires, look up the task to read its final state:
export async function getTask(taskId) {
const res = await fetch(`${BASE}/${taskId}`, { headers });
const { data } = await res.json();
return data; // data.status: "processing" | "succeeded" | "failed"
}
When status is succeeded, data.result holds the generated tracks. If it's failed, data.message explains why. Retry once with slightly shorter lyrics; you aren't charged for the failed attempt.
Step 4: Let the Customer Choose
One request can return more than one take, and customers love choosing. Show both versions side by side, with the lyrics underneath, and let them pick one to download.
Two details matter for a smooth experience:
- Copy the audio to your own storage as soon as the task succeeds. Customers often come back weeks later to re-download, and the API's links won't last that long.
- Offer one free revision. If the customer wants a different mood, change the style tags and regenerate. The lyrics usually don't need to change.
Pricing Your Product
Because API usage is billed per request, your cost per order is predictable: one generation (sometimes two with a revision) plus whatever you spend on lyric writing. That makes it easy to price gift songs profitably, even at low price points, and to run seasonal promotions for Valentine's Day, Mother's Day or the holidays.
Prefer to Make One Song Yourself?
If you just want a single custom song for someone you love, you don't need any code. Write or paste your lyrics into Lyrics Into Song and get your track in minutes. If you're building a product, start with the AI Music Generator API.