🎧 Listen to this article
On This Page
0%- What Problem Does the Music Generation API Solve?
- Who Is It For?
- How to Use the Music Generation API
- Option 1 — REST (any language)
- Option 2 — Python SDK
- Option 3 — MCP Tool Call
- How Does the AudioPod Music API Compare to Stock Music Libraries?
- What Does It Cost?
- Frequently Asked Questions
- Getting Started in 5 Minutes
Most developers who need background music for an AI app face the same fork: license a stock library, ask a designer to source tracks manually, or accept silence. There's a fourth path — generating the music at request time, from a text description, without downloading anything or clearing rights. That's what AudioPod's Music Generation API does, and this post is a practical guide to wiring it into your workflow.
TL;DR — what you get:
- REST endpoint —
POST /api/v1/music/generateaccepts a text caption and returns a download URL when the job completes. - MCP tool call —
generate_music(caption, duration_seconds)available in any MCP-compatible agent host (Claude Desktop, Cursor, Cline). - Python SDK —
audiopod.music.generate(caption)wraps polling automatically. - Output — WAV or MP3, 15 s–4 min, royalty-free, suitable for commercial use across all plans.
- Cost — starts at the Free tier (1,000 credits/month). Generator credits scale by duration; see /pricing for exact tables.
What Problem Does the Music Generation API Solve?
Background music is solved for human creators — stock libraries like Artlist and Epidemic Sound work well when a person is picking tracks. They break down in agent-driven workflows: you can't have an AI app pause and wait for a human to browse a catalog.
The alternative — calling a music-generation model yourself — means deploying GPU infrastructure, managing model weights, handling audio format normalization, and building a polling layer around generation jobs that can take 15–60 seconds. That's a significant platform investment for what is ultimately a supporting feature.
The AudioPod Music Generation API abstracts all of that. Your app sends a text caption describing the mood, tempo, and style you want. AudioPod queues the job, runs generation on its own infrastructure, and gives you a URL. Your app polls for completion (or uses a webhook) and plays or stores the result.
Who Is It For?
The API is a fit for three kinds of builders:
AI agent developers who need to give their agent a voice beyond text. A study-assistant agent that reads passages aloud is better with ambient background music during audio segments. A bedtime-story agent works better with soft accompaniment that fades as narration ends. These are use cases where the music is a UX layer, not a creative output.
Automated video pipelines — teams generating AI explainer videos, social shorts, or product demos at scale. When you're producing hundreds of clips per day, sourcing music manually is a bottleneck. Generating it per-clip, with a caption tuned to the script's tone, keeps the pipeline unattended.
Product developers adding ambient audio to apps — meditation timers, focus modes, interactive fiction, games. Rather than shipping a fixed audio bundle, these apps can generate new soundscapes on demand, matching context (current task, time of day, user preference) at runtime.
How to Use the Music Generation API
Option 1 — REST (any language)
All plan tiers have REST access. You'll need an API key from your dashboard.
12345678910
POST https://api.audiopod.ai/api/v1/music/generate
Authorization: Bearer
Content-Type: application/json
{
"caption": "Upbeat lo-fi hip-hop, 80 BPM, soft piano and vinyl crackle, good for focused work",
"duration_seconds": 60,
"format": "mp3"
}
Response:
123456
{
"job_id": "mj_9f2a41bc",
"status": "queued",
"poll_url": "https://api.audiopod.ai/api/v1/music/mj_9f2a41bc"
}
Poll poll_url until status is completed. Completed jobs include output_url — a time-limited signed URL for the audio file.
Generation typically completes in 20–40 seconds for a 60-second clip. Longer tracks (up to 4 minutes) take proportionally longer. Implement a simple back-off loop: poll every 5 seconds for the first minute, then every 10 seconds.
Option 2 — Python SDK
Install:
12
pip install audiopod
Generate and wait in two lines:
123456789
import audiopod
client = audiopod.Client(api_key="ap_...")
result = client.music.generate(
caption="Cinematic orchestral build, slow tempo, minor key, tension rising",
duration_seconds=90,
)
print(result.output_url) # ready when this line runs
The SDK handles polling internally. result.output_url is available as soon as the job completes; the call blocks until then.
Option 3 — MCP Tool Call
If your agent host supports MCP (Claude Desktop, Cursor, Continue, Cline, Goose), add AudioPod's MCP server and call generate_music as a tool:
12345678
{
"tool": "generate_music",
"arguments": {
"caption": "Soft ambient electronic, evolving pads, no drums, calm and contemplative",
"duration_seconds": 120
}
}
The agent receives the completed audio URL in the tool result, then passes it downstream — to a video assembler, a TTS narrator, a file-write step — without leaving the agent loop. Full setup instructions are on the /for-agents page.
How Does the AudioPod Music API Compare to Stock Music Libraries?
| Dimension | Stock library (Artlist, Epidemic Sound) | Build-your-own model | AudioPod Music API |
|---|---|---|---|
| Setup time | Account + search | Weeks (infra + training) | Minutes (API key) |
| Fits automated pipelines? | No — browsing is manual | Yes | Yes |
| Content customisation | Browse / filter only | Full control | Text caption → on-demand generation |
| Rights clearance | License per track | Your output | Royalty-free on all plans |
| Infrastructure cost | License fee (~$200–500/yr) | GPU budget | Credit-based; Free tier available |
| Variable cost at scale | Fixed regardless of volume | GPU $/hr | Credits per generation (see /pricing) |
| MCP / agent-native? | No | No | Yes — generate_music tool |
Stock libraries are the right choice when a human is doing the editing and wants catalog depth. The API is the right choice when the pipeline runs unattended and the music needs to match generated context it hasn't seen before.
What Does It Cost?
Music generation uses AudioPod credits. Costs scale by track duration. The Free (Basic) tier includes 1,000 credits per month — enough to generate several short clips without a credit card.
For production workloads:
- Creator ($20/month) — 200,000 credits/month. Suitable for up to ~200 one-minute tracks per month.
- Pro ($50/month) — 600,000 credits/month. For teams generating audio at scale alongside other tools (TTS, stem separation).
- Studio ($100/month) — 1,250,000 credits/month. Dedicated support channel included.
Pay-as-you-go is also available: $1 = 7,500 credits, no expiry. If your usage is occasional rather than daily, top-up credits are often the cheapest option.
Frequently Asked Questions
Can I use generated music in commercial projects? Yes. Music generated via the API is royalty-free and licensed for commercial use on all paid plans. The Free tier also permits commercial use within its monthly credit limit.
What audio formats does the API return?
MP3 and WAV. Specify "format": "mp3" or "format": "wav" in the request body. MP3 is the default when format is omitted.
How long does generation take? Typically 20–40 seconds for a 60-second track on standard generation. Longer tracks scale roughly linearly. There is no real-time streaming — the full clip is delivered as a single file when complete.
Is there a maximum track duration? The current maximum is 4 minutes (240 seconds) per API call. For longer pieces, generate multiple segments and concatenate. The stem separation feature can help if you later need to isolate or recombine elements.
What caption style gets the best results? The engine responds well to captions that specify tempo (BPM or a relative term like "slow", "medium", "driving"), instrumentation ("solo piano", "strings and brass", "lo-fi drums"), and mood ("tense", "hopeful", "introspective"). Vague captions like "nice music" produce inconsistent results.
Does the API support webhooks instead of polling?
Webhook delivery to a URL you specify is available on Pro and Studio tiers. Set "webhook_url": "https://your-app.com/hooks/music" in the request body; AudioPod will POST the completed job payload when it finishes.
How long are output URLs valid? Download URLs are signed and expire after 24 hours. If your pipeline needs to reference the file later, download it to your own storage within that window. AudioPod's own storage retention matches your plan tier — Creator keeps outputs for 2 years, Pro for 3 years, Studio for 5 years.
Getting Started in 5 Minutes
- Create a free account at audiopod.ai — no credit card required.
- Generate your API key in Settings → API Keys.
- Install the SDK (
pip install audiopodornpm install @audiopod/sdk) or construct the REST request directly. - Send a test caption — a 15-second clip uses minimal credits and confirms end-to-end connectivity.
- Add the MCP server (
mcp.audiopod.ai) to your agent host configuration to enable tool-call access from Claude Desktop, Cursor, or any MCP-compatible environment. Full setup at /for-agents.
If you're adding music to a larger agent pipeline that also uses text-to-speech or speech-to-text, all three services share the same API key and the same credit pool — no separate accounts.
Background music in agent-driven workflows has been an unsolved rough edge for most teams because the manual solutions simply don't fit automated pipelines. If you're building anything that generates audio, video, or interactive experiences at scale, a one-call music API is worth adding to the stack.
