← 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.

Daydream4 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 MP3 (and WAV on paid plans), plus its stems as separate drums, bass, guitar, keys and other tracks. It uses the same allowance as the website: 10 songs a month on a free account, 500 tracks for $4 a month on the Songs plan (as of October 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 session players run on.

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 seamless 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 couple of seconds until status is done.
  4. Download takes[n].mp3_url or takes[n].wav_url. The links are the song's own, 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.
  • duration: 10 to 120 seconds. Takes are made in whole bars.
  • bpm and key: set them, or leave them out and they're 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.
  • seed: to make a result repeatable.

GET /v1/usage tells you how many songs are left this month. At most three of your songs can wait in the queue at once.

Limits to know before you build

  • Instrumental only. No vocals or lyrics.
  • No artist names. A prompt that names an artist is refused with 422 prompt_rejected. 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.
  • The allowance is shared between the website and the API on the same account.

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

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.
  • 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 on every plan 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 browser-based studio for hybrid music production, where session players follow your part, chords and groove while it plays and you change any part 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.

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