Developers · HTTP API

Get a sound from the API

Send one request and save the sound it returns, with curl, Python or JavaScript.

Send one request to the Mirli server and save the sound it returns as a WAV file. The request waits while the model renders, so there is no job to follow.

Before you begin

  • Mirli is running on this machine. The desktop app starts the server; from a clone, Run Mirli from source describes how to start it.
  • The Stable Audio 3.0 SFX model is installed. In the app, go to the Models page to install it.
  • For the Python example, Python 3. For the JavaScript example, Node.js 18 or later.

Render a sound

  1. Check that the server answers on its default address:

    Terminal
    curl http://127.0.0.1:17494/api/health

    The response is JSON with "status": "ok". If the connection is refused, the server is not running or listens on another port.

  2. Send a render request for a two-second door slam. For Python, save the code as render.py and run python render.py; for JavaScript, save it as render.mjs and run node render.mjs:

    Terminal
    curl -X POST http://127.0.0.1:17494/api/render \
      -H 'Content-Type: application/json' \
      -d '{
        "model": "audiocpp-stable-audio-3-sfx",
        "prompt": "heavy wooden door slam, dry room",
        "duration_s": 2
      }' \
      -o door.wav

    The request returns when the render is done, which takes seconds to a minute, and door.wav appears in the current folder.

  3. Open door.wav in an audio player to hear the result. The sound is also in the app's library, because the server keeps every render by default.

If a step returns an error instead, its detail says why. Errors lists every status and what causes it.

What's next