← Blog

AI music API for developers

If your game, app or tool needs music on demand, an HTTP API is the shortest path: send a sentence, poll, download a song and its parts. Here's what to look for, and how Daydream's works.

Daydream7 min read

Yes. Several music generators now have an HTTP API, and the useful ones do three things: take a text description, return audio files you can ship, and let you control tempo, key, length and looping. Daydream's music generation API is one of them: POST a description to https://gen.daydream.live/v1/songs, poll until it's done, and download an instrumental up to two minutes long as an MP3 and a WAV, plus its stems as separate drums, bass, guitar, keys and other tracks. It's pay as you go: 5¢ a song from credit packs that start at $3 for 60 songs and never expire, with no subscription (as of November 2026), and the output is royalty-free for commercial games and apps. A second API, the one behind Daydream Studio, gives your code the same engine Studio's parts are made with.

What to look for in a music API

  • Files you can ship. A WAV for builds and releases, an MP3 for previews. Stream-only or watermarked output is fine for prototyping, not for a game.
  • Licensing that covers your users. If your app plays generated music to the public, the plan behind your key has to allow commercial use.
  • Control over the shape. Tempo (so a battle theme matches the action), key (so tracks sit together), length, and a loop for music that has to repeat.
  • Stems. Separate parts let your game bring the drums in when a fight starts, or duck the melody under dialogue.
  • Predictable pricing. Per song beats per second when you can't predict how long your prompts will ask for.
  • Async by design. Music takes seconds to render. A queued job with an id you poll, or a webhook, is easier to build on than a request that hangs.

How Daydream's API works

  1. Get a key from your Daydream dashboard and send it as Authorization: Bearer <key>.
  2. Ask for a song. POST /v1/songs with a JSON body. Only prompt is required.
  3. Poll GET /v1/songs/{id} every 2 seconds until status is done.
  4. Download takes[n].mp3_url or takes[n].wav_url. The links need no key and don't expire, so you can store them and load them from a game or an <audio> tag.
  5. Take the stems once stems_ready is true: lossless FLAC files for drums, bass, guitar, keys and other. The mix is the sum of the stems.

The smallest request is one line of JSON: {"prompt": "a calm village theme with flute and harp", "loop": true}. The API docs have the same call as curl, ready to paste.

The parameters

  • prompt: the music in words: genre, mood, instruments, scene. Up to 400 characters.
  • duration: up to 120 seconds. Takes are made in whole bars.
  • bpm and key: set them, or leave them out and the tempo is chosen from the prompt.
  • loop: true for a track that ends where it begins, so it repeats without a click.
  • variations: 1 or 2 versions of the same description. Either way it's one song.
  • seed: to make a result repeatable.

A description with no music in it ("footsteps on gravel", "a door slamming") comes back from the same endpoint as a sound effect up to 30 seconds long, at the same price.

Limits to know before you build

  • Instrumental only. No vocals or lyrics. Words that ask for them are dropped.
  • No artist names. They're removed from a prompt before the song is made, and the answer says so with artist_names_removed: true. Describe the sound instead: "warm Rhodes, brushed drums, late-night jazz trio".
  • Two minutes per song. For longer music, loop a track, or chain sections at one tempo and key.
  • Three at a time. Up to three of your songs can be in line or being made at once; a fourth answers 429 too_many until one finishes.
  • The API runs on credits. A free account's songs (5 your first week, then 2 every week) are for the generator page, Studio, ChatGPT and Claude, not the API. With no credits, a request answers 402 pack_required with a link to buy a pack.

The API docs have ready-to-paste examples for JavaScript, Python, Unity (C#) and Godot (GDScript), and an OpenAPI spec for code generators.

What it costs at a startup's volume

There's no monthly fee and no minimum, so the cost is the number of songs you make. The credit packs, as of November 2026, per the docs:

  • $3 makes 60 songs, at 5¢ a song.
  • $18 makes 400 songs, at 4.5¢ a song.
  • $40 makes 1,000 songs, at 4¢ a song.
  • $70 makes 2,000 songs, at 3.5¢ a song.

Credits don't expire, so a pack bought for a prototype is still there at launch. A song that fails gives its credits back. Asking for two variations is still one song, and making one stem again counts as one song.

Two things keep the bill small. Make music when you build, not when a user presses play: a game's soundtrack or an app's set of background tracks is a fixed number of songs, made once and shipped as files. And when users do make their own, the price per song is flat whether they ask for ten seconds or two minutes, so you can price your own feature without guessing.

How to add generated music to your app

  • Keep the key on your server. A key can do anything on its account, so it stays out of web pages, mobile apps and game builds. Call the API from your backend, a build step or your editor.
  • For music that ships with the app, generate it during development, pick the takes you like, and bundle the WAVs or stems. Nothing calls the API at run time.
  • For music your users ask for, take the description in your app, send it from your backend, and return the song's id. Poll every 2 seconds and show its place in line (position) while it waits.
  • Store what you'll play. The audio links don't expire, but copying the files to your own storage keeps playback under your control.
  • Handle three answers. 402 means the account is out of credits, 429 means three songs are already in line, and 503 means try again shortly.
  • Use the stems. Load the five FLAC files and play them from the same start time. Raise or lower each one with what's happening in your app.

If your product is an agent rather than an app, the same generator is an MCP server with the same songs and stems, and an agent with a wallet can pay 5¢ a song over HTTP 402 with no account.

Other music APIs, as of 20 October 2026

  • ElevenLabs has a music endpoint, POST /v1/music, from a prompt or a section-by-section composition plan, 3 seconds to 10 minutes long, with vocals or forced instrumental. Where it wins: longer pieces, and sung vocals. What you may do with the output depends on your plan's music terms. Already built on it? Switching from the ElevenLabs Music API maps each field.
  • Mubert sells a separate Music API with generation, continuous streaming and a pre-made library, steerable by BPM, genre and mood, 15 seconds to 25 minutes. Plans start from $49 a month (discounted from $99; no monetized use) and $199 a month for monetized content (discounted from $249); stems are on custom plans.
  • Soundraw lists API access on its Enterprise plan, priced on request.

Which one to pick

  • You need sung vocals: pick an API that does vocals; Daydream's doesn't.
  • You need game or app music you can ship, with stems and loops, on a small budget: Daydream's per-song pricing and stems with every song are built for that.
  • You need music that responds while it plays, a soundtrack that shifts with what the player does: that's a real-time session rather than a file. Daydream Studio is a music studio in your browser that you chat with: you describe a song and its parts (drums, bass, guitar, keys and other) are made together while it plays, and you keep, remake or change any of them as it goes. The music API behind it gives code the same engine; its reference documents what it accepts. Studio is a research preview, and you can try it in your browser before you write a line of code.

Short answers

Is there a free tier for the API? Not for the API itself. A free Daydream account gets 5 free songs your first week, then 2 every week, on the generator page, which is enough to hear what the API will return before you buy a $3 pack.

Can I ship the music in a commercial app or game? Yes. Everything is royalty-free for commercial use, with no credit owed. See royalty-free music for commercial use.

How long does a song take? A few seconds once it's next in line. A busy moment adds a short wait, and position tells you where you are.

Does it make sound effects? Yes, from the same endpoint: one take up to 30 seconds, MP3 and WAV, no stems.

For game soundtracks specifically, see the best music generator for video games. Plans are on pricing.

Updated