Use case

Game Development Music API

Game developers who need scene-aware or procedurally varied music instead of shipping a handful of fixed loops.

The problem

A game world has many states: a calm village, a tense dungeon, a boss fight. Licensing or composing a unique track for each one is expensive, and procedural games can have more states than you can pre-author. Reusing the same loop everywhere flattens the experience.

Why MusicAPI fits this

Generate distinct instrumental tracks per scene, biome, or encounter, so audio reflects game state instead of one loop.

tags-driven mood control lets you request calm exploration, rising tension, or combat intensity from the same pipeline.

Generate music at build time for fixed levels, or on demand for procedurally generated content, with full commercial rights.

Code sample

A real request against the live API: start a job, then poll the task endpoint until the audio is ready.

curl
# Generate a tense instrumental loop for a dungeon scene
# 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": "A tense, atmospheric instrumental for a dangerous dungeon level",
    "tags": "dark ambient, tense, low percussion, loopable",
    "title": "Dungeon Depths",
    "make_instrumental": true
  }'

# 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 generate different music for different game states?

Yes. Drive the tags and prompt per state: calm, pastoral for a village and dark, urgent for a boss fight produce distinct tracks from the same API, so audio tracks the game state.

Should I generate at build time or at runtime?

Both patterns work. Pre-generate and bundle tracks for fixed levels, or call the API at runtime for procedurally generated content and cache the results. The job-plus-poll flow suits both.

Can I ship generated music in a commercial game?

Yes. Every generation includes full commercial rights, so the music can ship in a paid game without separate licensing.

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.