Headphonaut ALPHA

Music from a prompt. As WAV or MIDI.

The Headphonaut Music API is for companies that need original music inside their own product. Send a short description, get back a mixed WAV or a multi-track MIDI file. The music is made by the same Maker as on this site: every part is picked from a pool of material rated by ear, and played on Headphonaut's own instrument emulations.

Step 1

Describe it

Post a prompt such as "warm lo-fi beat with dusty piano" or "driving 90s house in A minor": a style or mood, and if you like instruments, a tempo or a key. Say which format you want back.

Step 2

Wait for the job

The Maker plans the piece and, for WAV, our engine renders it. Poll the job until it is done: a MIDI file is usually ready within seconds of being picked up, a WAV within a minute or two.

Step 3

Download it

A finished job gives you a download link for the file. The link works for an hour, and asking for the status again gives you a new one.

What you get

WAV. A stereo, 16-bit, 48 kHz mix of the whole piece, rendered the way the Maker plays it, with the loop's tail carried into its start so it loops cleanly. The Maker keeps the tempo and key you name and picks them when you do not; a piece is a loop of a few bars.

MIDI. A Standard MIDI File (format 1, 480 ticks per quarter note): a tempo track and one track per part (drums, bass, chords, lines), each part on its own channel and at concert pitch, ready to load into a DAW and play on your own sounds.

Each job makes a new piece. The same prompt twice gives two different pieces.

Test access and price

Try it with a test key

Test keys are issued by hand, one per company, with 50 jobs each. A job that fails is not counted. Tell us what you are building and the volume you expect, and we will send a key and talk about the price and terms for production use.

API reference

The API

Base URL: https://headphonaut-samples.hans-g-moeller.workers.dev. Requests and responses are JSON, except the file download. All times are ISO 8601 in UTC.

Authentication

Send your key in the Authorization header of every job call: Authorization: Bearer hpk_.... Keep it on your server and never put it in a web page or an app. Only a hash of the key is stored on our side, so a lost key cannot be recovered: we revoke it and issue a new one.

Create a job

POST /api/b2b/jobs with exactly two fields:

FieldTypeMeaning
promptstring, 1 to 400 charactersWhat to make: genre, mood, instruments, tempo or key in plain words.
format"wav" or "midi"The file you want back.

The answer is 202:

{
  "jobId": "job-3f2a9c0d41b7e65a8c19d204",
  "status": "queued",
  "format": "midi",
  "statusUrl": "https://headphonaut-samples.hans-g-moeller.workers.dev/api/b2b/jobs/job-3f2a9c0d41b7e65a8c19d204",
  "createdAt": "2026-11-06T12:00:00.000Z",
  "quota": { "used": 1, "limit": 50 }
}

Job status

GET /api/b2b/jobs/{jobId} with the same key. A job moves from queued to running and ends as done or failed. Poll every 10 seconds or so.

{
  "jobId": "job-3f2a9c0d41b7e65a8c19d204",
  "status": "done",
  "format": "midi",
  "prompt": "warm lo-fi beat with dusty piano",
  "createdAt": "2026-11-06T12:00:00.000Z",
  "finishedAt": "2026-11-06T12:01:12.000Z",
  "quota": { "used": 1, "limit": 50 },
  "download": {
    "url": "https://headphonaut-samples.hans-g-moeller.workers.dev/api/b2b/jobs/job-3f2a9c0d41b7e65a8c19d204/download?exp=1793966472&sig=...",
    "expiresAt": "2026-11-06T13:01:12.000Z",
    "bytes": 7913,
    "contentType": "audio/midi"
  }
}

A failed job carries "error": "generation-failed: ..." with the reason, has no download, and does not count against your jobs. The most common reason is generation-failed: prompt-not-understood: the Maker found no style, mood or instrument it knows in the prompt, and the error suggests one it does.

Download

GET the download.url. The signed URL is the credential, so no key is needed and you can hand it to a browser. It expires after one hour; ask for the status again to get a fresh one. WAV files are audio/wav, MIDI files audio/midi (.mid).

Errors

Every error is JSON with a named error:

HTTPerrorMeaning
400bad-request:<field>The named field is missing, invalid or not part of the API (bad-request:prompt, bad-request:format, bad-request:body for a body that is not a JSON object).
401missing-keyNo Authorization: Bearer header.
401invalid-keyThe key is unknown, malformed or revoked.
429quota-exhaustedThe key has used all its test jobs.
429too-many-active-jobsThe key already has 3 jobs queued or running. Wait for one to finish.
429rate-limitedToo many requests from your address in the last minute.
404not-foundNo such job for this key.
403download-expired, download-signature-invalidThe download link is too old or was changed. Ask for the status again.
5xxinternal and othersOur side failed. Try again later, and tell us if it persists.

Limits for test keys

  • 50 jobs per key; failed jobs are not counted.
  • 3 jobs queued or running at a time per key.
  • 10 job requests a minute per address.
  • Prompts of up to 400 characters, in English, naming a style, mood, instrument, tempo or key.

Runnable example

Needs curl and jq. Put your key in KEY, run it, and it saves piece.mid (change FORMAT to wav for audio).

#!/bin/sh
set -eu
KEY="hpk_your_test_key"
FORMAT="midi"
API="https://headphonaut-samples.hans-g-moeller.workers.dev"

JOB=$(curl -s -X POST "$API/api/b2b/jobs" \
  -H "Authorization: Bearer $KEY" -H "Content-Type: application/json" \
  -d "{\"prompt\": \"warm lo-fi beat with dusty piano\", \"format\": \"$FORMAT\"}")
ID=$(echo "$JOB" | jq -r '.jobId // empty')
[ -n "$ID" ] || { echo "$JOB"; exit 1; }
echo "job $ID queued"

while :; do
  S=$(curl -s "$API/api/b2b/jobs/$ID" -H "Authorization: Bearer $KEY")
  case $(echo "$S" | jq -r '.status // "error"') in
    done)   EXT=$([ "$FORMAT" = wav ] && echo wav || echo mid)
            curl -s -o "piece.$EXT" "$(echo "$S" | jq -r .download.url)"
            echo "saved piece.$EXT"; break ;;
    failed) echo "$S" | jq -r .error; exit 1 ;;
    error)  echo "$S"; exit 1 ;;
    *)      sleep 10 ;;
  esac
done