Documentation Navigation
Getting Started
API Reference
Resources
Music API
Generate songs, instrumentals, and BGM. 32 models including Suno V4.5. From $0.018/track.
Async API. Music generation is asynchronous. Submit a job and poll
GET /v1/jobs/:id, or use a webhook_url callback. POST /v1/generations/music
Submit a music generation job. Supports text prompts, lyrics, genre tags, and instrumental mode.
Request body
| Field | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Model key (e.g. "suno-v4-5", "yue-v2", "diffrhythm", "mureka-v7-6"). |
prompt | string | Yes | Description or lyrics. Supports [Verse], [Chorus] section markers. |
genre | string | No | Genre tag: "pop", "jazz", "electronic", "classical", etc. |
duration | number | No | Duration in seconds. Max varies by model (60-480s). |
instrumental | boolean | No | Set to true for instrumental-only (no vocals). |
webhook_url | string (URL) | No | URL to POST the result to when complete. |
confirm | boolean | No | Set to false for cost estimate only. Default: true. |
Response fields
| Field | Type | Description |
|---|---|---|
id | string | Job ID (job_ prefix). |
status | string | "queued", "processing", "completed", or "failed". |
url | string | CDN URL of the generated audio (MP3). |
cost.micro | integer | Cost in microdollars. |
cost.display | string | Human-readable cost (e.g. "$0.10"). |
metadata.duration | number | Track duration in seconds. |
metadata.title | string | AI-generated track title (if applicable). |
Code examples
curl
curl -X POST https://api.fairstack.ai/v1/generations/music \
-H "Authorization: Bearer $FAIRSTACK_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "suno-v4-5",
"prompt": "An upbeat jazz track with walking bass and brushed drums"
}' Python
from fairstack import FairStack
client = FairStack(api_key="fs_live_YOUR_KEY")
# Submit async music generation
job = client.generate.music(
model="suno-v4-5",
prompt="An upbeat jazz track with walking bass and brushed drums"
)
# Poll for result
result = job.wait()
print(result.url) # https://media.fairstack.ai/music/...
print(result.cost) # $0.10 Node.js
import { FairStack } from "fairstack";
const client = new FairStack({ apiKey: "fs_live_YOUR_KEY" });
const job = await client.generate.music({
model: "suno-v4-5",
prompt: "An upbeat jazz track with walking bass and brushed drums",
});
const result = await job.wait();
console.log(result.url); // https://media.fairstack.ai/music/...
console.log(result.cost); // { micro: 100000, display: "$0.10" } Completed response
{
"id": "job_music_abc",
"status": "completed",
"url": "https://media.fairstack.ai/music/.../output.mp3",
"model": "suno-v4-5",
"modality": "music",
"cost": {
"micro": 100000,
"display": "$0.10",
"currency": "USD"
},
"metadata": {
"duration": 120,
"sample_rate": 44100,
"title": "Midnight Jazz Walk"
}
} Cost estimation
Set confirm: false to get the exact cost before generating.
curl -X POST https://api.fairstack.ai/v1/generations/music \
-H "Authorization: Bearer $FAIRSTACK_API_KEY" \
-d '{ "model": "suno-v4-5", "prompt": "test", "confirm": false }'
# Response: { "estimated_cost": { "micro": 100000, "display": "$0.10" } } Lyrics mode
Pass lyrics with section markers for structured song generation:
{
"model": "suno-v4-5",
"prompt": "[Verse 1]\nWalking through the city lights\nEvery shadow feels just right\n\n[Chorus]\nWe are the dreamers tonight",
"genre": "indie pop",
"duration": 180
} Instrumental mode
Set instrumental: true for background music, film scores, and BGM:
{
"model": "yue-v2",
"prompt": "Epic orchestral score for a fantasy film trailer",
"instrumental": true,
"duration": 60
} Quality tiers
| Tier | Example Model | Price | Max Duration | Best For |
|---|---|---|---|---|
| Budget | DiffRhythm, ACE-Step | $0.018-0.03 | 60s | BGM, prototyping, short clips |
| Standard | YuE V2, Mureka | $0.05-0.08 | 120s | Content creators, podcasts |
| Premium | Suno V4.5, Suno V4.5 Plus | $0.10-0.15 | 480s | Professional tracks, full songs |
Next steps
- Jobs API -- poll async music generation jobs
- Model Catalog -- browse all 32 music models
- Error Handling -- retries and idempotency