# Mirli for developers and AI agents > Mirli is a free, open-source (MIT) app that generates sound effects, music, speech and cloned voices on your own machine from open-weight models. Inference runs locally through the audio.cpp engine on an NVIDIA, Apple or CPU backend, so there is no account, no API key and no per-generation cost. One local server process serves the desktop and web UI, an HTTP API and an MCP server, all on 127.0.0.1:17494, and every result is a WAV file on disk with an absolute path. Version 0.7.3. Canonical page: https://mirli.app/developers/. Source: https://github.com/HamSanders/soundbox. Kept identifiers: the product is Mirli, but the MCP tools are `soundbox.*`, the CLI is `soundbox` and the Docker image is `ghcr.io/hamsanders/soundbox`. The environment variables are `MIRLI_*`; the old `SOUNDBOX_*` names still work, and are the only ones 0.5.0 and earlier read. ## Facts - **Server:** `http://127.0.0.1:17494` - **MCP endpoint:** `http://127.0.0.1:17494/mcp` (Streamable HTTP) - **Health check:** `GET http://127.0.0.1:17494/api/health` - **Auth:** None by default; the server binds to loopback. Set `MIRLI_API_TOKEN` to require `Authorization: Bearer `. - **Output:** WAV files on local disk, returned as absolute paths - **Licence:** MIT (the app). Each model has its own licence. - **Docker image:** `ghcr.io/hamsanders/soundbox:latest` (amd64), `:cuda` for NVIDIA - **Source:** https://github.com/HamSanders/soundbox ## Install ### Desktop app (Windows, macOS) A person's own Windows 10/11 x64 or macOS machine (Apple silicon or Intel). Download the installer for the machine from https://mirli.app/download/ (the latest GitHub release: an `x64-setup.exe`, an `aarch64.dmg` or an `x64.dmg`) and run it. The app carries its own Node and server. The builds are not code-signed yet, so the first launch shows SmartScreen (Windows) or Gatekeeper (macOS). An agent cannot click through that; ask the person to confirm it. With the app open, the server answers on `127.0.0.1:17494`: ```bash curl http://127.0.0.1:17494/api/health ``` ### Docker (Linux server, NAS, rented GPU) A headless machine. Server and web UI in one container, no desktop app. Prebuilt images are amd64 only. CPU image, port published on loopback only: ```bash docker run -d --name soundbox -p 127.0.0.1:17494:17494 \ -v soundbox-data:/data -v soundbox-models:/data/models \ ghcr.io/hamsanders/soundbox:latest ``` NVIDIA GPU (needs the NVIDIA Container Toolkit and a driver that supports CUDA 12.9, 575 or newer on GeForce): ```bash docker run -d --name soundbox --gpus all -p 127.0.0.1:17494:17494 \ -v soundbox-data:/data -v soundbox-models:/data/models \ ghcr.io/hamsanders/soundbox:cuda ``` The audio.cpp runtime is already in the image. Pull a model inside the container: ```bash docker exec soundbox soundbox pull audiocpp-stable-audio-3-sfx ``` Each release is also tagged by version (`:vX.Y.Z`, `:vX.Y.Z-cuda`). There is no authentication unless `MIRLI_API_TOKEN` is set, so never publish `0.0.0.0:17494` without a token or an authenticating proxy. Reaching `/mcp` by any name other than localhost needs that name in `MIRLI_ALLOWED_HOSTS`. ### From source (Linux, or any OS) Linux desktops, development, or arm64. Needs Node 22.12+ and git. The CLI is not published to npm. Clone, build, install the audio.cpp runtime for this machine, and start the server: ```bash git clone https://github.com/HamSanders/soundbox cd soundbox npm install npm run build npx soundbox model install audiocpp npx soundbox ``` `npx soundbox` starts the server on port 17494 and serves the web app at the same address. `npx soundbox --help` lists the subcommands. ### Rules for an agent installing Mirli - Check the hardware first. `GET /api/health` reports `device` (`cuda`, `metal` or `cpu`), `gpu_name`, `vram_total_mb` and `vram_free_mb`. - Say what each model costs before downloading it: `GET /api/models` gives `vram_estimate_mb`, `license.name` and `license.commercial` (`yes`, `conditional` or `no`). Wait for a yes. - Never accept a model licence on the person's behalf. - Reuse weights that are already installed; they live under `~/.mirli/models` and are shared by every profile. - Do not change network or firewall settings. The server binds to loopback and needs nothing opened. ## Connect the MCP server Endpoint: `http://127.0.0.1:17494/mcp` (Streamable HTTP, no auth by default). ### Claude Code Run in a terminal: ```bash claude mcp add --transport http soundbox http://127.0.0.1:17494/mcp ``` Add `--scope user` to make it available in every project. With an access token, add `--header "Authorization: Bearer "`. Syntax from https://code.claude.com/docs/en/mcp ### Cursor `~/.cursor/mcp.json` (every project) or `.cursor/mcp.json` (one project): ```json { "mcpServers": { "soundbox": { "url": "http://127.0.0.1:17494/mcp" } } } ``` One-click: [Add to Cursor](cursor://anysphere.cursor-deeplink/mcp/install?name=soundbox&config=eyJ1cmwiOiJodHRwOi8vMTI3LjAuMC4xOjE3NDk0L21jcCJ9) Syntax from https://cursor.com/docs/context/mcp ### VS Code Run in a terminal: ```bash code --add-mcp '{"name":"soundbox","type":"http","url":"http://127.0.0.1:17494/mcp"}' ``` Or in `.vscode/mcp.json`: ```json { "servers": { "soundbox": { "type": "http", "url": "http://127.0.0.1:17494/mcp" } } } ``` One-click: [Add to VS Code](vscode:mcp/install?%7B%22name%22%3A%22soundbox%22%2C%22type%22%3A%22http%22%2C%22url%22%3A%22http%3A%2F%2F127.0.0.1%3A17494%2Fmcp%22%7D) Syntax from https://code.visualstudio.com/docs/agents/reference/mcp-configuration ### Codex CLI Run in a terminal: ```bash codex mcp add soundbox --url http://127.0.0.1:17494/mcp ``` Or in `~/.codex/config.toml`: ```toml [mcp_servers.soundbox] url = "http://127.0.0.1:17494/mcp" ``` Syntax from https://learn.chatgpt.com/docs/extend/mcp?surface=cli ### Gemini CLI Run in a terminal: ```bash gemini mcp add --transport http soundbox http://127.0.0.1:17494/mcp ``` Or in `~/.gemini/settings.json` (`httpUrl` is Streamable HTTP; `url` would mean SSE): ```json { "mcpServers": { "soundbox": { "httpUrl": "http://127.0.0.1:17494/mcp" } } } ``` Syntax from https://geminicli.com/docs/tools/mcp-server/ ### Zed Zed's `settings.json`: ```json { "context_servers": { "soundbox": { "url": "http://127.0.0.1:17494/mcp" } } } ``` Syntax from https://zed.dev/docs/ai/mcp ### Claude Desktop and other stdio-only clients `claude_desktop_config.json`, or the client's own MCP config: ```json { "mcpServers": { "soundbox": { "command": "node", "args": [ "/absolute/path/to/soundbox/server/dist/mcp/stdio.js" ] } } } ``` Claude Desktop's config file takes stdio servers, and its custom connectors connect from Anthropic's cloud, which cannot reach 127.0.0.1. The stdio bridge proxies onto the running server and loads no models. It needs a source checkout after `npm run build` and an absolute path, and covers six tools: `generate`, `enhance_prompt`, `list_models`, `list_sounds`, `get_sound` and `delete_sound`. Use HTTP for the rest. `MIRLI_URL` and `MIRLI_API_TOKEN` point it at another server. Syntax from https://modelcontextprotocol.io/docs/develop/connect-local-servers - The MCP server runs inside the main Mirli process. There is no separate daemon: if the app or `soundbox` server is running, the tools are there; if not, connecting fails. - The URL has no trailing slash. - The server name in the configs above (`soundbox`) is the client-side label; the tool names are `soundbox.*` whatever you call it. - Generation is serialised: one GPU, one job at a time. Parallel calls queue. Use `variations` for several takes of one idea. - Tool calls block until the audio is on disk and return absolute file paths, so there is no job id to poll over MCP. - Licences are per model. `soundbox.list_models` reports `commercial_use` as yes, conditional or no; check it before generating for commercial work. - Optional agent skills ship with the server: `soundbox skills install` copies them to `~/.claude/skills/` (`--target cursor` for `~/.cursor/skills/`). ## MCP tools (27) Read from the server source (`server/src/mcp/server.ts`) at build time. `?` marks an optional argument. ### `soundbox.enhance_prompt`: Rewrite a prompt for a sound model Rewrite a short or abstract prompt into a concrete, descriptive one a text-to-audio model responds to, optionally returning several variations, plus a few suggested library tags (a separate field from the prompt — pass these to soundbox.generate's `tags`, not into the prompt itself). Prefer writing a descriptive prompt yourself when you already know the material/action/space; use this when the prompt is vague ('scary sound') or you want options. Only useful when the local prompt assistant is enabled — check the reply if it isn't. - `prompt: string`: The prompt to rewrite. - `n?: integer = 1 (1–5)`: How many distinct variations to return. - `category?: "sfx" | "music"`: Which kind of model this is for — sfx (default) or music. - `lyrics?: boolean`: True if this sets genre/instrumentation for a lyrics-conditioned model. - `model?: string`: The model id you intend to pass to soundbox.generate. Grounds the rewrite in that model's own documented prompting conventions — check soundbox.list_models for ids. Omit for generic guidance. ### `soundbox.generate`: Generate a sound effect Generate one or more sound effects from a text description and save them to the Mirli library. Blocks until the audio is on disk. - `prompt: string`: What the sound is. Describe material, action and space — 'glass bottle shattering on tile, small reverberant room'. For a lyrics-conditioned model (see `lyrics`), this instead sets the genre and instrumentation — 'dark orchestral-hybrid theme, slow dirge tempo, mournful choir vocals'. - `duration_s?: number = 5.0 (0.5–300)`: Clip length in seconds. A value above the model's own max_duration_s is refused with an error, except for edit "extend", which renders a longer target in windowed passes; check soundbox.list_models for per-model limits. - `model?: string`: Model id. Defaults to whichever model is already loaded. - `negative_prompt?: string`: What to avoid. Ignored by models that lack it. - `seed?: integer (0–)`: Seed for reproducibility. - `variations?: integer = 1 (1–4)`: How many different takes to generate. - `tags?: string[]`: Library tags. - `lyrics?: string`: Words for a lyrics-conditioned vocal music model (ACE-Step) to sing, e.g. '[verse]\nGame over\nYou have fallen'. Ignored by models that don't support lyrics — check `supports.lyrics` via soundbox.list_models. Omit for an instrumental render. - `track_name?: string`: Optional track title, only used alongside `lyrics`. - `source_sound_id?: string`: Edit an existing library sound instead of rendering from scratch. Pair with `edit`. The model must declare `supports.` in soundbox.list_models (ACE-Step does; MiniMax Music 3 does not). The result is a new sound whose `parent_id` is this one. - `edit?: "extend" | "cover" | "repaint"`: What to do with `source_sound_id`: 'extend' continues it so the result is `duration_s` seconds long (must exceed the source) with the original kept intact at the start; 'cover' re-renders it in the style of `prompt` (and `lyrics`) at the source's length; 'repaint' regenerates edit_options.repaint_start_s..repaint_end_s. - `edit_options?: object` ### `soundbox.separate`: Split a sound into stems Split a library sound into its stems — vocals, drums, bass, other — each saved as its own sound with its own file path. Name `stems` to keep only some of them; `rest: "merge"` sums the ones you didn't name into a single "rest" sound, which is the original minus what you took out. Blocks until the audio is on disk. Needs a separation model installed (`task: "sep"` in soundbox.list_models). - `sound_id: string`: Library sound to split. - `model?: string`: Separation model id. Omit for whichever `task: "sep"` model is installed, preferring one already loaded. - `stems?: string[]`: Which stems to keep, e.g. ["vocals"]. Omit for all of them. A name nothing answers to is reported back, not silently dropped. - `rest?: "discard" | "merge" = "discard"`: What happens to the stems not named: thrown away, or summed into one "rest" sound — the original minus what was taken out. Ignored when `stems` is omitted, since nothing is left over. ### `soundbox.list_models`: List sound models List every model, generation and otherwise, with its status and licence. `task` says which surface a model belongs to — "gen" for soundbox.generate, "tts" for the speech tools, "sep" for soundbox.separate — and calling one on the wrong surface is refused. Check `commercial_use` before using output commercially. `supports` says which optional soundbox.generate arguments a model takes: `lyrics`, `negative_prompt`, `seed`, and the `extend` / `cover` / `repaint` edits. For a text-to-speech model this is also where the `delivery` knobs it accepts come from — the authority on those names, since a wrong one is ignored silently rather than rejected. No arguments. ### `soundbox.list_sounds`: Search the sound library Search previously generated sounds. Use this before generating — the sound you want may already exist. Pass `voice_id` for what one saved voice has already said. - `q?: string`: Text to match in prompt or name. - `tag?: string`: Filter by tag. - `voice_id?: string`: Only sounds read in this saved voice (an id from soundbox.list_voices). Multi-voice dialogues are not filed under any one speaker. - `limit?: integer = 20 (1–100)` ### `soundbox.get_sound`: Get one sound Fetch a single sound by id, including its absolute file path. - `sound_id: string` ### `soundbox.delete_sound`: Delete a sound Permanently delete a sound and its audio file. - `sound_id: string` ### `soundbox.list_voices`: List saved voices List the saved voices a script can be read in. Call this before writing a story so lines can be cast to real voice ids. No arguments. ### `soundbox.speak`: Speak a line or a dialogue Read text aloud in a saved voice and save it to the library. One line or several with different voices, each on its own voice's model unless `model` overrides it. Blocks until the audio is on disk. `delivery` shapes the performance — never write stage directions into the text, they get read aloud. For anything you want to keep and arrange, build a story instead. - `lines: object[]`: The script. Several lines with different voice_ids is a dialogue. - `model?: string`: A text-to-speech model id for every line. Omit it and each line is read on its voice's own model (list_voices' `model_id`), or a ready one for a line with no voice or a voice with no model. - `gap_s?: number (0–5)`: Silence between lines. Default 0.4. - `name?: string` - `delivery?: object`: How to read it, using this model's own option names — see the `delivery` list from soundbox.list_models (e.g. {"exaggeration": "1.4"}). Unknown names are ignored silently, so take them from there. ### `soundbox.create_story`: Start a story Create a story — a script that persists, whose lines carry a place in time and can be voiced, arranged and mixed down. `delivery` here sets how every line is read unless it overrides it. - `title?: string`: What this story is. - `delivery?: object`: How every line in this story should be read unless it says otherwise. Set it here rather than per line — a script usually wants one delivery throughout and an exception on a line or two. ### `soundbox.list_stories`: List stories List existing stories, most recently worked on first. - `limit?: integer = 20 (1–200)` ### `soundbox.get_story`: Read a story Fetch a story with every line: text, voice, timing, and whether it has been voiced yet, plus each touched track's mix and device chain. A clip placed from the MIDI panel also carries `midi`: its notes, tempo, instrument and cover prompt (read-only). This is how you inspect what you have built. - `story_id: string` ### `soundbox.add_lines`: Add lines to a story Append lines to a story's script — spoken lines, pauses, or existing library sounds dropped onto the timeline. Adds many at once, each with its own `delivery` if one line should be read differently. - `story_id: string` - `lines: object[]` ### `soundbox.update_line`: Edit or arrange a line Change a line's words, voice, delivery, or where it sits in time — start, track, gain, mute, and the trim that shortens a clip without destroying audio. Changing words or delivery needs the line re-read before it is heard. - `line_id: string` - `text?: string` - `speaker?: string` - `voice_id?: string` - `track_index?: integer (-16–16)` - `start_s?: number (0–)` - `muted?: boolean` - `gain_db?: number (-40–24)` - `duration_s?: number (0–600)`: How much of the clip plays — shorten a clip without destroying its audio. - `trim_start_s?: number (0–)`: How far into the source sound the clip begins. - `delivery?: object`: How to read this line, overriding the story's. `{}` puts it back on the story's delivery. Re-read the line afterwards for it to be heard. ### `soundbox.speak_story`: Voice a story Read every line of a story that has no audio yet, in its assigned voice and on that voice's own model unless `model` overrides it. Blocks until they are all recorded. This is the slow one. - `story_id: string` - `model?: string`: A text-to-speech model id for every line. Omit it and each line is read on its voice's own model (list_voices' `model_id`), or a ready one for a line with no voice or a voice with no model. - `regenerate?: boolean = false`: Re-read lines that already have audio, not only the silent ones. ### `soundbox.open_in_studio`: Open a sound in the studio Open a library sound on a timeline, split into its stems on separate tracks where that is possible. Name `stems` to lay out only some of them. Reuses stems the sound already has rather than making more. - `sound_id: string` - `separate?: boolean = true`: Split it into stems first, each on its own track. Ignored for a sound that is already a stem or an edit. - `stems?: string[]`: Which stems get a track, e.g. ["vocals", "drums"]. Omit for all of them. - `rest?: "discard" | "merge" = "discard"`: What happens to the stems not named: thrown away, or summed into one "rest" track — the original minus what was taken out. ### `soundbox.mix_track`: Mute, solo or set a track's level Control one lane of a story: name it, mute it, solo it, or set its volume. These belong to the lane, not to the clips on it. - `story_id: string` - `track_index: integer (-16–16)`: Which lane. - `name?: string` - `muted?: boolean` - `soloed?: boolean`: With any track soloed, only soloed tracks are heard. - `gain_db?: number (-40–24)` ### `soundbox.add_device`: Add an effect to a track Put a device (compressor, eq, reverb, delay, distortion, gate, limiter, autotune) on one lane of a story, at the end of its chain or at `position`. It starts at its defaults; pass `params` to set knobs as it goes on. The studio's device rack shows it straight away. Heard in the studio's playback and in soundbox.export_story's mixdown. - `story_id: string` - `track_index: integer (-16–16)`: Which lane. - `kind: "compressor" | "eq" | "reverb" | "delay" | "distortion" | "gate" | "limiter" | "autotune"` - `params?: object` - `bypassed?: boolean` - `position?: integer (0–)`: Where in the chain, from 0. Omit to add it last. ### `soundbox.set_device`: Turn a device's knobs Change the knobs on a device already on a track, or bypass it (it stays in the chain with its settings, out of the signal path). Name the device by its id, or by kind when the track has only one of that kind. Values past a knob's range land at its end, and the result says which did. - `story_id: string` - `track_index: integer (-16–16)` - `device: string`: The device's id, or its kind when the track has one. - `params?: object` - `bypassed?: boolean`: true takes it out of the signal path and keeps its settings. ### `soundbox.remove_device`: Take an effect off a track Remove one device from a track's chain, by id, or by kind when the track has only one of that kind. Use `bypassed` on soundbox.set_device instead to switch it off and keep its settings. - `story_id: string` - `track_index: integer (-16–16)` - `device: string`: The device's id, or its kind when the track has one. ### `soundbox.remove_track`: Remove a track Delete a lane and the clips on it. Lanes above slide down. Use soundbox.get_story first if you are not certain what is on it. - `story_id: string` - `track_index: integer (-16–16)` ### `soundbox.delete_line`: Delete a line Remove one line from a story. Its audio stays in the library. - `line_id: string` ### `soundbox.split_line`: Split a line in two Cut a voiced line at a point in it, as it plays on the timeline, giving two clips. The words stay with the first half — there is no honest way to know which fell either side of the cut. - `line_id: string` - `at_s: number`: Seconds into the line as it plays on the timeline, after any trim. ### `soundbox.export_story`: Mix a story down Mix the whole arrangement to one sound, honouring where each clip sits, its trim, its gain, and whether it is muted, with each track run through its device rack. - `story_id: string` ### `soundbox.studio_context`: Read the open studio What the studio open in Mirli shows right now: its lanes (name, mute, solo, effects), every clip with its id, lane, position and label, the playhead, the selection and the voices a line can be cast to. Needs a studio open in the app; omit story_id when there is only one. Read this before soundbox.studio_apply — its ids are the only ones that will apply. - `story_id?: string`: Which studio. Omit when only one is open. ### `soundbox.studio_apply`: Edit the open studio - `story_id?: string`: Which studio. Omit when only one is open. - `actions: object[]`: The edits, in order. See the description for each action's shape. - `summary?: string`: One line for the studio's toast and history, in the user's terms. - `allow_delete?: boolean = false`: Let delete_clip actions run. Ask the user first. ### `soundbox.search_docs`: Search Mirli's documentation Find the sections of Mirli's own documentation (README and docs/) that answer a question — which model to use, licences, stems, the studio, connecting agents. Returns each section's source file, heading and text. Quote these rather than guessing how Mirli works. - `query: string`: The question, in plain words. - `limit?: integer = 4 (1–8)` ## HTTP API quick reference - Base URL `http://127.0.0.1:17494`, JSON in and out. - The `Host` header must be `localhost`, `127.0.0.1` or `[::1]` (or a name in `MIRLI_ALLOWED_HOSTS`); anything else is `403`. This blocks DNS rebinding. - `POST`, `PUT`, `PATCH` and `DELETE` under `/api/` need `Content-Type: application/json` (or a raw audio type on uploads) or an `X-Soundbox` header, or they get `403`. - With `MIRLI_API_TOKEN` set, `/api/*`, `/v1/*`, `/mcp`, `/files` and `/artwork` need `Authorization: Bearer `; `GET /api/health` stays open. ### Is it running, and on what hardware? Version, `device` (`cuda`, `metal` or `cpu`), GPU name, VRAM, loaded model and queue length. Stays open even when a token is set. ```bash curl http://127.0.0.1:17494/api/health ``` ### Which models are there? Every enabled model with `status` (`installed`, `loaded`, …), licence, `max_duration_s` and `vram_estimate_mb`. ```bash curl http://127.0.0.1:17494/api/models ``` ### Download a model Returns `202 { job_id }`. A POST with no JSON body needs the `X-Soundbox` header. ```bash curl -X POST -H 'X-Soundbox: 1' \ http://127.0.0.1:17494/api/models/audiocpp-stable-audio-3-sfx/download ``` ### Render and get the WAV back in one call `POST /api/render` runs one job, waits, and answers `200 audio/wav`. The body is a `/api/generate` or `/api/speak` body. `400` on bad input, `429` when the queue is full. ```bash 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":3}' \ -o door.wav ``` ### Queue a generation and follow the job `POST /api/generate` returns `202 { job_id }`. Poll `GET /api/jobs/{id}` (or `GET /api/jobs/{id}/events` for server-sent events) until `status` is `done`, then read `result.sounds`. ```bash curl -X POST http://127.0.0.1:17494/api/generate \ -H 'Content-Type: application/json' \ -d '{"model":"audiocpp-stable-audio-3-sfx","prompt":"glass bottle shattering on tile","duration_s":2,"variations":2}' curl http://127.0.0.1:17494/api/jobs/ ``` ### Find a sound and its file `GET /api/sounds` searches the library; each sound carries `path` (absolute) and `duration_s`. ```bash curl 'http://127.0.0.1:17494/api/sounds?q=door&limit=5' curl http://127.0.0.1:17494/api/sounds/ ``` ### Stream speech as it is made `POST /api/speak/stream` sends server-sent events with base64 16-bit PCM, or raw PCM with `format: "pcm"`. Not a job: it holds the GPU, never queues (`409` when busy), and closing the connection cancels it. ```bash curl -N -X POST http://127.0.0.1:17494/api/speak/stream \ -H 'Content-Type: application/json' \ -d '{"model":"audiocpp-supertonic-3","text":"Halt! Who goes there?","format":"sse"}' ``` The full route list is at https://mirli.app/docs/api/. ## Environment variables | Variable | Read by | What it does | |---|---|---| | `MIRLI_DATA_DIR` | server | The data folder. Default `~/.mirli`, or `~/.soundbox` when that exists and `~/.mirli` doesn't. `--data-dir` does the same for one run. | | `MIRLI_AUDIOCPP_BIN` | server | Absolute path to an `audiocpp_cli` of yours. Nothing is downloaded. | | `MIRLI_LLAMA_SERVER_BIN` | server | The same, for `llama-server`. | | `MIRLI_SD_SERVER_BIN` | server | The same, for `sd-server`. | | `MIRLI_AUDIOCPP_BACKEND` | server | Force the audio.cpp backend instead of detecting it: `cuda`, `hip`, `metal`, `vulkan`, `cpu`. | | `MIRLI_LLAMA_SERVER_BACKEND` | server | Changes the backend that `soundbox model status llm` and the app report for `llama-server`. It does not change the download; use `soundbox model install llm --backend ` for that. | | `MIRLI_SD_SERVER_BACKEND` | server | Changes the backend the app reports for `sd-server`. It does not change the download. | | `MIRLI_ALLOW_UNVERIFIED_BINARIES` | server | `1` installs an engine archive that no published SHA-256 covers. Off by default. A checksum mismatch is refused regardless. | | `HF_TOKEN` / `HUGGING_FACE_HUB_TOKEN` | server | Hugging Face token for gated models, used when none is saved in Settings. | | `HF_HOME` | server | Hugging Face cache location. Left alone if set; otherwise Mirli points it at `/models`. | | `MIRLI_API_TOKEN` | server, stdio MCP bridge, CLI | An access token of at least 16 characters. Set on the server, every `/api/*`, `/v1/*`, `/mcp`, `/files` and `/artwork` request needs it as `Authorization: Bearer ` or a session cookie from the UI's sign-in screen; `GET /api/health` stays open. Set for the stdio bridge, `soundbox ps` or `soundbox enhance`, it is sent to the server. See Access token. | | `MIRLI_ALLOWED_HOSTS` | server, Vite | Comma-separated `host` (any port) or `host:port` (that port only). Adds `Host` values the server accepts (UI, `/api/*` and `/mcp`) and trusted browser origins (CORS and the MCP `Origin` check); under `npm run dev` also Vite's `server.allowedHosts`, which reads it only as `SOUNDBOX_ALLOWED_HOSTS`. See Host checks and SECURITY.md. | | `MIRLI_SANDBOXED` | server | `1` for a server whose users don't own the machine: nothing in the UI touches the host. See Sandboxed mode. | | `MIRLI_DISABLE` | server | Comma-separated capabilities to turn off (`filesystem`, `reveal`, `downloads`, `local_models`, `custom_endpoints`, `updates`, `gpu_status`, `agent_connect`, `skills_install`, `logs`, `setup_wizard`). Turning off `custom_endpoints` also locks the prompt assistant's and artwork's external URLs and the OpenTelemetry endpoint. | | `MIRLI_URL` | stdio MCP bridge | Where the running server is. Default `http://127.0.0.1:17494`. Set `MIRLI_API_TOKEN` too if that server needs one. | | `OTEL_EXPORTER_OTLP_ENDPOINT` | server | OpenTelemetry collector for MCP call traces and metrics. Wins over the Settings value. | | `MIRLI_LOG_LEVEL` | server | `debug`, `info` (default), `warning`, `error` or `critical`; `warn` works too. Used when `--log-level` isn't given, so it reaches `npm run dev`, Docker and the desktop app, none of which pass the flag. An unknown value logs a warning and runs at `info`. See Troubleshoot a source install. | | `MIRLI_IDLE_EXIT_MINUTES` | server | Exit (status 0) after this many minutes with no requests, none still being answered, and no queued or running jobs. For hosts that scale to zero and start the server again on the next request. Health checks don't count as use. Off by default. | | `MIRLI_UPDATE_CHECK` | server | `0` (or `false`, `off`, `no`) turns off the daily "is there a newer version?" request, whatever Settings says; Settings shows the switch as locked. `npm run dev` sets it to `0`. See PRIVACY.md. | | `MIRLI_UPDATE_URL` | server | Where the update check asks. Default `https://mirli.app/api/update`. | | `PORT` | server, Vite | The Vite dev server's port (default 5174). The server also trusts it as a dev origin. | | `SOUNDBOX_PORT` | `npm run dev`, Vite | The port `scripts/dev.mjs` starts the server on, and the port Vite proxies to. Default 17494. The `soundbox` CLI itself takes `--port`. | | `SOUNDBOX_DEV_HOST` | `npm run dev`, Vite | The address Vite listens on (`0.0.0.0`, a LAN IP). Default localhost. The server stays on `127.0.0.1`. No authentication, so open it only on a network you trust. | | `MIRLI_DESKTOP_PORT` | desktop shell | The port the desktop app starts, or adopts, its server on. Default 17494. Also read as `SOUNDBOX_DESKTOP_PORT`. | | `SOUNDBOX_NODE` | desktop shell | The Node to run the built server with, if `node` is not on `PATH`. | | `SOUNDBOX_PROJECT_ROOT` | desktop shell | The path to the checkout, if the shell can't find it from its own location. | | `VITE_MOCK` | app build | `1` runs the UI against the in-browser fake backend (`npm run dev:mock` sets it). | | `VITE_MOCK_FIXTURE` | app build | With `VITE_MOCK=1`, `demo` starts the fake backend from the demo library the screenshots are taken from (`npm run capture:media` sets it). | | `VITE_REPO_URL` | app build | The repository URL in the app's links. Default `https://github.com/HamSanders/soundbox`. | | `VITE_SITE_ORIGIN` | app and site builds | The absolute origin for canonical URLs and the site's RSS feed. | ## Hardware and limits - **NVIDIA GPU:** CUDA. A few GB of VRAM covers the verified models; MiniMax Music 3 wants about 10 GB. - **Apple silicon:** Metal, with installers for Apple silicon and Intel. - **AMD or Intel GPU:** Runs on the CPU unless `MIRLI_AUDIOCPP_BACKEND=vulkan` is set. Vulkan is not yet confirmed on the verified models. - **No GPU:** Works, slowly: a clip that takes seconds on a GPU takes minutes on the CPU. - **Disk:** Model weights are one to ten gigabytes each, under `~/.mirli/models`. - **Clip length:** `duration_s` 0.5–300, clamped to each model's own `max_duration_s` (see `soundbox.list_models`). - **Concurrency:** One job at a time on one GPU; the rest queue. Streams never queue and answer `409` when the GPU is busy. - **Long renders:** `/api/render` holds the request open. Behind a proxy with a ~100 s timeout, use `/api/generate` and follow the job. - **Platforms:** Desktop installers for Windows 10/11 x64, macOS and Linux x64 (AppImage, .deb). Linux arm64 runs from source or Docker. Docker images are amd64 only. ## Full documentation - [Installing with a coding agent](https://github.com/HamSanders/soundbox/blob/main/docs/INSTALL-AGENT.md): The step-by-step guide written for an agent. - [Install](https://mirli.app/docs/install/): The CLI, audio.cpp backends, models, Docker, access tokens, every env var. - [MCP reference](https://mirli.app/docs/mcp/): Every tool with arguments, the stdio bridge, telemetry, skills. - [HTTP API](https://mirli.app/docs/api/): Every route, request rules, job and model shapes. - [Streaming speech](https://github.com/HamSanders/soundbox/blob/main/docs/STREAMING.md): SSE and raw PCM speech streams, with client examples. - [audio.cpp](https://mirli.app/docs/audiocpp/): The native engine, its backends and how to choose one. - [Models](https://mirli.app/models/): Every model it runs, with its licence. ## Machine-readable files - [This page as Markdown](https://mirli.app/developers/index.md): The same content, plain Markdown. - [llms.txt](https://mirli.app/llms.txt): A curated map of the site for language models (llmstxt.org). - [llms-full.txt](https://mirli.app/llms-full.txt): This page plus the MCP, API and install docs in one file. - [server.json](https://github.com/HamSanders/soundbox/blob/main/server.json): The MCP Registry entry for the server. - [AGENTS.md](https://github.com/HamSanders/soundbox/blob/main/AGENTS.md): How to build, test and change the code, for coding agents. --- # About AI agents in Mirli Mirli can be driven by an AI assistant as well as by you. An assistant such as Claude Code, Cursor or Codex can make sound effects and music, voice a script with your saved voices, lay it out in the studio, and edit the studio you have open, all on your own computer. Everything it makes lands in your library, and the **Agents** page shows each assistant that has connected and every request it made. ## What an assistant can do - **Make sounds for a project.** Effects, ambience and music written straight into the project's folders, including a full sound pass over a game: every event that needs a sound, made and named. - **Voice a scene.** Lines written, cast to your saved voices, read aloud and laid out on a timeline you can open in the studio. - **Arrange and mix.** Name, mute and level lanes, and put effects on them. - **Edit the studio you have open.** Changes go through the studio's own controls, so you can undo them as if you had made them. Deletes are held for a separate confirmation. - **Answer questions about Mirli,** from these docs. ## Which one should I use? Mirli offers three ways to hand work to software instead of clicking through it yourself. | | MCP | HTTP API | The studio's **Chat** panel | |---|---|---|---| | Who drives it | An AI assistant you already use | A script or program you write | You, typing in the studio | | Good for | Sound for a whole project, voiced scenes, work that spans your code and Mirli | Pipelines, batch jobs, other apps | Quick edits to the timeline in front of you | | Needs | Mirli running, and the assistant connected once | Mirli running, and some code | The prompt assistant turned on in **Settings** | | Can do | 27 tools: sounds, speech, stories, mixing, the open studio | Everything the app does | Edits, new takes and lines on the open timeline | | Start here | [Connect an AI agent to Mirli](https://mirli.app/docs/connect-agent/index.md) | [HTTP API](https://mirli.app/docs/api/index.md) | [The studio](https://mirli.app/docs/studio/index.md) | ## Where things are - To connect an assistant, follow [Connect an AI agent to Mirli](https://mirli.app/docs/connect-agent/index.md). - Developers building on the tools can read the [MCP server reference](https://mirli.app/docs/mcp/index.md). - Worked examples for the assistant itself are in the Recipes: [Do a sound pass for a game](https://mirli.app/docs/agents-sound-pass/index.md), [Voice a scene](https://mirli.app/docs/agents-voice-scene/index.md), [Sequence story calls](https://mirli.app/docs/agents-story-calls/index.md), the [studio action vocabulary](https://mirli.app/docs/agents-studio-actions/index.md) and [Troubleshoot agent calls](https://mirli.app/docs/agents-troubleshooting/index.md). --- # About Mirli for agent authors Why Mirli's MCP server behaves as it does, for anyone writing an agent, a skill or a prompt that drives it. The behaviour itself is specified in the [MCP server reference](https://mirli.app/docs/mcp/index.md); the call orders are in [Sequence story calls](https://mirli.app/docs/agents-story-calls/index.md). ## One render at a time Mirli runs models on the user's own machine, which has one GPU, so the server runs jobs one after another. Five parallel `generate` calls do not finish faster than five sequential ones; they queue. Several takes of one idea belong in one call as `variations`. The same reason makes long calls normal. A tool that renders blocks until the file exists, which is seconds for a short effect and minutes for a voiced script. Progress notifications exist so that a client can keep such a call alive instead of timing it out. ## Paths instead of payloads Results carry absolute file paths rather than audio, so the agent can use its ordinary file tools from there: copy a take into a project, pass it to ffmpeg. The path is only meaningful on the machine Mirli runs on, which is also why the stdio bridge, which only relays HTTP, returns a URL instead. ## An empty model list is not a fault The user chooses and downloads the models that fit their machine and their licence needs, so an install with no model yet is a normal state. `generate` then says so in an error meant to be shown to the user. Retrying cannot change it; only the user can, on the **Models** page. ## Why prompts describe what is heard The sound models respond to physical description (material, action, space, distance) and largely ignore mood words. "Scary sound" gives noise, while "low metallic groan of a ship's hull under pressure, distant" gives something usable. `enhance_prompt` exists for the cases where an agent only has the abstract idea. ## Why performance is not in the text A text-to-speech model reads every character it is given. A stage direction in brackets is spoken, not obeyed. Each model family instead exposes its own controls, such as an exaggeration or emotion setting, and Mirli passes them through as `delivery`. Because the names differ per family and an unknown name is accepted without complaint, the only reliable source is the `delivery` list that `list_models` reads from the engine itself. A voice also belongs to the model it was made on. A cloned voice read on another family does not sound like the person, which is why each line is read on its own voice's model unless the agent overrides it. ## Why a story instead of one read `speak` returns one finished file, which is right for a single line. A script changes: a line gets rewritten, a voice recast, a beat moved. A story keeps every line as its own clip on a timeline, so one line can be re-read without touching the rest, and the user can open the same story in the studio and keep working by hand. ## Why the open studio goes through the page `studio_apply` does not write to the database. It hands the actions to the studio page, which runs them through the handlers its own buttons use. That is what puts an agent's edits on the user's undo stack, and why every id is checked against what the page actually shows: an action that names a clip the user deleted a moment ago is dropped instead of resurrecting it. Deletes are held by default, and the tool's description tells the model to confirm them with the user first. ## How devices reach the export The device rack's audio graph lives in the app and runs during the studio's playback. The server stores each lane's chain so an agent's changes reach the studio, and the export renders the same chain with the server's own DSP. Each device follows the algorithm the studio uses, so the exported file sounds like playback, though not bit-for-bit. --- # Do a sound pass for a game A worked example: an agent reads a game's code, lists every event that needs a sound, makes each one with Mirli, and wires the files in. The bundled `soundbox-sound-pass` skill teaches the same method; see [Skills and call logs](https://mirli.app/docs/mcp-skills/index.md#skills). ## Before you begin - The agent is connected to Mirli and can read and write the game's files. - At least one sound-effect model is installed: `list_models` shows one with `task: "gen"` and `status` installed or loaded. ## List the events 1. Read the game's code and design notes, and list every moment that should make a sound: player actions, impacts, pickups, UI, and ambience for each level. 2. For each event, write down a file name, a length and a physical description of the sound. For example: ```text door_open 1.5 s heavy wooden door creaking open, iron hinges coin_pickup 0.5 s small bright metallic coin chime, close cave_ambience 20 s dripping water in a large stone cave, distant wind ``` 3. Show the list to the user before generating, so they can add or remove events. ## Choose a model 1. Call `soundbox.list_models`. 2. Pick a model whose `task` is `gen` and whose `max_duration_s` covers the longest event. If the game is commercial, pick one whose `commercial_use` is `yes`. A model marked `no` has a licence that forbids commercial use. 3. Optional: call `soundbox.list_sounds` with `q` set to each event. A sound already in the library can be reused. ## Make the sounds 1. For each event, call `soundbox.generate` with its description, its length and two or three takes: ```json title="soundbox.generate arguments" { "prompt": "heavy wooden door creaking open, iron hinges", "duration_s": 1.5, "variations": 3, "tags": ["door_open", "sound-pass"] } ``` The call blocks until the files exist. Each of the result's `sounds` has an absolute `path`. 2. Pick one take per event, or keep all of them as variants if the game plays a random one. Mirli renders one job at a time, so call `generate` once per event rather than in parallel. 3. Copy each chosen file into the game's sound folder under the event's file name. ## Wire them in 1. Add each file to the game's audio code where its event fires, the same way the code already plays sounds. 2. Give the user the list of events, the files and the model used, including its licence. ## What's next - [Troubleshoot agent calls](https://mirli.app/docs/agents-troubleshooting/index.md): what to do when `generate` fails. - [Sound tools](https://mirli.app/docs/mcp-sounds/index.md): every argument of `generate`. --- # Sequence story calls The order an agent calls the story tools in, and the traps between them. A story is a persistent script: each line has a lane, a start time and, once read, a sound. For a complete worked example, see [Voice a scene](https://mirli.app/docs/agents-voice-scene/index.md). Arguments and results are in [Voice and story tools](https://mirli.app/docs/mcp-stories/index.md). ## Before you begin - The agent is connected over Streamable HTTP. The stdio bridge has no story tools. - At least one text-to-speech model is installed: `list_models` shows one with `task: "tts"`. ## Build and read a story 1. Call `soundbox.list_voices` and choose a voice `id` for each speaker. 2. Call `soundbox.list_models` and read the `delivery` list of each voice's `model_id`. 3. Call `soundbox.create_story` with a `title`, and a story-wide `delivery` if the script needs one. The result carries `story_id` and `open_in_studio`. 4. Call `soundbox.add_lines` once with every line in order. In a new story, the lines are laid end to end on their lanes as they are read. 5. Call `soundbox.speak_story` with the `story_id` and no `model`. Each line is read on its own voice's model. The call blocks until every silent line is read, one at a time. 6. Call `soundbox.get_story` and check that every spoken line has `voiced: true`. Pauses have no audio and stay `voiced: false`. 7. Give the user the `open_in_studio` link. ## Add lines to a story that already has audio A spoken line has no length until it is read, so `add_lines` cannot place a line after another unread line. > [!WARNING] > Lines appended together to a lane that already has audio all get the same `start_s`: the end of the lane's last > voiced clip. After `speak_story` they play on top of each other. To avoid it, do one of these: - Give each new line its own `start_s` in the `add_lines` call. - After `speak_story`, call `soundbox.get_story`, read each new line's `duration_s`, and move the lines apart with `soundbox.update_line` and `start_s`. ## Change a line 1. Call `soundbox.update_line` with the new `text`, `voice_id` or `delivery`. The old audio stays until the line is read again. 2. Call `soundbox.speak_story` with the `story_id`. Only lines without audio are read. Pass `regenerate: true` only to read every line again. To shorten a clip without losing audio, set `duration_s` or `trim_start_s` with `update_line`. To cut a read line into two clips, call `soundbox.split_line`; the words stay with the first clip. ## Mix and export 1. Call `soundbox.get_story` to see each lane and its clips. 2. Call `soundbox.mix_track` to name, mute, solo or set the gain of a lane. 3. Call `soundbox.add_device` to put an effect on a lane, then `soundbox.set_device` with the returned `device` id to change it. 4. Optional: call `soundbox.export_story` for one mixed file. `export_story` renders each lane's devices into the mixdown, the same as the studio's playback. Bypassed devices are left out. ## Edit the studio the user has open 1. Call `soundbox.studio_context`, and use only the lane numbers, clip ids and voice ids it returns. 2. Call `soundbox.studio_apply` with the actions and a short `summary` in the user's words. The actions are in the [studio action vocabulary](https://mirli.app/docs/agents-studio-actions/index.md). 3. If the result's `held_deletes` is more than 0, ask the user, then send the same deletes with `allow_delete: true`. 4. If you sent `generate_clip` or `speak_lines`, call `soundbox.studio_context` again after a few seconds to see the clips fill in. ## What's next - [Voice a scene](https://mirli.app/docs/agents-voice-scene/index.md): every call for a two-character scene. - [Troubleshoot agent calls](https://mirli.app/docs/agents-troubleshooting/index.md): errors and what to do about them. --- # Studio action vocabulary The actions `soundbox.studio_apply` takes, which are also what the studio's own **Chat** panel produces. The vocabulary is kept beside the code that checks it, in `STUDIO_ACTIONS_HELP` in `server/src/studio-link.ts`, and the tool's description carries the same text. ## Actions Each action is an object with a `type`: | `type` | Fields | Effect | Undoable | |---|---|---|---| | `set_track` | `track_index`, `muted`, `soloed`, `gain_db` | Mute, solo or set a lane's gain | Yes | | `rename_track` | `track_index`, `name` | Name a lane | Yes | | `move_clip` | `clip_id`, `start_s`, `track_index` | Move a clip in time, to another lane, or both | Yes | | `set_clip` | `clip_id`, `muted`, `text`, `speaker`, `voice_id`, `gain_db`, `fade_in_s`, `fade_out_s`, `duration_s`, `trim_start_s` | Mute a clip, rewrite or recast its line, set gain, fades and trim | Yes | | `delete_clip` | `clip_id` | Remove a clip. Held unless `allow_delete` is true | Yes | | `add_clip` | `track_index`, `start_s`, `text` | Write a new line onto a lane at a time | Yes | | `add_lines` | `lines`: `{ text, speaker, voice_id }` or `{ kind: "pause", duration_s }` | Write script lines and pauses, in order | Yes | | `speak_lines` | `clip_ids` | Read written lines aloud | Yes | | `add_device`, `remove_device` | `track_index`, `kind` | Put a device on a lane's rack, or take it off | No | | `set_device` | `track_index`, `kind`, `params` | Turn a device's knobs | No | | `generate_clip` | `track_index`, `start_s`, `prompt` | Generate audio from a prompt and place it | Yes | | `show_panel` | `panel` (`script`, `insert`, `library`, `history`, `sample`, `devices`), `open` | Open or close a panel | Not an edit | | `start_recording` | None | Start a take | Not an edit | Device-rack changes and adding a lane are not undoable, whoever makes them. Every other edit goes through the same handler a click uses and lands on the user's undo stack. ## Selectors A clip action takes `select` in place of `clip_id` to act on many clips. Keys in one `select` combine with AND. | `select` | Matches | |---|---| | `{"scope": "all"}` | Every clip | | `{"scope": "selected"}` | The user's selection | | `{"from_track": 2}` | Every clip on lane 2 | | `{"matching": "vocal"}` | Clips whose label contains the text | Example `studio_apply` arguments that turn lane 2 down, name lane 1 and fade in every clip on lane 3: ```json title="soundbox.studio_apply arguments" { "summary": "Quieter drums, named lanes", "actions": [ { "type": "set_track", "track_index": 2, "gain_db": -6 }, { "type": "rename_track", "track_index": 1, "name": "Narration" }, { "type": "set_clip", "select": { "from_track": 3 }, "fade_in_s": 0.5 } ] } ``` ## Validation | Rule | Detail | |---|---| | Ids | Lane numbers, clip ids and voice ids must come from `soundbox.studio_context`. An action that names something not in the studio, or is malformed, is dropped and counted in `dropped` | | New lanes | `add_clip` may name the next free lane. `generate_clip` with an unknown lane goes on the next free one | | Devices | `kind` must be one of the eight the rack builds: `compressor`, `eq`, `reverb`, `delay`, `distortion`, `gate`, `limiter`, `autotune` | | Deletes | `delete_clip` is held and counted in `held_deletes` unless `allow_delete` is true | | Background work | `generate_clip` and `speak_lines` return at once; the clips fill in as the work finishes | ## In the Chat panel The studio's **Chat** panel turns a typed instruction into the same actions. It applies small edits (mute, solo, rename, move, level, fades, devices, panels) at once and lists them in its reply. A plan that deletes a clip, writes lines, generates audio or reads lines aloud is shown first and waits for the user to click the apply button, labelled with the count (for example **Apply 3 edits**), or **Discard**. Actions that refer to something not on the timeline are dropped before the plan is shown, and the reply gives the count. While an MCP tool works on a story, an open studio for that story shows a notice and pauses editing; the agent's changes stream into the page as they land. --- # Troubleshoot agent calls Errors and surprises an agent meets when it drives Mirli over MCP, and what to do about each. For a person setting up a connection, see [Connect an AI agent to Mirli](https://mirli.app/docs/connect-agent/index.md#troubleshoot-the-connection). ## Connection | Symptom | Cause | What to do | |---|---|---| | The client cannot connect | Mirli is not running, or the URL is wrong | Ask the user to open Mirli. Use the address on the **Agents** page, with no trailing slash | | `403` with `Forbidden host` | The client reached `/mcp` by a host name the server does not accept | Add the name to `MIRLI_ALLOWED_HOSTS` on the server. See [MCP transports](https://mirli.app/docs/mcp-connect/index.md#access-token-and-allowed-hosts) | | `401`: "This Mirli needs its access token" | The server has an access token | Send `Authorization: Bearer `, or set `MIRLI_API_TOKEN` for the stdio bridge | | Only six tools are listed | The client uses the stdio bridge | Connect over Streamable HTTP for speech, stories and the studio | | Results have a `url` but no `path` | The stdio bridge returns the HTTP API's objects | Connect over Streamable HTTP | ## Generating | Symptom | Cause | What to do | |---|---|---| | "No local model is installed yet" | The user has not downloaded a model | Tell the user to download one on the **Models** page. Retrying gives the same error | | "No free model is installed, and metered models ... are never picked by default" | Only models that bill per render are installed | Name one as `model` only if the user agrees to the cost | | `duration_s` refused | It is greater than the model's `max_duration_s` | Read `max_duration_s` in `list_models` and ask for less, or pick another model | | An `edit` fails | The model's `supports` flag for that edit is false | Pick a model with `supports.extend`, `supports.cover` or `supports.repaint` | | `lyrics` has no effect | The model's `supports.lyrics` is false | Pick a model that takes lyrics | | The call times out in the client | A long render outlasted the client's timeout | Send `_meta.progressToken`, raise the client's tool timeout, or ask for a shorter `duration_s` | | Parallel calls finish one after another | Mirli runs one job at a time | Use `variations` for several takes of one prompt | | `enhance_prompt` returns a sentence, not JSON | The user's prompt assistant is off | Pass the sentence to the user, or write the prompt yourself | ## Speech and stories | Symptom | Cause | What to do | |---|---|---| | A line says its stage direction aloud | The direction is in `text` | Move it to `delivery`, with names from the model's `delivery` list | | A `delivery` setting changes nothing | The name is not one the model takes | Use only names from `list_models`. Unknown names are ignored without an error | | A voice does not sound like itself | Its model was not installed, so another model read the line | Read the result's `notes` and tell the user | | New lines play on top of each other | Lines appended to a lane with audio share one `start_s` | See [Add lines to a story that already has audio](https://mirli.app/docs/agents-story-calls/index.md#add-lines-to-a-story-that-already-has-audio) | | A changed line still sounds the same | Changing `text` or `delivery` does not re-read it | Call `speak_story` again | | `split_line` fails | The line has not been read, or `at_s` is outside the clip | Read it first, and pass a point inside the clip as it plays | | The export has no effects | The devices are bypassed, or the export ran before they were added | Check the lane's chain with `get_story`, then export again | ## The open studio | Symptom | Cause | What to do | |---|---|---| | "No studio is open in Mirli" | No studio page is open | Ask the user to open one, or use the story tools on the saved story | | "*N* studios are open" | Several studios are open and no `story_id` was passed | Pass `story_id`; the error lists the open ones | | `dropped` is more than 0 | An action named a clip, lane, voice or effect that is not in the studio, or was malformed | Call `studio_context` and use only its ids | | `held_deletes` is more than 0 | `allow_delete` was not set | Ask the user, then send the deletes again with `allow_delete: true` | | New clips are not there yet | `generate_clip` and `speak_lines` run in the background | Call `studio_context` again after a few seconds | ## Report a problem To report a bug, include the tool name, its arguments and the error text. The **Agents** page lists every call with its arguments and error; click a row under **Recent calls** to see them. --- # Voice a scene A worked example: a two-line exchange between a guard and a thief, voiced, checked and handed to the user in the studio. The call order behind it is in [Sequence story calls](https://mirli.app/docs/agents-story-calls/index.md). ## Before you begin - The agent is connected over Streamable HTTP. - The user has at least two saved voices, and a text-to-speech model is installed. ## Cast the voices 1. Call `soundbox.list_voices` with no arguments. The result lists each voice's `id`, `name` and `model_id`. Choose one for the guard and one for the thief. In the examples that follow, `` and `` stand for those ids. 2. Call `soundbox.list_models` and find each voice's `model_id`. Its `delivery` list names the performance controls that model takes. A model with no list has none. ## Write the script 1. Call `soundbox.create_story` with a title: ```json title="soundbox.create_story arguments" { "title": "Guard and thief" } ``` Keep the `story_id` from the result. `` stands for it from here on. 2. Call `soundbox.add_lines` with both lines and a beat between them: ```json title="soundbox.add_lines arguments" { "story_id": "", "lines": [ { "speaker": "Guard", "voice_id": "", "text": "Who goes there?" }, { "kind": "pause", "duration_s": 0.6 }, { "speaker": "Thief", "voice_id": "", "text": "Just the wind." } ] } ``` The result reports `added: 3`, two `lines` and one `pause`, with `voiced: 0`. To have a line performed a certain way, add a `delivery` object to it with names from that model's `delivery` list. Never write the direction into `text`: `(whispering)` is read aloud. ## Read it aloud 1. Call `soundbox.speak_story`: ```json title="soundbox.speak_story arguments" { "story_id": "" } ``` The call blocks while each line is read on its own voice's model. The result reports `read: 2` and `models`, the number of lines each model read. 2. If the result has `notes`, tell the user. A note means a voice's model was not installed and another model read the line, so it will not sound like that voice. ## Check and hand over 1. Call `soundbox.get_story` with the `story_id`. Both spoken lines show `voiced: true`, with a `duration_s` and a `start_s` that follow one another. The pause has no audio of its own, so it shows `voiced: false`. 2. Give the user the `open_in_studio` link from any of the results, so they can listen and keep editing. 3. Optional: if the user wants one file, call `soundbox.export_story` with the `story_id`. The result is a library sound with an absolute `path`. ## What's next - [Sequence story calls](https://mirli.app/docs/agents-story-calls/index.md): adding to a scene that already has audio, rewriting a line, mixing. - [Studio action vocabulary](https://mirli.app/docs/agents-studio-actions/index.md): editing the scene while the user has it open. --- # Connect an AI agent to Mirli Connect Claude Code, Cursor, Codex or another AI assistant to Mirli so it can make sound for you: effects written straight into your project, or a voiced scene laid out in the studio for you to keep editing. It all runs on your computer, and every sound lands in your library. ## Before you begin - Mirli is open. The connection is on whenever the app runs; there is nothing to turn on. - Your assistant supports MCP servers. Every assistant in this guide does. ## Find the address 1. In the Mirli sidebar, click **Agents**. The **Agents** page opens, with the address in the **Connect an agent** card. ![The Agents page, with the Connect an agent card showing the MCP address and the Connected agents card listing three assistants](https://github.com/HamSanders/soundbox/blob/main/site/public/docs/agents/connect.webp) 2. Under **Streamable HTTP (preferred)**, check the address. If it is not `http://127.0.0.1:17494/mcp`, use yours in the next section. ## Connect your assistant 1. Add Mirli to your assistant: run the command on its tab, or add the entry to its settings file. If the file already lists other servers, add the `soundbox` entry next to them instead of replacing them. The command or entry for each assistant: ```bash title="Claude Code" claude mcp add --transport http -s user soundbox http://127.0.0.1:17494/mcp ``` ```bash title="Codex" codex mcp add soundbox --url http://127.0.0.1:17494/mcp ``` ```json title="Cursor" { "mcpServers": { "soundbox": { "url": "http://127.0.0.1:17494/mcp" } } } ``` ```json title="VS Code" { "servers": { "soundbox": { "type": "http", "url": "http://127.0.0.1:17494/mcp" } } } ``` ```json title="Claude Desktop" { "mcpServers": { "soundbox": { "command": "npx", "args": ["-y", "mcp-remote", "http://127.0.0.1:17494/mcp"] } } } ``` ```json title="Antigravity" { "mcpServers": { "soundbox": { "serverUrl": "http://127.0.0.1:17494/mcp" } } } ``` ```bash title="Devin Desktop" devin mcp add soundbox http://127.0.0.1:17494/mcp ``` ```json title="Zed" { "context_servers": { "soundbox": { "url": "http://127.0.0.1:17494/mcp" } } } ``` ```json title="Cline" { "mcpServers": { "soundbox": { "type": "streamableHttp", "url": "http://127.0.0.1:17494/mcp", "disabled": false, "autoApprove": [] } } } ``` ```yaml title="Goose" extensions: soundbox: name: soundbox type: streamable_http uri: http://127.0.0.1:17494/mcp enabled: true timeout: 300 ``` ```json title="LM Studio" { "mcpServers": { "soundbox": { "url": "http://127.0.0.1:17494/mcp" } } } ``` ```bash title="opencode" opencode mcp add soundbox --url http://127.0.0.1:17494/mcp ``` ```yaml title="Continue" mcpServers: - name: soundbox type: streamable-http url: http://127.0.0.1:17494/mcp ``` For any other assistant, add a remote or HTTP server with the address. 2. Follow the notes for your assistant: where its settings file is, anything else to turn on, and how to check that it worked. The settings file, the check and the common fix for each assistant: ```text title="Claude Code" File: ~/.claude.json (written by the command) Check: start claude and type /mcp. soundbox shows as connected. Fix: a hand-written .mcp.json entry needs "type": "http", or Claude Code skips it. ``` ```text title="Codex" File: ~/.codex/config.toml, shared by the Codex CLI, the IDE extension and the ChatGPT desktop app Check: start a new Codex session and run /mcp. Fix: a project's own .codex/config.toml is read only in trusted projects. ``` ```text title="Cursor" File: ~/.cursor/mcp.json for every project, or .cursor/mcp.json for one project Then: in Cursor Settings > MCP, turn on soundbox. Check: Cursor Settings > MCP lists soundbox and its tools. ``` ```text title="VS Code" File: .vscode/mcp.json in your workspace. Or run MCP: Add Server > HTTP from the Command Palette. Check: in Copilot Chat, switch to Agent mode and open the tools picker. It lists the soundbox tools. Fix: this file's key is "servers", not "mcpServers". ``` ```text title="Claude Desktop" File: open it with Settings > Developer > Edit Config. Needs: Node.js, because the entry runs mcp-remote. Then: quit Claude Desktop completely and open it again. Check: in a new chat, the tools menu lists soundbox. Fix: don't add a "url" entry to this file, and don't use Settings > Connectors: it cannot reach Mirli. ``` ```text title="Antigravity" File: ~/.gemini/config/mcp_config.json for every project, or .agents/mcp_config.json for one workspace Check: restart the session and run /mcp. Fix: Antigravity rejects "httpUrl". The older Gemini CLI is the reverse: it wants "httpUrl" in ~/.gemini/settings.json. ``` ```text title="Devin Desktop" File: .devin/mcp_config.json (written by the command). Add -s user to the command for every project. Check: start a new Devin Local session. The MCP server list shows soundbox. ``` ```text title="Zed" File: run "zed: open settings file". Or use Settings > AI > MCP Servers > Add Remote Server and paste the address. Check: the Agent panel's MCP server list shows soundbox running. ``` ```text title="Cline" File: open it with MCP Servers > Configure. Check: the MCP Servers panel lists soundbox and its tools. Fix: keep the "type" line. Without it Cline tries an older transport and cannot connect. ``` ```text title="Goose" File: ~/.config/goose/config.yaml. Or run goose configure > Add Extension > Remote Extension (Streamable HTTP). Check: the extension list shows soundbox enabled. Fix: the key is "uri", not "url". ``` ```text title="LM Studio" File: open it with Program > Install > Edit mcp.json. Check: the Program tab lists soundbox. Turn its tools on in a chat. ``` ```text title="opencode" File: opencode.json (written by the command). Add --global for every project. Check: opencode mcp list shows soundbox as connected. Fix: a hand-written entry needs "oauth": false, because Mirli has no sign-in. ``` ```text title="Continue" File: .continue/mcpServers/soundbox.yaml, or your main Continue config Check: in Agent mode, the tools list includes soundbox. Fix: a file of its own in .continue/mcpServers/ also needs top-level name, version and schema keys. ``` 3. Quit your assistant completely and start it again, so it loads the new server. The [Mirli MCP page](https://mirli.app/mcp) has one-click install links for Cursor, VS Code, Goose and LM Studio. ## Check the connection 1. Ask your assistant to "list Mirli's models". The assistant answers with the models you have installed. 2. In Mirli, go to the **Agents** page. Your assistant appears in **Connected agents**, and its request appears in **Recent calls** with a tick. A cross means it failed; click the row to see the error. If **Connected agents** still says **No agent has connected yet**, see [Troubleshoot the connection](#troubleshoot-the-connection). ## Install the skills Skills are instruction files that teach an assistant to write good sound prompts, check licences, voice a script and do a sound pass over a whole project. 1. On the **Agents** page, click the **Skills** tab. ![The Skills tab on the Agents page, with the assistant list and the Install all skills button](https://github.com/HamSanders/soundbox/blob/main/site/public/docs/agents/skills.webp) 2. In the list, select your assistant: **Claude Code**, **Cursor** or **Codex**. An assistant marked **(not found)** is not installed on this computer. 3. Click **Install all skills**. 4. Optional: after each Mirli update, click **Install all skills** again so the skills match the new version. ## Ask for your first sound 1. Ask your assistant for a sound, describing what makes it. For example: ```text Make three takes of a wooden crate breaking, two seconds each, and copy the best one into assets/sfx. ``` The assistant waits while Mirli renders, then the sounds appear in your library. > [!TIP] > Describe the material, the action and the space. "Low metallic groan of a ship's hull under pressure, distant" works > far better than "scary sound". Other requests that work well: - "Go through this game's code, list every event that needs a sound, and make them all." - "Write a short scene between a guard and a thief, cast it to my saved voices and open it in the studio." Mirli makes one sound at a time, so ten sounds take ten times as long as one. ## Troubleshoot the connection | Problem | What to do | |---|---| | The assistant says it cannot reach the server | Open Mirli and try again. | | It still cannot connect | Compare the address with the **Agents** page, including the port, with no slash at the end. | | The `soundbox` tools don't appear | Quit the assistant completely and start it again. | | The **Agents** page says **This server doesn't offer agent connections** | This is a hosted copy of Mirli. Agents connect only to Mirli on your own computer. | | Long music stops partway | Ask for a shorter clip, or raise the assistant's tool timeout. | ## What's next - [About AI agents in Mirli](https://mirli.app/docs/agents/index.md): what an assistant can do, and when to use the HTTP API instead. - [The studio](https://mirli.app/docs/studio/index.md): edit what your assistant arranged. - [MCP server reference](https://mirli.app/docs/mcp/index.md): every tool and argument, for developers building on Mirli. --- # MCP server reference Mirli exposes its generation pipeline over [MCP](https://modelcontextprotocol.io). An agent can generate sound effects, music and speech as part of a larger task, and arrange longer pieces on a timeline it can return to later. The MCP server runs inside the main Mirli process, on the same port as the app and the HTTP API. There is no separate daemon, so Mirli has to be running for a client to connect. The endpoint, on the default port: ```text title="Endpoint" http://127.0.0.1:17494/mcp ``` This reference covers the transports and every tool. To connect a particular assistant, see [Connect an AI agent to Mirli](https://mirli.app/docs/connect-agent/index.md); for call orders written for agents, see [Sequence story calls](https://mirli.app/docs/agents-story-calls/index.md). ## Pages | Page | What it covers | |---|---| | [Transports](https://mirli.app/docs/mcp-connect/index.md) | Streamable HTTP, the stdio bridge, access tokens, allowed hosts, progress notifications | | [Sound tools](https://mirli.app/docs/mcp-sounds/index.md) | `generate`, `separate`, `enhance_prompt`, `list_models`, the library tools, `search_docs` | | [Voice and story tools](https://mirli.app/docs/mcp-stories/index.md) | `list_voices`, `speak`, model selection, `delivery`, and the nine story tools | | [Studio tools](https://mirli.app/docs/mcp-studio/index.md) | Lanes, the device rack, and reading and editing the open studio | | [Skills and call logs](https://mirli.app/docs/mcp-skills/index.md) | The bundled skills, call attribution, the call log and OpenTelemetry | ## The tools There are twenty-seven tools in six groups. Every name is prefixed `soundbox.`, which this table leaves off. | Group | Tools | Page | |---|---|---| | Sounds | `generate`, `separate`, `enhance_prompt`, `list_models`, `list_sounds`, `get_sound`, `delete_sound` | [Sound tools](https://mirli.app/docs/mcp-sounds/index.md) | | Voices | `list_voices`, `speak` | [Voice and story tools](https://mirli.app/docs/mcp-stories/index.md#voices) | | Stories | `create_story`, `list_stories`, `get_story`, `add_lines`, `update_line`, `speak_story`, `delete_line`, `split_line`, `export_story` | [Voice and story tools](https://mirli.app/docs/mcp-stories/index.md#stories) | | Arrangement | `open_in_studio`, `mix_track`, `remove_track`, `add_device`, `set_device`, `remove_device` | [Studio tools](https://mirli.app/docs/mcp-studio/index.md#arrangement) | | The open studio | `studio_context`, `studio_apply` | [Studio tools](https://mirli.app/docs/mcp-studio/index.md#the-open-studio) | | Documentation | `search_docs` | [Sound tools](https://mirli.app/docs/mcp-sounds/index.md#soundboxsearch_docs) | Six of them wait on a render or a split before they answer: `generate`, `separate`, `speak`, `speak_story`, `export_story` and `open_in_studio`. They send [progress notifications](https://mirli.app/docs/mcp-connect/index.md#progress-and-timeouts) while they wait. Four remove something: `delete_sound`, `delete_line`, `remove_track`, and `studio_apply` when it carries `delete_clip` with `allow_delete`. The authority is `server/src/mcp/server.ts`: the `MCP_TOOLS` table for names and descriptions, and the zod `inputSchema` on each `registerTool` call for arguments. Where these pages and that file disagree, the file is right. The site's tool list and the app's MCP reference read `app/src/content/mcp/tools.ts`, which is derived from it. ## Results A tool answers with one text content block, nearly always pretty-printed JSON. The exceptions are short sentences: `delete_sound` confirms with `Deleted `, and `enhance_prompt` explains itself in plain text when the prompt assistant is off. A failure comes back as a tool error whose text says what to do. A result that names a sound carries its **absolute filesystem path**, so the agent can pass it to ffmpeg or copy it into a project with its own file tools. Over the stdio bridge a sound comes back as the HTTP API's object instead, with a `file` URL such as `/files/.wav` and no path. See [Stdio bridge](https://mirli.app/docs/mcp-connect/index.md#stdio-bridge). ## Related - [HTTP API](https://mirli.app/docs/api/index.md): the same operations as REST endpoints, including `/api/mcp/status` and `/api/mcp/calls`. - The bundled skills in `server/skills/` teach an agent how to use these tools. See [Skills](https://mirli.app/docs/mcp-skills/index.md#skills). --- # MCP transports Mirli serves MCP two ways: Streamable HTTP on the app's own port, and a stdio bridge for clients that cannot speak HTTP. HTTP covers every tool; the bridge covers six. Step-by-step setup for thirteen named clients is in the how-to guide [Connect an AI agent to Mirli](https://mirli.app/docs/connect-agent/index.md). ## Streamable HTTP The endpoint, on the server's default port: ```text title="Endpoint" http://127.0.0.1:17494/mcp ``` | Property | Behaviour | |---|---| | Auth | None by default. With an access token set on the server, `/mcp` requires it. See [Access token and allowed hosts](#access-token-and-allowed-hosts) | | Path | `/mcp` with no trailing slash. Mirli answers on `/mcp` directly and never redirects, so a client that does not follow a `307` on `POST` works | | Port | Follows the server. The **Agents** page in the app (`/#/agents`) prints the endpoint of the running server | | Sessions | Streamable HTTP sessions, identified by the `mcp-session-id` header. The session id appears in the call log | A generic `mcpServers` entry, as most clients read it: ```json title="mcp.json" { "mcpServers": { "soundbox": { "type": "http", "url": "http://127.0.0.1:17494/mcp" } } } ``` ### Client config keys Config keys differ by client, and most clients ignore an entry with a wrong key without an error. The full entries, each checked against the vendor's page in November 2026, are in `app/src/content/mcp/clients.ts`. | Client | Key or file detail | |---|---| | Claude Code | In a hand-written `.mcp.json`, `"type": "http"` is required. An entry with `url` and no `type` is read as stdio and skipped | | Claude Desktop | `claude_desktop_config.json` takes stdio servers only, and **Settings > Connectors** connects from Anthropic's cloud, which cannot reach `127.0.0.1`. The entry runs `npx -y mcp-remote ` or the stdio bridge | | VS Code | `.vscode/mcp.json` uses a `servers` key, not `mcpServers` | | Antigravity | `serverUrl` (or `url`). `httpUrl` is rejected | | Gemini CLI (legacy) | `httpUrl` is Streamable HTTP and `url` means SSE: the reverse of Antigravity | | Devin Desktop | The `.devin/mcp_config.json` entry carries `"transport": "http"` next to `url` | | Zed | `context_servers`, not `mcpServers` | | Cline | `"type": "streamableHttp"` is required; without it Cline falls back to SSE | | Goose | The key is `uri`, not `url`, and `type` is `streamable_http` | | opencode | Remote servers default to OAuth. Mirli has none, so the entry sets `"oauth": false` | | Continue | `type: streamable-http`. A standalone file in `.continue/mcpServers/` also needs `name`, `version` and `schema` | A client that speaks only stdio can reach the HTTP endpoint through `mcp-remote`, which needs Node.js. The command a client config runs: ```bash npx -y mcp-remote http://127.0.0.1:17494/mcp ``` ## Stdio bridge `server/dist/mcp/stdio.js` is a thin proxy onto the running server. It does not load models, so there is never a second copy of a model on the GPU, and its calls appear on the **Agents** page tagged `stdio`. A client entry for it: ```json title="mcp.json" { "mcpServers": { "soundbox": { "command": "node", "args": ["/server/dist/mcp/stdio.js"] } } } ``` `` is the absolute path to the Mirli clone. The **Agents** page prints the command with the path resolved for the running install. | Property | Behaviour | |---|---| | Build | The file exists only after `npm run build` (or `npm run build --workspace server`). A fresh clone does not have it | | Path | Absolute. `npx soundbox-mcp` fails because the package is private, and a bare `soundbox-mcp` fails because the bin is linked only into the checkout's own `node_modules/.bin`, which is not on the `PATH` an editor starts MCP servers with | | Tools | Six: `generate`, `enhance_prompt`, `list_models`, `list_sounds`, `get_sound`, `delete_sound`. `separate`, speech, stories and the studio are HTTP only | | Results | A sound is the HTTP API's object, with a `file` URL such as `/files/.wav` and no absolute path | Environment variables the bridge reads: | Variable | Default | Purpose | |---|---|---| | `MIRLI_URL` | `http://127.0.0.1:17494` | Where the running server listens | | `MIRLI_API_TOKEN` | none | The server's access token, sent with every request | ## Access token and allowed hosts When the server is started with an access token, `/mcp` requires it like every other route, as `Authorization: Bearer `. A Claude Code `.mcp.json` entry that sends it: ```json title=".mcp.json" { "mcpServers": { "soundbox": { "type": "http", "url": "http://127.0.0.1:17494/mcp", "headers": { "Authorization": "Bearer " } } } } ``` `` is the value of `MIRLI_API_TOKEN` on the server. Over the stdio bridge, `MIRLI_API_TOKEN` in the bridge's environment does the same. See [Access token](https://mirli.app/docs/install-access/index.md#access-token). `/mcp` checks the `Host` header against DNS rebinding. A client that reaches it by any name other than `localhost`, `127.0.0.1` or `[::1]` needs that name in `MIRLI_ALLOWED_HOSTS` on the server, or the endpoint answers `403`. This holds even when the server is bound to `0.0.0.0`. See [Reverse proxy or another machine](https://mirli.app/docs/install-remote/index.md#put-mirli-behind-a-reverse-proxy). ## Progress and timeouts A long music render can outlast a client's tool-call timeout; some clients cut a call off at 60 seconds. When the request carries `_meta.progressToken`, Mirli sends `notifications/progress` while the job runs: | Field | Value | |---|---| | `progress` | 0 to 1 | | `total` | `1` | | `message` | The job's own phase, such as `loading model` or `sampling` | | Behaviour | Detail | |---|---| | Frequency | One when the job moves, at most once a second, plus one every 5 seconds while nothing moves, such as while weights load | | Tools | Every tool that waits on a job: `generate`, `speak`, `speak_story` (one bar across all the lines it reads), `separate`, `export_story`, `open_in_studio`. Over the stdio bridge, `generate` | | No token | No notifications. A client that neither sends a token nor resets its timeout on progress needs a longer tool timeout or a shorter `duration_s` | | Server limit | 15 minutes per job (per line, for `speak_story`). The job is then cancelled and the tool returns an error | --- # Skills and call logs The agent skills Mirli ships, and the records the server keeps of every MCP call. ## Skills The skills under `server/skills/` are instruction files an agent reads to prompt and call the tools well. | Skill | Covers | |---|---| | `soundbox-sfx` | Prompting and tool use for effects, foley and ambience | | `soundbox-sound-pass` | Inventorying and generating every sound event a project needs | | `soundbox-voice-story` | Writing, voicing and arranging spoken audio as a story | | Target | Folder | Install from | |---|---|---| | Claude Code | `~/.claude/skills/` | `soundbox skills install`, or the **Agents** page | | Cursor | `~/.cursor/skills/` | `soundbox skills install --target cursor`, or the **Agents** page | | Codex | `~/.codex/skills/` | `soundbox skills install --target codex`, or the **Agents** page | The **Agents** page's **Install all skills** button calls `POST /api/mcp/skills/install`. `soundbox skills list` prints what is bundled and what is installed. An install overwrites earlier copies. The CLI commands, one per line: ```bash soundbox skills install soundbox skills install --target cursor soundbox skills list ``` ## Call records Every call the server handles, over HTTP or the stdio bridge, is recorded three ways. | Record | Content | |---|---| | Attribution | The MCP handshake's `clientInfo` name and version, captured with no header. Sounds from `generate` carry `source = "mcp"` and `client`, e.g. `claude-code 2.1.0`, and the Library can filter to them. A `speak` read carries `source = "mcp"` only. Story lines and exports carry neither | | Call log | One line per call in the server log, and a row served by `GET /api/mcp/calls` and summarised by `GET /api/mcp/status`. The **Agents** page (`/#/agents`) reads these | | OpenTelemetry | Optional. One span per call carrying client, session, tool, model and resulting sound ids, plus metrics, over OTLP/HTTP | The server log sits in `~/.mirli/`, named for the port. The command that reads the MCP lines on the default port: ```bash grep mcp ~/.mirli/soundbox-17494.log ``` ### OpenTelemetry export Export is built in. It turns on when a collector endpoint is set, in **Settings** or with this `PATCH /api/settings` body: ```json title="PATCH /api/settings" { "otel_endpoint": "http://localhost:4318" } ``` | Setting | Detail | |---|---| | `otel_endpoint` | The collector's base URL. Traces go to `/v1/traces` and metrics to `/v1/metrics` | | `OTEL_EXPORTER_OTLP_ENDPOINT` | The same, as a server environment variable. Wins over the setting | Any OTLP/HTTP receiver works: Jaeger, Tempo, Honeycomb, the OpenTelemetry Collector. The call log endpoints are in the [HTTP API reference](https://mirli.app/docs/api/index.md). --- # Sound tools Tools that make, split, find and delete sounds in the library, plus `search_docs`. A sound in a result carries an absolute `path` to a WAV on the server's machine, a `url` under `/files/`, and its `id`, `name`, `model`, `prompt`, `duration_s`, `sample_rate`, `channels`, `seed`, `tags` and `parent_id`. | Tool | Description | |---|---| | [`soundbox.generate`](#soundboxgenerate) | Render sounds from a text description | | [`soundbox.separate`](#soundboxseparate) | Split a sound into stems | | [`soundbox.enhance_prompt`](#soundboxenhance_prompt) | Rewrite a prompt for a sound model | | [`soundbox.list_models`](#soundboxlist_models) | List models with licence and capabilities | | [`soundbox.list_sounds`](#soundboxlist_sounds) | Search the library | | [`soundbox.get_sound`](#soundboxget_sound) | Get one sound | | [`soundbox.delete_sound`](#soundboxdelete_sound) | Delete a sound and its file | | [`soundbox.search_docs`](#soundboxsearch_docs) | Search Mirli's documentation | ## Sounds ### `soundbox.generate` Renders one or more sounds from a text description, saves them to the library, and blocks until the audio is on disk. | Argument | Type | Required | Description | |---|---|---|---| | `prompt` | string | Yes | Material, action and space. With `lyrics`, genre and instrumentation instead | | `duration_s` | number | No | 0.5–300. Default `5.0` | | `model` | string | No | Model id. Default: the loaded model, else the first installed one. A model that bills per render is used only when named | | `negative_prompt` | string | No | What to avoid. Ignored by models without `supports.negative_prompt` | | `seed` | integer | No | ≥ 0. Default random | | `variations` | integer | No | 1–4 takes. Default `1` | | `tags` | string[] | No | Library tags | | `lyrics` | string | No | Up to 4,000 characters to sing, e.g. `[verse]\nGame over`. Ignored by models without `supports.lyrics` | | `track_name` | string | No | Track title, used only with `lyrics` | | `source_sound_id` | string | No | Edit this sound instead of rendering fresh. The result's `parent_id` is this id | | `edit` | `extend`, `cover`, `repaint` | No | The edit to apply to `source_sound_id` | | `edit_options` | object | No | Options for the edit | | `edit` | Result | `edit_options` | |---|---|---| | `extend` | The source continued to `duration_s`, which must exceed the source's length. The original stays intact at the start | None | | `cover` | The source re-rendered in the style of `prompt` and `lyrics`, at the source's length | `cover_strength` 0–1; 1 stays close to the source | | `repaint` | The span from `repaint_start_s` to `repaint_end_s` regenerated | `repaint_start_s` and `repaint_end_s` required; `repaint_mode` (`balanced`, `conservative`, `aggressive`) and `repaint_strength` 0–1 optional | Example arguments: ```json title="soundbox.generate arguments" { "prompt": "heavy wooden door slamming in a stone corridor", "duration_s": 3, "variations": 2 } ``` **Result:** `sounds` (one per variation), `model` (the id used) and `elapsed_s`. **Errors:** - `duration_s` greater than the model's `max_duration_s`. - A model whose `task` is not `gen`. - An `edit` the model does not support. In the shipped catalogue the ACE-Step models support all three edits and lyrics; MiniMax Music 3 supports lyrics only. - No model installed, or only models that bill per render and none named. - The job failed, was cancelled, or ran past 15 minutes. ### `soundbox.separate` Splits a library sound into stems (vocals, drums, bass, other), saves each as its own sound, and blocks until the audio is on disk. | Argument | Type | Required | Description | |---|---|---|---| | `sound_id` | string | Yes | The sound to split | | `model` | string | No | A model with `task: "sep"`. Default: an installed separator, preferring a loaded one | | `stems` | string[] | No | Stems to keep, e.g. `["vocals"]`. Default all. A name no stem answers to is reported in the result | | `rest` | `discard`, `merge` | No | What happens to the stems not named. `merge` sums them into one "rest" sound. Default `discard`; ignored without `stems` | **Result:** `sounds` (the stems, each with `stem_name`), `model` and `elapsed_s`. **Errors:** no separation model installed; no sound with that id; the job failed or was cancelled. ### `soundbox.enhance_prompt` Rewrites a vague prompt into one or more concrete ones for a sound model. | Argument | Type | Required | Description | |---|---|---|---| | `prompt` | string | Yes | 1–2,000 characters | | `n` | integer | No | 1–5 variations. Default `1` | | `category` | `sfx`, `music` | No | Default `sfx` | | `lyrics` | boolean | No | True when the prompt sets genre for a model that will sing lyrics | | `model` | string | No | The id to generate with. The rewrite follows that model's prompting conventions | **Result:** `variations` (the rewritten prompts) and `tags` (suggested library tags, for `generate`'s `tags`). **Errors:** none. When the prompt assistant is off, or it fails, the tool returns a plain-text explanation instead of JSON. ### `soundbox.list_models` Lists every model, generation and otherwise, with its status and licence. Takes no arguments. **Result:** an array of models: | Field | Description | |---|---| | `id`, `name`, `vendor`, `description` | Identity | | `task` | `gen` (`generate`), `tts` (speech tools) or `sep` (`separate`) | | `status` | Install and load state | | `license`, `commercial_use` | Licence name, and `yes`, `no` or `conditional` | | `max_duration_s`, `sample_rate` | Limits of the output | | `gated` | Whether the download needs an access token | | `supports` | Booleans: `negative_prompt`, `seed`, `lyrics`, `extend`, `cover`, `repaint` | | `delivery` | Text-to-speech models only: each parameter's name, group, default, range or choices | `delivery` is read from audio.cpp's own parameter table. audio.cpp accepts unknown options without an error, so only these names have an effect. The stdio bridge returns `supports` but not `task`, `description`, `gated` or `delivery`. **Errors:** none. ### `soundbox.list_sounds` Searches the library. | Argument | Type | Required | Description | |---|---|---|---| | `q` | string | No | Text to match in the prompt or name | | `tag` | string | No | A library tag | | `voice_id` | string | No | Only sounds read in this saved voice. A multi-voice dialogue is filed under no single voice | | `limit` | integer | No | 1–100. Default `20` | **Result:** an array of sounds. **Errors:** none. ### `soundbox.get_sound` Gets one sound by id. | Argument | Type | Required | Description | |---|---|---|---| | `sound_id` | string | Yes | The sound | **Result:** the sound, with its absolute `path`. **Errors:** `No sound with id `. ### `soundbox.delete_sound` Permanently deletes a sound's row and its file on disk. Sounds derived from it are kept and lose the link. | Argument | Type | Required | Description | |---|---|---|---| | `sound_id` | string | Yes | The sound | **Result:** the text `Deleted `. **Errors:** `No sound with id `; the sound is on a story's timeline (the error names the story). ## Documentation ### `soundbox.search_docs` Finds the sections of Mirli's README and `docs/` that match a question. Needs no studio open. | Argument | Type | Required | Description | |---|---|---|---| | `query` | string | Yes | 1–500 characters | | `limit` | integer | No | 1–8. Default `4` | **Result:** `sections`, each with `source` (the file), `heading` and `text` (cut at 4,000 characters). With no match, an empty list and a `note`. **Errors:** none. --- # Voice and story tools Tools that read text aloud and build stories. A story is a persistent script whose lines each carry a lane, a start time and, once read, a sound. For the order an agent calls them in, see [Sequence story calls](https://mirli.app/docs/agents-story-calls/index.md). | Tool | Description | |---|---| | [`soundbox.list_voices`](#soundboxlist_voices) | List saved voices | | [`soundbox.speak`](#soundboxspeak) | Read a line or a dialogue into one sound | | [`soundbox.create_story`](#soundboxcreate_story) | Start a story | | [`soundbox.list_stories`](#soundboxlist_stories) | List stories | | [`soundbox.get_story`](#soundboxget_story) | Read a story | | [`soundbox.add_lines`](#soundboxadd_lines) | Add lines, pauses or sounds | | [`soundbox.update_line`](#soundboxupdate_line) | Edit or move a line | | [`soundbox.speak_story`](#soundboxspeak_story) | Read every silent line | | [`soundbox.delete_line`](#soundboxdelete_line) | Delete a line | | [`soundbox.split_line`](#soundboxsplit_line) | Split a voiced line in two | | [`soundbox.export_story`](#soundboxexport_story) | Mix a story to one sound | ## Shared behaviour **Model selection.** `speak` and `speak_story` choose a model for each line, first match wins: | Order | Model | When | |---|---|---| | 1 | The `model` argument | Passed | | 2 | The line's voice's `model_id` | That model is installed | | 3 | A ready text-to-speech model, preferring the loaded one; never one that bills per read | Otherwise | A line that falls to order 3 although its voice has a model gets an entry in the result's `notes`. **Delivery.** `delivery` is an object of parameter names to values, taken from the model's `delivery` list in `list_models`. Unknown names are ignored without an error. The narrowest level wins: | Set on | Applies to | |---|---| | `create_story` | Every line without its own | | `add_lines`, per line | That line | | `update_line` | That line; `{}` returns it to the story's | | `speak` | The whole read | Changing a delivery does not re-read a line. **Story summary.** `create_story`, `add_lines`, `speak_story`, `delete_line`, `split_line`, `remove_track` and `open_in_studio` return `story_id`, `title`, `lines`, `pauses`, `voiced`, `tracks` (when more than one), `duration_s`, `delivery` (when set) and `open_in_studio`, a URL that opens the story in the app. **Errors.** Every story tool fails with `No story with id ` or `No line with id ` for an unknown id. ## Voices ### `soundbox.list_voices` Lists the saved voices a line can be cast to. Takes no arguments. **Result:** an array of voices with `id`, `name`, `kind`, `model_id` (the model the voice was made on) and `notes`. **Errors:** none. ### `soundbox.speak` Reads one line, or a dialogue, into one finished sound in the library, and blocks until the audio is on disk. | Argument | Type | Required | Description | |---|---|---|---| | `lines` | `{ text, voice_id?, speaker? }[]` | Yes | 1–200 lines. `text` is 1–20,000 characters, `speaker` up to 80. Different `voice_id`s make a dialogue | | `model` | string | No | One text-to-speech model for every line. See [Shared behaviour](#shared-behaviour) | | `gap_s` | number | No | Silence between lines, 0–5. Default `0.4` | | `name` | string | No | The sound's name in the library, up to 200 characters | | `delivery` | object | No | How the read is performed | **Result:** an array of sounds, each with `models` (lines per model id) when the read spanned model families, and `notes`. **Errors:** no text-to-speech model ready; the read failed. ## Stories ### `soundbox.create_story` Creates an empty story. | Argument | Type | Required | Description | |---|---|---|---| | `title` | string | No | The story's title, up to 200 characters | | `delivery` | object | No | The default delivery for every line | **Result:** the story summary. **Errors:** none. ### `soundbox.list_stories` Lists stories, most recently worked on first. | Argument | Type | Required | Description | |---|---|---|---| | `limit` | integer | No | 1–200. Default `20` | **Result:** an array of stories. **Errors:** none. ### `soundbox.get_story` Reads a story with every line and every touched lane. | Argument | Type | Required | Description | |---|---|---|---| | `story_id` | string | Yes | The story | **Result:** the story's fields, `open_in_studio`, `tracks` (each touched lane's mix and device chain) and `lines`. Each line has `id`, `kind`, `position`, `text`, `speaker`, `voice_id`, `track_index`, `start_s`, `duration_s`, `trim_start_s`, `muted`, `gain_db`, `voiced`, `sound_id`, its own `delivery` when set, and `midi` for a clip placed from the studio's MIDI panel (notes, tempo, instrument, cover prompt and strength, dry or cover, `take_id`). MIDI notes are read-only over MCP. **Errors:** `No story with id `. ### `soundbox.add_lines` Appends lines to a story. | Argument | Type | Required | Description | |---|---|---|---| | `story_id` | string | Yes | The story | | `lines` | object[] | Yes | 1–200 entries | Each entry is one of three kinds, and any kind takes `track_index` (−16 to 16, default `0`) and `start_s` (≥ 0): | Kind | Fields | |---|---| | Spoken line | `text` (up to 20,000 characters), `speaker` (up to 80), `voice_id`, `delivery` | | Pause | `kind: "pause"`, `duration_s` (0–600) | | Library sound | `sound_id` | An entry without `start_s` starts where its track's last clip ends. A spoken line has no length until it is read. Example arguments, two cast lines with a pause between them: ```json title="soundbox.add_lines arguments" { "story_id": "", "lines": [ { "speaker": "Guard", "voice_id": "", "text": "Who goes there?" }, { "kind": "pause", "duration_s": 0.6 }, { "speaker": "Thief", "voice_id": "", "text": "Just the wind." } ] } ``` `` comes from `create_story`; the voice ids come from `list_voices`. **Result:** `added` (the count) and the story summary. **Errors:** `No story with id `. ### `soundbox.update_line` Changes one line. Changing `text` or `delivery` does not re-read it. | Argument | Type | Required | Description | |---|---|---|---| | `line_id` | string | Yes | The line | | `text` | string | No | New words, up to 20,000 characters | | `speaker`, `voice_id` | string or null | No | Recast. `speaker` is up to 80 characters | | `track_index` | integer | No | −16 to 16 | | `start_s` | number | No | Position on the timeline, ≥ 0 | | `muted` | boolean | No | | | `gain_db` | number | No | −40 to 24 | | `duration_s` | number | No | How much of the clip plays, 0–600 | | `trim_start_s` | number | No | How far into the source the clip begins, ≥ 0 | | `delivery` | object | No | Overrides the story's; `{}` removes the override | **Result:** the line, in the same shape as in `get_story`. **Errors:** `No line with id `. ### `soundbox.speak_story` Reads every line that has no audio yet, one line at a time, and blocks until all are read. | Argument | Type | Required | Description | |---|---|---|---| | `story_id` | string | Yes | The story | | `model` | string | No | One model for every line. See [Shared behaviour](#shared-behaviour) | | `regenerate` | boolean | No | Also re-read lines that have audio. Default `false` | **Result:** `read` (the count), `models` (lines per model id), `notes`, and the story summary. **Errors:** a read failed, or ran past 15 minutes for one line. ### `soundbox.delete_line` Removes one line from its story. The sound it used stays in the library. | Argument | Type | Required | Description | |---|---|---|---| | `line_id` | string | Yes | The line | **Result:** the story summary. **Errors:** `No line with id `. ### `soundbox.split_line` Cuts a voiced line into two clips. The text stays with the first. | Argument | Type | Required | Description | |---|---|---|---| | `line_id` | string | Yes | The line | | `at_s` | number | Yes | Seconds into the clip as it plays, after any trim. Greater than 0 | **Result:** `halves` (the two lines) and the story summary. **Errors:** the line has not been read yet; `at_s` falls outside the clip; the line's audio is missing. ### `soundbox.export_story` Mixes the arrangement to one sound, honouring each clip's position, trim, gain and mute, and blocks until it is on disk. Devices on the lanes are not applied. | Argument | Type | Required | Description | |---|---|---|---| | `story_id` | string | Yes | The story | **Result:** the new sound and `open_in_studio`. **Errors:** the export failed or produced no audio. --- # Studio tools Tools for a story's lanes and device racks, and for the studio the user has open. The arrangement tools change the saved story and need nothing open. The open-studio tools work on a live studio through its own controls. | Tool | Description | |---|---| | [`soundbox.open_in_studio`](#soundboxopen_in_studio) | Lay a sound out on a new timeline | | [`soundbox.mix_track`](#soundboxmix_track) | Name, mute, solo or set the level of a lane | | [`soundbox.remove_track`](#soundboxremove_track) | Delete a lane and its clips | | [`soundbox.add_device`](#soundboxadd_device) | Add a device to a lane's rack | | [`soundbox.set_device`](#soundboxset_device) | Change or bypass a device | | [`soundbox.remove_device`](#soundboxremove_device) | Remove a device | | [`soundbox.studio_context`](#soundboxstudio_context) | Read the open studio | | [`soundbox.studio_apply`](#soundboxstudio_apply) | Edit the open studio | `track_index` runs from −16 to 16 on every tool. An unknown `story_id` fails with `No story with id `. ## Arrangement ### `soundbox.open_in_studio` Lays a library sound out on a new story's timeline, split into stems on separate lanes where possible, and blocks until the split is done. Stems the sound already has are reused. | Argument | Type | Required | Description | |---|---|---|---| | `sound_id` | string | Yes | The sound | | `separate` | boolean | No | Split into stems first. Default `true`; ignored for a stem or an edit | | `stems` | string[] | No | Stems that get a lane, up to 16. Default all | | `rest` | `discard`, `merge` | No | What happens to stems not named. `merge` puts them on one "rest" lane. Default `discard` | **Result:** the story summary of the new story. See [Story summary](https://mirli.app/docs/mcp-stories/index.md#shared-behaviour). **Errors:** the split failed; nothing was opened. ### `soundbox.mix_track` Sets one lane's name, mute, solo or level. These belong to the lane, not to its clips. With any lane soloed, only soloed lanes are heard. | Argument | Type | Required | Description | |---|---|---|---| | `story_id` | string | Yes | The story | | `track_index` | integer | Yes | The lane | | `name` | string or null | No | The lane's name, up to 80 characters | | `muted`, `soloed` | boolean | No | | | `gain_db` | number | No | −40 to 24 | **Result:** the lane's settings and `open_in_studio`. **Errors:** `No story with id `. ### `soundbox.remove_track` Deletes a lane and every clip on it. The lanes numbered after it each shift by one to close the gap. | Argument | Type | Required | Description | |---|---|---|---| | `story_id` | string | Yes | The story | | `track_index` | integer | Yes | The lane | **Result:** `removed_clips` and the story summary. **Errors:** `No story with id `. ### `soundbox.add_device` Adds a device to a lane's rack at its defaults, with any `params` applied. | Argument | Type | Required | Description | |---|---|---|---| | `story_id` | string | Yes | The story | | `track_index` | integer | Yes | The lane | | `kind` | string | Yes | `compressor`, `eq`, `reverb`, `delay`, `distortion`, `gate`, `limiter` or `autotune` | | `params` | object | No | Knob values in stored units: seconds, dB, 0–1 for mixes. The input schema lists every knob's range and default | | `bypassed` | boolean | No | Out of the signal path, settings kept | | `position` | integer | No | Place in the chain from 0. Default last | Example arguments, a compressor on lane 2 with two knobs changed: ```json title="soundbox.add_device arguments" { "story_id": "", "track_index": 2, "kind": "compressor", "params": { "threshold": -18, "attack": 0.02 } } ``` **Result:** `story_id`, `track_index`, `device` (the new id), `clamped` (knobs set past their range, placed at the end), `devices` (the lane's whole chain), `note` and `open_in_studio`. Devices are heard in the studio's playback and rendered into `export_story`'s mixdown. **Errors:** a knob the device does not have (the error lists its knobs). ### `soundbox.set_device` Changes a device's knobs, bypasses it, or both. | Argument | Type | Required | Description | |---|---|---|---| | `story_id` | string | Yes | The story | | `track_index` | integer | Yes | The lane | | `device` | string | Yes | The device's id, or its kind when the lane has one of that kind | | `params` | object | No | Knob values | | `bypassed` | boolean | No | | **Result:** the same shape as `add_device`. **Errors:** neither `params` nor `bypassed` passed; no such device (the error lists the chain); a kind with several devices on the lane (the error lists their ids); an unknown knob. ### `soundbox.remove_device` Removes one device from a lane's chain. | Argument | Type | Required | Description | |---|---|---|---| | `story_id` | string | Yes | The story | | `track_index` | integer | Yes | The lane | | `device` | string | Yes | Id, or kind when the lane has one of that kind | **Result:** the same shape as `add_device`. **Errors:** as `set_device`. ## The open studio These need Mirli open in a browser or the desktop app with a studio showing. The server asks that page and waits a few seconds for its answer. ### `soundbox.studio_context` Reads what an open studio shows. | Argument | Type | Required | Description | |---|---|---|---| | `story_id` | string | No | Which studio. Omit when one is open | **Result:** `story_id`, `title`, `open_in_studio`, and the live state: lanes (name, muted, soloed, effect kinds), every clip (`id`, lane, start, length, label), the playhead in seconds, the selected clip ids, and the voices a line can be cast to. **Errors:** no studio open; the named story is not open in a studio; several studios open and no `story_id` (the error lists them); the page sent a context the server cannot read. ### `soundbox.studio_apply` Applies edits to an open studio through its own controls, so they land on the user's undo stack. | Argument | Type | Required | Description | |---|---|---|---| | `actions` | object[] | Yes | 1–50 studio actions, applied in order. See [Studio action vocabulary](https://mirli.app/docs/agents-studio-actions/index.md) | | `story_id` | string | No | Which studio. Omit when one is open | | `summary` | string | No | Up to 200 characters, shown in the studio's toast and history | | `allow_delete` | boolean | No | Run `delete_clip` actions. Default `false`: they are held | **Result:** `story_id`, `applied` (the count), `actions` (those applied), `dropped` (actions naming nothing in the studio, or malformed), `held_deletes`, `notes` and `open_in_studio`. **Errors:** as `studio_context`. --- # HTTP API Not a developer? Start with the [guides to making sound](https://mirli.app/docs/generating/index.md). The app itself uses this API, so a script can do anything the app does. The [API quickstart](https://mirli.app/docs/api-quickstart/index.md) makes a first request. ## Base URL The server listens on this address by default: ```text http://127.0.0.1:17494 ``` Routes are under `/api/`, audio under `/files/`, images under `/artwork/`, OpenAI-compatible routes under `/v1/`, and MCP at `/mcp`. Bodies are JSON unless an endpoint says otherwise: uploads take WAV, and some endpoints return audio or an event stream. ## Request rules Three checks run before any endpoint, so a web page in a browser cannot drive the server. | Check | Rule | Refused with | |---|---|---| | Host | The `Host` header must name `localhost`, `127.0.0.1` or `[::1]` (any port), the host passed to `soundbox --host`, or a name in `MIRLI_ALLOWED_HOSTS`. Binding a wildcard (`--host 0.0.0.0`) turns this off, except on `/mcp` | `403` | | Mutating requests | `POST`, `PUT`, `PATCH` and `DELETE` under `/api/` need a non-simple `Content-Type` (`application/json`, or `audio/wav` or `application/octet-stream` on uploads) or an `X-Soundbox` header with any value. The `/v1/` routes have [their own rule](https://mirli.app/docs/api-openai/index.md) | `403` | | Access token | When the server runs with `MIRLI_API_TOKEN`, every `/api/`, `/v1/`, `/mcp`, `/files/` and `/artwork/` request needs `Authorization: Bearer ` or the session cookie from [signing in](https://mirli.app/docs/api-server/index.md). Health and the three sign-in endpoints stay open | `401` | A request with no body therefore sends the header: ```bash curl -X POST -H 'X-Soundbox: 1' http://127.0.0.1:17494/api/sessions ``` [Access token](https://mirli.app/docs/install-access/index.md#access-token) describes how to set a token. ## Conventions - **Jobs.** Slow work runs as a job. An endpoint that starts one returns `202 Accepted` with `{ "job_id": "" }`, and the [jobs endpoints](https://mirli.app/docs/api-jobs/index.md) report its progress and result. - **Parameters.** In the parameter tables, `` is a path parameter, `?limit` a query parameter, and a bare name such as `prompt` a body field. - **Errors.** An error is a status and a `detail`. [Errors](https://mirli.app/docs/api-errors/index.md) lists the status codes, the body shapes, and the errors any endpoint can return. ## Endpoint groups The endpoints are grouped as `server/src/routes/` registers them: | Group | Covers | |---|---| | [Generation](https://mirli.app/docs/api-generate/index.md) | Render, generate, stems, repaint | | [Jobs](https://mirli.app/docs/api-jobs/index.md) | Job status, events and cancelling | | [Speech](https://mirli.app/docs/api-speech/index.md) | Speech, streaming, conversion, transcription | | [Voices](https://mirli.app/docs/api-voices/index.md) | Saved voices, their clips, export and import | | [Sounds](https://mirli.app/docs/api-sounds/index.md) | The library, uploads, edits and audio files | | [Sessions and projects](https://mirli.app/docs/api-sessions/index.md) | Grouping sounds | | [Stories](https://mirli.app/docs/api-stories/index.md) | Scripts and studio timelines | | [Story segments](https://mirli.app/docs/api-segments/index.md) | Lines, pauses, clips, MIDI takes | | [Story tracks](https://mirli.app/docs/api-tracks/index.md) | Lanes and device chains | | [Models](https://mirli.app/docs/api-models/index.md) | Model status, downloads and loading | | [audio.cpp runtime](https://mirli.app/docs/api-audiocpp/index.md) | The model catalogue and the inference engine | | [Artwork](https://mirli.app/docs/api-artwork/index.md) | Cover art, voice avatars and image models | | [Instruments](https://mirli.app/docs/api-instruments/index.md) | Sampled instruments for the studio | | [Server](https://mirli.app/docs/api-server/index.md) | Health, capabilities, sign-in, updates, logs | | [Settings and profiles](https://mirli.app/docs/api-settings/index.md) | Settings, folders and separate libraries | | [MCP activity](https://mirli.app/docs/api-agents/index.md) | What agents have done over MCP | | [Prompt assistant](https://mirli.app/docs/api-assistant/index.md) | Prompt rewriting, lyrics, chat and studio commands | | [Chat history](https://mirli.app/docs/api-conversations/index.md) | Saved assistant conversations | | [OpenAI-compatible](https://mirli.app/docs/api-openai/index.md) | Speech and transcription in OpenAI's request shapes | ## Other routes | Route | Where it is described | |---|---| | `/api/endpoints` | [Custom endpoints](https://mirli.app/docs/endpoints-reference/index.md#http-api) | | `/mcp` | [MCP tools](https://mirli.app/docs/mcp/index.md) | | `/api/calls`, `/api/characters` | Registered only with `MIRLI_CALLS=1`; `live/README.md` | | `GET /` | The built app when it is staged in `server/web`, otherwise a JSON stub | The website's [API and MCP reference](https://mirli.app/docs/reference/) has a copy-paste quickstart and the MCP tool list. --- # MCP activity endpoints MCP activity is the record of the tool calls agents make over MCP, with the server's connection details and its bundled agent skills. These endpoints feed the app's **Agents** page. The MCP endpoint itself is `/mcp` on the same port; its tools are on [MCP tools](https://mirli.app/docs/mcp/index.md). Each endpoint lists the errors it returns itself. Any endpoint can also return the [common errors](https://mirli.app/docs/api-errors/index.md#common-errors). ## Call object The call endpoints return this object. Calls over HTTP are recorded by the server; calls through the stdio bridge are reported by the bridge with [Record a call](#record-a-call) and [Finish a call](#finish-a-call). | Field | Type | Description | |---|---|---| | `id` | string | The call's id | | `ts` | string | ISO 8601 time the call started | | `tool` | string | The tool's name | | `status` | string | `running`, `ok` or `error` | | `client_name`, `client_version` | string or null | The MCP client that made the call | | `session_id` | string or null | The MCP session | | `transport` | string | `http` or `stdio` | | `args` | object | The arguments the tool was called with | | `duration_ms` | integer or null | How long the call took | | `error` | string or null | Why the call failed | | `job_id` | string or null | The job the call started | | `sound_ids` | string[] | The sounds the call made | | `trace_id` | string or null | The OpenTelemetry trace id, when export is on | ## Get MCP status `GET /api/mcp/status` Returns the connection details, the connected clients, call totals, the OpenTelemetry state and the bundled skills in one response. This endpoint takes no parameters. This request reads the MCP status: ```bash curl http://127.0.0.1:17494/api/mcp/status ``` A successful response is `200 OK` with the status. The example is abridged: ```jsonc { "endpoint": "http://127.0.0.1:17494/mcp", "stdio_command": "node C:\\mirli\\server\\dist\\mcp\\stdio.js", "server_name": "soundbox", "server_version": "0.6.4", "calls_total": 42, "errors_total": 1, "sounds_total": 17, "calls_24h": 6, "last_call_at": "2026-11-29T09:12:44.000Z", "active_sessions": 0 // ...more fields } ``` | Field | Type | Description | |---|---|---| | `endpoint` | string | The MCP URL, built from the request's `Host` | | `stdio_command` | string | The command that starts this install's stdio bridge, with its absolute path | | `server_name`, `server_version` | string | The MCP server's name and version | | `tools` | object[] | Each tool's `name`, `title`, `description` and `calls` count. Empty when MCP failed to start | | `clients` | object[] | One entry per client name and version: `name` (`unknown` when the client sent none), `version`, `calls`, `errors`, `sounds`, `sessions`, `first_seen`, `last_seen`, and `active` (a call in the last ten minutes) | | `calls_total`, `errors_total`, `calls_24h` | integer | Recorded calls, failed calls, and calls in the last 24 hours | | `sounds_total` | integer | Library sounds made over MCP | | `last_call_at` | string or null | ISO 8601 time of the newest call | | `active_sessions` | integer | MCP sessions with a call running now | | `otel` | object | OpenTelemetry export: `enabled`, `installed`, `endpoint`, `source` (`env`, `settings` or `none`), `service_name` and `error` | | `skills` | object[] | Each bundled skill's `name`, `description`, `path`, `files`, and `installed_at`: the folder it is installed in, per target | | `skill_targets` | object[] | Each install target's `id`, `label`, `path`, and `exists` (its parent folder exists) | This endpoint returns only the common errors. ## List calls `GET /api/mcp/calls` Returns recorded calls, newest first. | Name | Type | Required | Description | |---|---|---|---| | `?limit` | integer | No | 1 to 1,000. Default 100 | | `?client` | string | No | One client name | | `?tool` | string | No | One tool name | | `?status` | string | No | `running`, `ok` or `error` | | `?since` | string | No | ISO 8601 time. Calls that started at or after it | This request lists the last 20 failed calls: ```bash curl "http://127.0.0.1:17494/api/mcp/calls?status=error&limit=20" ``` A successful response is `200 OK` with an array of [call objects](#call-object). The example is abridged: ```jsonc [ { "id": "8c1d0f52-6a3e-4b7d-9e21-5f4a0c3b7d19", "ts": "2026-11-29T09:12:44.000Z", "tool": "soundbox.split_line", "status": "error", "error": "ModelError: Split point has to fall inside the clip." // ...the rest of the call object } ] ``` | Status | Cause | |---|---| | `422` | `limit` is not an integer from 1 to 1,000 | ## Record a call `POST /api/mcp/calls` Records a call that has started. The stdio bridge reports each call it proxies through this endpoint, so it appears alongside HTTP calls. The call is recorded as `running` whatever `status` says, and goes out on the [calls feed](#follow-calls). | Name | Type | Required | Description | |---|---|---|---| | `id` | string | Yes | The call's id. [Finish a call](#finish-a-call) uses it | | `ts` | string | Yes | ISO 8601 start time. `""` means now | | `tool` | string | Yes | The tool's name | | `transport` | string | No | `http` or `stdio`. Default `http` | | `client_name`, `client_version`, `session_id` | string or null | No | Who made the call | | `args` | object | No | The tool's arguments. Default `{}` | | `status`, `duration_ms`, `error`, `job_id`, `sound_ids`, `trace_id` | As listed | No | See the [call object](#call-object) | This request records a call from the stdio bridge: ```bash curl -X POST "http://127.0.0.1:17494/api/mcp/calls" \ -H 'Content-Type: application/json' \ -d '{ "id": "", "ts": "", "tool": "soundbox.generate", "transport": "stdio", "args": { "prompt": "door slam" } }' ``` A successful response is `201 Created` with the recorded [call object](#call-object). This endpoint returns only the common errors. ## Finish a call `PATCH /api/mcp/calls/` Settles a call recorded with [Record a call](#record-a-call). Fields sent as `null` and fields not in the table are ignored. A call that is still `running` afterwards becomes `ok`. | Name | Type | Required | Description | |---|---|---|---| | `` | string | Yes | The call's id | | `status` | string | No | `ok` or `error` | | `duration_ms` | integer | No | How long the call took | | `error` | string | No | Why the call failed | | `job_id` | string | No | The job the call started | | `sound_ids` | string[] | No | The sounds the call made | This request marks a call as failed: ```bash curl -X PATCH "http://127.0.0.1:17494/api/mcp/calls/" \ -H 'Content-Type: application/json' \ -d '{"status": "error", "duration_ms": 812, "error": "Timed out"}' ``` A successful response is `200 OK` with the finished [call object](#call-object). | Status | Cause | |---|---| | `404` | No running call has this id: it is unknown, already finished, or was running when the server restarted | ## Follow calls `GET /api/mcp/calls/events` Streams calls as server-sent events. On connect, the stream sends one event per running call. After that it sends one event when a call starts (`status` is `running`) and one when it settles. A `: keepalive` comment goes out every 15 seconds while nothing happens. This endpoint takes no parameters. This request follows calls as they happen: ```bash curl -N http://127.0.0.1:17494/api/mcp/calls/events ``` A successful response is `200 OK` with `Content-Type: text/event-stream`: ```text data: : keepalive data: ``` Each `` is a [call object](#call-object) as one line of JSON. This endpoint returns only the common errors. ## Install skills `POST /api/mcp/skills/install` Copies the bundled agent skills into a client's skills folder on the server's machine. Each copy replaces any earlier one with the same name. The bundled skills are `soundbox-sfx`, `soundbox-sound-pass` and `soundbox-voice-story`. | Name | Type | Required | Description | |---|---|---|---| | `target` | string | No | `claude` (`~/.claude/skills`, the default), `cursor` (`~/.cursor/skills`), `codex` (`~/.codex/skills`) or `dir` | | `path` | string | For `dir` | The folder to copy into. A leading `~` is the home directory | | `skills` | string[] | No | Skill names or folder names. Default: every bundled skill | This request installs every skill for Cursor: ```bash curl -X POST "http://127.0.0.1:17494/api/mcp/skills/install" \ -H 'Content-Type: application/json' \ -d '{"target": "cursor"}' ``` A successful response is `200 OK` with the target, the folder and the skills copied: ```json { "target": "cursor", "dest": "C:\\Users\\x\\.cursor\\skills", "installed": [ "soundbox-sfx", "soundbox-sound-pass", "soundbox-voice-story" ] } ``` | Status | Cause | |---|---| | `400` | `target` is unknown, `dir` has no `path`, no bundled skill matches `skills`, or the copy failed | | `403` | The server's capabilities turn `skills_install` off | --- # Artwork endpoints Artwork is the cover art drawn for a sound and the avatar drawn for a voice, each a PNG file the sound's or voice's `artwork` field points at. These endpoints report and install the image engine and its models, draw and remove artwork, and serve the files. [Artwork](https://mirli.app/docs/artwork/index.md) describes the modes and settings. Each endpoint lists the errors it returns itself. Any endpoint can also return the [common errors](https://mirli.app/docs/api-errors/index.md#common-errors). ## Get the artwork status `GET /api/image/status` Returns the artwork mode, whether artwork can be drawn now, and the engine, model and catalogue behind it. Each call also probes this machine for image servers already running. This endpoint takes no parameters. This request reads the artwork status: ```bash curl "http://127.0.0.1:17494/api/image/status" ``` A successful response is `200 OK` with the status. The example is abridged: ```jsonc { "mode": "managed", "ready": true, "detail": null, "engine": { "installed": true, "version": "master-827-97d2990", "backend": "cuda" }, "model": { "id": "sd-turbo", "name": "SD-Turbo (Q8)", "hf_repo": "Green-Sky/SD-Turbo-GGUF", "resolution": 512, "steps": 1, "cfg": 1, "recommended": true, "source": "builtin", "installed": true, "size_bytes": 2023745376 // ...more fields }, "external": { "kind": "openai", "base_url": "", "model": "", "api_key_set": false }, "running": false, "auto_artwork": false, "detected": [] // ...more fields, including catalog } ``` | Field | Type | Description | |---|---|---| | `mode` | string | `off` (the default), `managed` or `external` | | `ready` | boolean | Artwork can be drawn now | | `detail` | string or null | What is missing, in words, when `ready` is `false` | | `engine` | object | The `sd-server` engine: `installed`, `version` and `backend` | | `model` | object or null | The catalogue entry of the chosen model | | `catalog` | object[] | Every image model: the built-in `sd-turbo`, `sdxl-turbo` and `sd35-medium`, then entries from the `image_models` key of `/models/custom.json` | | `external` | object | The external server's `kind` (`openai` or `a1111`), `base_url`, `model`, and `api_key_set` in place of the key | | `running` | boolean | The managed engine is running | | `auto_artwork` | boolean | A cover is drawn after each music render | | `detected` | object[] | Image servers found on this machine: `label`, `base_url`, `kind` and `models` | A catalogue entry has `id`, `name`, `vendor`, `license`, `hf_repo` (empty for files already on disk), `files` (each a `flag`, `path` and `size_bytes`), `description`, `resolution`, `steps`, `cfg`, `extra_args`, `recommended`, `source` (`builtin` or `custom`), `installed`, and `size_bytes`, the download size (`0` for files already on disk). This endpoint returns only the common errors. ## Install the artwork engine `POST /api/image/engine/install` Queues a job that downloads stable-diffusion.cpp's `sd-server` from GitHub and installs it under `/bin/sd//`. While an install is running, the endpoint returns that job instead of queuing another. The body is optional. | Name | Type | Required | Description | |---|---|---|---| | `version` | string | No | `latest` or a release tag, such as `master-827-97d2990`. Default `latest` | | `backend` | string | No | Accepted and validated, but not used | This request installs the latest release: ```bash curl -X POST -H 'X-Soundbox: 1' \ "http://127.0.0.1:17494/api/image/engine/install" ``` A successful response is `202 Accepted` with the job's id. Progress streams from [the job's events](https://mirli.app/docs/api-jobs/index.md#stream-a-jobs-events): ```json { "job_id": "5a3e8c1d-7b2f-4e9a-8d6c-1f0b3a9e7c42" } ``` | Status | Cause | |---|---| | `403` | The server's capabilities turn `downloads` off | ## Download an image model `POST /api/image/models//download` Queues a job that downloads an image model's files from Hugging Face, fetching only those not yet on disk. While a download of the model is running, the endpoint returns that job instead of queuing another. | Name | Type | Required | Description | |---|---|---|---| | `` | string | Yes | The image model's id, such as `sd-turbo` | This request downloads SD-Turbo: ```bash curl -X POST -H 'X-Soundbox: 1' \ "http://127.0.0.1:17494/api/image/models/sd-turbo/download" ``` A successful response is `202 Accepted` with the job's id: ```json { "job_id": "e41b7d90-3c6a-4f25-9b8e-0d2a6c5f1e73" } ``` | Status | Cause | |---|---| | `400` | No image model has this id. The body has `detail` and `failure` | | `403` | The server's capabilities turn `downloads` off | ## Delete an image model `DELETE /api/image/models/` Deletes an image model's downloaded files. When it is the chosen model, the engine is stopped first. | Name | Type | Required | Description | |---|---|---|---| | `` | string | Yes | The image model's id | This request deletes SD-Turbo: ```bash curl -X DELETE -H 'X-Soundbox: 1' \ "http://127.0.0.1:17494/api/image/models/sd-turbo" ``` A successful response is `204 No Content`. | Status | Cause | |---|---| | `400` | No image model has this id, or its files are all ones already on disk, which Mirli did not download. The body has `detail` and `failure` | | `403` | The server's capabilities turn `downloads` off | ## Draw a sound's cover `POST /api/sounds//artwork` Draws cover art for a sound and waits for it, replacing any cover it had. The prompt comes from the sound's prompt (or its track name, or its name) plus its first four tags, and the render uses the sound's seed. The old file is deleted only once the new one exists. | Name | Type | Required | Description | |---|---|---|---| | `` | string | Yes | The sound's id | This request draws one sound's cover: ```bash curl -X POST -H 'X-Soundbox: 1' \ "http://127.0.0.1:17494/api/sounds//artwork" ``` A successful response is `200 OK` with the updated [sound object](https://mirli.app/docs/api-sounds/index.md#sound-object), its `artwork` set to `/artwork/cover-.png`. | Status | Cause | |---|---| | `400` | No sound has this id, or the image render failed: artwork is off, the engine or model is missing, or no external server is set. The body has `detail` and `failure` | ## Remove a sound's cover `DELETE /api/sounds//artwork` Deletes a sound's cover file and sets its `artwork` to `null`. An id with no sound also returns `204`. | Name | Type | Required | Description | |---|---|---|---| | `` | string | Yes | The sound's id | This request removes one sound's cover: ```bash curl -X DELETE -H 'X-Soundbox: 1' \ "http://127.0.0.1:17494/api/sounds//artwork" ``` A successful response is `204 No Content`. This endpoint returns only the common errors. ## Draw a voice's avatar `POST /api/voices//artwork` Draws an avatar for a voice and waits for it, replacing any avatar it had. The prompt comes from the voice's `notes`, or its name when there are none, and each draw is a new take. The old file is deleted only once the new one exists. | Name | Type | Required | Description | |---|---|---|---| | `` | string | Yes | The voice's id | This request draws one voice's avatar: ```bash curl -X POST -H 'X-Soundbox: 1' \ "http://127.0.0.1:17494/api/voices//artwork" ``` A successful response is `200 OK` with the updated [voice object](https://mirli.app/docs/api-voices/index.md#voice-object), its `artwork` set to `/artwork/avatar-.png`. | Status | Cause | |---|---| | `400` | No voice has this id, or the image render failed. The body has `detail` and `failure` | ## Remove a voice's avatar `DELETE /api/voices//artwork` Deletes a voice's avatar file and sets its `artwork` to `null`. An id with no voice also returns `204`. | Name | Type | Required | Description | |---|---|---|---| | `` | string | Yes | The voice's id | This request removes one voice's avatar: ```bash curl -X DELETE -H 'X-Soundbox: 1' \ "http://127.0.0.1:17494/api/voices//artwork" ``` A successful response is `204 No Content`. This endpoint returns only the common errors. ## Get an artwork image `GET /artwork/` Returns one cover or avatar as `image/png`, served inline. Each render gets a new file name, so the response is cached for a year as immutable. | Name | Type | Required | Description | |---|---|---|---| | `` | string | Yes | The file name from an `artwork` field, such as `cover-.png` | This request saves one cover: ```bash curl -o cover.png "http://127.0.0.1:17494/artwork/cover-.png" ``` A successful response is `200 OK` with the PNG and the header `Cache-Control: public, max-age=31536000, immutable`. | Status | Cause | |---|---| | `400` | The file name contains a path | | `404` | No such file | --- # Prompt assistant endpoints The prompt assistant is an optional language model. It rewrites a terse prompt ("scary sound") into a descriptive one, writes lyrics, answers questions about Mirli, and turns studio instructions into edits. These endpoints call it and manage the engine and models it runs on. Saved assistant conversations are on [Chat history endpoints](https://mirli.app/docs/api-conversations/index.md). Each endpoint lists the errors it returns itself. Any endpoint can also return the [common errors](https://mirli.app/docs/api-errors/index.md#common-errors). ## Assistant modes The `llm_mode` setting decides what answers, and is `off` by default. It is set with [`PATCH /api/settings`](https://mirli.app/docs/api-settings/index.md), together with `llm_model`, `llm_external_base_url`, `llm_external_model` and `llm_external_api_key`: | `llm_mode` | What runs | |---|---| | `off` | Nothing. Every endpoint that calls the model answers `400` with a message saying what to set up | | `managed` | A small model Mirli installs and manages: `llama-server` and a curated GGUF | | `external` | Any OpenAI-compatible endpoint the settings name, such as one already running on this machine | An endpoint that calls the model returns `400` with `detail` and a [failure object](https://mirli.app/docs/api-errors/index.md#failure-object) when the mode is `off`, the external endpoint has no base URL or model, the managed engine or model is not installed, or the model does not answer, times out, returns an HTTP error or returns nothing. ## Rewrite a prompt `POST /api/enhance` Rewrites a prompt into descriptive variations, with suggested tags. | Name | Type | Required | Description | |---|---|---|---| | `prompt` | string | Yes | 1 to 2,000 characters | | `n` | integer | No | 1 to 5 variations. Default 1 | | `category` | string | No | `sfx` or `music` | | `lyrics` | boolean | No | Whether the prompt is for a lyrics model | | `model` | string | No | The model the prompt is for, so the rewrite follows that model's prompting conventions. An unknown or missing id means generic guidance | This request rewrites "scary sound" for Stable Audio: ```bash curl -X POST "http://127.0.0.1:17494/api/enhance" \ -H 'Content-Type: application/json' \ -d '{ "prompt": "scary sound", "category": "sfx", "model": "audiocpp-stable-audio-3-sfx" }' ``` A successful response is `200 OK` with the variations and tags. `tags` are suggestions for the library's tags, not part of the prompt: ```json { "variations": [ "heavy wooden door slamming shut in a stone corridor" ], "tags": ["door", "slam"] } ``` | Status | Cause | |---|---| | `400` | The assistant is off, not set up, or did not answer: see [Assistant modes](#assistant-modes) | ## Write lyrics `POST /api/enhance/lyrics` Writes a song's lyrics from a theme. | Name | Type | Required | Description | |---|---|---|---| | `theme` | string | Yes | What the song is about. 1 to 2,000 characters | | `style` | string | No | The current style prompt, so the lyrics' tags agree with it. Up to 2,000 characters | This request writes lyrics for a lighthouse song: ```bash curl -X POST "http://127.0.0.1:17494/api/enhance/lyrics" \ -H 'Content-Type: application/json' \ -d '{ "theme": "a lighthouse keeper alone in a storm", "style": "folk, acoustic guitar" }' ``` A successful response is `200 OK` with the lyrics as one string: ```json { "lyrics": "[verse]\nThe lamp turns slow across the sea" } ``` | Status | Cause | |---|---| | `400` | The assistant is off, not set up, or did not answer: see [Assistant modes](#assistant-modes) | ## Send an assistant message `POST /api/assistant/chat` Runs one turn of the assistant, which answers questions about Mirli from its documentation and the installed models. The server keeps no conversation state, so the request carries the whole thread; the model reads the last 20 turns. The assistant runs nothing and proposes no request. | Name | Type | Required | Description | |---|---|---|---| | `messages` | object[] | Yes | 1 to 60 turns of `{ role, content }`. `role` is `user` or `assistant`; `content` is 1 to 8,000 characters | | `draft` | object | No | The composer's contents: `model` and `prompt`, and optionally `negative_prompt`, `lyrics`, `track_name`, `duration_s` and up to 20 `tags` | | `studio` | object | No | The open timeline: up to 200 `tracks` (`track_index`, `name`, `muted`, `soloed`), up to 500 `clips` (`id`, `track_index`, `start_s`, `duration_s`, `label`), `playhead_s` and `selected_ids` | This request asks which model suits a door slam: ```bash curl -X POST "http://127.0.0.1:17494/api/assistant/chat" \ -H 'Content-Type: application/json' \ -d '{ "messages": [ { "role": "user", "content": "Which model should I use for a door slam?" } ], "draft": { "model": "audiocpp-stable-audio-3-sfx", "prompt": "door slam" } }' ``` A successful response is `200 OK` with the reply. `links` are pages in the app the reply points at, and `sources` names the documentation sections it drew on: ```json { "reply": "Stable Audio 3.0 SFX is made for short effects like this.", "links": [ { "to": "/models", "label": "Models" } ], "sources": ["docs/GENERATING.md › Writing a prompt"] } ``` | Status | Cause | |---|---| | `400` | The assistant is off, not set up, or did not answer: see [Assistant modes](#assistant-modes) | ## List conversation openers `POST /api/assistant/openers` Suggests two to four first messages for an empty chat, written for the installed models and the open timeline. When the model's answer holds fewer than two, the response is a fixed set of openers. | Name | Type | Required | Description | |---|---|---|---| | `studio` | object | No | The open timeline, in the same shape as on [Send an assistant message](#send-an-assistant-message) | This request asks for openers with no timeline open: ```bash curl -X POST "http://127.0.0.1:17494/api/assistant/openers" \ -H 'Content-Type: application/json' \ -d '{}' ``` A successful response is `200 OK` with the openers. `label` is the chip's text and `text` is the message it sends: ```json { "openers": [ { "label": "Horror door", "text": "I need a door slam for a horror game" }, { "label": "Lo-fi loop", "text": "Write me a 20 second lo-fi beat to loop under a menu" } ] } ``` | Status | Cause | |---|---| | `400` | The assistant is off, not set up, or did not answer: see [Assistant modes](#assistant-modes) | ## Plan a studio command `POST /api/studio/command` Turns an instruction into a plan of edits for the open timeline. The server applies nothing: the caller applies the actions. | Name | Type | Required | Description | |---|---|---|---| | `instruction` | string | Yes | 1 to 2,000 characters | | `context` | object | Yes | The timeline: `tracks` (up to 200; each `track_index`, `name`, `muted`, `soloed` and up to 32 `devices`, the device kinds in chain order), `clips` (up to 500), `playhead_s`, `selected_ids`, and up to 200 `voices` a written line may be cast to, as `{ id, name, kind, notes }` with `kind` `clone` or `builtin` | This request takes the reverb off a vocal track: ```bash curl -X POST "http://127.0.0.1:17494/api/studio/command" \ -H 'Content-Type: application/json' \ -d '{ "instruction": "take the reverb off the vocal", "context": { "tracks": [ { "track_index": 0, "name": "Vocal", "devices": ["reverb"] } ], "clips": [] } }' ``` A successful response is `200 OK` with the plan: ```json { "intent": "edit", "actions": [ { "type": "remove_device", "track_index": 0, "kind": "reverb" } ], "summary": "Took the reverb off the Vocal track.", "dropped": 0, "classified": "edit" } ``` | Field | Description | |---|---| | `intent` | `edit`, or `generate` when the text describes audio to make rather than a change and the plan has no actions | | `actions` | The edits. `type` is `rename_track`, `set_track`, `move_clip`, `set_clip`, `delete_clip`, `add_clip`, `add_lines`, `speak_lines`, `add_device`, `remove_device`, `set_device`, `generate_clip`, `show_panel` or `start_recording` | | `summary` | One line about what is about to happen | | `dropped` | How many actions were removed because they named a clip, track or voice not in `context` | | `classified` | The planner the instruction was routed to: `edit`, `generate_clip`, `compose`, `script` or `panel` | | Status | Cause | |---|---| | `400` | The assistant is off, not set up, or did not answer: see [Assistant modes](#assistant-modes) | ## Get the assistant status `GET /api/llm/status` Returns the mode, the install state of the engine and models, and the local model servers found on this machine. This endpoint takes no parameters. This request reads the status: ```bash curl "http://127.0.0.1:17494/api/llm/status" ``` A successful response is `200 OK` with the status. The example is abridged to part of one catalogue entry: ```jsonc { "mode": "off", "engine": { "installed": false, "version": null, "backend": null }, "model": null, "catalog": [ { "id": "qwen3-1.7b", "name": "Qwen3 1.7B", "vendor": "Alibaba", "license": "Apache-2.0", "hf_repo": "Qwen/Qwen3-1.7B-GGUF", "filename": "Qwen3-1.7B-Q8_0.gguf", "size_bytes": 1834426016, "recommended": true, "installed": false // ...more fields } // ...more catalogue entries ], "external": { "base_url": "", "model": "", "api_key_set": false }, "running": false, "detected": [ { "label": "Ollama", "base_url": "http://127.0.0.1:11434", "models": ["llama3.1"] } ] } ``` | Field | Description | |---|---| | `mode` | The `llm_mode` setting | | `engine` | Whether `llama-server` is installed, and its version and backend | | `model` | The catalogue entry `llm_model` names, or `null` | | `catalog` | The assistant models, `qwen3-0.6b`, `qwen3-1.7b` and `qwen3-4b`, each with a `description` and `installed` | | `external` | The external endpoint's base URL and model, and whether a key is set | | `running` | Whether the managed `llama-server` is running | | `detected` | A probe of the default ports of Ollama (11434), LM Studio (1234) and `llama-server` (8080). Each server whose OpenAI-compatible `/v1/models` answers is listed with the model ids it reports | This endpoint returns only the common errors. ## Install the assistant engine `POST /api/llm/engine/install` Queues a job that installs `llama-server`. When an install is already running, the response is that job. | Name | Type | Required | Description | |---|---|---|---| | `version` | string | No | `latest` or a release tag such as `v1.2.3` | | `backend` | string | No | Accepted and not used by this endpoint | This request installs the latest engine: ```bash curl -X POST -H 'X-Soundbox: 1' \ "http://127.0.0.1:17494/api/llm/engine/install" ``` A successful response is `202 Accepted` with the job's id. Its progress is on [Get a job](https://mirli.app/docs/api-jobs/index.md#get-a-job): ```json { "job_id": "8d1f2c4a-5b6e-4f70-9a81-2c3d4e5f6a7b" } ``` | Status | Cause | |---|---| | `403` | The server's capabilities turn `downloads` off | ## Download an assistant model `POST /api/llm/models//download` Queues a job that downloads one catalogue model's GGUF. When that model is already downloading, the response is that job. | Name | Type | Required | Description | |---|---|---|---| | `` | string | Yes | `qwen3-0.6b`, `qwen3-1.7b` or `qwen3-4b` | This request downloads Qwen3 1.7B: ```bash curl -X POST -H 'X-Soundbox: 1' \ "http://127.0.0.1:17494/api/llm/models/qwen3-1.7b/download" ``` A successful response is `202 Accepted` with the job's id: ```json { "job_id": "2b7e9c1d-3f4a-4e5b-8c6d-7e8f9a0b1c2d" } ``` | Status | Cause | |---|---| | `400` | No assistant model has this id | | `403` | The server's capabilities turn `downloads` off | ## Delete an assistant model `DELETE /api/llm/models/` Deletes one catalogue model's weights from disk. A model that is not downloaded is not an error. | Name | Type | Required | Description | |---|---|---|---| | `` | string | Yes | `qwen3-0.6b`, `qwen3-1.7b` or `qwen3-4b` | This request deletes Qwen3 4B: ```bash curl -X DELETE -H 'X-Soundbox: 1' \ "http://127.0.0.1:17494/api/llm/models/qwen3-4b" ``` A successful response is `204 No Content`. | Status | Cause | |---|---| | `400` | No assistant model has this id | | `403` | The server's capabilities turn `downloads` off | --- # audio.cpp runtime endpoints audio.cpp is the native runtime that runs every local model. These endpoints read the catalogue of models it can run, report which `audiocpp_cli` binary is in force, and install one. The models themselves are on [Models endpoints](https://mirli.app/docs/api-models/index.md), and [About audio.cpp](https://mirli.app/docs/audiocpp/index.md) describes the runtime. Each endpoint lists the errors it returns itself. Any endpoint can also return the [common errors](https://mirli.app/docs/api-errors/index.md#common-errors). ## List the catalogue `GET /api/models/audiocpp/catalog` Returns every model the audio.cpp adapter knows, enabled or not. This endpoint takes no parameters. `always_on` models are in [`GET /api/models`](https://mirli.app/docs/api-models/index.md#list-models) regardless. The rest appear there once their id is in the `enabled_audiocpp_models` setting ([Update settings](https://mirli.app/docs/api-settings/index.md#update-settings)), which takes effect without a restart, or once their weights are on disk. Weights are shared by every profile, so weights on disk enable a model in every profile. `source` is `builtin` or `custom`. A `custom` entry comes from `/models/custom.json`, where `` is the data folder. These entries are always on, never `verified`, and replace a built-in entry with the same id. That file adds a model Mirli does not ship, including one whose weights are already on disk; see [Add your own model](https://mirli.app/docs/audiocpp-models/index.md). This request lists the catalogue: ```bash curl "http://127.0.0.1:17494/api/models/audiocpp/catalog" ``` A successful response is `200 OK` with an array of entries. The example is abridged: ```jsonc [ { "source": "builtin", "id": "audiocpp-htdemucs-sep", "name": "HTDemucs stem separation (audio.cpp)", "vendor": "Meta AI (Demucs)", "verified": false, "always_on": false, "enabled": true, "on_disk": false, "category": "utility" // ...more fields } ] ``` Each entry has these fields: | Field | Type | Description | |---|---|---| | `id`, `name`, `vendor`, `description` | string | What the model is | | `license` | object | `name`, `commercial` (`yes`, `no` or `conditional`), `url` and `note` | | `verified` | boolean | The model has been run and checked with Mirli | | `always_on` | boolean | Listed in `GET /api/models` whatever the settings | | `enabled` | boolean | Listed in `GET /api/models`: always on, in `enabled_audiocpp_models`, or on disk | | `on_disk` | boolean | Its weights are on this machine | | `category` | string | `sfx`, `music`, `voice` or `utility` | | `source` | string | `builtin`, or `custom` for an entry from `custom.json` | This endpoint returns only the common errors. ## Get the runtime status `GET /api/models/audiocpp/runtime` Returns which `audiocpp_cli` binary resolved, how it was found, and where model weights live. The binary is looked for in this order: the `MIRLI_AUDIOCPP_BIN` environment variable, a managed install, then `PATH`. This endpoint takes no parameters. This request reads the runtime status: ```bash curl "http://127.0.0.1:17494/api/models/audiocpp/runtime" ``` A successful response is `200 OK` with the status: ```json { "mode": "managed", "engine": { "installed": true, "version": "v0.9.2", "path": "/home/me/.mirli/bin/audiocpp/v0.9.2/audiocpp_cli", "backend": "cuda", "source": "managed" }, "models_dir": "/home/me/.mirli/models/audiocpp", "models_dir_default": "/home/me/.mirli/models/audiocpp", "install_job_id": null, "env_override": null } ``` | Field | Type | Description | |---|---|---| | `mode` | string | The `audiocpp_mode` setting: `managed` (Mirli's own install) or `external` (an audio.cpp already on the machine, sharing its weights) | | `engine.installed` | boolean | A usable binary was found | | `engine.version` | string or null | The release tag of a managed install. `null` for a binary found another way | | `engine.path` | string or null | The binary's path | | `engine.backend` | string or null | The backend detected on this machine: `metal` on macOS, `cuda` when an NVIDIA driver answers, otherwise `cpu` | | `engine.source` | string or null | `managed`, `env` (from `MIRLI_AUDIOCPP_BIN`) or `path` | | `models_dir` | string | The weights folder in force | | `models_dir_default` | string | The folder a managed install uses, so an override can be told apart | | `install_job_id` | string or null | The job installing the runtime right now, or `null` | | `env_override` | string or null | The value of `MIRLI_AUDIOCPP_BIN`, or `null` when it is not set | This endpoint returns only the common errors. ## Install the audio.cpp runtime `POST /api/models/audiocpp/engine/install` Queues a job that downloads an `audiocpp_cli` release from GitHub, checks it against the release's checksums, and installs it under `/bin/audiocpp//`, shared by every profile. The newest install is the one used. With an empty body, an install already running, including one a model download started, is returned instead of queuing another. The body is optional. | Name | Type | Required | Description | |---|---|---|---| | `version` | string | No | `latest` or a release tag, such as `v0.9.2`: letters, digits, dot, dash and underscore, no path segments. Default `latest` | | `backend` | string | No | A short name, such as `cuda`, `vulkan` or `cpu`, that picks the release asset. Default: the backend detected on this machine | This request installs the latest release with the Vulkan backend: ```bash curl -X POST "http://127.0.0.1:17494/api/models/audiocpp/engine/install" \ -H 'Content-Type: application/json' \ -d '{"backend": "vulkan"}' ``` A successful response is `202 Accepted` with the job's id. Progress streams from [the job's events](https://mirli.app/docs/api-jobs/index.md#stream-a-jobs-events), and a failed install, such as a release with no asset for this machine, fails the job: ```json { "job_id": "2c7e9b14-5f3a-4d8e-b1c6-9a0f4e7d2b53" } ``` | Status | Cause | |---|---| | `403` | The server's capabilities turn `downloads` off | | `409` | `MIRLI_AUDIOCPP_BIN` is set, so an installed runtime would never be used. Unset it first | --- # Chat history endpoints A conversation is a saved thread of what happened in a studio: what was said, the edits that were applied, and the sounds that came of it. The studio's **History** panel uses these endpoints, so a reopened timeline shows how it got that way. The assistant itself keeps no state; see [Prompt assistant endpoints](https://mirli.app/docs/api-assistant/index.md). Each endpoint lists the errors it returns itself. Any endpoint can also return the [common errors](https://mirli.app/docs/api-errors/index.md#common-errors). ## Conversation object The conversation endpoints return this object: | Field | Type | Description | |---|---|---| | `id` | string | The conversation's id | | `title` | string | Display name. `New conversation` until named; the first user entry with text names an unnamed, empty conversation, cut to about 48 characters | | `story_id` | string or null | The story it belongs to. A story has at most one conversation. Becomes `null` when the story is deleted | | `created_at` | string | ISO 8601 time it was made | | `updated_at` | string | ISO 8601 time of the last append or rename | | `entry_count` | integer | Number of entries | ## Entry object An entry is one turn of cause and effect. Every field but `role` can be empty, since a question has words and no effect, and a render has an effect and no words: | Field | Type | Description | |---|---|---| | `id` | string | The entry's id | | `conversation_id` | string | The conversation it is in | | `position` | integer | Its place in the conversation, from 0 | | `role` | string | `user` for something a person typed or clicked, `assistant` for a reply or an action taken for them | | `content` | string | What was said. Empty when nothing was | | `actions` | string[] | One line per edit applied, in the words the chat showed | | `sound_ids` | string[] | Sounds this turn produced | | `job_id` | string or null | The job that carried it out | | `created_at` | string | ISO 8601 time it was appended | ## List conversations `GET /api/conversations` Returns the most recently updated conversations, newest first. With `?story_id`, it returns that story's conversation instead, as a list of zero or one. | Name | Type | Required | Description | |---|---|---|---| | `?limit` | integer | No | 1 to 200. Default 50. Ignored with `?story_id` | | `?story_id` | string | No | One story's conversation | This request reads one story's conversation: ```bash curl "http://127.0.0.1:17494/api/conversations?story_id=" ``` A successful response is `200 OK` with a list of [conversation objects](#conversation-object): ```json [ { "id": "6a2f8e1c-9d3b-4c7a-8e5f-1b2c3d4e5f60", "title": "Add a door slam at four seconds", "story_id": "0c9b8a7d-6e5f-4a3b-9c2d-1e0f9a8b7c6d", "created_at": "2026-11-29T10:00:00.000Z", "updated_at": "2026-11-29T10:04:00.000Z", "entry_count": 2 } ] ``` | Status | Cause | |---|---| | `422` | `limit` is not an integer from 1 to 200 | ## Create a conversation `POST /api/conversations` Creates a conversation. When `story_id` names a story that already has one, the response is that existing conversation. | Name | Type | Required | Description | |---|---|---|---| | `title` | string | No | 1 to 200 characters. Default `New conversation` | | `story_id` | string | No | The story it belongs to | This request creates a conversation for one story: ```bash curl -X POST "http://127.0.0.1:17494/api/conversations" \ -H 'Content-Type: application/json' \ -d '{"story_id": ""}' ``` A successful response is `201 Created` with the [conversation object](#conversation-object). This endpoint returns only the common errors. ## Get a conversation `GET /api/conversations/` Returns one conversation, without its entries. | Name | Type | Required | Description | |---|---|---|---| | `` | string | Yes | The conversation's id | This request reads one conversation: ```bash curl "http://127.0.0.1:17494/api/conversations/" ``` A successful response is `200 OK` with the [conversation object](#conversation-object). | Status | Cause | |---|---| | `404` | No conversation has this id | ## Rename a conversation `PATCH /api/conversations/` Changes a conversation's title and bumps its `updated_at`. | Name | Type | Required | Description | |---|---|---|---| | `` | string | Yes | The conversation's id | | `title` | string | Yes | 1 to 200 characters. Surrounding spaces are trimmed | This request renames a conversation: ```bash curl -X PATCH \ "http://127.0.0.1:17494/api/conversations/" \ -H 'Content-Type: application/json' \ -d '{"title": "Gate scene"}' ``` A successful response is `200 OK` with the updated [conversation object](#conversation-object). | Status | Cause | |---|---| | `404` | No conversation has this id | ## Delete a conversation `DELETE /api/conversations/` Deletes a conversation and all its entries. The sounds its entries name are kept. | Name | Type | Required | Description | |---|---|---|---| | `` | string | Yes | The conversation's id | This request deletes one conversation: ```bash curl -X DELETE -H 'X-Soundbox: 1' \ "http://127.0.0.1:17494/api/conversations/" ``` A successful response is `204 No Content`. | Status | Cause | |---|---| | `404` | No conversation has this id | ## List entries `GET /api/conversations//entries` Returns every entry in a conversation, in order. | Name | Type | Required | Description | |---|---|---|---| | `` | string | Yes | The conversation's id | This request reads a conversation's entries: ```bash curl \ "http://127.0.0.1:17494/api/conversations//entries" ``` A successful response is `200 OK` with a list of [entry objects](#entry-object): ```json [ { "id": "f1e2d3c4-b5a6-4978-8a9b-0c1d2e3f4a5b", "conversation_id": "6a2f8e1c-9d3b-4c7a-8e5f-1b2c3d4e5f60", "position": 0, "role": "assistant", "content": "Added a door slam at 0:04.", "actions": ["Added clip on lane 2"], "sound_ids": ["3f6c1b9e-2a4d-4f0e-9c1a-7b5d2e8f0a11"], "job_id": null, "created_at": "2026-11-29T10:04:00.000Z" } ] ``` | Status | Cause | |---|---| | `404` | No conversation has this id | ## Append entries `POST /api/conversations//entries` Adds entries to the end of a conversation in one write and bumps its `updated_at`. The server assigns each entry's `id`, `position` and `created_at`. | Name | Type | Required | Description | |---|---|---|---| | `` | string | Yes | The conversation's id | | `entries` | object[] | Yes | 1 to 50 entries | | `entries[].role` | string | Yes | `user` or `assistant` | | `entries[].content` | string | No | Up to 8,000 characters | | `entries[].actions` | string[] | No | Up to 100 lines of up to 400 characters | | `entries[].sound_ids` | string[] | No | Up to 50 sound ids | | `entries[].job_id` | string or null | No | The job that carried it out | This request appends a question and its answer: ```bash curl -X POST \ "http://127.0.0.1:17494/api/conversations//entries" \ -H 'Content-Type: application/json' \ -d '{ "entries": [ { "role": "user", "content": "Add a door slam at four seconds" }, { "role": "assistant", "content": "Added a door slam at 0:04.", "actions": ["Added clip on lane 2"] } ] }' ``` A successful response is `201 Created` with every entry in the conversation, in order, as a list of [entry objects](#entry-object). | Status | Cause | |---|---| | `404` | No conversation has this id | --- # Errors The Mirli server reports an error with an HTTP status and a JSON body. This page describes the status codes, the body shapes, and the errors any endpoint can return. Each endpoint page lists the errors that endpoint returns itself. ## Status codes The API uses these status codes: | Status | Meaning | |---|---| | `200 OK` | The request succeeded and the body is the result | | `201 Created` | A new resource was made and the body is that resource | | `202 Accepted` | A job was queued. The body is `{ "job_id": "" }` | | `204 No Content` | The request succeeded and there is no body | | `206 Partial Content` | Part of an audio file, for a range request | | `400 Bad Request` | The request cannot run as sent: an unknown model, an option the model does not support, a file that cannot be read | | `401 Unauthorized` | The server has an access token and the request did not carry it | | `403 Forbidden` | A request rule or a capability refused the request | | `404 Not Found` | No route, or no resource with that id | | `409 Conflict` | The request conflicts with the current state, such as deleting a sound that is on a timeline | | `413 Content Too Large` | An upload is over its size limit | | `416 Range Not Satisfiable` | A range request outside the file | | `422 Unprocessable Content` | The body failed validation | | `429 Too Many Requests` | The job queue is full, or a rate limit was reached | | `499` | The client disconnected before a waiting request finished | | `500 Internal Server Error` | A job failed, or the server hit an unexpected error | ## Error body Most errors have a body with a `detail` string: ```json { "detail": "Sound not found" } ``` ### Validation errors A body that fails validation is `422`, and `detail` is a list with one entry per field: ```json { "detail": [ { "loc": ["body", "duration_s"], "msg": "Too big: expected number to be <=300", "type": "too_big" } ] } ``` | Field | Description | |---|---| | `loc` | Where the problem is: `"body"` and then the field path | | `msg` | What is wrong | | `type` | The validation rule that failed, such as `too_big` or `invalid_type` | ### Model errors An error the caller can act on, such as an unknown model or a model that cannot run, is `400` with a `detail` and a [failure object](#failure-object). This example is an unknown model id on a server with one model: ```json { "detail": "Unknown model 'sfx-v9'. Available: audiocpp-stable-audio-3-sfx", "failure": { "topic": null, "title": "Unknown model 'sfx-v9'. Available: audiocpp-stable-audio-3-sfx", "hint": null, "fixes": [], "terminal": false, "stage": null, "detail": "Unknown model 'sfx-v9'. Available: audiocpp-stable-audio-3-sfx" } } ``` ### Job failures A job that fails keeps its error on the [job object](https://mirli.app/docs/api-jobs/index.md#job-object), in `error` and `failure`. An endpoint that waits for its job reports the failure in the response instead: | Endpoint | Status | Body | |---|---|---| | `POST /api/render` | `500` | `{ detail, failure, job_id }` | | `POST /api/transcribe` | `500` | `{ detail, job_id }` | ## Failure object A failure says what went wrong in terms a person can act on, and keeps the raw message. The app shows it as an error card. | Field | Type | Description | |---|---|---| | `topic` | string or null | A stable name for the class of failure; see the next table. `null` when unclassified | | `title` | string | What happened, in one line | | `hint` | string or null | Why, what to do, and what is kept. `null` when unclassified | | `fixes` | array | Up to two `{ label, to }` pairs: a label for the fix and the app route that offers it | | `terminal` | boolean | `true` when a retry with nothing changed would fail the same way | | `stage` | string or null | The job phase or step it failed in, when known | | `detail` | string | Exactly what the runtime or server said | The `topic` is one of these: | Topic | Title | |---|---| | `gpu_oom` | The GPU ran out of memory | | `host_memory` | The machine ran out of system memory | | `paging_file` | Windows could not map the model into memory | | `backend_mismatch` | The CUDA runtime cannot use this GPU driver | | `runtime_missing` | The audio.cpp runtime is missing or cannot start | | `disk_full` | There is not enough disk space | | `hf_gated` | Hugging Face refused the download | | `hf_unreachable` | The server could not reach huggingface.co | | `download_stalled` | The download stopped receiving data | | `download_truncated` | The download ended before the whole file arrived | | `model_not_installed` | The model's weights are not on this machine | | `model_file_corrupt` | The model file could not be read | | `timeout` | audio.cpp did not finish in time | | `no_audio` | audio.cpp ran but produced nothing | | `queue_full` | The queue is full | ## Common errors Any endpoint can return these errors. The endpoint pages do not repeat them. | Status | Cause | `detail` | |---|---|---| | `401` | The server runs with `MIRLI_API_TOKEN` and the request has no valid token or session cookie. The response carries `WWW-Authenticate: Bearer` | `This Mirli needs its access token. ...` | | `403` | The `Host` header names a host the server does not serve | `Forbidden host` | | `403` | A mutating request under `/api/` has neither a non-simple `Content-Type` nor an `X-Soundbox` header | `Mutating API requests need Content-Type: application/json (or an audio upload type) or an X-Soundbox header` | | `403` | A [capability](https://mirli.app/docs/api-server/index.md#get-capabilities) turns the feature off | `This server doesn't allow that.` | | `404` | No route matches | `Not Found` | | `422` | The body failed [validation](#validation-errors) | A list of field errors | | `429` | The job queue is full | The queue's message | | `429` | The address sent 30 wrong access tokens in ten minutes. The response carries `Retry-After` | `Too many wrong access tokens from this address. ...` | | `500` | An unexpected server error | `Internal Server Error` | The [request rules](https://mirli.app/docs/api/index.md#request-rules) describe the `Host`, mutating request and access token checks. ## Streaming errors `POST /api/speak/stream` does not queue. When it cannot start, it returns `409` with a `reason`: | `reason` | Cause | |---|---| | `unsupported` | The model cannot stream on this audio.cpp build | | `busy` | A generation holds the GPU. The response carries `Retry-After` | A failure after the audio has started arrives as an `error` event in the stream. See [Stream speech](https://mirli.app/docs/api-speech/index.md#stream-speech). ## OpenAI error envelope The [OpenAI-compatible endpoints](https://mirli.app/docs/api-openai/index.md) under `/v1/` use OpenAI's error shape for every error, including the common errors: ```json { "error": { "message": "No voice is called 'shimmer'.", "type": "invalid_request_error", "param": "voice", "code": "voice_not_found" } } ``` | Field | Description | |---|---| | `message` | What went wrong. For a failed read, the same explanation the app shows | | `type` | `invalid_request_error` for a 4xx other than 429, `rate_limit_error` for 429, `server_error` for 5xx | | `param` | The request field at fault, or `null` | | `code` | A stable name; see the next table | | `detail` | Mirli's own field, on a failed read only: the raw text of the failure | | `code` | Status | Cause | |---|---|---| | `invalid_request` | `400` | The body failed validation, or the multipart form has no `file` | | `model_not_found` | `400` | `model` names a Mirli model of the wrong kind | | `voice_not_found` | `400` | `voice` names no voice on this server | | `unsupported_format` | `400` | `response_format` is not available | | `unsupported_stream` | `400` | A transcription asked for `stream: true` | | `invalid_audio` | `400` | The uploaded file cannot be read as audio | | a failure topic, or `model_error` | `400` | A [model error](#model-errors), such as a model that cannot run | | `invalid_api_key` | `401` | The access token is wrong or missing | | `cross_site_request` | `403` | A simple request came from another site | | `model_not_installed` | `404` | The model, or any model of that kind, is not downloaded | | `cancelled` | `409` | The job was cancelled from the app | | `queue_full` | `429` | The job queue is full | | `gpu_busy` | `429` | A generation holds the GPU | | `rate_limit_exceeded` | `429` | The address sent 30 wrong access tokens in ten minutes | | a failure topic, or `generation_failed` | `500` | The read failed while it ran. `code` is the [failure topic](#failure-object) when there is one | --- # Generation endpoints These endpoints make audio from a prompt, rework a library sound, and separate stems. `POST /api/render` answers with the WAV; the others queue a [job](https://mirli.app/docs/api-jobs/index.md). Speech is on [Speech endpoints](https://mirli.app/docs/api-speech/index.md). Each endpoint lists the errors it returns itself. Any endpoint can also return the [common errors](https://mirli.app/docs/api-errors/index.md#common-errors). ## Render and wait `POST /api/render` Runs one generation or speech job and answers with its WAV. The job waits its turn in the app's queue, and shows there while it runs. If the caller disconnects first, the job is cancelled. A proxy can cut a long wait; a GPU host's HTTP proxy often allows about 100 seconds. The body is a [generate body](#generate-a-sound) or a speak body from [Speech endpoints](https://mirli.app/docs/api-speech/index.md); one that fails that schema is a `422` [validation error](https://mirli.app/docs/api-errors/index.md#validation-errors). The answer is one file, so `variations` must be 1 and `separate` is refused. These fields belong to this endpoint alone: | Name | Type | Required | Description | |---|---|---|---| | `task` | string | No | `generate` or `speak`. Left out, a body with `text` or `lines` is speech and anything else is a generation | | `keep` | boolean | No | `false` deletes the sound once sent, for a server that only renders for others. Default `true` | | `text` | string | No | Speech shorthand: one line, up to 20,000 characters | | `voice` | string | No | With `text`: a saved voice's id, or its name in any case | This request renders a two-second door slam to `door.wav`: ```bash curl -X POST "http://127.0.0.1:17494/api/render" \ -H 'Content-Type: application/json' \ -d '{ "model": "audiocpp-stable-audio-3-sfx", "prompt": "door slam", "duration_s": 2 }' \ -o door.wav ``` A successful response is `200 OK` with `Content-Type: audio/wav`, the WAV as the body, and the headers `X-Soundbox-Job-Id` and `X-Soundbox-Sound-Id`. The sound id is empty when `keep` is `false`. | Status | Cause | |---|---| | `400` | Refused before anything runs: `variations` above 1, `separate` set, both `text` and `lines` or neither on speech, or a `voice` that matches no saved voice. Also any [model error](https://mirli.app/docs/api-errors/index.md#model-errors) from the generate or speak checks | | `409` | The job was cancelled on the server before it finished | | `429` | One client sent more than 60 calls in a minute, or the job queue is full | | `500` | The render failed. The body is `{ detail, failure, job_id }`, with a [failure object](https://mirli.app/docs/api-errors/index.md#failure-object). A job that finished without a sound gives `{ detail, job_id }` | ## Generate a sound `POST /api/generate` Queues a job that renders a prompt, or reworks a library sound. An unloaded model is loaded first, in the `loading` phase. | Name | Type | Required | Description | |---|---|---|---| | `model` | string | Yes | A model id from [Models endpoints](https://mirli.app/docs/api-models/index.md) | | `prompt` | string | Yes | 1 to 2,000 characters | | `negative_prompt` | string | No | Ignored by models whose `supports.negative_prompt` is false | | `duration_s` | number | No | Above 0, up to 300 and the model's `max_duration_s`. Default 5. For `extend`, the new total length | | `seed` | integer | No | 0 to 2³¹−1. Left out or `null`, random. Only the first variation uses it | | `steps` | integer | No | 1 to 500. Default: the model's. Ignored without `supports.steps` | | `cfg` | number | No | 0 to 30, and at most the model's `max_cfg`. Default: the model's | | `variations` | integer | No | 1 to 4 takes. Default 1 | | `tags` | string[] | No | Trimmed, lower-cased and de-duplicated; first 20 kept | | `lyrics` | string | No | Up to 4,000 characters, for models with `supports.lyrics` (ACE-Step) | | `track_name` | string | No | Up to 200 characters | | `source_sound_id` | string | No | A library sound to edit. Needs `edit` | | `edit` | string | No | Needs `source_sound_id`. `extend` continues the source to `duration_s` total seconds; `cover` re-renders it in the style of `prompt` at its length; `repaint` regenerates the `edit_options` window | | `edit_options` | object | No | Settings for the edit | | `separate` | object | No | `{ keep, rest, model }`: splits the result into stems before the job reports done | | `session_id` | string | No | The session to add to. Left out, or naming no session, the server makes one titled from the prompt | | `project_id` | string | No | The project a new session is filed in | An edit needs a model that declares `supports.`, and makes a new sound whose `parent_id` is the source. The `edit_options` fields are: | Name | Type | Description | |---|---|---| | `cover_strength` | number | `cover` only. 0 to 1: 1 follows the source faithfully, 0 loosely | | `extend_window_s` | number | `extend` only. 1 to 300 seconds of tail fed back as context when the target runs past the model's maximum. Default half that maximum. Each pass also renders up to 6 s past what it keeps and discards it, so the model's ending never lands mid-take | | `repaint_start_s`, `repaint_end_s` | number | `repaint` only, and required. Seconds in the source; start before end | | `repaint_mode` | string | `balanced`, `conservative` or `aggressive` | | `repaint_strength` | number | 0 to 1. How far the new material may drift | `separate` takes the `keep` and `rest` of [Split a sound into stems](#split-a-sound-into-stems), and a `model` whose `task` is `sep`; left out, the server picks an installed one. The job's `result.sounds` are then the stems, and the mixes stay in the library as their parents, listed in `result.sources`. This request queues a three-second door slam: ```bash curl -X POST "http://127.0.0.1:17494/api/generate" \ -H 'Content-Type: application/json' \ -d '{ "model": "audiocpp-stable-audio-3-sfx", "prompt": "heavy wooden door slam, dry room", "duration_s": 3, "tags": ["door", "impact"] }' ``` A successful response is `202 Accepted` with the [job](https://mirli.app/docs/api-jobs/index.md#get-a-job) id: ```json { "job_id": "5f0c2a9e-3b1d-4c6a-9e2f-8a7b6c5d4e3f" } ``` These end the job with status `error` before the model loads: a model that cannot do the edit, a missing source, an `extend` no longer than the source, or a repaint window past its end. So does a `separate` without `model` when no separator is installed, after the render. | Status | Cause | |---|---| | `400` | A [model error](https://mirli.app/docs/api-errors/index.md#model-errors): an unknown `model`, `duration_s` past the model's maximum (except for `extend`), `cfg` above its `max_cfg`, or a `separate.model` that is not a separator | ## Split a sound into stems `POST /api/separate` Queues a job that splits a library sound into stems, each saved as its own sound and listed in the job's `result.sounds`. | Name | Type | Required | Description | |---|---|---|---| | `model` | string | Yes | A model whose `task` is `sep` | | `source_sound_id` | string | Yes | The sound to split | | `stems.keep` | string[] | No | Up to 16 stem names, such as `vocals`, `drums`, `bass` or `other`, matched ignoring case and punctuation. Empty, or no `stems`, keeps all | | `stems.rest` | string | No | `discard` (the default) drops the others; `merge` sums them into one sound named `rest` | This request keeps the vocals and merges the rest into one sound: ```bash curl -X POST "http://127.0.0.1:17494/api/separate" \ -H 'Content-Type: application/json' \ -d '{ "model": "audiocpp-htdemucs-sep", "source_sound_id": "", "stems": { "keep": ["vocals"], "rest": "merge" } }' ``` A successful response is `202 Accepted` with the [job](https://mirli.app/docs/api-jobs/index.md#get-a-job) id: ```json { "job_id": "5f0c2a9e-3b1d-4c6a-9e2f-8a7b6c5d4e3f" } ``` A `keep` matching none of the model's stems ends the job with status `error`. | Status | Cause | |---|---| | `400` | A [model error](https://mirli.app/docs/api-errors/index.md#model-errors): an unknown `model`, a model that does not separate, or no sound with `source_sound_id` | ## Repaint a window `POST /api/repaint` Queues a job that regenerates `start_s` to `end_s` of a library sound and keeps the rest sample for sample: the editor's **Repaint** tool. The length, and unless overridden the prompt, lyrics, tags and session, are the source's. It is `POST /api/generate` with `edit: "repaint"` underneath: the job's `kind` is `generate`, and its `request` is that generate body. | Name | Type | Required | Description | |---|---|---|---| | `source_sound_id` | string | Yes | The sound to repaint | | `start_s`, `end_s` | number | Yes | The window in seconds. `end_s` must be greater than `start_s` | | `prompt` | string | No | Up to 2,000 characters: what should be there instead. Default: the source's prompt | | `lyrics` | string | No | Up to 4,000 characters. Replaces the source's lyrics | | `model` | string | No | Default: the source's model if it can repaint, otherwise a ready one that can | | `strength` | number | No | 0 to 1. How far the new material may drift | | `mode` | string | No | `balanced`, `conservative` or `aggressive` | | `seed` | integer | No | 0 to 2³¹−1 | | `variations` | integer | No | 1 to 4. Default 1 | | `session_id`, `project_id` | string | No | As on [Generate a sound](#generate-a-sound) | This request repaints 12 s to 18.5 s of a track: ```bash curl -X POST "http://127.0.0.1:17494/api/repaint" \ -H 'Content-Type: application/json' \ -d '{ "source_sound_id": "", "start_s": 12.0, "end_s": 18.5, "prompt": "brass stabs instead of the pad", "mode": "balanced" }' ``` A successful response is `202 Accepted` with the [job](https://mirli.app/docs/api-jobs/index.md#get-a-job) id: ```json { "job_id": "5f0c2a9e-3b1d-4c6a-9e2f-8a7b6c5d4e3f" } ``` | Status | Cause | |---|---| | `400` | A [model error](https://mirli.app/docs/api-errors/index.md#model-errors): no sound with `source_sound_id`, a window ending past the source, a `model` that is unknown or cannot repaint (only ACE-Step can), none installed that can, or a source longer than the model renders in one pass | --- # Instruments endpoints An instrument is one of the eight VSCO 2 Community Edition sampled instruments that the studio's MIDI dry render plays. These endpoints list them, download and delete their samples, and serve the parsed SFZ regions and the sample files the browser plays. [Sampled instruments](https://mirli.app/docs/studio-instruments/index.md#download-a-sampled-instrument) describes how the studio uses them. Each endpoint lists the errors it returns itself. Any endpoint can also return the [common errors](https://mirli.app/docs/api-errors/index.md#common-errors). ## Instrument object The list endpoint returns this object: | Field | Type | Description | |---|---|---| | `id` | string | The instrument's id | | `label` | string | Display name | | `family` | string | `strings`, `woodwinds` or `brass` | | `library` | string | Always `VSCO 2 CE` | | `license` | string | Always `CC0-1.0` | | `size_bytes` | integer | Total size of its files | | `installed` | boolean | Its samples are downloaded | The eight instruments are these: | `id` | `label` | `family` | |---|---|---| | `violin` | Solo violin | `strings` | | `violins` | Violin section | `strings` | | `cellos` | Cello section | `strings` | | `harp` | Harp | `strings` | | `flute` | Flute | `woodwinds` | | `clarinet` | Clarinet | `woodwinds` | | `trumpet` | Trumpet | `brass` | | `horn` | French horn | `brass` | ## List instruments `GET /api/instruments` Returns all eight instruments, installed or not. This endpoint takes no parameters. This request lists the instruments: ```bash curl "http://127.0.0.1:17494/api/instruments" ``` A successful response is `200 OK` with an array of [instrument objects](#instrument-object). The example is abridged: ```jsonc [ { "id": "clarinet", "label": "Clarinet", "family": "woodwinds", "library": "VSCO 2 CE", "license": "CC0-1.0", "size_bytes": 59351881, "installed": true } // ...more instruments ] ``` This endpoint returns only the common errors. ## Get an instrument `GET /api/instruments/` Returns an installed instrument's SFZ file parsed into regions: each region is a sample and the keys and velocities it answers to. | Name | Type | Required | Description | |---|---|---|---| | `` | string | Yes | The instrument's id | This request reads the clarinet's regions: ```bash curl "http://127.0.0.1:17494/api/instruments/clarinet" ``` A successful response is `200 OK` with the regions. The example is abridged: ```jsonc { "id": "clarinet", "files_url": "/api/instruments/clarinet/files", "regions": [ { "sample": "Woodwinds/Clarinet/susLong/DCClar_susLong_A#2_v1_rr1_sum.wav", "lokey": 56, "hikey": 59, "pitchKeycenter": 58, "lovel": 0, "hivel": 41, "volume": 20, "tune": 0, "ampegAttack": 0.001, "ampegRelease": 0.7 } // ...more regions ] } ``` | Field | Type | Description | |---|---|---| | `files_url` | string | The URL the sample paths are served under | | `regions[].sample` | string | The sample's path, relative to `files_url` | | `lokey`, `hikey` | integer | The MIDI key range the region plays | | `pitchKeycenter` | integer | The key the sample was recorded at | | `lovel`, `hivel` | integer | The velocity range | | `volume` | number | Level in dB | | `tune` | number | Tuning in cents | | `ampegAttack`, `ampegRelease` | number | Fade in and fade out, in seconds | An opcode a region does not set takes the SFZ default. | Status | Cause | |---|---| | `400` | No instrument has this id. The body has `detail` and `failure` | | `404` | The instrument's samples are not installed | ## Download an instrument `POST /api/instruments//download` Queues a job that downloads the instrument's files from one pinned commit of the VSCO 2 CE repository on GitHub into `/models/instruments/`, shared by every profile. Files already on disk at the right size are skipped, so an interrupted download continues. While a download of the instrument is running, the endpoint returns that job instead of queuing another. | Name | Type | Required | Description | |---|---|---|---| | `` | string | Yes | The instrument's id | This request downloads the clarinet: ```bash curl -X POST -H 'X-Soundbox: 1' \ "http://127.0.0.1:17494/api/instruments/clarinet/download" ``` A successful response is `202 Accepted` with the job's id. Progress streams from [the job's events](https://mirli.app/docs/api-jobs/index.md#stream-a-jobs-events): ```json { "job_id": "b7d2e5a1-4c9f-4a3b-8e6d-2f1c0a9b7e58" } ``` | Status | Cause | |---|---| | `400` | No instrument has this id. The body has `detail` and `failure` | | `403` | The server's capabilities turn `downloads` off | ## Delete an instrument `DELETE /api/instruments/` Deletes the instrument's downloaded files. An instrument that is not installed also returns `204`. | Name | Type | Required | Description | |---|---|---|---| | `` | string | Yes | The instrument's id | This request deletes the clarinet's samples: ```bash curl -X DELETE -H 'X-Soundbox: 1' \ "http://127.0.0.1:17494/api/instruments/clarinet" ``` A successful response is `204 No Content`. | Status | Cause | |---|---| | `400` | No instrument has this id. The body has `detail` and `failure` | | `403` | The server's capabilities turn `downloads` off | ## Get a sample file `GET /api/instruments//files/` Returns one of an installed instrument's files. Only paths in the instrument's manifest are served, so nothing outside its folder can be named. | Name | Type | Required | Description | |---|---|---|---| | `` | string | Yes | The instrument's id | | `` | string | Yes | A region's `sample` path, each segment URL-encoded. Names contain `#` and spaces | This request saves one clarinet sample: ```bash curl -o a2.wav "http://127.0.0.1:17494/api/instruments/clarinet/files/\ Woodwinds/Clarinet/susLong/DCClar_susLong_A%232_v1_rr1_sum.wav" ``` A successful response is `200 OK` with `audio/wav`, or `text/plain; charset=utf-8` for the `.sfz` file. The header `Cache-Control: private, max-age=86400` lets a browser cache it for a day. | Status | Cause | |---|---| | `404` | The instrument is unknown or not installed, or the path is not in its manifest | --- # Jobs endpoints A job is one piece of slow work the server runs in its queue: a generation, a download, a stem split, a speech read, an export. The endpoints that start one answer `202 Accepted` with a `job_id`, and these endpoints list, read, cancel and stream jobs. Jobs are held in memory: the server keeps the 200 most recent and forgets them on restart. At most 10 generation jobs (`generate`, `speak`, `convert`, `separate` and `transcribe`) wait at once. Each endpoint lists the errors it returns itself. Any endpoint can also return the [common errors](https://mirli.app/docs/api-errors/index.md#common-errors). ## Job object The job endpoints return this object: | Field | Type | Description | |---|---|---| | `id` | string | The job's id | | `kind` | string | `generate`, `download`, `separate`, `speak`, `convert`, `segment`, `export`, `selftest` or `transcribe` | | `status` | string | `queued`, `running`, `done`, `error` or `cancelled`. The last three are terminal | | `phase` | string | `queued`, `installing`, `loading`, `downloading`, `generating`, `encoding` or `done` | | `progress` | number | 0 to 1 | | `message` | string | What the job is doing now, such as `Generating` or `Variation 2/3` | | `error` | string or null | The error message when `status` is `error` | | `failure` | object or null | Set with `error`: a [failure object](https://mirli.app/docs/api-errors/index.md#failure-object) | | `request` | object | The request body as the server stored it. A generation's `session_id` is the resolved session | | `result` | object or null | `null` until done. A `generate` or `separate` job gives `{ "sounds": [...] }`, the new sound ids; a generation with `separate` also gives `sources`, the mixes the stems came from | | `created_at` | string | ISO 8601 time it was queued | | `started_at`, `finished_at` | string or null | ISO 8601 times it started and reached a terminal status | | `queue_position` | integer or null | 1-based position among the queued jobs, oldest first. `null` once running or finished | | `eta_s` | number or null | Rough seconds until the job starts: the running job's remaining time plus the jobs ahead, from the average of recent successful jobs of the same kind and model. `null` with no timing history, or when the job is not queued | This is a queued generation. The example is abridged: ```jsonc { "id": "5f0c2a9e-3b1d-4c6a-9e2f-8a7b6c5d4e3f", "kind": "generate", "status": "queued", "phase": "queued", "progress": 0, "message": "", "error": null, "failure": null, "request": { "model": "audiocpp-stable-audio-3-sfx", "prompt": "heavy wooden door slam, dry room", "session_id": "9b2e7d41-6c3a-4f58-8e1d-2a7c5b9f0e64" // ...more fields }, "result": null, "created_at": "2026-11-29T10:00:00.000Z", "started_at": null, "finished_at": null, "queue_position": 2, "eta_s": 41.5 } ``` ## List jobs `GET /api/jobs` Returns recent jobs, newest first. | Name | Type | Required | Description | |---|---|---|---| | `?limit` | integer | No | 1 to 200. Default 50 | This request lists the ten most recent jobs: ```bash curl "http://127.0.0.1:17494/api/jobs?limit=10" ``` A successful response is `200 OK` with an array of [job objects](#job-object). | Status | Cause | |---|---| | `422` | `limit` is not an integer, or is out of range | ## Get a job `GET /api/jobs/` Returns one job. A finished job's `result.sounds` are library sounds, and their audio is at `/files/.wav` on [Sounds endpoints](https://mirli.app/docs/api-sounds/index.md#get-a-sounds-audio). | Name | Type | Required | Description | |---|---|---|---| | `` | string | Yes | The job's id | This request reads one job: ```bash curl "http://127.0.0.1:17494/api/jobs/" ``` A successful response is `200 OK` with the [job object](#job-object). | Status | Cause | |---|---| | `404` | No job has this id | ## Cancel a job `POST /api/jobs//cancel` Cancels a queued or running job. A queued job is `cancelled` at once. A running job stops at its next check and then reaches `cancelled`, so the returned job can still show `running`. A job that has already finished is returned unchanged. | Name | Type | Required | Description | |---|---|---|---| | `` | string | Yes | The job's id | This request cancels one job: ```bash curl -X POST -H 'X-Soundbox: 1' \ "http://127.0.0.1:17494/api/jobs//cancel" ``` A successful response is `200 OK` with the [job object](#job-object). | Status | Cause | |---|---| | `404` | No job has this id | ## Stream a job's events `GET /api/jobs//events` Streams the job as server-sent events. The first event is the job as it is now, then one follows on every change, each a `data:` line holding the [job object](#job-object). The stream closes after the event with a terminal status, and sends a `: keepalive` comment every 15 seconds while nothing changes. `GET /api/jobs/` gives the same object to a client that does not read event streams. | Name | Type | Required | Description | |---|---|---|---| | `` | string | Yes | The job's id | This request follows one job until it ends: ```bash curl -N -H 'Accept: text/event-stream' \ "http://127.0.0.1:17494/api/jobs//events" ``` A successful response is `200 OK` with `Content-Type: text/event-stream`, one event per change: ```text data: data: ``` `` is the job object on one line. | Status | Cause | |---|---| | `404` | No job has this id | --- # Models endpoints A model is an engine the server renders with: weights on this machine run by audio.cpp, or a [custom endpoint](https://mirli.app/docs/endpoints/index.md) reached over HTTP. The audio.cpp runtime is on [audio.cpp runtime endpoints](https://mirli.app/docs/api-audiocpp/index.md), image models on [Artwork endpoints](https://mirli.app/docs/api-artwork/index.md), and language models on [Prompt assistant endpoints](https://mirli.app/docs/api-assistant/index.md). Each endpoint lists the errors it returns itself. Any endpoint can also return the [common errors](https://mirli.app/docs/api-errors/index.md#common-errors). ## Model object The model endpoints return this object: | Field | Type | Description | |---|---|---| | `id`, `name`, `vendor`, `description` | string | What the model is | | `license` | object | `name`, `commercial` (`yes`, `no` or `conditional`), `url` and `note` | | `hf_repo` | string | The Hugging Face repository of its weights. Empty for weights on disk | | `gated` | boolean | The repository is gated on Hugging Face | | `family` | string | audio.cpp's loader family, such as `stable_audio` | | `task` | string | The job it runs: `gen`, `tts`, `vc`, `sep` or `asr` | | `category` | string | `sfx`, `music`, `voice` or `utility` | | `params` | object[] | The knobs the family accepts: the keys `request_options` takes. Empty means the words and the voice are the only controls | | `voice_ids` | string[] | Built-in voice names. Empty when only a reference clip picks a voice | | `requires_voice_reference` | boolean | No default voice; reads only with a cloned one | | `max_duration_s` | number | Longest render in seconds | | `sample_rate`, `channels` | integer | Output format | | `supports` | object | What the model takes; see [the supports flags](#supports-flags) | | `defaults` | object | Default `duration_s`, `steps` and `cfg` | | `max_cfg` | number or null | Highest `cfg` accepted | | `vram_estimate_mb` | integer | Expected VRAM use. `0` for an endpoint | | `provider` | string | `local` (weights on this machine, run by audio.cpp) or `endpoint` (a custom endpoint) | | `metered` | boolean | A render may cost money. Never picked by default, by the app or by MCP | | `downloadable` | boolean | Has weights to fetch, load and delete | | `status` | string | Whether it can be used now; see [the status values](#status-values) | | `installed_deps` | boolean | Whether the runtime half is installed, on its own | | `auto_installable`, `manual_install_reason`, `install_command` | boolean, string or null | Whether the runtime installs itself, and what to do when not | | `extras` | string[] | `["audio-cpp"]` for a local model | | `error`, `failure` | string, object | Why `status` is `error`; `failure` is a [failure object](https://mirli.app/docs/api-errors/index.md#failure-object) | | `download_failure` | object or null | Why the last download failed: a failure object plus `at` (ISO 8601). Kept across restarts until a download succeeds, the weights are deleted, or it is dismissed. Set only while `status` is `not_installed` or `incomplete` | | `active_job_id` | string or null | The download's job, while `status` is `downloading` | | `avg_duration_s` | number or null | Rolling average wall time in seconds of recent successful generate jobs, `null` until one completes. The app shows it before **Generate** is clicked; it feeds `eta_s` on this model's queued jobs | ### Status values `status` covers both the weights and the runtime: | `status` | Meaning | |---|---| | `not_installed` | No weights on disk | | `needs_runtime` | Weights downloaded, audio.cpp runtime missing. **Install runtime** on the Models page, `soundbox model install audiocpp` or [installing the runtime](https://mirli.app/docs/api-audiocpp/index.md#install-the-audiocpp-runtime) fixes it; there is nothing to download again | | `incomplete` | Part of the weights is on disk, not enough to run. Downloading again fetches the rest | | `downloading` | A download job is running | | `installed` | Ready to load | | `loaded` | In memory | | `error` | See `error` | ### Supports flags `supports` holds booleans: `negative_prompt`, `seed`, `steps`, `cfg`, `lyrics`, `text` (reads a script), `voice_reference` (clones from a clip), the edits `extend`, `cover` and `repaint`, and `streaming` (reads a line as it is generated, on this audio.cpp build). ## List models `GET /api/models` Returns every model the server offers, with its status and licence. When the server's capabilities turn `local_models` off, models with `provider: "local"` are left out. This endpoint takes no parameters. This request lists the models: ```bash curl "http://127.0.0.1:17494/api/models" ``` A successful response is `200 OK` with an array of [model objects](#model-object). The example is abridged: ```jsonc [ { "id": "audiocpp-stable-audio-3-sfx", "name": "Stable Audio 3.0 SFX (audio.cpp)", "vendor": "Stability AI", "license": { "name": "Stability AI Community License", "commercial": "conditional", "url": "https://stability.ai/license" }, "hf_repo": "audio-cpp/audio.cpp-gguf", "family": "stable_audio", "task": "gen", "category": "sfx", "max_duration_s": 120, "sample_rate": 44100, "channels": 2, "defaults": { "duration_s": 10, "steps": 8, "cfg": 1 }, "max_cfg": 3, "vram_estimate_mb": 2500, "provider": "local", "status": "installed", "installed_deps": true, "error": null, "avg_duration_s": 187.4 // ...more fields } ] ``` This endpoint returns only the common errors. ## Get a model `GET /api/models/` Returns one model. | Name | Type | Required | Description | |---|---|---|---| | `` | string | Yes | The model's id | This request reads one model: ```bash curl "http://127.0.0.1:17494/api/models/audiocpp-ace-step" ``` A successful response is `200 OK` with the [model object](#model-object). | Status | Cause | |---|---| | `404` | No model has this id | ## Download a model `POST /api/models//download` Queues a job that downloads the model's weights from Hugging Face, continuing an interrupted download. For an audio.cpp model with no runtime found, the job installs the runtime first, in phase `installing`. While one is running, the endpoint returns that job instead of queuing another. Success clears `download_failure` and lists the model in every profile. | Name | Type | Required | Description | |---|---|---|---| | `` | string | Yes | The model's id | This request downloads one model: ```bash curl -X POST -H 'X-Soundbox: 1' \ "http://127.0.0.1:17494/api/models/audiocpp-ace-step/download" ``` A successful response is `202 Accepted` with the job's id. Progress streams from [the job's events](https://mirli.app/docs/api-jobs/index.md#stream-a-jobs-events): ```json { "job_id": "8d1f4c2a-6b3e-4f7a-9e2d-5c0b1a7f3e64" } ``` | Status | Cause | |---|---| | `400` | No model has this id. The body has `detail` and `failure` | | `403` | The server's capabilities turn `downloads` off | ## Dismiss a download failure `DELETE /api/models//download-failure` Forgets the remembered failure of the model's last download, so `download_failure` becomes `null`. | Name | Type | Required | Description | |---|---|---|---| | `` | string | Yes | The model's id | This request dismisses one model's download failure: ```bash curl -X DELETE -H 'X-Soundbox: 1' \ "http://127.0.0.1:17494/api/models/audiocpp-ace-step/download-failure" ``` A successful response is `204 No Content`. | Status | Cause | |---|---| | `403` | The server's capabilities turn `downloads` off | | `404` | No model has this id | ## Test a model `POST /api/models//selftest` Renders about one second through the job queue, loading the model if needed, and saves nothing. Only `gen` and `tts` models can be tested; any other task, or a model that reads only with a cloned voice, answers `ok: false`. | Name | Type | Required | Description | |---|---|---|---| | `` | string | Yes | The model's id | This request tests one model: ```bash curl -X POST -H 'X-Soundbox: 1' \ "http://127.0.0.1:17494/api/models/audiocpp-stable-audio-3-sfx/selftest" ``` A successful response is `200 OK` with the result: `device` as the health endpoint names it, wall time including any load, and seconds of audio rendered: ```json { "model": "audiocpp-stable-audio-3-sfx", "ok": true, "device": "cuda", "elapsed_s": 4.2, "rendered_s": 1.0, "error": null } ``` A failed render is also `200 OK`, with `ok: false`, `rendered_s: null` and `error` set. | Status | Cause | |---|---| | `400` | No model has this id. The body has `detail` and `failure` | | `403` | The server's capabilities turn `local_models` off | ## Load a model `POST /api/models//load` Loads the model into memory. One model is resident at a time, so any other loaded model is unloaded first. A model that is already loaded is returned as it is. | Name | Type | Required | Description | |---|---|---|---| | `` | string | Yes | The model's id | This request loads one model: ```bash curl -X POST -H 'X-Soundbox: 1' \ "http://127.0.0.1:17494/api/models/audiocpp-stable-audio-3-sfx/load" ``` A successful response is `200 OK` with the [model object](#model-object), its `status` now `loaded`. | Status | Cause | |---|---| | `400` | No model has this id, the runtime is missing, or the load failed. The body has `detail` and `failure` | | `403` | The server's capabilities turn `local_models` off | ## Unload a model `POST /api/models//unload` Releases the model from memory. A model that is not loaded is returned unchanged. | Name | Type | Required | Description | |---|---|---|---| | `` | string | Yes | The model's id | This request unloads one model: ```bash curl -X POST -H 'X-Soundbox: 1' \ "http://127.0.0.1:17494/api/models/audiocpp-stable-audio-3-sfx/unload" ``` A successful response is `200 OK` with the [model object](#model-object). | Status | Cause | |---|---| | `400` | No model has this id. The body has `detail` and `failure` | | `403` | The server's capabilities turn `local_models` off | ## Delete a model's weights `DELETE /api/models//weights` Deletes the model's downloaded weights, unloading it first if it is loaded, and clears `download_failure`. Files another catalogue entry shares stay on disk. A model listed only because its weights were on disk drops out of the list; one enabled in settings stays. | Name | Type | Required | Description | |---|---|---|---| | `` | string | Yes | The model's id | This request deletes one model's weights: ```bash curl -X DELETE -H 'X-Soundbox: 1' \ "http://127.0.0.1:17494/api/models/audiocpp-ace-step/weights" ``` A successful response is `204 No Content`. | Status | Cause | |---|---| | `400` | No model has this id, no weights were found, or it has none to delete: a custom endpoint, or a `custom.json` entry with `weights_path`, whose files Mirli did not download (see [Add your own model](https://mirli.app/docs/audiocpp-models/index.md)). The body has `detail` and `failure` | | `403` | The server's capabilities turn `downloads` off | --- # OpenAI-compatible endpoints Four endpoints under `/v1/` take the same requests as OpenAI's audio API, so a program with an "OpenAI base URL" setting (a chat UI, a voice agent framework or OpenAI's own SDK) can use Mirli for speech and transcription. They run the same models through the same queue as the [speech endpoints](https://mirli.app/docs/api-speech/index.md). The base URL is `http://127.0.0.1:17494/v1`. The API key can be any string, unless the server has an [access token](https://mirli.app/docs/install-access/index.md#access-token); then the token is the key, since both travel as `Authorization: Bearer `. Each endpoint lists the errors it returns itself. Every error here, the common errors included, uses OpenAI's [error envelope](https://mirli.app/docs/api-errors/index.md#openai-error-envelope), `{ "error": { message, type, param, code } }`. The common errors arrive with these codes: | Status | `code` | Cause | |---|---|---| | `400` | `invalid_request` | The body failed validation (`400` here, not `422`). `param` names the field | | `401` | `invalid_api_key` | The access token is wrong or missing | | `403` | `cross_site_request` | A simple request from a web page on another site | | `429` | `queue_full` | The job queue is full | | `429` | `gpu_busy` | A generation holds the GPU. `Retry-After` gives the wait when known | ## Requests from a browser `POST` requests here do not need the `X-Soundbox` header that `/api/` asks for. A JSON body passes, because another site's page cannot send one without a preflight the server's CORS policy refuses. A simple body (multipart, form-encoded, plain text or none) is refused with `403` when it carries an untrusted `Origin` or `Sec-Fetch-Site: cross-site`. Browsers add those to every cross-site `POST`; scripts and SDKs send neither. ## Create speech `POST /v1/audio/speech` Reads text aloud and answers with the audio. The model is the one `model` names when it is a speech model here; otherwise the model the voice was made on, when it is ready; otherwise a ready speech model, preferring the one in memory and never one that may charge per read. A name the server does not know (`tts-1`, which many clients send) falls through to the next choice. When the model can stream (`supports.streaming` on the [model object](https://mirli.app/docs/api-models/index.md#model-object)), the input is at most 5,000 characters and the format is `wav`, `pcm` or `sse`, the audio is sent while it is being made; a streamed WAV has open-ended sizes in its header. Otherwise, or when the GPU is busy, the read goes through the queue and arrives whole. | Name | Type | Required | Description | |---|---|---|---| | `input` | string | Yes | 1 to 20,000 characters | | `voice` | string or object | No | See [Supported fields](#speech). Default: the model's default voice | | `model` | string | No | A Mirli speech model, by id or name | | `response_format` | string | No | `wav` (as the model made it), `pcm` (headerless 16-bit little-endian mono at 24 kHz) or `mp3`. Default `mp3` | | `speed` | number | No | 0.25 to 4. Default 1 | | `instructions` | string | No | Up to 4,096 characters. The first 2,000 are passed on | | `stream_format` | string | No | `audio` (the default) or `sse` | | `keep` | boolean | No | Mirli's own. `true` keeps the read in the library; by default it is deleted once sent | This request reads one line as WAV, with curl or with OpenAI's Python SDK: ```bash title="curl" curl "http://127.0.0.1:17494/v1/audio/speech" \ -H 'Content-Type: application/json' \ -d '{ "model": "tts-1", "input": "Hello from Mirli.", "voice": "default", "response_format": "wav" }' \ -o hello.wav ``` ```python title="Python" from openai import OpenAI client = OpenAI(base_url="http://127.0.0.1:17494/v1", api_key="mirli") with client.audio.speech.with_streaming_response.create( model="tts-1", voice="default", input="Hello from Mirli.", response_format="wav", ) as response: response.stream_to_file("hello.wav") ``` A successful response is `200 OK` with `audio/wav`, `audio/pcm` or `audio/mpeg`. `X-Soundbox-Model` and `X-Soundbox-Voice` name what read it, `X-Soundbox-Sample-Rate` gives the rate of PCM and streamed audio, and `X-Soundbox-Sound-Id` is the kept sound's id. With no `response_format` and no `ffmpeg`, the response is the WAV with `X-Soundbox-Format-Fallback: wav`. With `stream_format: "sse"`, `speech.audio.delta` events carry base64 PCM (24 kHz mono) in `audio`, and a last `speech.audio.done` carries a `usage` of zeros. A failure mid-stream is an `error` event; a raw audio stream stops. | Status | Cause | |---|---| | `400` | `model_not_found`: `model` names a Mirli model that cannot speak | | `400` | `voice_not_found`: no voice has this name. `message` lists the voices | | `400` | `unsupported_format`: the format is not available, `mp3` needs `ffmpeg`, or `sse` was asked for with a format other than `pcm` | | `400` | The read cannot start. `code` is the [failure topic](https://mirli.app/docs/api-errors/index.md#failure-object) or `model_error` | | `404` | `model_not_installed`: the named model is not downloaded, or no speech model is ready | | `409` | `cancelled`: cancelled from the app | | `499` | The caller disconnected; the read is cancelled | | `500` | The read failed. `code` is the failure topic or `generation_failed`; `detail` holds the raw text | ## Create a transcription `POST /v1/audio/transcriptions` Turns speech into text. The body is `multipart/form-data`, up to 64 MB. The model is the one `model` names when it is a ready transcription model, otherwise a ready one, preferring the one in memory. | Name | Type | Required | Description | |---|---|---|---| | `file` | file | Yes | The audio. WAV is read directly; MP3, M4A, WebM and other formats need `ffmpeg` | | `model` | string | No | A transcription model, by id or name | | `language` | string | No | A language hint | | `response_format` | string | No | `json` (the default), `text` or `verbose_json` | | `stream` | string | No | `true` or `1` is refused | This request transcribes `hello.wav`: ```bash curl "http://127.0.0.1:17494/v1/audio/transcriptions" \ -F file=@hello.wav \ -F model=whisper-1 ``` A successful response is `200 OK` with the text, and `X-Soundbox-Model` names the model. `json` is `{ "text" }` and `text` is plain text. `verbose_json` adds `task`, `language` and `duration` in seconds: ```json { "task": "transcribe", "language": "en", "duration": 1.62, "text": "Hello from Mirli." } ``` | Status | Cause | |---|---| | `400` | `invalid_request`: the body is not multipart, or has no `file` with audio | | `400` | `unsupported_format`: `response_format` is `srt`, `vtt` or another value | | `400` | `unsupported_stream`: `stream` is `true` | | `400` | `invalid_audio`: the file cannot be read as audio | | `400` | `model_not_found`: `model` names a Mirli model that does not transcribe | | `404` | `model_not_installed`: no transcription model is ready | | `409` | `cancelled`: cancelled from the app | | `499` | The caller disconnected | | `500` | The transcription failed. `code` is the failure topic or `generation_failed` | ## List models `GET /v1/models` Returns the ready speech and transcription models in OpenAI's list shape. This endpoint takes no parameters. This request lists the models: ```bash curl "http://127.0.0.1:17494/v1/models" ``` A successful response is `200 OK` with the list. `name` and `task` (`speech` or `transcription`) are Mirli's own: ```json { "object": "list", "data": [ { "id": "audiocpp-supertonic-3", "object": "model", "created": 0, "owned_by": "Supertone", "name": "Supertonic 3 (audio.cpp)", "task": "speech" } ] } ``` This endpoint returns only the common errors. ## List voices `GET /v1/audio/voices` Returns the saved voices and the ready models' own voices. OpenAI has no such endpoint. This endpoint takes no parameters. This request lists the voices: ```bash curl "http://127.0.0.1:17494/v1/audio/voices" ``` A successful response is `200 OK` with the same entries under `data` and `voices`. `kind` is `clone` or `builtin` for a saved voice, `builtin` for a model's own voice, and `default` for the model's default voice, listed when a ready model needs no voice reference. A model's voice named like a saved voice is left out. An entry's `id` or `name` works as `voice`: ```json { "object": "list", "data": [ { "id": "7b3e2a1c-4d5f-4e6a-9b8c-0d1e2f3a4b5c", "object": "audio.voice", "name": "Ada", "kind": "clone", "model": "audiocpp-supertonic-3" } ], "voices": [ { "id": "7b3e2a1c-4d5f-4e6a-9b8c-0d1e2f3a4b5c", "object": "audio.voice", "name": "Ada", "kind": "clone", "model": "audiocpp-supertonic-3" } ] } ``` This endpoint returns only the common errors. ## Supported fields `/v1/audio/translations` and every OpenAI route outside audio are not provided and return `404`. `/v1/audio/voices` has no OpenAI equivalent. ### Speech | OpenAI field | Mirli | |---|---| | `model` | **Partly**: a Mirli speech model id or name. Any other name falls back to the voice's model, then a ready one | | `input` | **Supported**, up to 20,000 characters | | `voice` | **Supported**: a saved voice id or name (any case), a model's own voice, `default`, or `{ "id" }` | | `instructions` | **Partly**: passed as `instruct` to models that have it, ignored by others | | `response_format` | **Partly**: `wav`, `pcm`, and `mp3` with `ffmpeg`. `opus`, `aac` and `flac` are **Refused**, `400` `unsupported_format` | | `speed` | **Partly**: applied to models with a speed setting, held to the model's range | | `stream_format` | **Supported**: `audio` and `sse`. `sse` needs `pcm` or no format | Unknown fields are ignored. Mirli adds `keep`. ### Transcriptions | OpenAI field | Mirli | |---|---| | `file` | **Supported**. Formats other than WAV need `ffmpeg`, else `400` `invalid_audio` | | `model` | **Partly**: a transcription model id or name; other values pick a ready one. A Mirli model that does not transcribe is `400` `model_not_found` | | `language` | **Supported**, as a hint | | `response_format` | **Partly**: `json`, `text`, and `verbose_json` without segments or word timings. `srt` and `vtt` are **Refused**, `400` `unsupported_format` | | `stream` | **Refused** when true, `400` `unsupported_stream` | | `prompt`, `temperature`, `timestamp_granularities[]`, `chunking_strategy`, `include[]` | **Ignored** | ### Models | OpenAI field | Mirli | |---|---| | `id`, `object` | **Supported** | | `created` | **Partly**: always `0` | | `owned_by` | **Partly**: the model's vendor, or `mirli` | Mirli adds `name` and `task`. --- # Get a sound from the API 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](https://mirli.app/docs/install/index.md) 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: ```bash 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`: ```bash title="curl" 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 ``` ```python title="Python" import json import urllib.request body = json.dumps({ "model": "audiocpp-stable-audio-3-sfx", "prompt": "heavy wooden door slam, dry room", "duration_s": 2, }).encode() request = urllib.request.Request( "http://127.0.0.1:17494/api/render", data=body, headers={"Content-Type": "application/json"}, ) with urllib.request.urlopen(request) as response: with open("door.wav", "wb") as out: out.write(response.read()) ``` ```js title="JavaScript" import { writeFile } from "node:fs/promises"; const response = await fetch("http://127.0.0.1:17494/api/render", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ model: "audiocpp-stable-audio-3-sfx", prompt: "heavy wooden door slam, dry room", duration_s: 2, }), }); if (!response.ok) throw new Error(await response.text()); const audio = Buffer.from(await response.arrayBuffer()); await writeFile("door.wav", audio); ``` 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](https://mirli.app/docs/api-errors/index.md) lists every status and what causes it. ## What's next - [Generation endpoints](https://mirli.app/docs/api-generate/index.md) describe every field of a render, and the job-based endpoints for long renders. - [Speech endpoints](https://mirli.app/docs/api-speech/index.md) describe reading text aloud with a saved voice. - [OpenAI-compatible endpoints](https://mirli.app/docs/api-openai/index.md) describe using an OpenAI client library with Mirli. --- # Story segments endpoints A segment is a line, a pause or a placed sound in a [story](https://mirli.app/docs/api-stories/index.md). Lanes and their device chains are on [Story tracks endpoints](https://mirli.app/docs/api-tracks/index.md). Each endpoint lists the errors it returns itself. A `400` body has `detail` and [`failure`](https://mirli.app/docs/api-errors/index.md#failure-object). Any endpoint can also return the [common errors](https://mirli.app/docs/api-errors/index.md#common-errors). ## Segment object The segment endpoints return this object. Ranges and defaults apply on create and update: | Field | Type | Description | |---|---|---| | `id`, `story_id` | string | Its id and its story's | | `kind`, `text` | string | `kind` is `line` (default) or `pause`, a silence. `text` is up to 20,000 characters | | `speaker`, `voice_id`, `language` | string or null | Display name (up to 80 characters), the saved voice that reads it, and language (up to 20) | | `request_options` | object | Its delivery. Empty follows the story's | | `track_index` | integer | Lane, −16 to 16. Default 0 | | `start_s` | number | Seconds on the timeline. Default: after its lane's last clip | | `position` | integer | Reading order, from 0. Default: last. Moving the clip renumbers it | | `sound_id` | string or null | Its audio: a placed sound, or `null` until spoken | | `sound` | object or null | The [sound object](https://mirli.app/docs/api-sounds/index.md#sound-object) for `sound_id` | | `duration_s` | number or null | 0 to 600. A pause's length, or how much sound plays: by default all after `trim_start_s`, never more | | `trim_start_s` | number | Where in the sound the clip starts | | `fade_in_s`, `fade_out_s`, `gain_db` | number | Fades 0 to 60, gain −40 to 24 | | `muted` | boolean | Left out of playback and export | | `midi` | object or null | Its [MIDI take](#midi-take-object) | | `created_at`, `updated_at` | string | ISO 8601 times | ## MIDI take object A clip rendered from MIDI keeps its notes, to edit and render again in place. The eight sampled instruments are on [Instruments endpoints](https://mirli.app/docs/api-instruments/index.md). | Field | Type | Description | |---|---|---| | `notes` | object[] | 1 to 10,000, each `note` 0–127, `velocity` 0–1, `start_s` 0–3,600 from the take's start, `duration_s` above 0, up to 600 | | `bpm` | number | Optional, 20–240, for the bar grid | | `instrument` | string | The dry preset it was rendered with | | `cover` | object or null | The ACE-Step cover's `{ prompt, strength }` (`strength` 0–1), or `null` | | `role`, `take_id` | string | `dry` (default) or `cover`; the id the dry clip and its cover share | ## List segments `GET /api/stories//segments` Returns the segments in reading order. | Name | Type | Required | Description | |---|---|---|---| | `` | string | Yes | The story's id | This request lists segments: ```bash curl "http://127.0.0.1:17494/api/stories//segments" ``` A successful response is `200 OK` with an array of [segment objects](#segment-object). | Status | Cause | |---|---| | `404` | No story has this id | ## Create a segment `POST /api/stories//segments` Adds a segment. The body takes the [segment object](#segment-object) fields except `id`, `story_id`, `sound` and the times, all optional. | Name | Type | Required | Description | |---|---|---|---| | `` | string | Yes | The story's id | This request adds a line for a guard: ```bash curl -X POST "http://127.0.0.1:17494/api/stories//segments" \ -H 'Content-Type: application/json' \ -d '{ "speaker": "Guard", "voice_id": "", "text": "Halt! Who goes there?", "track_index": 0 }' ``` A successful response is `201 Created` with the new [segment object](#segment-object). | Status | Cause | |---|---| | `400` | No sound has the `sound_id` | | `404` | No story has this id | ## Reorder segments `PUT /api/stories//segments/reorder` Sets the whole reading order. | Name | Type | Required | Description | |---|---|---|---| | `` | string | Yes | The story's id | | `segment_ids` | string[] | Yes | Every segment id, 1 to 500, in order | This request orders two segments: ```bash curl -X PUT \ "http://127.0.0.1:17494/api/stories//segments/reorder" \ -H 'Content-Type: application/json' \ -d '{"segment_ids": ["", ""]}' ``` A successful response is `200 OK` with the [segment objects](#segment-object) in the new order. | Status | Cause | |---|---| | `404` | No story has this id | | `409` | `segment_ids` does not match the story's segments, for example after another client added one | ## Update a segment `PATCH /api/stories//segments/` Changes a segment. The body takes the [create](#create-a-segment) fields except `kind` and `position`. A new `sound_id` keeps the clip's place and trim, `request_options: {}` follows the story again, and `midi: null` forgets the notes. | Name | Type | Required | Description | |---|---|---|---| | ``, `` | string | Yes | The story's and the segment's ids | This request moves a clip to lane 1 at 4.5 s: ```bash curl -X PATCH \ "http://127.0.0.1:17494/api/stories//segments/" \ -H 'Content-Type: application/json' \ -d '{"track_index": 1, "start_s": 4.5}' ``` A successful response is `200 OK` with the updated [segment object](#segment-object). | Status | Cause | |---|---| | `400` | No sound has the `sound_id` | | `404` | No segment has this id | ## Delete a segment `DELETE /api/stories//segments/` Deletes a segment and closes the gap in the reading order. Its sound stays in the library. | Name | Type | Required | Description | |---|---|---|---| | ``, `` | string | Yes | The story's and the segment's ids | This request deletes one segment: ```bash curl -X DELETE -H 'X-Soundbox: 1' \ "http://127.0.0.1:17494/api/stories//segments/" ``` A successful response is `204 No Content`. | Status | Cause | |---|---| | `404` | No segment has this id | ## Speak a line `POST /api/stories//segments//generate` Starts a `segment` job reading the line. A line still at 0 s then moves after its lane's last clip. The job fails if the line has no text or the model is not text-to-speech. For Fish Audio, every clip of the voice needs a transcript ([Voices endpoints](https://mirli.app/docs/api-voices/index.md)). | Name | Type | Required | Description | |---|---|---|---| | ``, `` | string | Yes | The story's and the segment's ids | | `model` | string | Yes | A text-to-speech model id | | `seed`, `steps`, `cfg` | number or null | No | 0 to 2,147,483,647; 1 to 500; 0 to 30 | | `load_options` | object | No | Names to string values | | `request_options` | object | No | Delivery for this take only | This request reads one line: ```bash curl -X POST -H 'Content-Type: application/json' \ -d '{"model": "audiocpp-supertonic-3", "seed": 7}' \ "http://127.0.0.1:17494/api/stories//segments//generate" ``` A successful response is `202 Accepted` with the job's id. Its `result` holds `sounds` and `segment_id`: ```json { "job_id": "e7a03b52-1f9c-4d28-b6e4-90c2a5d17f3e" } ``` | Status | Cause | |---|---| | `400` | No such segment, unknown `model`, missing voice or clip file, or a Fish Audio clip without transcript | ## Split a clip `POST /api/stories//segments//split` Cuts a clip in two, each half a new derived sound. The first keeps the text and fade in, the second the fade out; both keep gain and mute, and lose the MIDI take. | Name | Type | Required | Description | |---|---|---|---| | ``, `` | string | Yes | The story's and the segment's ids | | `at_s` | number | Yes | Seconds from the clip's left edge on the timeline | This request cuts a clip 1.5 s in: ```bash curl -X POST \ "http://127.0.0.1:17494/api/stories//segments//split" \ -H 'Content-Type: application/json' \ -d '{"at_s": 1.5}' ``` A successful response is `200 OK` with the two halves as [segment objects](#segment-object). | Status | Cause | |---|---| | `400` | No audio, missing file, or `at_s` outside the clip | | `404` | No segment has this id | --- # Server endpoints These endpoints describe the server itself: whether it is up, what it allows, who is signed in, whether a newer version exists, and what it has logged. Settings and profiles are on [Settings and profiles endpoints](https://mirli.app/docs/api-settings/index.md). Each endpoint lists the errors it returns itself. Any endpoint can also return the [common errors](https://mirli.app/docs/api-errors/index.md#common-errors). ## Get health `GET /api/health` Returns the version, the backend device, the loaded model and the queue length. This endpoint takes no parameters and needs no access token. This request reads the server's health: ```bash curl http://127.0.0.1:17494/api/health ``` A successful response is `200 OK` with the health report: ```json { "status": "ok", "version": "0.6.4", "device": "cuda", "gpu_name": "NVIDIA GeForce RTX 3080", "vram_total_mb": 10240, "vram_free_mb": 9800, "loaded_model": "audiocpp-stable-audio-3-sfx", "queue_length": 0 } ``` | Field | Type | Description | |---|---|---| | `status` | string | Always `ok` | | `version` | string | The server's version | | `device` | string | The audio.cpp backend: `cuda`, `metal` or `cpu`, from the same detection the model runner uses, or the value of `MIRLI_AUDIOCPP_BACKEND` when set | | `gpu_name`, `vram_total_mb`, `vram_free_mb` | string or null, integer or null | The first GPU in `CUDA_VISIBLE_DEVICES`, or GPU 0 when that is unset, read from `nvidia-smi`. `null` without `nvidia-smi` (Metal, AMD, Intel, CPU) and when the `gpu_status` capability is off | | `loaded_model` | string or null | The model id in memory, or `null` | | `queue_length` | integer | Jobs waiting in the queue | This endpoint returns only the common errors. ## Get capabilities `GET /api/capabilities` Returns what this server lets its user do. The app shows only what is allowed, and the server refuses the rest. This endpoint takes no parameters. This request reads the capabilities: ```bash curl http://127.0.0.1:17494/api/capabilities ``` A successful response is `200 OK` with the capabilities. On a desktop with the full setup every flag is `true`: ```json { "sandboxed": false, "settings_locked": [], "filesystem": true, "reveal": true, "downloads": true, "local_models": true, "custom_endpoints": true, "updates": true, "gpu_status": true, "agent_connect": true, "skills_install": true, "logs": true, "setup_wizard": true, "setup": "full", "setup_locked": false } ``` | Field | Type | Description | |---|---|---| | `filesystem` | boolean | Browse folders, set folder paths, see where a profile's data lives, and create or delete profiles | | `reveal` | boolean | Show a sound's file in the system file manager | | `downloads` | boolean | Download model weights, engines and sample packs | | `local_models` | boolean | Run models on this machine. Off: only models that run elsewhere | | `custom_endpoints` | boolean | Add and edit custom endpoints | | `updates` | boolean | The daily update check and the update notice | | `gpu_status` | boolean | Report this machine's GPU and memory | | `agent_connect` | boolean | Hand out an MCP endpoint and stdio command | | `skills_install` | boolean | Install the bundled agent skills on this machine | | `logs` | boolean | Read the server's log | | `setup_wizard` | boolean | The first-run setup dialog | | `sandboxed` | boolean | `true` when the server runs with `MIRLI_SANDBOXED=1` | | `settings_locked` | string[] | Settings that need a capability the server has turned off (a path on the host, a local engine, or a URL the server would fetch). [Update settings](https://mirli.app/docs/api-settings/index.md#update-settings) ignores them | | `setup` | string | `full` (models on this machine plus any from elsewhere) or `simple` (only models that run elsewhere) | | `setup_locked` | boolean | `true` when the server cannot run models itself, which makes `setup` always `simple` | The flags change with how the server runs: - With `MIRLI_SANDBOXED=1`, every flag is `false`. - `MIRLI_DISABLE` turns off single flags, for example `MIRLI_DISABLE=reveal,updates`. - A profile on the simple setup has `downloads` and `gpu_status` off, and `local_models` off unless the profile keeps its installed models (`setup_include_local`). A request to an endpoint that a flag turns off gets `403` with `{"detail": "This server doesn't allow that."}`. The capabilities are read per request, so switching the setup changes what is allowed at once. See [Sandboxed mode](https://mirli.app/docs/install-access/index.md#sandboxed-mode). This endpoint returns only the common errors. ## Get sign-in status `GET /api/auth/status` Says whether the server needs an access token and whether this request carries a valid one. This endpoint takes no parameters and needs no access token. A wrong token or stale cookie sent with it counts as a wrong guess. This request reads the sign-in status: ```bash curl http://127.0.0.1:17494/api/auth/status ``` A successful response is `200 OK` with the status. Without `MIRLI_API_TOKEN`, `required` is `false` and `signed_in` is `true`: ```json { "required": true, "signed_in": false } ``` | Status | Cause | |---|---| | `429` | This address sent 30 wrong access tokens in ten minutes. The response carries `Retry-After` in seconds | ## Sign in `POST /api/auth/login` Exchanges the access token for a session cookie. This endpoint needs no access token. Without `MIRLI_API_TOKEN` it does nothing and answers `204`. | Name | Type | Required | Description | |---|---|---|---| | `token` | string | Yes | The server's access token. Surrounding spaces are ignored | This request signs in: ```bash curl -X POST "http://127.0.0.1:17494/api/auth/login" \ -H 'Content-Type: application/json' \ -d '{"token": ""}' ``` A successful response is `204 No Content` with a `Set-Cookie` header for the `soundbox_session` cookie: `Path=/`, `HttpOnly`, `SameSite=Strict`, a 30-day `Max-Age`, and `Secure` when the request arrived over HTTPS (directly or with `X-Forwarded-Proto: https`). The cookie holds an HMAC of the token, not the token, so changing the token signs every browser out. | Status | Cause | |---|---| | `401` | The token is wrong. `detail` is `That is not this Mirli's access token.` The attempt counts as a wrong guess | | `429` | This address sent 30 wrong access tokens in ten minutes. The response carries `Retry-After` in seconds, and a right token is refused too until the window ends | ## Sign out `POST /api/auth/logout` Clears the session cookie. This endpoint takes no parameters and needs no access token. This request signs out: ```bash curl -X POST -H 'X-Soundbox: 1' \ "http://127.0.0.1:17494/api/auth/logout" ``` A successful response is `204 No Content` with a `Set-Cookie` header that expires the cookie. This endpoint returns only the common errors. ## Get update status `GET /api/update` Returns what the daily update check last learned. This endpoint takes no parameters. This request reads the update status: ```bash curl http://127.0.0.1:17494/api/update ``` A successful response is `200 OK` with the update status: ```json { "enabled": true, "disabled_by": null, "current": "0.6.4", "latest": "0.7.0", "available": true, "url": "https://github.com/HamSanders/soundbox/releases/tag/v0.7.0", "checked_at": "2026-11-29T09:12:44.000Z", "stars": 1284, "endpoint": "https://mirli.app/api/update", "error": null } ``` | Field | Type | Description | |---|---|---| | `enabled` | boolean | Whether a check will happen | | `disabled_by` | string or null | `env` when `MIRLI_UPDATE_CHECK=0` turned it off, `setting` when the `update_check` setting did, else `null` | | `current` | string | The running version | | `latest` | string or null | The newest published version, from the last answer | | `available` | boolean | `true` when `latest` is newer than `current`. Always `false` while the check is off | | `url` | string or null | The release page for `latest`. `null` while the check is off | | `checked_at` | string or null | ISO 8601 time of the last answer | | `stars` | number or null | The repository's GitHub star count, refreshed every 15 minutes from `/api/stars` while the check is on. `null` while the check is off or before the first answer | | `endpoint` | string | The address asked: `https://mirli.app/api/update`, or `MIRLI_UPDATE_URL` when set | | `error` | string or null | Why the last check failed | This endpoint returns only the common errors. ## Check for updates `POST /api/update/check` Asks the update endpoint now, like **Check now** in Settings. The request carries only the version and the platform. When the check is off, nothing is sent and the current status comes back. A failed check is reported in `error`, not as an HTTP error. This endpoint takes no parameters. This request checks for a newer version: ```bash curl -X POST -H 'X-Soundbox: 1' \ "http://127.0.0.1:17494/api/update/check" ``` A successful response is `200 OK` with the [update status](#get-update-status). | Status | Cause | |---|---| | `403` | The server's capabilities turn `updates` off | ## Get logs `GET /api/logs` Returns the last lines of the server's log file, oldest first. The file is `/soundbox-.log`; see [Find the server log](https://mirli.app/docs/install-troubleshooting/index.md#find-the-server-log). With no log file the list is empty. | Name | Type | Required | Description | |---|---|---|---| | `?lines` | integer | No | 1 to 5,000. Default 200 | This request reads the last 50 lines: ```bash curl "http://127.0.0.1:17494/api/logs?lines=50" ``` A successful response is `200 OK` with the lines. The example is abridged: ```jsonc { "lines": [ "09:12:44 INFO mirli.update: update check: running 0.6.4" // ...more lines ] } ``` | Status | Cause | |---|---| | `403` | The server's capabilities turn `logs` off | | `422` | `lines` is not an integer from 1 to 5,000 | --- # Sessions and projects endpoints A session groups a run of related generations so the app can show them as one thread. A project is a named folder for sounds and sessions. Sounds are on [Sounds endpoints](https://mirli.app/docs/api-sounds/index.md); one session's sounds are `GET /api/sounds?session_id=`. Some sounds have no session: anything generated before sessions existed, uploads and recordings, and audio made inside a story (line reads, splits and exports). The library lists every sound regardless of session. A generation or a speech job submitted without a `session_id` creates a session, titled from the first six words of the prompt (for speech, the `name` or the first line). The resolved id comes back on the job's `request`. A `session_id` that no longer exists starts a fresh session, and the job still runs. Every new sound bumps its session's `updated_at`. A session whose job was cancelled or failed before it produced audio is deleted, and the server deletes every session with no sounds when it starts. Each endpoint lists the errors it returns itself. Any endpoint can also return the [common errors](https://mirli.app/docs/api-errors/index.md#common-errors). ## Session object The session endpoints return this object: | Field | Type | Description | |---|---|---| | `id` | string | The session's id | | `title` | string | Display name | | `created_at` | string | ISO 8601 time it was made | | `updated_at` | string | ISO 8601 time its newest sound was made, or `created_at` when it has none | | `sound_count` | integer | Number of sounds in it | | `project_id` | string or null | The project it is filed in. Its sounds without a project of their own count as filed there too | ## Project object The project endpoints return this object: | Field | Type | Description | |---|---|---| | `id` | string | The project's id | | `name` | string | Display name | | `created_at` | string | ISO 8601 time it was made | | `sound_count` | integer | Sounds filed in it: their own `project_id`, or their session's when they have none | ## List sessions `GET /api/sessions` Returns the sessions with the most recent activity first. | Name | Type | Required | Description | |---|---|---|---| | `?limit` | integer | No | 1 to 200. Default 50 | This request lists the ten most recent sessions: ```bash curl "http://127.0.0.1:17494/api/sessions?limit=10" ``` A successful response is `200 OK` with a list of [session objects](#session-object): ```json [ { "id": "5c1d2e3f-4a5b-4c6d-8e7f-9a0b1c2d3e4f", "title": "Glass bottle shattering on tile", "created_at": "2026-11-29T10:00:00.000Z", "updated_at": "2026-11-29T10:04:00.000Z", "sound_count": 2, "project_id": null } ] ``` | Status | Cause | |---|---| | `422` | `limit` is not an integer from 1 to 200 | ## Create a session `POST /api/sessions` Creates an empty session. Generating creates one too, so this is for a session that should exist before its first sound. The body is optional. | Name | Type | Required | Description | |---|---|---|---| | `title` | string | No | 1 to 200 characters. Default `New session` | | `project_id` | string or null | No | The project to file it in | This request creates a session with the default title: ```bash curl -X POST -H 'X-Soundbox: 1' "http://127.0.0.1:17494/api/sessions" ``` A successful response is `201 Created` with the [session object](#session-object). This endpoint returns only the common errors. ## Get a session `GET /api/sessions/` Returns one session. | Name | Type | Required | Description | |---|---|---|---| | `` | string | Yes | The session's id | This request reads one session: ```bash curl "http://127.0.0.1:17494/api/sessions/" ``` A successful response is `200 OK` with the [session object](#session-object). | Status | Cause | |---|---| | `404` | No session has this id | ## Update a session `PATCH /api/sessions/` Renames a session or files it in a project. Its sounds follow the session's project at once, unless they have a project of their own. Renaming does not change `updated_at`. | Name | Type | Required | Description | |---|---|---|---| | `` | string | Yes | The session's id | | `title` | string | No | 1 to 200 characters | | `project_id` | string or null | No | The project to file it in. `null` takes it out; leaving the field out leaves the project unchanged | This request files a session in a project: ```bash curl -X PATCH "http://127.0.0.1:17494/api/sessions/" \ -H 'Content-Type: application/json' \ -d '{"project_id": ""}' ``` A successful response is `200 OK` with the updated [session object](#session-object). | Status | Cause | |---|---| | `404` | No session has this id | | `422` | The body has neither `title` nor `project_id`. `detail` is `Nothing to update` | ## Delete a session `DELETE /api/sessions/` Deletes a session and every sound in it. > [!WARNING] > Deleting a session deletes every sound in it, with its audio file. It cannot > be undone. | Name | Type | Required | Description | |---|---|---|---| | `` | string | Yes | The session's id | This request deletes one session and its sounds: ```bash curl -X DELETE -H 'X-Soundbox: 1' \ "http://127.0.0.1:17494/api/sessions/" ``` A successful response is `204 No Content`. | Status | Cause | |---|---| | `404` | No session has this id | ## List projects `GET /api/projects` Returns every project, newest first. This endpoint takes no parameters. This request lists the projects: ```bash curl "http://127.0.0.1:17494/api/projects" ``` A successful response is `200 OK` with a list of [project objects](#project-object): ```json [ { "id": "9e8d7c6b-5a4f-4e3d-8c2b-1a0f9e8d7c6b", "name": "Lighthouse game", "created_at": "2026-11-28T09:00:00.000Z", "sound_count": 14 } ] ``` This endpoint returns only the common errors. ## Create a project `POST /api/projects` Creates an empty project. | Name | Type | Required | Description | |---|---|---|---| | `name` | string | Yes | 1 to 200 characters | This request creates a project: ```bash curl -X POST "http://127.0.0.1:17494/api/projects" \ -H 'Content-Type: application/json' \ -d '{"name": "Lighthouse game"}' ``` A successful response is `201 Created` with the [project object](#project-object). This endpoint returns only the common errors. ## Delete a project `DELETE /api/projects/` Deletes a project. Its sounds and sessions stay in the library, no longer filed in any project. | Name | Type | Required | Description | |---|---|---|---| | `` | string | Yes | The project's id | This request deletes one project: ```bash curl -X DELETE -H 'X-Soundbox: 1' \ "http://127.0.0.1:17494/api/projects/" ``` A successful response is `204 No Content`. | Status | Cause | |---|---| | `404` | No project has this id | --- # Settings and profiles endpoints Settings are the active profile's preferences. A profile is a separate library in the same install. These endpoints read and change settings, browse folders on the server's disk, and manage profiles. Each endpoint lists the errors it returns itself. Any endpoint can also return the [common errors](https://mirli.app/docs/api-errors/index.md#common-errors). ## Settings object The settings endpoints return this object, one per profile: | Field | Type | Description | |---|---|---| | `data_dir` | string | The active profile's directory | | `output_format` | string | `wav` or `mp3`. Default `wav` | | `normalize_lufs` | number or null | Loudness target in LUFS, or `null` for none. Default −16 | | `trim_silence` | boolean | Trim silence from new sounds. Default `true` | | `auto_unload_minutes` | integer | Idle minutes before the loaded model and engines stop, 0 to 600 (0: never). Default 10 | | `device` | string | `auto`, `cuda`, `mps` or `cpu`. Default `auto` | | `hf_token_set` | boolean | A Hugging Face token is stored, or `HF_TOKEN` is set | | `enabled_audiocpp_models` | string[] | The audio.cpp model ids that are on | | `audiocpp_mode` | string | `managed` (Mirli's own audio.cpp, the default) or `external` (one already installed) | | `audiocpp_models_dir` | string | Where audio.cpp weights are read, always resolved: the custom folder in `external` mode, else `/models/audiocpp` | | `sounds_dir` | string | The folder new audio is written to, always resolved. Default `/sounds` | | `llm_mode`, `image_mode` | string | Prompt assistant and artwork engines: `off` (the default), `managed` or `external` | | `llm_model`, `image_model` | string | The managed models. Defaults `qwen3-1.7b` and `sd-turbo` | | `llm_external_base_url`, `llm_external_model`, `image_external_base_url`, `image_external_model` | string | The external servers and models | | `llm_external_api_key_set`, `image_external_api_key_set` | boolean | An external key is stored | | `image_external_kind` | string | `openai` (the default) or `a1111` | | `image_auto_artwork` | boolean | Draw cover art after each music generation | | `otel_endpoint` | string | OpenTelemetry endpoint. `OTEL_EXPORTER_OTLP_ENDPOINT` takes precedence | | `update_check` | boolean | The daily update check. Default `true` | | `setup` | string | `full` or `simple` (only models that run elsewhere). Default `full` | | `setup_include_local` | boolean | On the simple setup, also offer models installed here | | `onboarded_at` | string or null | ISO 8601 time first-run setup was finished or skipped | ## Get settings `GET /api/settings` Returns the active profile's settings. This endpoint takes no parameters. This request reads the settings: ```bash curl http://127.0.0.1:17494/api/settings ``` A successful response is `200 OK` with the settings. The example is abridged: ```jsonc { "data_dir": "C:\\Users\\x\\.mirli", "hf_token_set": true, "output_format": "wav", "normalize_lufs": -16.0, "trim_silence": true, "auto_unload_minutes": 10, "sounds_dir": "C:\\Users\\x\\.mirli\\sounds", "llm_mode": "off", "llm_model": "qwen3-1.7b", "llm_external_api_key_set": false // ...more fields } ``` This endpoint returns only the common errors. ## Update settings `PATCH /api/settings` Changes the settings sent and keeps the rest. A missing or `null` field is unchanged, except `"normalize_lufs": null`, which switches normalisation off. Unknown fields and settings in the [capabilities](https://mirli.app/docs/api-server/index.md#get-capabilities)' `settings_locked` are ignored; the rest are saved. | Name | Type | Required | Description | |---|---|---|---| | `output_format`, `trim_silence`, `auto_unload_minutes`, `device`, `audiocpp_mode`, `llm_mode`, `llm_model`, `llm_external_base_url`, `llm_external_model`, `image_mode`, `image_model`, `image_external_kind`, `image_external_base_url`, `image_external_model`, `image_auto_artwork`, `otel_endpoint`, `update_check`, `setup`, `setup_include_local` | As listed | No | See the [settings object](#settings-object) | | `normalize_lufs` | number or null | No | `null` switches normalisation off | | `hf_token`, `llm_external_api_key`, `image_external_api_key` | string | No | Write-only: the response has `hf_token_set`, `llm_external_api_key_set` and `image_external_api_key_set` instead. `""` clears one | | `enabled_audiocpp_models` | string[] | No | Replaces the whole list: send every id that stays on | | `audiocpp_models_dir` | string | No | The external weights folder. `""` restores the default | | `sounds_dir` | string | No | `""` resets to `/sounds`. Changing it moves the existing library to the new folder | | `onboarded_at` | string | No | ISO 8601 time. `""` clears it, so first-run setup shows again | This request switches loudness normalisation off: ```bash curl -X PATCH "http://127.0.0.1:17494/api/settings" \ -H 'Content-Type: application/json' \ -d '{"normalize_lufs": null}' ``` A successful response is `200 OK` with the updated [settings object](#settings-object). | Status | Cause | |---|---| | `400` | `sounds_dir` is sent while anything is queued or generating, names a network share, is inside the current folder or contains it, or cannot be created. The body has `detail` and [`failure`](https://mirli.app/docs/api-errors/index.md#failure-object) | ## List folders `GET /api/fs/dirs` Lists the subfolders of a folder on the server's own disk, for the folder pickers in Settings. It never returns files. A missing path resolves to its nearest existing ancestor; a folder that cannot be opened has no entries. | Name | Type | Required | Description | |---|---|---|---| | `?path` | string | No | The folder to list. Default: the server user's home | This request lists the folders in a home directory: ```bash curl "http://127.0.0.1:17494/api/fs/dirs?path=C:%5CUsers%5Cx" ``` A successful response is `200 OK` with the listing: ```json { "path": "C:\\Users\\x", "parent": "C:\\Users", "separator": "\\", "home": "C:\\Users\\x", "writable": true, "roots": [ { "name": "C:", "path": "C:\\" } ], "entries": [ { "name": "Music", "path": "C:\\Users\\x\\Music" } ] } ``` `parent` is `null` at a root, and `writable` is a best-effort hint. `roots` holds every drive letter that answers on Windows, or `/` elsewhere. `entries` includes symbolic links to folders and is sorted by name. | Status | Cause | |---|---| | `400` | `path` is a network share, is not a folder, or cannot be read | | `403` | The server's capabilities turn `filesystem` off | ## Profile object A profile is a data directory with its own `soundbox.db`, `sounds/`, `artwork/` and `settings.json`, so switching profiles changes everything the library endpoints return. Model weights (`models/`) and runtime binaries (`bin/`) live at the install root, shared by every profile. The install root is `~/.mirli`, or `MIRLI_DATA_DIR` or `--data-dir`. The `default` profile is the install root itself, so an install that predates profiles is the default profile. Named profiles live in `/profiles/`. At startup, `--profile NAME` opens the profile with that id (the default one if none matches); without it, the last active profile opens. The profile endpoints return this object: | Field | Type | Description | |---|---|---| | `id` | string | A slug of the name, fixed at creation: lower-case letters, digits and hyphens, up to 40 characters | | `name` | string | Display name | | `created_at` | string | ISO 8601 time it was made. `""` for the default profile | | `data_dir` | string | Its directory | | `active` | boolean | The profile the server has open | ## List profiles `GET /api/profiles` Returns every profile and the active id. This endpoint takes no parameters. This request lists the profiles: ```bash curl http://127.0.0.1:17494/api/profiles ``` A successful response is `200 OK` with the list: ```json { "active": "default", "profiles": [ { "id": "default", "name": "Default", "created_at": "", "data_dir": "C:\\Users\\x\\.mirli", "active": true }, { "id": "demo", "name": "Demo", "created_at": "2026-02-01T10:00:00Z", "data_dir": "C:\\Users\\x\\.mirli\\profiles\\demo", "active": false } ] } ``` This endpoint returns only the common errors. ## Create a profile `POST /api/profiles` Creates a profile and its directory without switching to it. A taken slug gets `-2`, `-3` and so on; `default` is never reused. | Name | Type | Required | Description | |---|---|---|---| | `name` | string | Yes | 1 to 60 characters, trimmed | This request creates a profile named "Demo": ```bash curl -X POST "http://127.0.0.1:17494/api/profiles" \ -H 'Content-Type: application/json' \ -d '{"name": "Demo"}' ``` A successful response is `201 Created` with the new [profile object](#profile-object). | Status | Cause | |---|---| | `400` | `name` is only spaces | | `403` | The server's capabilities turn `filesystem` off | ## Rename a profile `PATCH /api/profiles/` Changes a profile's display name; the id and directory stay. | Name | Type | Required | Description | |---|---|---|---| | `` | string | Yes | The profile's id | | `name` | string | Yes | 1 to 60 characters, trimmed | This request renames a profile: ```bash curl -X PATCH "http://127.0.0.1:17494/api/profiles/" \ -H 'Content-Type: application/json' \ -d '{"name": "Client demo"}' ``` A successful response is `200 OK` with the updated [profile object](#profile-object). | Status | Cause | |---|---| | `400` | `name` is only spaces | | `404` | No profile has this id | ## Activate a profile `POST /api/profiles//activate` Switches the running server to another profile without a restart. The loaded model stays in memory; the profile's settings, enabled models and custom endpoints take over. | Name | Type | Required | Description | |---|---|---|---| | `` | string | Yes | The profile's id | This request switches to another profile: ```bash curl -X POST -H 'X-Soundbox: 1' \ "http://127.0.0.1:17494/api/profiles//activate" ``` A successful response is `200 OK` with the [profile list](#list-profiles), whose `active` is the new id. | Status | Cause | |---|---| | `400` | No profile has this id, or a job is queued or running (its file and database row, written at the end, would land in the wrong library). The body has `detail` and [`failure`](https://mirli.app/docs/api-errors/index.md#failure-object) | ## Delete a profile `DELETE /api/profiles/` Removes a profile from the list. Its directory stays by default. | Name | Type | Required | Description | |---|---|---|---| | `` | string | Yes | The profile's id | | `?delete_data` | string | No | `1` also deletes the profile's directory | > [!WARNING] > `?delete_data=1` permanently deletes the profile's directory: its database, > settings and artwork, and its sounds unless its `sounds_dir` is elsewhere. This request removes a profile and keeps its files: ```bash curl -X DELETE -H 'X-Soundbox: 1' \ "http://127.0.0.1:17494/api/profiles/" ``` A successful response is `204 No Content`. | Status | Cause | |---|---| | `400` | The profile is the default profile or the active profile, which cannot be deleted | | `403` | The server's capabilities turn `filesystem` off | | `404` | No profile has this id | --- # Sounds endpoints A sound is one audio file in the library and the row that describes it. These endpoints read and change sounds, add audio from disk, make edited copies, and serve the files. Cover art is on [Artwork endpoints](https://mirli.app/docs/api-artwork/index.md). Each endpoint lists the errors it returns itself. Any endpoint can also return the [common errors](https://mirli.app/docs/api-errors/index.md#common-errors). ## Sound object The sound endpoints return this object: | Field | Type | Description | |---|---|---| | `id` | string | The sound's id | | `created_at` | string | ISO 8601 time it was made | | `model` | string | The model id that made it. For an upload, the upload's `source` | | `prompt`, `negative_prompt`, `lyrics`, `track_name` | string or null | What it was made from | | `edit`, `edit_options` | string or null, object or null | The edit that made it from `parent_id`: `extend`, `cover` or `repaint` | | `duration_s` | number | Length in seconds | | `seed`, `steps`, `cfg` | number or null | Settings it was made with | | `sample_rate`, `channels` | integer | Audio format | | `file` | string | URL of the WAV, `/files/.wav` | | `peaks` | number[] | 256 normalised peaks for drawing the waveform | | `favorite` | boolean | Marked as a favourite | | `tags` | string[] | Lower-case tags | | `name` | string | Display name | | `size_bytes` | integer | File size | | `session_id`, `project_id` | string or null | Where it is filed | | `effective_project_id` | string or null | `project_id`, or the session's project when the sound has none | | `source` | string | Where the request came from: `app`, `api` or `mcp` | | `client` | string or null | The MCP client name and version, when an agent made it | | `parent_id` | string or null | The sound it was derived from (a stem, an edit, a split half) | | `artwork` | string or null | URL of its cover art, `/artwork/.png` | | `voice_id` | string or null | The saved voice that read it, when exactly one did | ## List sounds `GET /api/sounds` Returns a page of library sounds, filtered and sorted. | Name | Type | Required | Description | |---|---|---|---| | `?q` | string | No | Text search | | `?tag` | string | No | One tag | | `?favorite` | boolean | No | `true` for favourites only | | `?model` | string | No | One model id | | `?models` | string | No | Several model ids | | `?session_id` | string | No | One session's sounds | | `?project_id` | string | No | One project's sounds | | `?parent_id` | string | No | Sounds derived from this one | | `?voice_id` | string | No | Sounds one saved voice read alone: single-voice reads and conversions, not dialogues | | `?source` | string | No | `app`, `api` or `mcp` | | `?sort` | string | No | `newest`, `oldest`, `longest`, `shortest` or `name` | | `?limit` | integer | No | 1 to 500. Default 100 | | `?offset` | integer | No | Default 0 | This request lists up to 20 sounds tagged `impact` that match "door": ```bash curl "http://127.0.0.1:17494/api/sounds?q=door&tag=impact&limit=20" ``` A successful response is `200 OK` with the page and the total match count. The example is abridged: ```jsonc { "items": [ { "id": "3f6c1b9e-2a4d-4f0e-9c1a-7b5d2e8f0a11", "name": "Door slam 01" // ...the rest of the sound object } ], "total": 1 } ``` | Status | Cause | |---|---| | `422` | A query value is out of range or not one of the allowed values | ## Get a sound `GET /api/sounds/` Returns one sound. | Name | Type | Required | Description | |---|---|---|---| | `` | string | Yes | The sound's id | This request reads one sound: ```bash curl "http://127.0.0.1:17494/api/sounds/" ``` A successful response is `200 OK` with the [sound object](#sound-object). | Status | Cause | |---|---| | `404` | No sound has this id | ## Update a sound `PATCH /api/sounds/` Changes a sound's name, favourite flag, tags or project. | Name | Type | Required | Description | |---|---|---|---| | `` | string | Yes | The sound's id | | `name` | string | No | New display name | | `favorite` | boolean | No | Favourite flag | | `tags` | string[] | No | Replaces the tags | | `project_id` | string or null | No | The project to file it in. `null` takes it out; leaving the field out leaves the project unchanged | This request renames a sound and marks it as a favourite: ```bash curl -X PATCH "http://127.0.0.1:17494/api/sounds/" \ -H 'Content-Type: application/json' \ -d '{"name": "Door slam 01", "favorite": true}' ``` A successful response is `200 OK` with the updated [sound object](#sound-object). | Status | Cause | |---|---| | `404` | No sound has this id | ## Delete a sound `DELETE /api/sounds/` Deletes a sound's row and its file. Sounds derived from it are kept, and their `parent_id` becomes `null`. | Name | Type | Required | Description | |---|---|---|---| | `` | string | Yes | The sound's id | This request deletes one sound: ```bash curl -X DELETE -H 'X-Soundbox: 1' \ "http://127.0.0.1:17494/api/sounds/" ``` A successful response is `204 No Content`. | Status | Cause | |---|---| | `404` | No sound has this id | | `409` | The sound is on a story's timeline. `detail` names the story, for example: `This sound is on the timeline of the story "Gate scene". Remove it from that timeline first, then delete it.` | ## Upload a sound `POST /api/sounds/upload` Adds a WAV file from disk or a recording to the library. The body is the WAV file itself, up to 256 MB, sent as `audio/wav` or `application/octet-stream`. | Name | Type | Required | Description | |---|---|---|---| | `?name` | string | No | Display name. Default `Recording` | | `?source` | string | No | `recording` (the default), `import` or `midi`. Stored as the sound's `model` | | `?project_id` | string | No | The project to file it in | This request uploads `footsteps.wav` as an import: ```bash curl -X POST \ "http://127.0.0.1:17494/api/sounds/upload?name=Footsteps&source=import" \ -H 'Content-Type: audio/wav' \ --data-binary @footsteps.wav ``` A successful response is `201 Created` with the new [sound object](#sound-object). | Status | Cause | |---|---| | `400` | The body is empty or is not a readable WAV | | `413` | The body is larger than 256 MB | | `422` | `source` is not one of the allowed values | ## Edit a sound `POST /api/sounds//edit` Writes a new sound derived from this one. The original is not changed, and the new sound's `parent_id` points at it. | Name | Type | Required | Description | |---|---|---|---| | `` | string | Yes | The sound to edit | | `op` | string | Yes | `trim`, `normalize`, `reverse`, `gain`, `highpass`, `lowpass`, `pitch` or `stretch` | | `start_s`, `end_s` | number | For `trim` | The range to keep, in seconds | | `target_lufs` | number | For `normalize` | −40 to 0 | | `gain_db` | number | For `gain` | −40 to 24 | | `cutoff_hz` | number | For `highpass`, `lowpass` | Above 0, up to 20,000 | | `semitones` | number | For `pitch` | −24 to 24 | | `rate` | number | For `stretch` | Above 0.25, up to 4 | This request keeps 0.2 s to 2.5 s of a sound: ```bash curl -X POST "http://127.0.0.1:17494/api/sounds//edit" \ -H 'Content-Type: application/json' \ -d '{"op": "trim", "start_s": 0.2, "end_s": 2.5}' ``` A successful response is `201 Created` with the new [sound object](#sound-object). | Status | Cause | |---|---| | `404` | No sound has this id | ## Reveal a sound's file `POST /api/sounds//reveal` Opens the operating system's file manager on the server's machine, with the sound's file selected. | Name | Type | Required | Description | |---|---|---|---| | `` | string | Yes | The sound's id | This request shows one sound's file: ```bash curl -X POST -H 'X-Soundbox: 1' \ "http://127.0.0.1:17494/api/sounds//reveal" ``` A successful response is `204 No Content`. | Status | Cause | |---|---| | `403` | The server's capabilities turn `reveal` off | | `404` | No sound has this id | ## List tags `GET /api/tags` Returns every tag in the library with the number of sounds that carry it. This endpoint takes no parameters. This request lists the tags: ```bash curl http://127.0.0.1:17494/api/tags ``` A successful response is `200 OK` with the tags: ```json [ { "tag": "impact", "count": 12 } ] ``` This endpoint returns only the common errors. ## Get a sound's audio `GET /files/.wav` Returns the audio file. The response supports byte ranges, so a player can seek. | Name | Type | Required | Description | |---|---|---|---| | `` | string | Yes | The sound's id | | `?format` | string | No | `mp3` transcodes the file when `ffmpeg` is installed, and caches the result | This request saves a sound as MP3: ```bash curl -o door.mp3 \ "http://127.0.0.1:17494/files/.wav?format=mp3" ``` A successful response is `200 OK` (or `206 Partial Content` for a range) with `audio/wav` or `audio/mpeg`. When `format=mp3` is asked for and `ffmpeg` is missing, the response is the WAV with the header `X-Soundbox-Format-Fallback: wav`. | Status | Cause | |---|---| | `400` | The file name contains a path | | `404` | No such file | | `416` | The requested range is outside the file | --- # Speech endpoints These endpoints read text aloud in saved voices, as a job or as a live stream, re-voice recordings and transcribe speech. Saved voices are on [Voices endpoints](https://mirli.app/docs/api-voices/index.md), and the [OpenAI-compatible endpoints](https://mirli.app/docs/api-openai/index.md) reach the same models in OpenAI's request shapes. Each endpoint lists the errors it returns itself. Any endpoint can also return the [common errors](https://mirli.app/docs/api-errors/index.md#common-errors). A `400` from a model error has `detail` and a [failure object](https://mirli.app/docs/api-errors/index.md#failure-object). ## Speak a script `POST /api/speak` Queues a job that reads a script and saves it as one library sound. A single read is a one-line script, and a dialogue is several lines. Every model and voice is checked before the job is queued. Each line is read on its own, with one seed for the whole read, and the reads are joined with `gap_s` of silence between turns. The result is never trimmed and is loudness-normalised to the `normalize_lufs` setting. Without a `session_id`, or with one that no longer exists, the read starts a new session titled from `name` or the first line. The sound's `voice_id` is set only when every line used the same saved voice. For Fish Audio, every clip of a line's voice needs a transcript. The server builds `request_options.reference_text` from the voice's clip transcripts, in clip order (`created_at`, then `id`), joined with spaces. This overrides any other transcript, over HTTP and over MCP alike. | Name | Type | Required | Description | |---|---|---|---| | `model` | string | Yes | A model whose `task` is `tts` | | `lines` | object[] | Yes | 1 to 200 lines | | `lines[].text` | string | Yes | 1 to 20,000 characters | | `lines[].voice_id` | string or null | No | A saved voice's id, or `builtin:` for one of the model's own voices. Omit for the model's default voice | | `lines[].speaker` | string or null | No | Display name, up to 80 characters, such as `Narrator`. Not sent to the model | | `lines[].model` | string or null | No | Another `tts` model for this line, for a dialogue between voices made on different families | | `gap_s` | number | No | Silence between lines, 0 to 5 seconds. Default 0.4 | | `seed` | integer | No | 0 to 2,147,483,647 | | `steps` | integer | No | 1 to 500 | | `cfg` | number | No | 0 to 30 | | `request_options` | object | No | How the lines are read. Keys are names from the model's `params` on the [model object](https://mirli.app/docs/api-models/index.md#model-object), up to 60 characters; values are strings up to 2,000 characters. Unknown keys are accepted | | `load_options` | object | No | Load-time settings as string values, such as PocketTTS' `language` | | `name` | string | No | Name for the sound, up to 200 characters. Default: from the first line | | `tags` | string[] | No | Normalised as on [Generate a sound](https://mirli.app/docs/api-generate/index.md#generate-a-sound) | | `session_id`, `project_id` | string | No | Where the sound is filed | This request reads a two-line dialogue: ```bash curl -X POST "http://127.0.0.1:17494/api/speak" \ -H 'Content-Type: application/json' \ -d '{ "model": "audiocpp-supertonic-3", "lines": [ { "speaker": "Guard", "voice_id": "", "text": "Who goes there?" }, { "speaker": "Ada", "text": "A friend." } ], "gap_s": 0.4, "name": "Gate scene" }' ``` A successful response is `202 Accepted` with the job's id. When the [job](https://mirli.app/docs/api-jobs/index.md#get-a-job) is done, `result.sounds` holds the new sound's id: ```json { "job_id": "5b2e9c40-7d1a-4f3e-8a6b-0c9d2e4f1a37" } ``` | Status | Cause | |---|---| | `400` | A model is unknown or not `tts`, a `voice_id` names no voice, a clone has no clip on disk, or, for Fish Audio, a clip has no transcript (`detail` names the voice and clips) | ## Stream speech `POST /api/speak/stream` Speaks one line and sends the audio while it is being made. It is not a job: it never queues, holds the GPU while the client listens, and closing the connection cancels it. Voices resolve as on `POST /api/speak`, including the Fish Audio transcript rule. Nothing is saved unless `save` is `true`; a saved stream is kept as heard, not normalised. Which models stream is `supports.streaming` on the [model object](https://mirli.app/docs/api-models/index.md#model-object). Client examples are in [Streaming speech](https://github.com/HamSanders/soundbox/blob/main/docs/STREAMING.md#client-examples-ship-with-the-docs). | Name | Type | Required | Description | |---|---|---|---| | `model` | string | Yes | A `tts` model that streams | | `text` | string | Yes | 1 to 5,000 characters | | `voice_id` | string or null | No | As on a `POST /api/speak` line | | `format` | string | No | `sse` (the default) or `pcm` | | `seed` | integer | No | 0 to 2,147,483,647 | | `steps` | integer | No | 1 to 500 | | `cfg` | number | No | 0 to 30 | | `request_options` | object | No | As on `POST /api/speak` | | `save` | boolean | No | `true` also saves the audio to the library. Default `false` | | `name` | string | No | Name for a saved sound, up to 200 characters | | `tags` | string[] | No | Tags for a saved sound | | `project_id` | string | No | The project to file a saved sound in | This request streams one line as server-sent events: ```bash curl -N -X POST "http://127.0.0.1:17494/api/speak/stream" \ -H 'Content-Type: application/json' \ -d '{"model": "audiocpp-supertonic-3", "text": "Who goes there?"}' ``` A successful response is `200 OK`, sent once the first audio exists. Both formats carry the headers `X-Soundbox-Sample-Rate`, `X-Soundbox-Channels` and `X-Soundbox-Stream-Id`. With `format: "sse"`, the body is `text/event-stream` with these events: | Event | Data | |---|---| | `start` | `stream_id`, `model`, `sample_rate`, `channels` and `encoding: "pcm_s16le"` | | `audio` | `seq` (counting from 0), `pcm` (base64 interleaved 16-bit little-endian PCM) and `frames` | | `done` | `duration_s`; `ttft_ms`, the time to first audio including the model load; `model_ttft_ms`, audio.cpp's own figure; `sound_id`, null unless `save` | | `error` | `message`, for a failure after audio has started | This is a `done` event: ```text event: done data: {"duration_s":1.42,"ttft_ms":380,"model_ttft_ms":210,"sound_id":null} ``` With `format: "pcm"`, the body is raw interleaved 16-bit little-endian PCM with `Content-Type: audio/L16; rate=; channels=`. A failure after audio has started ends the body without an error. | Status | Cause | |---|---| | `400` | Before any audio: the model is unknown or not `tts`, `voice_id` names no voice, or a Fish Audio clip has no transcript | | `409` | `reason: "unsupported"`: the model cannot stream on this audio.cpp build | | `409` | `reason: "busy"`: another stream or a running generation holds the GPU. `retry_after_s`, also sent as `Retry-After`, estimates the wait in seconds, or is null | ## Convert a voice `POST /api/convert` Queues a job that re-voices a library sound through a voice-conversion model, as a new sound. The new sound's `parent_id` is the source. Its name is the source's name with the voice's name in brackets, its tags are copied from the source, and it is filed in `session_id`, or else in the source's session. It is loudness-normalised to the `normalize_lufs` setting. The model is checked when the job runs: an unknown model, or one whose `task` is not `vc`, fails the job. A trained singing voice always runs on `audiocpp-rvc`, whatever `model` says, since no other family can read its model. A trained voice that has not finished training is refused. | Name | Type | Required | Description | |---|---|---|---| | `model` | string | Yes | A model whose `task` is `vc` | | `source_sound_id` | string | Yes | The library sound to re-voice | | `voice_id` | string | Yes | A saved `clone` voice, or a ready [trained singing voice](https://mirli.app/docs/api-voices/index.md#trained-singing-voices). A `builtin` voice is refused | | `semitones` | integer | No | Semitones, -24 to 24, to move the melody before it is re-voiced. Default 0 | | `auto_octave` | boolean | No | Trained voices only: ignore `semitones` and shift by the whole number of octaves worked out from the source's and the voice's median pitch. The job's `result.pitch_shift` says which. Default false | | `seed` | integer | No | 0 to 2,147,483,647 | | `session_id`, `project_id` | string | No | Where the sound is filed | This request re-voices a sound in a saved voice: ```bash curl -X POST "http://127.0.0.1:17494/api/convert" \ -H 'Content-Type: application/json' \ -d '{ "model": "audiocpp-seed-vc", "source_sound_id": "", "voice_id": "" }' ``` A successful response is `202 Accepted` with the job's id: ```json { "job_id": "9e1f4b27-3c8d-4a6e-b05f-2d7a9c1e6b83" } ``` | Status | Cause | |---|---| | `400` | No sound has `source_sound_id`, no voice has `voice_id`, or the voice is `builtin` | ## Transcribe speech `POST /api/transcribe` Turns speech into text and waits for the answer. The body is a WAV file, up to 64 MB, sent as `audio/wav` or `application/octet-stream`, or it is empty and `?sound_id` names a library sound. The clip is converted to 16 kHz mono first. The work runs as a queued `transcribe` job, and closing the connection cancels it. | Name | Type | Required | Description | |---|---|---|---| | `?sound_id` | string | No | A library sound to transcribe instead of the body | | `?model` | string | No | A model whose `task` is `asr`, such as `audiocpp-qwen3-asr-0-6b`. Default: an installed one, preferring a loaded one | | `?language` | string | No | A language hint, such as `en` | This request transcribes `clip.wav`: ```bash curl -X POST "http://127.0.0.1:17494/api/transcribe?language=en" \ -H 'Content-Type: audio/wav' \ --data-binary @clip.wav ``` A successful response is `200 OK` with the text, the language and the model that was used. `language` is null when the model does not report one: ```json { "text": "Who goes there?", "language": "en", "model": "audiocpp-qwen3-asr-0-6b" } ``` | Status | Cause | |---|---| | `400` | The body is not a readable WAV, or `model` is unknown or does not transcribe | | `404` | `sound_id` names no sound | | `409` | No `model` was given and none is installed (`code: "no_transcription_model"`), or the job was cancelled | | `413` | The body is larger than 64 MB | | `500` | The transcription failed. The body has `detail` and `job_id` | --- # Stories endpoints A story is a script that persists and gets arranged: each line has a place in the reading order and a place on the timeline. The studio's timelines are stories too. Lines and clips are on [Story segments endpoints](https://mirli.app/docs/api-segments/index.md), and lanes on [Story tracks endpoints](https://mirli.app/docs/api-tracks/index.md). Agents reach the same work through the [MCP tools](https://mirli.app/docs/mcp-stories/index.md#stories). Each endpoint lists the errors it returns itself. Any endpoint can also return the [common errors](https://mirli.app/docs/api-errors/index.md#common-errors). ## Story object The story endpoints return this object: | Field | Type | Description | |---|---|---| | `id` | string | The story's id | | `title` | string | Up to 200 characters. Default `Untitled story` | | `created_at`, `updated_at` | string | ISO 8601 times. Every edit to the story or its lines moves `updated_at` | | `project_id` | string or null | The project it is filed in | | `request_options` | object | The story's default delivery: option names to string values, applied to every line without its own | | `segment_count` | integer | How many segments it has | | `studio` | string or null | A guess at what it holds, made on every read: `voice` when any line has a voice or text, otherwise `music` or `sfx` from its clips' models, or `null` | | `builder` | string | Which builder opens it: `script` or `music`. Stories made before the field existed take it from `studio` | | `timeline` | object[] | List only. Up to 64 clips, earliest first, each `{ t, s, d }`: lane, start and length in seconds, for drawing a thumbnail. Pauses are left out, and an unspoken line's length is estimated from its word count | ## List stories `GET /api/stories` Returns stories, most recently updated first, each with its `timeline`. | Name | Type | Required | Description | |---|---|---|---| | `?limit` | integer | No | 1 to 200. Default 50 | This request lists the ten most recent stories: ```bash curl "http://127.0.0.1:17494/api/stories?limit=10" ``` A successful response is `200 OK` with an array of [story objects](#story-object). The example is abridged: ```jsonc [ { "id": "8d2f4a10-6c3b-4e7a-9f21-0b5c7d9e1a32", "title": "Gate scene", "segment_count": 2, "studio": "voice", "builder": "script", "timeline": [ { "t": 0, "s": 0, "d": 1.84 }, { "t": 0, "s": 1.84, "d": 2.1 } ] // ...more fields } ] ``` | Status | Cause | |---|---| | `422` | `limit` is not an integer from 1 to 200 | ## Create a story `POST /api/stories` Creates an empty story. The body is optional. | Name | Type | Required | Description | |---|---|---|---| | `title` | string | No | 1 to 200 characters. Default `Untitled story` | | `project_id` | string or null | No | The project to file it in | | `builder` | string | No | `script` (the default) or `music`. Fixed once the story exists | This request creates a story for the Script Builder: ```bash curl -X POST "http://127.0.0.1:17494/api/stories" \ -H 'Content-Type: application/json' \ -d '{"title": "Gate scene", "builder": "script"}' ``` A successful response is `201 Created` with the new [story object](#story-object). This endpoint returns only the common errors. ## Get a story `GET /api/stories/` Returns one story, without `timeline`. | Name | Type | Required | Description | |---|---|---|---| | `` | string | Yes | The story's id | This request reads one story: ```bash curl "http://127.0.0.1:17494/api/stories/" ``` A successful response is `200 OK` with the [story object](#story-object). | Status | Cause | |---|---| | `404` | No story has this id | ## Update a story `PATCH /api/stories/` Changes a story's title, project or default delivery. The body carries at least one of the three fields. | Name | Type | Required | Description | |---|---|---|---| | `` | string | Yes | The story's id | | `title` | string | No | 1 to 200 characters | | `project_id` | string or null | No | The project to file it in. `null` takes it out | | `request_options` | object | No | The default delivery. `{}` puts every line without its own back on the model's defaults | This request renames a story: ```bash curl -X PATCH "http://127.0.0.1:17494/api/stories/" \ -H 'Content-Type: application/json' \ -d '{"title": "Gate scene, take 2"}' ``` A successful response is `200 OK` with the updated [story object](#story-object). | Status | Cause | |---|---| | `404` | No story has this id | | `422` | The body has none of `title`, `project_id` and `request_options` (`Nothing to update`) | ## Delete a story `DELETE /api/stories/` Deletes a story and its segments. Its audio stays in the library unless `delete_sounds` is set. | Name | Type | Required | Description | |---|---|---|---| | `` | string | Yes | The story's id | | `?delete_sounds` | boolean | No | `true` or `1` also deletes the sounds on its timeline that no other story uses. Sounds derived from them are kept, and their `parent_id` becomes `null` | This request deletes a story and its audio: ```bash curl -X DELETE -H 'X-Soundbox: 1' \ "http://127.0.0.1:17494/api/stories/?delete_sounds=true" ``` A successful response is `204 No Content`. | Status | Cause | |---|---| | `404` | No story has this id | ## Open a sound as a story `POST /api/stories/from-sound` Starts a `separate` job that lays a library sound out on a new story's timeline. With `separate`, the sound is split into stems first and each stem lands on its own lane, all starting together. A sound derived from another (a stem, an edit, a split half) opens whole. Stems from an earlier separation are reused when they cover the request. | Name | Type | Required | Description | |---|---|---|---| | `sound_id` | string | Yes | The library sound | | `separate` | boolean | No | Split it into stems first. Default `false` | | `model` | string or null | No | A separation model, such as `audiocpp-htdemucs-sep`. Default: a ready one | | `stems` | object or null | No | Which stems get a lane: `keep`, up to 16 stem names, and `rest`, `discard` (the default) or `merge` to put the other stems on one lane. Default: all of them | This request opens a sound as vocals and drums, with the rest merged: ```bash curl -X POST "http://127.0.0.1:17494/api/stories/from-sound" \ -H 'Content-Type: application/json' \ -d '{ "sound_id": "", "separate": true, "stems": { "keep": ["vocals", "drums"], "rest": "merge" } }' ``` A successful response is `202 Accepted` with the id of the job, which [Get a job](https://mirli.app/docs/api-jobs/index.md#get-a-job) follows: ```json { "job_id": "5b9e2c71-0d4a-4f3b-8e6a-2c1f7d0b9a54" } ``` | Status | Cause | |---|---| | `400` | No sound has this id, or with `separate`, `model` is unknown or cannot separate stems. The body has `detail` and [`failure`](https://mirli.app/docs/api-errors/index.md#failure-object) | ## Stream story events `GET /api/stories//events` Opens a server-sent event stream of changes to one story. Each event is a `data:` line holding one JSON object: - `{ "type": "agent", "active", "label", "count" }`: whether an agent is working on the story, what it is doing, and how many calls hold it. The stream always starts with one. - `{ "type": "changed" }`: the story, its segments or its lanes changed. - `{ "type": "request", "id", "op", "payload" }`: a question for an open studio. `op` is `context` (its live state) or `apply` (edits to run through its own handlers). Sent only to the most recently opened stream with `?answer=1`. | Name | Type | Required | Description | |---|---|---|---| | `` | string | Yes | The story's id | | `?answer` | string | No | `1` marks the client as an open studio that can answer requests | This request follows one story's changes: ```bash curl -N "http://127.0.0.1:17494/api/stories//events" ``` A successful response is `200 OK` with `text/event-stream`. Comment lines (`: keepalive`) keep the connection open: ```text data: {"type":"agent","active":false,"label":"","count":0} data: {"type":"changed"} ``` | Status | Cause | |---|---| | `404` | No story has this id | ## Answer a studio request `POST /api/stories//studio/replies/` Delivers an open studio's answer to a `request` event. A request waits 8 seconds for its answer. | Name | Type | Required | Description | |---|---|---|---| | `` | string | Yes | The story's id | | `` | string | Yes | The `id` of the `request` event | | `ok` | boolean | Yes | Whether the studio did what was asked | | `result` | any | No | The answer, such as the live state for `context` | | `error` | string or null | No | Why it refused, up to 2,000 characters | This request answers a request: ```bash curl -X POST \ "http://127.0.0.1:17494/api/stories//studio/replies/" \ -H 'Content-Type: application/json' \ -d '{"ok": true, "result": {"tracks": []}}' ``` A successful response is `204 No Content`. | Status | Cause | |---|---| | `404` | No such request is waiting: it timed out, was answered already, or belongs to another story | ## Export a story `POST /api/stories//export` Starts an `export` job that mixes the story down to one new library sound. Muted clips and lanes that are not heard are left out, lane gain applies on top of each clip's, and clips that overlap on a lane crossfade across the overlap. Each lane's devices are rendered after clip gain and before lane gain, and bypassed devices are skipped. The job fails when no heard clip has audio. | Name | Type | Required | Description | |---|---|---|---| | `` | string | Yes | The story's id | This request exports a story: ```bash curl -X POST -H 'X-Soundbox: 1' \ "http://127.0.0.1:17494/api/stories//export" ``` A successful response is `202 Accepted` with the job's id. The finished job's `result` holds `sounds`, the new sound's id, and `story_id`: ```json { "job_id": "c41a7e0f-93b2-4d6e-a518-7f2b0e9d3c86" } ``` | Status | Cause | |---|---| | `400` | No story has this id. The body has `detail` and [`failure`](https://mirli.app/docs/api-errors/index.md#failure-object) | --- # Story tracks endpoints A track is one lane of a [story](https://mirli.app/docs/api-stories/index.md)'s timeline: its name, mute, solo and gain, and its device chain. The clips on a lane are [segments](https://mirli.app/docs/api-segments/index.md). Each endpoint lists the errors it returns itself. A `400` body has `detail` and [`failure`](https://mirli.app/docs/api-errors/index.md#failure-object). Any endpoint can also return the [common errors](https://mirli.app/docs/api-errors/index.md#common-errors). ## Track object A lane gets a row when a setting first changes; until then it has the defaults. | Field | Type | Description | |---|---|---| | `story_id`, `track_index` | string, integer | The story and the lane | | `name` | string or null | Up to 80 characters. Default `null` | | `muted`, `soloed` | boolean | Default `false`. With any lane soloed, only soloed lanes are heard | | `gain_db` | number | −40 to 24. Default 0 | | `devices` | object[] | The insert chain, each `{ id, kind, bypassed, params }`. `id` is stable; a bypassed device stays in the chain, unheard; `params` holds every knob | Each device kind has these knobs, given as range (default), with times in seconds: - `compressor`: `threshold` −60 to 0 dB (−24), `ratio` 1–20 (4), `attack` 0.001–0.3 (0.006), `release` 0.01–1 (0.15) - `eq`: `low`, `mid`, `high` −24 to 12 dB (0), `lowFrequency` 80–1,000 Hz (400), `highFrequency` 1,000–10,000 Hz (2,500) - `reverb`: `decay` 0.1–10 (1.8), `preDelay` 0–0.3 (0.02), `wet` 0–1 (0.25) - `delay`: `delayTime` 0.01–1 (0.25), `feedback` 0–0.95 (0.3), `wet` 0–1 (0.25) - `distortion`: `distortion` 0–1 (0.3), `wet` 0–1 (0.5) - `gate`: `threshold` −80 to 0 dB (−45), `smoothing` 0.01–0.5 (0.06) - `limiter`: `threshold` −24 to 0 dB (−1) - `autotune`: `tuneKey` 0–11, C to B (0), `scale` 0–2, Chromatic, Major, Minor (0), `retune` 0–0.4 (0.08), `amount` 0–1 (1) ## List tracks `GET /api/stories//tracks` Returns the lanes with a row, in order. | Name | Type | Required | Description | |---|---|---|---| | `` | string | Yes | The story's id | This request lists lanes: ```bash curl "http://127.0.0.1:17494/api/stories//tracks" ``` A successful response is `200 OK` with an array of [track objects](#track-object). | Status | Cause | |---|---| | `404` | No story has this id | ## Update a track `PATCH /api/stories//tracks/` Changes a lane, creating its row if needed. `devices` replaces the chain: unknown knobs are dropped, values clamped (`tuneKey` and `scale` also rounded), and missing knobs take defaults. | Name | Type | Required | Description | |---|---|---|---| | ``, `` | string, integer | Yes | The story's id and the lane | | `name`, `muted`, `soloed`, `gain_db` | mixed | No | As in the [track object](#track-object) | | `devices` | object[] | No | Up to 16 `{ kind, id?, bypassed?, params? }`. `[]` empties it | This request names lane 0 and adds two devices: ```bash curl -X PATCH "http://127.0.0.1:17494/api/stories//tracks/0" \ -H 'Content-Type: application/json' \ -d '{ "name": "Dialogue", "gain_db": -3, "devices": [ { "kind": "compressor" }, { "kind": "reverb", "params": { "wet": 0.2 } } ] }' ``` A successful response is `200 OK` with the [track object](#track-object). | Status | Cause | |---|---| | `404` | No story has this id | | `422` | `` is not an integer | ## Delete a track `DELETE /api/stories//tracks/` Deletes a lane and its clips. Higher lanes move down one. | Name | Type | Required | Description | |---|---|---|---| | ``, `` | string, integer | Yes | The story's id and the lane | This request deletes lane 2: ```bash curl -X DELETE -H 'X-Soundbox: 1' \ "http://127.0.0.1:17494/api/stories//tracks/2" ``` A successful response is `200 OK` with the clips removed: ```json { "removed_clips": 3 } ``` | Status | Cause | |---|---| | `404` | No story has this id | | `422` | `` is not an integer | --- # Voices endpoints A voice is a saved speaker: a `clone`, made from clips of a real speaker, or a `builtin`, one of a model's own voices. Avatars are on [Artwork endpoints](https://mirli.app/docs/api-artwork/index.md); transcription is [Transcribe speech](https://mirli.app/docs/api-speech/index.md#transcribe-speech). Each endpoint lists the errors it returns itself. Any endpoint can also return the [common errors](https://mirli.app/docs/api-errors/index.md#common-errors). A `400` from a model error has `detail` and a [failure object](https://mirli.app/docs/api-errors/index.md#failure-object). ## Voice object The voice endpoints return this object: | Field | Type | Description | |---|---|---| | `id`, `name`, `created_at` | string | Id, display name, ISO 8601 creation time | | `kind` | string | `clone`, `builtin` or `trained` (see [Trained singing voices](#trained-singing-voices)) | | `reference_file` | string or null | `clone`: the file the model reads, `/files/.wav` | | `voice_id` | string or null | `builtin`: the model's own voice id | | `model_id` | string or null | The model it speaks through. Null on old clones | | `notes` | string or null | Free text; its avatar's prompt | | `artwork` | string or null | Avatar URL, `/artwork/.png` | | `read_count` | integer | Its single-voice reads and conversions | | `samples` | object[] | `clone`: its clips, oldest first, each with `id`, `file` (`/files/.wav`), `duration_s`, `created_at` and `reference_text`. `trained`: its training clips | | `trained` | object | `trained` only: `status` (`draft`, `training` or `ready`), `f0_median_hz`, `sample_rate`, `epochs`, `has_index`, `dataset_s`, `train_s`, `trained_at` and `last_error` | A clip's `reference_text` is its exact transcript, up to 20,000 characters (**Reference Transcript** in Voice Lab). `duration_s` is null on old clips. A clone holds 1 to 5 clips of one speaker, joined into the one file audio.cpp reads: each mono, levelled to the set's median loudness, 0.3 s apart. `reference_file` is that file or the only clip, and its URL changes with them. A clip under 1 s, over 60 s or almost silent is refused, and a voice's clips total under 90 s, since models read only the start of a longer reference. For Fish Audio, every clip needs a non-blank transcript: speech and segment generation return `400` before any work if one is missing, naming the voice and clips. The transcripts, joined in clip order, become `request_options.reference_text`. Other models need none. `tidy` (off by default over the API, on in the app) removes DC offset, trims near-silence from both ends, leaving some padding, and pulls a peak over full scale back under. It never boosts a clip or changes its tone, and the result is rechecked. ## List voices `GET /api/voices` Returns every voice a script can be read in (`clone` and `builtin`), newest first. `?kind=trained` returns the trained singing voices instead; nothing else is accepted for `kind`. This request lists the voices: ```bash curl http://127.0.0.1:17494/api/voices ``` A successful response is `200 OK` with the voices: ```json [ { "id": "8d0f3a52-6b1e-4c7a-9f24-3e5b7c1d9a60", "name": "Ada", "kind": "clone", "created_at": "2026-11-29T10:00:00.000Z", "reference_file": "/files/voice-8d0f3a52-6b1e-4c7a-9f24-3e5b7c1d9a60.wav", "voice_id": null, "model_id": "audiocpp-chatterbox", "notes": "Warm, low, unhurried", "artwork": null, "read_count": 3, "samples": [ { "id": "8d0f3a52-6b1e-4c7a-9f24-3e5b7c1d9a60", "file": "/files/voice-8d0f3a52-6b1e-4c7a-9f24-3e5b7c1d9a60.wav", "duration_s": 8.2, "created_at": "2026-11-29T10:00:00.000Z", "reference_text": "The quick brown fox jumps over the lazy dog." } ] } ] ``` This endpoint returns only the common errors. ## Get a voice `GET /api/voices/` Returns one voice. | Name | Type | Required | Description | |---|---|---|---| | `` | string | Yes | The voice's id | This request reads one voice: ```bash curl "http://127.0.0.1:17494/api/voices/" ``` A successful response is `200 OK` with the [voice object](#voice-object). | Status | Cause | |---|---| | `404` | No voice has this id | ## Create a voice `POST /api/voices` Saves a `builtin`, or a `clone` from a copy of a library sound. | Name | Type | Required | Description | |---|---|---|---| | `name` | string | Yes | 1 to 120 characters | | `kind` | string | No | `clone` (default) or `builtin` | | `voice_id` | string | For `builtin` | The model's voice id, up to 120 characters | | `model_id` | string | No | For a clone, a `tts` model that clones | | `notes` | string | No | Up to 2,000 characters | | `source_sound_id` | string | For `clone` | The library sound to copy | | `reference_text` | string | No | The clip's transcript, up to 20,000 characters | | `tidy` | boolean | No | Tidies the clip. Default `false` | This request clones a library sound: ```bash curl -X POST "http://127.0.0.1:17494/api/voices" \ -H 'Content-Type: application/json' \ -d '{ "name": "Ada", "model_id": "audiocpp-chatterbox", "source_sound_id": "", "reference_text": "The quick brown fox jumps over the lazy dog.", "tidy": true }' ``` A successful response is `201 Created` with the new [voice object](#voice-object). | Status | Cause | |---|---| | `400` | `model_id` is unknown or unfit, `voice_id` is missing or not the model's, `source_sound_id` is missing or not a sound, or the clip breaks the rules | ## Create a voice from a file `POST /api/voices/upload` Saves a `clone` from a WAV body up to 64 MB (`audio/wav`, `audio/x-wav`, `audio/wave` or `application/octet-stream`) and URL-encoded query parameters. | Name | Type | Required | Description | |---|---|---|---| | `?name` | string | Yes | 1 to 120 characters | | `?notes`, `?model_id`, `?reference_text`, `?tidy` | string, boolean | No | As on [Create a voice](#create-a-voice) | This request clones a voice from `ada.wav`: ```bash curl -X POST "http://127.0.0.1:17494/api/voices/upload?name=Ada&tidy=true" \ -H 'Content-Type: audio/wav' \ --data-binary @ada.wav ``` A successful response is `201 Created` with the new [voice object](#voice-object). | Status | Cause | |---|---| | `400` | The body is not a readable WAV, `model_id` is unfit, or the clip breaks the rules | | `413` | The body is over 64 MB | | `422` | `name` is missing | ## Update a voice `PATCH /api/voices/` Changes a voice's name, notes or clip transcripts, not its audio. | Name | Type | Required | Description | |---|---|---|---| | `` | string | Yes | The voice's id | | `name` | string | No | 1 to 120 characters | | `notes` | string or null | No | Up to 2,000 characters; `null` clears | | `samples` | object[] | No | Up to 5 `{ "id", "reference_text" }` transcript changes | This request sets one clip's transcript: ```bash curl -X PATCH "http://127.0.0.1:17494/api/voices/" \ -H 'Content-Type: application/json' \ -d '{"samples": [{"id": "", "reference_text": "Halt."}]}' ``` A successful response is `200 OK` with the updated [voice object](#voice-object). | Status | Cause | |---|---| | `400` | A clip id in `samples` is not this voice's | | `404` | No voice has this id | ## Delete a voice `DELETE /api/voices/` Deletes the voice and its clip and reference files. | Name | Type | Required | Description | |---|---|---|---| | `` | string | Yes | The voice's id | This request deletes one voice: ```bash curl -X DELETE -H 'X-Soundbox: 1' \ "http://127.0.0.1:17494/api/voices/" ``` A successful response is `204 No Content`. | Status | Cause | |---|---| | `404` | No voice has this id | ## Add a clip `POST /api/voices//samples` Adds a clip to a clone and rebuilds its reference file. The body is JSON, or a WAV up to 64 MB with the fields as query parameters. | Name | Type | Required | Description | |---|---|---|---| | `` | string | Yes | The voice's id | | `source_sound_id` | string | For JSON | The library sound to add | | `reference_text`, `tidy` | string, boolean | No | As on [Create a voice](#create-a-voice) | This request adds a library sound as a clip: ```bash curl -X POST "http://127.0.0.1:17494/api/voices//samples" \ -H 'Content-Type: application/json' \ -d '{"source_sound_id": "", "reference_text": "Halt."}' ``` A successful response is `201 Created` with the updated [voice object](#voice-object). | Status | Cause | |---|---| | `400` | The WAV is unreadable, the voice is `builtin` or full, the clips would pass 90 s, the sound does not exist, or the clip breaks the rules | | `404` | No voice has this id | | `413` | The body is over 64 MB | ## Remove a clip `DELETE /api/voices//samples/` Removes a clip and its file and rebuilds the reference file. | Name | Type | Required | Description | |---|---|---|---| | `` | string | Yes | The voice's id | | `` | string | Yes | The clip's id | This request removes one clip: ```bash curl -X DELETE -H 'X-Soundbox: 1' \ "http://127.0.0.1:17494/api/voices//samples/" ``` A successful response is `200 OK` with the updated [voice object](#voice-object). | Status | Cause | |---|---| | `400` | It is the only clip | | `404` | No such voice, or no such clip on it | ## Export a voice `GET /api/voices//export` Returns the voice as a download, `.soundbox-voice.json`, where the name keeps only ASCII letters, digits, spaces, `_` and `-` (else `voice`). Each clip travels as base64 WAV, oldest first. The joined file, which import rebuilds, and the avatar, which can be redrawn from the notes, are left out. | Name | Type | Required | Description | |---|---|---|---| | `` | string | Yes | The voice's id | This request saves a voice to a file: ```bash curl -o Ada.soundbox-voice.json \ "http://127.0.0.1:17494/api/voices//export" ``` A successful response is `200 OK` with the export. The example shortens the base64: ```json { "format": "soundbox-voice", "version": 1, "exported_at": "2026-11-29T10:00:00.000Z", "voice": { "name": "Ada", "kind": "clone", "voice_id": null, "model_id": "audiocpp-chatterbox", "notes": "Warm, low, unhurried" }, "samples": [ { "wav_base64": "UklGRiQAAABXQVZF", "duration_s": 8.2, "reference_text": "The quick brown fox jumps over the lazy dog." } ] } ``` | Status | Cause | |---|---| | `404` | No voice has this id | ## Import a voice `POST /api/voices/import` Copies an exported voice under a new id. A taken name gets " (2)", " (3)" and so on, and a clone's unknown `model_id` is dropped. Clips are checked against the clip rules, untidied; one bad clip undoes the import. | Name | Type | Required | Description | |---|---|---|---| | `format` | string | Yes | `soundbox-voice` | | `version` | integer | Yes | `1` | | `voice` | object | Yes | As in an [export](#export-a-voice) | | `samples` | object[] | No | Up to 5 clips, as in an export. `exported_at` is ignored | This request imports a voice from a file: ```bash curl -X POST "http://127.0.0.1:17494/api/voices/import" \ -H 'Content-Type: application/json' \ --data-binary @Ada.soundbox-voice.json ``` A successful response is `201 Created` with the new [voice object](#voice-object). | Status | Cause | |---|---| | `400` | A `builtin`'s model or `voice_id` is not on this Mirli, a clone has no clips, or a clip is unreadable or breaks the clip rules | | `413` | The body is over 64 MB | ## Trained singing voices A `trained` voice is a model of one singer's voice, trained on this machine from their recordings. It only [converts](https://mirli.app/docs/api-speech/index.md#convert-a-voice) recordings; speaking or reading a script in one is refused. It is listed with `GET /api/voices?kind=trained`, not with the speech voices. Training runs [Applio](https://github.com/IAHispano/Applio)'s RVC v2 trainer in its own Python environment; conversion runs on `audiocpp-rvc`. Measurements and licences: [singing-voice-training.md](https://github.com/HamSanders/soundbox/blob/main/docs/singing-voice-training.md). A trained voice moves from `draft` (gathering clips) to `training` to `ready`. A run that fails or is cancelled goes back to where it was, with `trained.last_error` set, and keeps the clips; a retrain that fails keeps the previous model. Deleting one is refused while it trains. | Endpoint | What it does | |---|---| | `GET /api/trainer` | Whether training can run here: `installed`, `source` (`env` or `managed`), `python`, `applio_dir`, `install_job_id`, and `problem` (why it can't, or null) | | `POST /api/trainer/install` | `202` with a `job_id`: sets up the trainer under `/runtimes/rvc-train` with [uv](https://docs.astral.sh/uv/), about 7 GB. Needs the `downloads` capability | | `POST /api/voices/trained` | `201` with a new `draft` voice. Body: `name`, optional `notes`, and `consent`, which must be `true`. Anything else is `422` | | `POST /api/voices//training-clips` | `201` with the voice. Body: a WAV (up to 1 GB), or JSON `{ "source_sound_id": ... }`. A clip under 1 s, or a set over 60 minutes, is refused | | `POST /api/voices//training-clips/folder` | Adds every `.wav` in a folder on this machine, in name order. Body: `{ "path": ... }`. Answers `{ voice, added, skipped }`. Needs the `filesystem` capability | | `DELETE /api/voices//samples/` | Removes a training clip, as for a clone's clip | | `POST /api/voices//train` | `202` with a `job_id` (kind `train_voice`). Body, optional: `epochs` (10 to 1000, default 200) and `batch_size` (1 to 32, default 8). Needs at least 60 s of clips and an installed trainer. Cancel it with `POST /api/jobs//cancel` | `MIRLI_RVC_PYTHON` and `MIRLI_RVC_APPLIO_DIR` point Mirli at a Python and an Applio checkout you installed yourself, instead of its own. This request trains a voice from a folder of takes: ```bash VOICE=$(curl -s -X POST http://127.0.0.1:17494/api/voices/trained -H 'Content-Type: application/json' -d '{"name": "My voice", "consent": true}' | jq -r .id) curl -X POST "http://127.0.0.1:17494/api/voices/$VOICE/training-clips/folder" -H 'Content-Type: application/json' -d '{"path": "C:/takes"}' curl -X POST "http://127.0.0.1:17494/api/voices/$VOICE/train" -H 'Content-Type: application/json' -d '{"epochs": 200}' ``` --- # Run Mirli from source This guide builds Mirli from a clone of the repository, installs the audio.cpp runtime and one sound-effects model, and starts the server. If you want the app rather than the code, download the installer from [mirli.app/download](https://mirli.app/download/) instead. To check whether your computer can run the models, see the [requirements guide](https://mirli.app/docs/requirements/index.md). ## Before you begin - Install Node 22.12 or later, and `git`. The repository's `.nvmrc` pins Node 22, so `nvm use` picks a matching version. - Make sure you have free disk space for model weights. Each model takes one to ten gigabytes. - Optional: Put `ffmpeg` on your `PATH` if you want MP3 export. The commands are the same on Windows, macOS and Linux. ## Build and start Mirli 1. Clone the repository and go into it: ```bash git clone https://github.com/HamSanders/soundbox cd soundbox ``` 2. Install the dependencies, which also links the `soundbox` command: ```bash npm install ``` 3. Build the web app and the server: ```bash npm run build ``` The web app is built into `server/web` and the server into `server/dist`. 4. Install the audio.cpp runtime: ```bash npx soundbox model install audiocpp ``` Mirli downloads the build for your OS and GPU and verifies its checksum. 5. Download the sound-effects model, which needs no account: ```bash npx soundbox pull audiocpp-stable-audio-3-sfx ``` 6. Optional: Render a test sound without starting the server: ```bash npx soundbox run audiocpp-stable-audio-3-sfx "glass breaking" --out test.wav ``` A file named `test.wav` appears in the current folder. 7. Start the server: ```bash npx soundbox ``` The server prints the app's address, `http://127.0.0.1:17494`, and the MCP endpoint, `http://127.0.0.1:17494/mcp`. 8. Open `http://127.0.0.1:17494` in your browser. > [!NOTE] > To skip the build, run the TypeScript source with > `npx tsx server/src/cli.ts` in place of `npx soundbox`. It takes the same > subcommands. The rest of these pages write `soundbox` for either one. ## Check which GPU backend is in use 1. With the server running, ask it for its health report: ```bash title="macOS / Linux" curl http://127.0.0.1:17494/api/health ``` ```powershell title="Windows" Invoke-RestMethod http://127.0.0.1:17494/api/health ``` 2. Read the `device` field. It names the backend Mirli asks audio.cpp to use, such as `cuda`, `metal` or `cpu`. If `device` is `cpu` on a machine with a GPU, see [Choose a backend](https://mirli.app/docs/audiocpp-binary/index.md#choose-a-backend). ## Start the development servers To work on the code, start the server and the Vite dev server for the UI together: ```bash npm run dev ``` Then open `http://localhost:5174`. Vite reloads the page when you edit the UI, and forwards `/api`, `/mcp`, `/files` and `/artwork` to the server on port 17494. The other npm scripts are listed in the [command-line reference](https://mirli.app/docs/install-cli/index.md#npm-scripts). ## What's next - [Download models from the command line](https://mirli.app/docs/install-models/index.md) - [Run Mirli in Docker](https://mirli.app/docs/install-docker/index.md) - [Troubleshoot a source install](https://mirli.app/docs/install-troubleshooting/index.md) --- # Access control By default the server listens on loopback and has no login. Anyone who can reach its port can generate audio, read and delete the library, change settings and call every MCP tool. Four mechanisms control access: the access token, the host checks, sandboxed mode and single capability switches. To set them up, see [Reach Mirli from another machine](https://mirli.app/docs/install-remote/index.md). ## Access token `MIRLI_API_TOKEN` turns on authentication. | Property | Value | |---|---| | Length | At least 16 characters. A shorter token stops the server at startup. | | Startup banner | Shows `Access token -> required` when a token is in force. | | Protected paths | `/api/*`, `/v1/*`, `/mcp`, `/files/*` and `/artwork/*`. Without the token, they answer **401**. | | Open paths | `GET /api/health` (used by the Docker health check and the desktop app's startup probe; it says nothing about the library), the sign-in routes, and the web UI's static files. | | Rate limit | 30 wrong tokens from one address in ten minutes, by bearer header, cookie or sign-in form, earn that address **429** until the ten minutes are up, even with the right token. Requests with no token or the right one don't count. Behind a reverse proxy every client shares the proxy's address. | | Changing the token | Signs every browser out. | How each client sends the token: | Client | Method | |---|---| | Web UI | A sign-in screen. The browser then holds an HttpOnly cookie for 30 days. The cookie holds a value derived from the token, not the token itself. | | Scripts, MCP clients, another Mirli | `Authorization: Bearer ` | | Stdio MCP bridge, `soundbox ps`, `soundbox enhance` | Sent automatically when `MIRLI_API_TOKEN` is set in their own environment. | Over plain `http://`, the token and the cookie cross the network unencrypted. Behind a proxy that terminates HTTPS, the cookie is marked `Secure` when the proxy sends `X-Forwarded-Proto: https`. ## Host checks The checks defend against DNS rebinding. They apply with or without a token. | Check | Rule | |---|---| | UI and `/api/*` | A `Host` header other than `localhost`, `127.0.0.1`, `::1` or a listed name gets **403 Forbidden host**. Binding a specific address with `--host` also accepts that address. Binding `0.0.0.0` turns this check off. | | `/mcp` | `Host` and, when a browser sends one, `Origin` must be loopback or a listed name, whatever the bind address. Otherwise **403**. | | Browser origins | CORS and the MCP `Origin` check trust loopback and the listed names. | `MIRLI_ALLOWED_HOSTS` is the list. It is comma-separated: | Entry | Matches | |---|---| | `host` | That name on any port. | | `host:port` | That name on that port only. | Under `npm run dev`, Vite reads the same list as `SOUNDBOX_ALLOWED_HOSTS` for its own `server.allowedHosts`, with ports dropped. Vite accepts IP addresses as `Host` without a list. ## Sandboxed mode `MIRLI_SANDBOXED=1` is for a server whose users don't own the machine, such as a shared server, a NAS or a container behind a sign-in proxy. The UI then offers nothing that touches the host, and the server answers **403** if asked anyway: - folder browsing, folder settings, **Open in Finder** in a sound's menu, and creating or removing profiles - model, engine and sample downloads, and models run on this machine - custom endpoints, so the server never fetches a URL a page hands it - the update check, the GPU readout, the server log, the connection details for agents, and installing agent skills - first-run setup Settings that name a path, a device, an engine or a URL are locked. Generation still works through whatever model sources the server has. ## Capability switches `MIRLI_DISABLE` turns off single capabilities, as a comma-separated list. The names are the flags `GET /api/capabilities` reports: | Name | Turns off | |---|---| | `filesystem` | Folder browsing and folder settings | | `reveal` | **Open in Finder** in a sound's menu, which opens the system file manager | | `downloads` | Model weights, engine and sample pack downloads | | `local_models` | Models run on this machine through audio.cpp | | `custom_endpoints` | Adding and editing custom endpoints. Also locks the prompt assistant's and artwork's external URLs and the OpenTelemetry endpoint. | | `updates` | The daily update check and the update notice | | `gpu_status` | The GPU and memory readout | | `agent_connect` | The MCP endpoint and stdio command shown to agents | | `skills_install` | Installing the bundled agent skills into a client's folder | | `logs` | Reading the server log | | `setup_wizard` | The first-run setup dialog | For example, to turn off **Open in Finder** and the update check: ```bash MIRLI_DISABLE=reveal,updates soundbox ``` --- # Install Mirli with a coding agent This page is written for an agent such as Claude Code, Cursor or Codex that has been asked to install Mirli on the machine it is running on. Paste this into the agent to start: ```text Install Mirli on this machine and confirm it works, following https://github.com/HamSanders/soundbox/blob/main/docs/INSTALL-AGENT.md ``` Mirli runs entirely on the user's machine. The server listens on `http://127.0.0.1:17494` and every step below can be checked against its HTTP API, which is documented in full in [API.md](https://mirli.app/docs/api/index.md). ## Rules - **Say what each model costs before downloading it.** Every entry from `GET /api/models` carries `vram_estimate_mb`, `license.name` and `license.commercial` (`yes`, `conditional` or `no`). Tell the user the model's name, footprint and licence, then wait for a yes. - **Never accept a licence on the user's behalf.** A model whose `license.commercial` is `no` or `conditional` is the user's decision. The app asks for a confirmation before such weights are used; leave that to them. - **Check the hardware before choosing anything.** `GET /api/health` reports `device` (`cuda`, `metal` or `cpu`), `gpu_name`, `vram_total_mb` and `vram_free_mb`. Pick models that fit, and say so if the machine is CPU-only: generation works there, but takes minutes rather than seconds. - **Reuse what exists.** Weights live under `~/.mirli/models` and are shared by every profile. If `GET /api/models` shows a model as `installed`, do not download it again. - **Name what you could not do.** The first launch of an unsigned installer needs a click from the user (SmartScreen or Gatekeeper). Say so rather than skipping it. - **Do not change network settings or firewall rules.** The server binds to loopback and needs nothing opened. ## Steps 1. **Inspect the machine.** Note the OS, the CPU architecture, the GPU and its VRAM (`nvidia-smi` on Windows and Linux, `system_profiler SPDisplaysDataType` on macOS), and free disk space on the home drive. Model weights are one to ten gigabytes each. 2. **Install.** - **Windows or macOS:** download the installer for this machine from [the download page](https://mirli.app/download/) (`Soundbox__x64-setup.exe`, or the `.dmg` for Apple silicon or Intel) and run it. The app carries its own Node and server. The builds are not signed yet, so the first launch asks the user to confirm; the exact clicks are in [DESKTOP.md](https://mirli.app/docs/desktop/index.md#installation). Ask the user to do that step. - **Linux, or from source:** with Node 22.12 or later and `git` installed, build and start the server: ```bash git clone https://github.com/HamSanders/soundbox cd soundbox npm install npm run build npx soundbox model install audiocpp npx soundbox ``` `npx soundbox` starts the server on port 17494 and serves the web app at the same address. [INSTALL.md](https://mirli.app/docs/install/index.md) covers the CLI, and [INSTALL-ENV.md](https://mirli.app/docs/install-env/index.md) the environment variables. 3. **Confirm the server answers.** Ask it for its health report: ```bash curl http://127.0.0.1:17494/api/health ``` Report `version`, `device`, `gpu_name` and `vram_total_mb` to the user. If `device` is `cpu` on a machine with an NVIDIA GPU, the audio.cpp runtime was not matched to the driver; `npx soundbox model status audiocpp` says which binary and backend resolved, and [AUDIOCPP-BINARY.md](https://mirli.app/docs/audiocpp-binary/index.md#choose-a-backend) explains how to force one. 4. **Choose a model with the user.** `GET /api/models` lists every enabled model. The four verified ones are `audiocpp-stable-audio-3-sfx` (sound effects), `audiocpp-stable-audio-3-small-music` (instrumentals), `audiocpp-ace-step` (ACE-Step 1.5 Turbo: songs with lyrics, MIT) and `audiocpp-minimax-music3` (songs, about 10 GB of VRAM). For a first test on any GPU, propose the SFX model. State its size and licence, then wait. 5. **Download it.** `POST /api/models/{id}/download` returns a job. Poll `GET /api/jobs/{id}` until `status` is `done` (or follow `GET /api/jobs/{id}/events`, a server-sent event stream). Mutating requests need the header `X-Soundbox: 1` when they carry no JSON body; see the request rules in [API.md](https://mirli.app/docs/api/index.md#request-rules). 6. **Generate one sound.** Send a prompt to the model you downloaded: ```bash curl -X POST http://127.0.0.1:17494/api/generate \ -H 'Content-Type: application/json' \ -d '{ "model": "audiocpp-stable-audio-3-sfx", "prompt": "heavy wooden door slamming in a stone corridor", "duration_s": 3 }' ``` Poll the job. When it is `done`, `result.sounds` holds one sound id; `GET /api/sounds/{id}` returns its `path` on disk and `duration_s`. Check the file exists and is not empty before calling it a success. 7. **Connect an MCP client if asked.** The server is also an MCP server at `http://127.0.0.1:17494/mcp`. For Claude Code: ```bash claude mcp add --transport http soundbox http://127.0.0.1:17494/mcp ``` Other clients and the three bundled skills are in [MCP.md](https://mirli.app/docs/mcp/index.md). 8. **Report.** Tell the user: where Mirli is installed, what `GET /api/health` said about the GPU, which model was downloaded and under which licence, the path of the test WAV, and anything from the rules above that needed their hand. ## If something fails - `GET /api/health` does not answer: on the desktop the app starts the server itself; wait a few seconds after launch. From source, check that nothing else owns port 17494. - A model shows `needs_runtime`: run `npx soundbox model install audiocpp`, or on the desktop open the Models page, which offers the install. - A download fails with 401 or 403: the model is gated on Hugging Face. The user has to accept its terms on the model's page and add a token in Settings; do not ask them for the token in chat. - Generation is far slower than expected: it is running on the CPU. See step 3. Everything else is in [INSTALL-TROUBLESHOOTING.md](https://mirli.app/docs/install-troubleshooting/index.md). --- # Command-line reference The `soundbox` command starts the server and manages models and engines. From a clone it runs as `npx soundbox` after `npm run build`, or as `npx tsx server/src/cli.ts` without a build. Both take the same arguments. ## soundbox Starts the server. It serves the web app, the HTTP API and the MCP endpoint on one port. | Flag | Default | Description | |---|---|---| | `--host ` | `127.0.0.1` | Address to listen on. | | `--port ` | `17494` | Port to listen on. | | `--data-dir ` | `~/.mirli`, or `~/.soundbox` from an older install | The data folder. Applies to the server only. | | `--profile ` | The last active profile | The library to open. | | `--no-ui` | Off | Serve the API only. | | `--log-level ` | `MIRLI_LOG_LEVEL`, else `info` | `debug`, `info`, `warning`, `error` or `critical`. | | `--version` | | Print the version and exit. | | `--help`, `-h` | | Print usage and exit. | ## soundbox model Installs and reports the native engines. | Command | Description | |---|---| | `model status audiocpp` | The audio.cpp version, detected backend and resolved path. | | `model install audiocpp` | Download and verify the audio.cpp build for this machine. | | `model status llm` | The same for `llama-server`, plus each prompt-assistant model and whether it is downloaded. | | `model install llm` | Install `llama-server` and the default prompt-assistant model. | | Flag | Applies to | Description | |---|---|---| | `--backend ` | `install` | Download the build for another backend, such as `cuda`, `metal`, `vulkan` or `cpu`. | | `--version ` | `install` | Download this release. Takes the tag exactly as upstream's releases page shows it: `v0.9.6`, not `0.9.6`. | | `--engine-only` | `install llm` | Install the engine without model weights. | | `--model ` | `install llm` | Install this prompt-assistant model instead of the one in Settings. | A managed engine reports its version. An engine of yours reports `external (env)` or `external (PATH)`. See [Engines and GPU backends](https://mirli.app/docs/install-engines/index.md). ## Model commands These run without the server. They read the data folder from `MIRLI_DATA_DIR`, not from `--data-dir`. | Command | Description | |---|---| | `list` | The catalogue, with what is downloaded. Entries from `custom.json` are tagged `[custom - from your custom.json]`. | | `pull ` | Download a model's weights. | | `rm ` | Delete a model's weights folder. | | `run ""` | Render one sound. Offers to download a missing model first. | `run` takes these flags: | Flag | Description | |---|---| | `--out ` | Where to write the WAV. | | `--duration ` | Length of the sound. | | `--seed `, `--steps `, `--cfg ` | Sampler settings. | | `--yes`, `-y` | Download a missing model without asking. | ## Commands that talk to a running server These call the server's HTTP API. Each takes `--host` and `--port`, with the same defaults as the server, and sends `MIRLI_API_TOKEN` when it is set. | Command | Description | |---|---| | `ps` | The models loaded in memory. | | `enhance ""` | Rewrite a prompt with the prompt assistant. `--n <1-5>` sets how many variations, `--category` is `sfx` or `music`. | ## soundbox skills Manages the agent skills bundled with Mirli. | Command | Description | |---|---| | `skills list` | Each skill and where it is installed. | | `skills path` | The folder the bundled skills are read from. | | `skills install [...]` | Copy skills into a client's folder. `--target` names the client (default `claude`); `--path` gives a folder instead. With no names, every skill is installed. | ## npm scripts Run these from the repository root. | Script | Description | |---|---| | `npm run build` | Build the web app into `server/web` and the server into `server/dist`. | | `npm run dev` | The server on 17494 and the Vite dev server on 5174. | | `npm run dev:ui` | Vite alone. Every `/api` call answers 502 until a server runs on 17494. | | `npm run dev:mock` | The UI against an in-browser fake backend. No server and no models. | | `npm run typecheck`, `npm run lint`, `npm test` | The checks CI runs. | | `npm run desktop` | Build, then compile and open the desktop shell. | | `npm run desktop:build` | Build a desktop installer. See [Build the desktop app](https://mirli.app/docs/desktop-build/index.md). | | `npm run site:dev`, `npm run site:build` | The public site. | | `npm run capture:media` | Regenerate the screenshots from the demo library. | ## Download behaviour Mirli's own downloader fetches the prompt assistant, the artwork models and the engines. It also fetches audio models when the audio.cpp runtime has no package manager of its own; when it has one, audio.cpp does the transfer and Mirli reports its progress. | Stage | Behaviour | |---|---| | Before it starts | Compares what is left to download, plus 2 GB to keep free, with the free space on the drive that holds the models folder. If it does not fit, nothing is downloaded and the message names the three sizes and the folder. Engines and sampled instruments are checked without the 2 GB margin. | | While it runs | Writes to `.part`, with a `.part.meta` beside it that records which version of the file the bytes came from. Progress shows the rate and the time left. | | Dropped connection, stall, 429 or 5xx | Waits and tries again, up to five tries, waiting longer each time. Follows a `Retry-After` of a minute or less. Does not retry a 401, 403 or 404. | | Each new try | Continues from the `.part` with an HTTP `Range` request. Starts again from the beginning if the file changed upstream or the server cannot continue it. | | Finished | Checks the size, and the SHA-256 where the source publishes one, before renaming the file into place. | | Every try failed | Keeps the `.part`. The model shows as **Incomplete** on the **Models** page with the reason, and **Repair** continues from where it stopped, even after a restart. The reason is kept in `models/download-failures.json` until a download succeeds, the weights are deleted or you dismiss it. | | Cancelled, disk full, wrong size or checksum | Removes the `.part`. | --- # Configuration Mirli keeps everything in one data folder. Most settings live in the app under **Settings**; this page describes the data folder and the audio output settings that matter when you run Mirli yourself. ## Data folder The default data folder is `~/.mirli`, or `~/.soundbox` for an install from before the rename while no `~/.mirli` exists. Nothing is moved between the two. It holds: ```text ~/.mirli/ soundbox.db library index sounds/ generated WAVs artwork/ generated cover art and voice avatars cache/ MP3 transcodes models/ model weights, and custom.json for your own models bin/audiocpp/ the audio.cpp runtime, one folder per version bin/llama/ the prompt-assistant engine, same layout bin/sd/ the artwork engine, same layout soundbox-.log the server log, rotated settings.json settings, including the Hugging Face token ``` | Property | Value | |---|---| | Location | `MIRLI_DATA_DIR`, or `--data-dir` for one run of the server. The other `soundbox` commands read only `MIRLI_DATA_DIR`. | | Moving it | Safe. Downloaded weights are found in the new place, and an interrupted download resumes. | | Uninstalling | Delete the folder. | | Sounds folder | Can live elsewhere, set in **Settings > Storage > Sounds folder**. Existing and new audio move there. **Browse** opens a folder picker on the machine running the server, and a folder that does not exist yet is created on save. | | Windows paths | Windows caps paths at 260 characters unless long paths are turned on. A deep data folder can make downloads fail with *"The system cannot find the path specified"*. The default `%USERPROFILE%\.mirli` is short enough. | To point the server at another data folder: ```bash title="macOS / Linux" export MIRLI_DATA_DIR=/mnt/big/mirli soundbox ``` ```powershell title="Windows" $env:MIRLI_DATA_DIR = "C:\mirli" npx soundbox ``` ## Loudness and MP3 | Feature | Behaviour | |---|---| | Loudness normalisation | Built in (an EBU R 128 meter in the server). On by default at -16 LUFS. Set the target or turn it off under **Settings > Sound & files > Normalise loudness**. If metering fails on an unusual input, the server falls back to peak normalisation and logs it. | | MP3 export | Needs `ffmpeg` on `PATH`. Without it, `/files/.wav?format=mp3` answers with the WAV and an `X-Soundbox-Format-Fallback: wav` header, and the app says the MP3 was not made. | Every environment variable is listed in [Environment variables](https://mirli.app/docs/install-env/index.md). --- # Docker image reference The Mirli image runs the server and the web UI in one container. To start it, see [Run Mirli in Docker](https://mirli.app/docs/install-docker/index.md). ## Tags | Tag | Contents | |---|---| | `ghcr.io/hamsanders/soundbox:latest` | CPU build, amd64. About 3.5 GB. | | `ghcr.io/hamsanders/soundbox:cuda` | NVIDIA build. About 10 GB, most of it the CUDA runtime. | | `:v`, for example `:v0.4.0` | A release, CPU build. | | `:v-cuda`, for example `:v0.4.0-cuda` | A release, NVIDIA build. | To pin a release, change the `image:` line in `docker-compose.yml`. ## Compose files | File | Adds | |---|---| | `docker-compose.yml` | The service, its port on `127.0.0.1:17494`, its two volumes and an example `SOUNDBOX_ALLOWED_HOSTS`, using the prebuilt CPU image. | | `docker-compose.cuda.yml` | The CUDA image and GPU access. | | `docker-compose.build.yml` | Builds the image from the checkout instead of pulling it. | | `docker-compose.build-cuda.yml` | With `docker-compose.build.yml`, builds the CUDA image. | | `Dockerfile.slim` | Not a Compose file: a build without audio.cpp. It sets `MIRLI_DISABLE=local_models`. | ## Volumes | Path in the container | Contents | |---|---| | `/data` | The whole data folder, the same as `~/.mirli` outside Docker. See [Data folder](https://mirli.app/docs/install-config/index.md#data-folder). | | `/data/models` | The model weights, mounted separately so they can live on another disk. | The container runs as uid 1000. Named volumes work as they are. A host folder must exist and be owned by `1000:1000` before the container starts; a folder Docker creates is owned by root, and the server cannot write to it. ## Build arguments The image builds on [audio.cpp's own images](https://github.com/0xShug0/audio.cpp/blob/main/docs/docker.md), `ghcr.io/0xshug0/audio.cpp:full-`, which carry `audiocpp_cli`, its backend libraries and ffmpeg. Mirli adds Node and the server. | Argument | Values | |---|---| | `AUDIOCPP_TAG` | `full-cpu` (default). `full-cuda12`: CUDA 12.9, needs driver 575 or newer on GeForce cards. `full-cuda13`: for newer drivers. `full-vulkan`: AMD and Intel GPUs. Upstream's tags move daily; a dated tag such as `full-cuda12--` gives a reproducible build. | | `AUDIOCPP_BACKEND` | `cpu` (default), `cuda` or `vulkan`. The backend audio.cpp is asked for. It is set, not detected, so a CPU image started with `--gpus` does not ask for a CUDA backend it lacks. | For example, to build and run a CUDA image by hand: ```bash docker build -t soundbox:cuda \ --build-arg AUDIOCPP_TAG=full-cuda12 --build-arg AUDIOCPP_BACKEND=cuda . docker run -d --gpus all -p 127.0.0.1:17494:17494 \ -v soundbox-data:/data -v soundbox-models:/data/models soundbox:cuda ``` A Vulkan image runs with `--device /dev/dri` and the host's `render` and `video` groups added. ## Inside the image | Setting | Value | |---|---| | `--host` | `0.0.0.0`, because a published port cannot reach loopback inside a container. Unless `MIRLI_API_TOKEN` is set, the server logs a warning about binding beyond loopback on every start. | | Port | 17494 | | audio.cpp | Set through `SOUNDBOX_AUDIOCPP_BIN`, the older spelling of `MIRLI_AUDIOCPP_BIN`, so `soundbox model install audiocpp` is never needed. | | Prompt assistant | The managed `llama-server` is not included. Point the assistant at an external OpenAI-compatible endpoint. | ## Host names and the MCP endpoint Because the server binds `0.0.0.0` in the container, the `Host` check for the web UI and `/api/*` is off. `/mcp` still accepts only loopback and the names in `MIRLI_ALLOWED_HOSTS`, so `http://localhost:17494/mcp` from the Docker host works and any other name answers **403**. To reach `/mcp` by a LAN address or a proxy name, list it: ```bash docker run -d -p 127.0.0.1:17494:17494 -v soundbox-data:/data \ -e MIRLI_ALLOWED_HOSTS=mirli.lan,192.168.1.20:17494 \ ghcr.io/hamsanders/soundbox:latest ``` A proxy that rewrites `Host` to `127.0.0.1` also passes, but forwarding the original name and listing it is clearer. See [Host checks](https://mirli.app/docs/install-access/index.md#host-checks). --- # Run Mirli in Docker This guide runs the Mirli server and web UI in a container, without the desktop app, on a home server, a NAS or a GPU machine. The image already contains the audio.cpp runtime. > [!WARNING] > The server has no login unless you set a token. These steps publish the > port on `127.0.0.1` only. To reach it from other machines, follow > [Reach Mirli from another machine](https://mirli.app/docs/install-remote/index.md) first. ## Before you begin - Install Docker with Compose. - Get `docker-compose.yml` from the repository, or clone the repository. - For an NVIDIA GPU, install the [NVIDIA Container Toolkit](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html) on the host. Prebuilt images are amd64 only. On arm64, follow [Build the image yourself](#build-the-image-yourself). ## Start the container 1. In the folder with `docker-compose.yml`, start Mirli: ```bash docker compose up -d ``` Compose pulls `ghcr.io/hamsanders/soundbox:latest` and starts it. 2. Open `http://localhost:17494`. 3. Download a model from the **Models** page, or from the command line: ```bash docker compose exec soundbox soundbox pull audiocpp-stable-audio-3-sfx ``` The container keeps its data in two volumes, described in the [Docker image reference](https://mirli.app/docs/install-docker-image/index.md#volumes). ## Start the container with an NVIDIA GPU 1. Check that a container can see your GPU: ```bash docker run --rm --gpus all ubuntu nvidia-smi ``` The output lists your GPU. 2. Start Mirli with the CUDA override file: ```bash docker compose -f docker-compose.yml -f docker-compose.cuda.yml up -d ``` Compose pulls `ghcr.io/hamsanders/soundbox:cuda`. For AMD and Intel GPUs, build a Vulkan image; see the [build arguments](https://mirli.app/docs/install-docker-image/index.md#build-arguments). ## Run without Compose To start the CPU image with `docker run`: ```bash docker run -d --name soundbox -p 127.0.0.1:17494:17494 \ -v soundbox-data:/data -v soundbox-models:/data/models \ ghcr.io/hamsanders/soundbox:latest ``` For the CUDA image, add `--gpus all` after `-d` and use the `:cuda` tag. ## Build the image yourself To run your own changes, or on arm64, build from a clone of the repository: ```bash title="CPU" docker compose -f docker-compose.yml -f docker-compose.build.yml up -d --build ``` ```bash title="NVIDIA" docker compose -f docker-compose.yml -f docker-compose.cuda.yml \ -f docker-compose.build.yml -f docker-compose.build-cuda.yml up -d --build ``` ## Run without local models For a machine that generates only through [custom endpoints](https://mirli.app/docs/endpoints/index.md), build the slim image. It has no audio.cpp, needs no GPU and is a fraction of the size: ```bash docker build -f Dockerfile.slim -t mirli-slim . docker run -d -p 127.0.0.1:17494:17494 -v mirli-data:/data mirli-slim ``` The **Models** page then offers no models to download. ## What's next - [Docker image reference](https://mirli.app/docs/install-docker-image/index.md) - [Reach Mirli from another machine](https://mirli.app/docs/install-remote/index.md) - [Send generation to another server](https://mirli.app/docs/endpoints/index.md) --- # Engines and GPU backends Mirli ships and vendors no native binaries. It uses three engines, each fetched from its upstream GitHub releases on request and cached under the data folder. Nothing is installed system-wide. ## Engines | Binary | Upstream | Role | Installed by | |---|---|---|---| | `audiocpp_cli` | [`0xShug0/audio.cpp`](https://github.com/0xShug0/audio.cpp) | Audio inference runtime | With the first model download, **Install runtime** on the Models page, or `soundbox model install audiocpp` | | `llama-server` | [`ggml-org/llama.cpp`](https://github.com/ggml-org/llama.cpp) | Optional prompt assistant | `soundbox model install llm`, or the app when the prompt assistant is set to managed | | `sd-server` | [`leejet/stable-diffusion.cpp`](https://github.com/leejet/stable-diffusion.cpp) | Optional artwork generator | The app, when artwork is turned on in the setup wizard or in **Settings > Prompt assistant & artwork** (`POST /api/image/engine/install`) | The install and status commands and their flags are in the [command-line reference](https://mirli.app/docs/install-cli/index.md#soundbox-model). ## Install location Each engine version gets its own folder: ```text /bin/audiocpp// audiocpp_cli and its runtime libraries /bin/llama// llama-server, same layout /bin/sd// sd-server, same layout ``` `` is the data folder and `` the release tag. - The engines live beside `models/`, not inside it. Deleting models keeps the engines, and reinstalling an engine keeps the weights. - The most recently installed version is used. An upgrade never overwrites the copy that is running. - Uninstalling an engine means deleting its folder. ## Checksums Every download is checked before anything is unpacked: - against GitHub's SHA-256 digest for the release asset, and - against the release's checksum manifest, when the release publishes one. An asset covered by neither is refused unless `MIRLI_ALLOW_UNVERIFIED_BINARIES=1` is set for that run. A checksum mismatch is always refused. ## Resolution order When Mirli needs an engine, it uses the first of these that exists: 1. The environment override: an absolute path in `MIRLI_AUDIOCPP_BIN`, `MIRLI_LLAMA_SERVER_BIN` or `MIRLI_SD_SERVER_BIN`. 2. The managed install under `/bin/`. 3. `PATH`. 4. On macOS, `/opt/homebrew/bin` and `/usr/local/bin`. A server started from a desktop launcher often inherits a `PATH` without Homebrew. The managed install comes before `PATH`, so a binary installed through Mirli wins over a system-wide copy. `soundbox model status` reports which one was used: a managed install shows its version, an override shows `external (env)`, and a binary found on `PATH` shows `external (PATH)`. ## Backend detection The backend is detected once per machine and decides which release asset is downloaded: | Machine | audio.cpp | `llama-server`, `sd-server` | |---|---|---| | macOS | Metal | Metal | | `nvidia-smi` answers | CUDA | CUDA | | Anything else | CPU | Vulkan | `--backend` on `install` downloads another build. Separately, these variables change what is reported or requested at run time without changing the download: | Variable | Effect | |---|---| | `MIRLI_AUDIOCPP_BACKEND` | The backend audio.cpp is asked to run with. `GET /api/health` reports it as `device`. | | `MIRLI_LLAMA_SERVER_BACKEND` | The backend reported for `llama-server`. | | `MIRLI_SD_SERVER_BACKEND` | The backend reported for `sd-server`. | For audio.cpp's CUDA builds and ROCm, see [About audio.cpp](https://mirli.app/docs/audiocpp/index.md). To use a binary of your own, see [Use your own audio.cpp build](https://mirli.app/docs/audiocpp-binary/index.md). --- # Environment variables Mirli reads these environment variables. The server reads each one as `MIRLI_*` first, then by its name from before the rename, `SOUNDBOX_*`, so existing Docker, service and MCP client configs keep working; if both are set, `MIRLI_*` wins. Releases up to 0.5.0 read only the `SOUNDBOX_*` names. The few variables that only `npm run dev`, Vite or the desktop shell read still use the `SOUNDBOX_*` name, as the table shows. Server variables are read by the process running `soundbox`, `npm run dev` or the desktop shell, which passes its environment through. The server sets `MIRLI_LOG_FILE` for its own use. How the access variables fit together is described in [Access control](https://mirli.app/docs/install-access/index.md). | Variable | Read by | What it does | |---|---|---| | `MIRLI_DATA_DIR` | server | The data folder. Default `~/.mirli`, or `~/.soundbox` when that exists and `~/.mirli` doesn't. `--data-dir` does the same for one run. | | `MIRLI_AUDIOCPP_BIN` | server | Absolute path to an `audiocpp_cli` of yours. Nothing is downloaded. | | `MIRLI_LLAMA_SERVER_BIN` | server | The same, for `llama-server`. | | `MIRLI_SD_SERVER_BIN` | server | The same, for `sd-server`. | | `MIRLI_AUDIOCPP_BACKEND` | server | Force the audio.cpp backend instead of detecting it: `cuda`, `hip`, `metal`, `vulkan`, `cpu`. | | `MIRLI_LLAMA_SERVER_BACKEND` | server | Changes the backend that `soundbox model status llm` and the app report for `llama-server`. It does not change the download; use `soundbox model install llm --backend ` for that. | | `MIRLI_SD_SERVER_BACKEND` | server | Changes the backend the app reports for `sd-server`. It does not change the download. | | `MIRLI_ALLOW_UNVERIFIED_BINARIES` | server | `1` installs an engine archive that no published SHA-256 covers. Off by default. A checksum mismatch is refused regardless. | | `HF_TOKEN`, `HUGGING_FACE_HUB_TOKEN` | server | Hugging Face token for gated models, used when none is saved in Settings. | | `HF_HOME` | server | Hugging Face cache location. Left alone if set; otherwise Mirli points it at `/models`. | | `MIRLI_API_TOKEN` | server, stdio MCP bridge, CLI | An access token of at least 16 characters. Set on the server, every `/api/*`, `/v1/*`, `/mcp`, `/files` and `/artwork` request needs it as `Authorization: Bearer ` or a session cookie from the UI's sign-in screen; `GET /api/health` stays open. Set for the stdio bridge, `soundbox ps` or `soundbox enhance`, it is sent to the server. See [Access token](https://mirli.app/docs/install-access/index.md#access-token). | | `MIRLI_ALLOWED_HOSTS` | server, Vite | Comma-separated `host` (any port) or `host:port` (that port only). Adds `Host` values the server accepts (UI, `/api/*` and `/mcp`) and trusted browser origins (CORS and the MCP `Origin` check); under `npm run dev` also Vite's `server.allowedHosts`, which reads it only as `SOUNDBOX_ALLOWED_HOSTS`. See [Host checks](https://mirli.app/docs/install-access/index.md#host-checks) and [SECURITY.md](https://github.com/HamSanders/soundbox/blob/main/SECURITY.md). | | `MIRLI_SANDBOXED` | server | `1` for a server whose users don't own the machine: nothing in the UI touches the host. See [Sandboxed mode](https://mirli.app/docs/install-access/index.md#sandboxed-mode). | | `MIRLI_DISABLE` | server | Comma-separated capabilities to turn off (`filesystem`, `reveal`, `downloads`, `local_models`, `custom_endpoints`, `updates`, `gpu_status`, `agent_connect`, `skills_install`, `logs`, `setup_wizard`). Turning off `custom_endpoints` also locks the prompt assistant's and artwork's external URLs and the OpenTelemetry endpoint. | | `MIRLI_URL` | stdio MCP bridge | Where the running server is. Default `http://127.0.0.1:17494`. Set `MIRLI_API_TOKEN` too if that server needs one. | | `OTEL_EXPORTER_OTLP_ENDPOINT` | server | OpenTelemetry collector for MCP call traces and metrics. Wins over the Settings value. | | `MIRLI_LOG_LEVEL` | server | `debug`, `info` (default), `warning`, `error` or `critical`; `warn` works too. Used when `--log-level` isn't given, so it reaches `npm run dev`, Docker and the desktop app, none of which pass the flag. An unknown value logs a warning and runs at `info`. See [Troubleshoot a source install](https://mirli.app/docs/install-troubleshooting/index.md#find-the-server-log). | | `MIRLI_IDLE_EXIT_MINUTES` | server | Exit (status 0) after this many minutes with no requests, none still being answered, and no queued or running jobs. For hosts that scale to zero and start the server again on the next request. Health checks don't count as use. Off by default. | | `MIRLI_UPDATE_CHECK` | server | `0` (or `false`, `off`, `no`) turns off the daily "is there a newer version?" request, whatever Settings says; Settings shows the switch as locked. `npm run dev` sets it to `0`. See [PRIVACY.md](https://mirli.app/docs/privacy/index.md). | | `MIRLI_UPDATE_URL` | server | Where the update check asks. Default `https://mirli.app/api/update`. | | `PORT` | server, Vite | The Vite dev server's port (default 5174). The server also trusts it as a dev origin. | | `SOUNDBOX_PORT` | `npm run dev`, Vite | The port `scripts/dev.mjs` starts the server on, and the port Vite proxies to. Default 17494. The `soundbox` CLI itself takes `--port`. | | `SOUNDBOX_DEV_HOST` | `npm run dev`, Vite | The address Vite listens on (`0.0.0.0`, a LAN IP). Default localhost. The server stays on `127.0.0.1`. No authentication, so open it only on a network you trust. | | `MIRLI_DESKTOP_PORT` | desktop shell | The port the desktop app starts, or adopts, its server on. Default 17494. Also read as `SOUNDBOX_DESKTOP_PORT`. | | `SOUNDBOX_NODE` | desktop shell | The Node to run the built server with, if `node` is not on `PATH`. | | `SOUNDBOX_PROJECT_ROOT` | desktop shell | The path to the checkout, if the shell can't find it from its own location. | | `VITE_MOCK` | app build | `1` runs the UI against the in-browser fake backend (`npm run dev:mock` sets it). | | `VITE_MOCK_FIXTURE` | app build | With `VITE_MOCK=1`, `demo` starts the fake backend from the demo library the screenshots are taken from (`npm run capture:media` sets it). | | `VITE_REPO_URL` | app build | The repository URL in the app's links. Default `https://github.com/HamSanders/soundbox`. | | `VITE_SITE_ORIGIN` | app and site builds | The absolute origin for canonical URLs and the site's RSS feed. | --- # Download models from the command line The `soundbox` command downloads, tries and removes models without the server or the app running. The **Models** page in the app uses the same catalogue and the same downloader. ## Before you begin - Build Mirli and install the audio.cpp runtime, as described in [Run Mirli from source](https://mirli.app/docs/install/index.md). - If your data folder is not in the default place, set `MIRLI_DATA_DIR`. These commands do not read the server's `--data-dir` flag. ## Download and try a model 1. List the catalogue: ```bash soundbox list ``` Each line shows a model's id and whether it is downloaded. 2. Download a model's weights: ```bash soundbox pull ``` Replace `` with an id from the list, such as `audiocpp-stable-audio-3-sfx`. Mirli downloads only the model's own files, not the whole Hugging Face repository. 3. Render a sound to check the model works: ```bash soundbox run "heavy wooden door slamming" --out test.wav ``` A file named `test.wav` appears in the current folder. Each model shows its licence before you download it. Some licences allow open use of the weights but forbid selling what the model makes. ## Remove a model To free the disk space a model uses, delete its weights: ```bash soundbox rm ``` ## Download a gated model None of the audio models is gated. The optional Stable Diffusion 3.5 Medium artwork model is, and so is any custom model you point at a gated repository. If a download fails with 401 or 403, the repository is gated and Mirli needs your Hugging Face token. Mirli cannot accept the terms for you. 1. Sign in to Hugging Face and accept the licence on the model's page, such as `huggingface.co/stabilityai/stable-diffusion-3.5-medium`. 2. Create a token with **read** access at . 3. In the app, go to **Settings > Models & engines > Hugging Face token** and paste the token. Alternatively, set `HF_TOKEN` in the server's environment. 4. Run `soundbox pull ` again. The server stores the token in its `settings.json` and never returns it over the API. ## Resume an interrupted download If a download stops partway, the partial file is kept. 1. Run `soundbox pull ` again, or on the **Models** page, click **Repair** on the model. The download continues from where it stopped. For what Mirli does at each stage of a download, see [Download behaviour](https://mirli.app/docs/install-cli/index.md#download-behaviour). ## What's next - [Add your own model](https://mirli.app/docs/audiocpp-models/index.md) - [Configuration](https://mirli.app/docs/install-config/index.md) - [Command-line reference](https://mirli.app/docs/install-cli/index.md) --- # Reach Mirli from another machine This guide opens a Mirli server to other machines, such as a rented GPU or a box on your LAN, with an access token so that only you can use it. It also covers putting the server behind a reverse proxy and running it for other people. > [!WARNING] > Without a token, anyone who can reach the port can generate audio, read and > delete your library, change settings and call every MCP tool. Set a token > before you bind any address other than loopback. ## Before you begin - Build Mirli as described in [Run Mirli from source](https://mirli.app/docs/install/index.md), or run the [Docker image](https://mirli.app/docs/install-docker/index.md). - Plan how the connection is encrypted: a reverse proxy with a certificate, a tunnel such as Tailscale, or a GPU host's own HTTPS proxy. Over plain `http://`, the token crosses the network unencrypted. ## Start the server with an access token 1. Generate a random token and put it in `MIRLI_API_TOKEN`: ```bash title="macOS / Linux" export MIRLI_API_TOKEN="$(node -p "crypto.randomBytes(32).toString('hex')")" ``` ```powershell title="Windows" $env:MIRLI_API_TOKEN = node -p "crypto.randomBytes(32).toString('hex')" ``` The token must be at least 16 characters. For Docker, pass it with `-e MIRLI_API_TOKEN=`. 2. Start the server on every interface: ```bash soundbox --host 0.0.0.0 ``` The startup banner shows `Access token -> required`. 3. Open the server's address in a browser and paste the token on the sign-in screen. The browser stays signed in for 30 days. 4. Optional: Connect an MCP client with the token in a header. For Claude Code: ```bash claude mcp add --transport http soundbox https:///mcp \ --header "Authorization: Bearer $MIRLI_API_TOKEN" ``` Replace `` with the name or address you reach the server by. If that is anything other than `localhost` or `127.0.0.1`, also list it in `MIRLI_ALLOWED_HOSTS`, or `/mcp` answers 403. What the token protects, and the rate limit on wrong tokens, are described in [Access control](https://mirli.app/docs/install-access/index.md#access-token). ## Put Mirli behind a reverse proxy 1. Start the server on loopback, listing the host name the proxy forwards in the `Host` header: ```bash MIRLI_ALLOWED_HOSTS=mirli.lan soundbox ``` To accept that name on one port only, write `mirli.lan:8443`. 2. Point Caddy or nginx at `127.0.0.1:17494`, and have it forward the original `Host` header. 3. If the proxy terminates HTTPS, have it send `X-Forwarded-Proto: https`, so the sign-in cookie is marked `Secure`. Use an access token as well, or a proxy that authenticates (basic auth, Authelia or Authentik). ## Open the dev servers to your network Under `npm run dev`, the server stays on `127.0.0.1` and only Vite listens more widely. 1. Start the dev servers with Vite listening on every interface, and list the name you reach it by: ```bash SOUNDBOX_DEV_HOST=0.0.0.0 SOUNDBOX_ALLOWED_HOSTS=mirli.lan npm run dev ``` 2. Open `http://:5174` from the other machine. Behind a proxy on the same machine, set only `SOUNDBOX_ALLOWED_HOSTS` and point the proxy at `127.0.0.1:5174`. For a LAN IP address, set only `SOUNDBOX_DEV_HOST`. The dev servers have no authentication. ## Run Mirli for other people When the people using Mirli don't own the machine it runs on, such as a shared server or a NAS: 1. Set an access token, as in [Start the server with an access token](#start-the-server-with-an-access-token). 2. Set `MIRLI_SANDBOXED=1` in the server's environment. 3. Restart the server. The UI then offers nothing that touches the host, and settings that name a path, a device, an engine or a URL are locked. To turn off only some of this, set `MIRLI_DISABLE` instead. Both are described in [Access control](https://mirli.app/docs/install-access/index.md#sandboxed-mode). ## What's next - [Access control](https://mirli.app/docs/install-access/index.md) - [Run Mirli in Docker](https://mirli.app/docs/install-docker/index.md) - [Use another Mirli as an endpoint](https://mirli.app/docs/endpoints/index.md#use-another-mirli) --- # Troubleshoot a source install This guide fixes the problems people run into most when they run Mirli from source or in Docker. Start with the server log: most of these problems name themselves there. ## Find the server log 1. Look for the log path in the server's startup output. By default it is: ```text /soundbox-.log ``` `` is the data folder, `~/.mirli` by default, and `` the server's port, 17494 by default. The file rotates at 10 MB and keeps three older copies, `.1` to `.3`. 2. To see everything that happened in one generation, search the log for the job's id: ```bash grep soundbox-17494.log ``` Every line about a job carries its id. Without shell access, `GET /api/logs?lines=200` returns the end of the same file as JSON. 3. Optional: For more detail, restart the server with `MIRLI_LOG_LEVEL=debug`. Each request to the prompt assistant, artwork and custom endpoints is then logged with its URL, status and timing. Keys, headers, prompts and lyrics are never logged. For the desktop app, set `MIRLI_LOG_LEVEL` as a user environment variable on Windows, or with `launchctl setenv` on macOS, then restart the app. The desktop shell writes its own startup lines to a separate file; see [About the desktop shell](https://mirli.app/docs/desktop-shell/index.md#logs). ## The Models page is empty or every request answers 502 The server is not running, so Vite on port 5174 has nothing to forward to. 1. Stop the dev servers. 2. Start both together from the repository root: ```bash npm run dev ``` If you started Vite alone with `npm run dev:ui`, start the server separately instead. ## The audio.cpp runtime is not installed If `soundbox model status audiocpp` says not installed, install it: ```bash soundbox model install audiocpp ``` To use a binary you built or downloaded instead, see [Use your own audio.cpp build](https://mirli.app/docs/audiocpp-binary/index.md). ## Generation is much slower than expected Generation is probably running on the CPU. 1. Check the `device` field of `GET /api/health`. 2. If it says `cpu` on a machine with a GPU, follow [Choose a backend](https://mirli.app/docs/audiocpp-binary/index.md#choose-a-backend). ## CUDA runs out of memory Only one model is loaded at a time, but a long clip can still fill a small card. Shorten the clip, or on the **Models** page, click **Unload** on the model and load it again. ## A model is installed but fails to load 1. On the **Models** page, open the model and read the error it shows. 2. For the full audio.cpp output, read the server log. A download that stopped partway shows as **Incomplete**, not installed. ## A model shows as Incomplete A download stopped before every file arrived. The **Models** page shows why. 1. On the **Models** page, click **Repair** on the model. Mirli downloads only what is missing and continues a half-fetched file. ## A download says there is not enough disk space The message gives the size still to download, the 2 GB Mirli keeps free, the free space and the folder. Free space on that drive, or move the weights to a larger one in either of these ways: - Move the whole data folder with `MIRLI_DATA_DIR`. See [Data folder](https://mirli.app/docs/install-config/index.md#data-folder). - Go to **Settings > Models & engines > Audio engine**, select **External**, and set **Models folder** to the new place. ## A download fails with 401 or 403 The repository is gated, and you have not accepted its terms or the token is missing. Follow [Download a gated model](https://mirli.app/docs/install-models/index.md#download-a-gated-model). ## Windows says the path cannot be found during a download The data folder path is too long for Windows' 260-character limit. Move the data folder somewhere short, such as `C:\mirli`, with `MIRLI_DATA_DIR`. ## A job stays queued for a long time The job queue runs one generation at a time, first in first out, so every job waits for the one ahead of it. 1. Check what is running with `GET /api/jobs`, or in the log. 2. For a queued job, `GET /api/jobs/` reports `queue_position` and a rough `eta_s`. The app's job panel shows the same. ## An MCP client cannot connect 1. Check the client uses `http://127.0.0.1:17494/mcp`. 2. If you started the server with `--host` on another address, add the name the client uses to `MIRLI_ALLOWED_HOSTS`, then restart the server. ## A reverse proxy gets 403 Forbidden host The proxy forwards a `Host` header the server does not know. Add that name to `MIRLI_ALLOWED_HOSTS` and restart the server. See [Put Mirli behind a reverse proxy](https://mirli.app/docs/install-remote/index.md#put-mirli-behind-a-reverse-proxy). ## What's next - [Configuration](https://mirli.app/docs/install-config/index.md) - [Access control](https://mirli.app/docs/install-access/index.md) - [Command-line reference](https://mirli.app/docs/install-cli/index.md) --- # Streaming speech > Status: **phase 1 built and run end to end** (the HTTP route, the GPU lock, > `supports.streaming`) on Supertonic 3, VoxCPM2 and OmniVoice. The WebSocket, the MCP tool and the > UI are still design. Sections marked _(to verify)_ need a measurement > before release. ## Measured (2026-11-05) The audio.cpp Windows CUDA build in `~/tools/audio.cpp` (the one the dev machine runs), RTX 5080. The same 26-word line each time; "first audio" is when the first chunk reached the client, "last" when the final one did. | Model | Cold, first audio | Warm, first audio | Warm, last chunk | Chunks | Audio | | --- | --- | --- | --- | --- | --- | | **VoxCPM2** (`audiocpp-voxcpm2`) | 5.95 s | **0.19 to 0.21 s** | 1.65 s | 48 x 160 ms | 7.7 s, 48 kHz | | OmniVoice (`audiocpp-omnivoice`) | 5.6 s | 0.63 s | same | 1 | 8.8 s, 24 kHz | | Supertonic 3 (`audiocpp-supertonic-3`) | 8.5 s | 0.10 to 0.14 s | same | 1 | 10.6 s, 44.1 kHz | - **VoxCPM2 is the one that really streams**: the first 160 ms of speech arrives in about 200 ms and the rest follows at roughly 3x real time. Use it for chat agents and long lines. - **OmniVoice and Supertonic send each line as one chunk.** Nothing arrives early, but Supertonic is so fast warm (10.6 s of speech in about 0.1 s) that it's the better pick for short game barks. - **Cloned voice, VoxCPM2:** works and streams (57 chunks). The first two reads with a new clip took 4.2 to 5.2 s to first audio, the third 0.17 s. _(to verify: what audio.cpp caches per reference clip.)_ - **Cloned voice, OmniVoice:** refused. audio.cpp needs the clip's transcript (`reference_text`), and Mirli voices don't store one yet. This affects OmniVoice cloning everywhere, not just streaming. - Cold times include loading both the offline and the streaming copy. - A client hanging up mid-stream released the GPU lock; the next request took 0.47 s. - `supports.streaming` came back true for all three from the build's `model_specs`, and `save: true` wrote a library sound. **What this build actually does** (and the code now handles): - `/v1/tasks/stream` ignores `stream_format: "sse"` and answers with one `{ events, result }` JSON body once the run is over, so it can't stream. `/v1/audio/speech` with `stream_format: "sse"` does stream. Mirli uses the speech route, and falls back to the task route only for the first stream of a model, because the speech route's PCM deltas carry no sample rate and the task route's WAVs do. The rate is remembered per model after that (an ordinary `/api/speak` read also records it). The catalogue's `sample_rate` was wrong for both VoxCPM2 (listed 44.1 kHz, really 48) and OmniVoice (really 24), so it isn't used for this. - Audio can come in `named_audio_outputs[].audio` rather than `audio`. - **Per-family request options go in `options`, not `request_options`.** audio.cpp ignored `request_options`, so before this branch every delivery knob (exaggeration, temperature and so on) was silently dropped whenever a model ran resident in the server. Fixed for generate, speak, convert and the stream. It showed up here because VoxCPM2 refuses to stream unless `retry_badcase=false` reaches it; Mirli now sets that for VoxCPM2 streams. Today `POST /api/speak` is a job: you submit a script, poll or watch `/api/jobs/{id}`, and get a finished WAV in the library. That's right for voiceovers and stories. It's wrong for anything conversational. A game NPC or a chat agent wants the first syllable out in a few hundred milliseconds, while the rest of the sentence is still being made, and usually doesn't want a library entry for every line at all. Streaming adds that second mode: **text in, audio chunks out, as they're made.** ## Who it's for - **Game TTS.** NPC barks and dialogue generated at runtime (Godot plugin, Unity/Unreal over HTTP). Needs low first-audio latency and raw PCM a game audio engine can push into a buffer. - **Chat agents.** An LLM writes its reply token by token; the agent wants to speak each sentence as soon as it's complete, not after the whole reply. - **The UI.** A "Play as it generates" preview in the Speak panel, so you hear a line before committing to it. ## What already exists underneath The `audiocpp_server` Mirli already runs (see [`server/src/models/audiocppRuntime.ts`](https://github.com/HamSanders/soundbox/blob/main/server/src/models/audiocppRuntime.ts)) streams natively. Upstream exposes: | Upstream route | What it does | | --- | --- | | `POST /v1/audio/speech` with `stream_format: "sse"` | OpenAI-shaped SSE: `speech.audio.delta` (base64 PCM) … `speech.audio.done`, `data: [DONE]` | | `POST /v1/audio/speech` with `stream_format: "audio"`, `response_format: "pcm"` | raw PCM over chunked transfer encoding | | `POST /v1/tasks/stream` | generic streaming run; SSE events carry a WAV per event plus `is_final` | Only families whose session implements the streaming run mode can do it. audio.cpp ships `model_specs/.json` beside its binaries, and each lists its `modes`; Mirli reads that folder and sets `supports.streaming` from it (`server/src/models/audiocppModes.ts`), so the flag follows whatever build is installed, including your own via `MIRLI_AUDIOCPP_BIN`. In the bundled **audio.cpp 0.6.1**, the TTS families that list `streaming` and that the Mirli catalogue carries are: | Model id | Family | | --- | --- | | `audiocpp-supertonic-3` | `supertonic` | | `audiocpp-voxcpm2` | `voxcpm2` | | `audiocpp-omnivoice` | `omnivoice` | | `audiocpp-neutts-2e` | `neutts` | | `audiocpp-dots-tts-*` | `dots_tts` | | `audiocpp-confucius4-tts` | `confucius4_tts` | Kokoro, Chatterbox, PocketTTS, IndexTTS2, Irodori and VibeVoice do **not** stream in 0.6.1. VoxCPM2 also needs `retry_badcase=false` when streaming _(to verify whether Mirli should set that automatically)_. audio.cpp fixes a model entry's run mode at load time, so a streamed read loads a second resident copy of the weights (`::stream`) next to the offline one. Both are held until the model unloads: plan on **twice the model's memory** while you use both `/api/speak` and the stream. So most of the work is in Mirli's own layer: a route, a capability flag, voice resolution, cancellation, and the clients. ## Design principles 1. **Not a job.** A stream is a connection, not a queued job with progress. It doesn't appear in `/api/jobs`, and dropping the connection cancels it. 2. **Nothing saved unless asked.** Conversational audio is disposable. Pass `save: true` to also write the joined result into the library as an ordinary `Sound` once the stream finishes. 3. **Same inputs as `/api/speak`.** Same `model`, `voice_id`, `seed`, `request_options`. A voice you made for a story works in a stream with no changes. 4. **Two wire formats, one route.** SSE for browsers and agents (JSON, metadata, errors in-band); raw PCM for game engines (no parsing). 5. **Fall back honestly.** A model that can't stream returns `409` with a message saying so. We do not fake streaming by generating the whole line and then chunking it — that hides exactly the latency people are asking about. _(An opt-in `allow_buffered: true` could be added later.)_ ## HTTP API ### `POST /api/speak/stream` Body: ```json { "model": "audiocpp-voxcpm2", "text": "Halt! Who goes there?", "voice_id": "guard-gruff", "format": "sse", "seed": 7, "request_options": { "temperature": "0.7" }, "save": false, "name": "Guard bark", "session_id": null, "project_id": null } ``` | Field | Default | Notes | | --- | --- | --- | | `model` | required | must report `supports.streaming: true` | | `text` | required | one utterance. For multi-line scripts use `/api/speak` or the socket below | | `voice_id` | model default | saved voice (built-in or clone), same as `/api/speak` | | `format` | `"sse"` | `"sse"` or `"pcm"` | | `save` | `false` | write the finished audio to the library (not normalised, so it sounds like what played) | | `steps`, `cfg`, `request_options`, `name`, `tags`, `project_id` | | as `/api/speak` | Not accepted: multi-line scripts (one request is one utterance) and `load_options` (a weights variant is chosen at load time; the request gets `409`). Output is at the model's own sample rate; resampling chunk by chunk would click at the joins, so it isn't offered. **`format: "sse"`** — `Content-Type: text/event-stream`: ```text event: start data: {"stream_id":"…","model":"audiocpp-voxcpm2","sample_rate":24000,"channels":1,"encoding":"pcm_s16le"} event: audio data: {"seq":0,"pcm":"","frames":4800} event: audio data: {"seq":1,"pcm":"…","frames":4800} event: done data: {"duration_s":1.84,"ttft_ms":212,"model_ttft_ms":180,"sound_id":null} ``` `ttft_ms` is what the caller waited: from the request to the first chunk, model load included. `model_ttft_ms` is audio.cpp's own figure, from the start of the run. On failure mid-stream: `event: error` with `{ "message": "…" }`, then the connection closes. `sound_id` is filled when `save: true`. `pcm` is interleaved when `channels` is more than 1. **`format: "pcm"`** — `Content-Type: audio/L16; rate=24000; channels=1`, chunked, raw little-endian 16-bit PCM and nothing else. The format is in the headers (`X-Soundbox-Sample-Rate`, `X-Soundbox-Channels`) so a client can set up its buffer before the first byte. Errors before the first chunk are normal JSON with a 4xx/5xx status; an error after audio has started just closes the stream (there's no in-band channel), and is logged. **Cancel:** close the connection. Because audio.cpp has no per-request cancel, Mirli stops the audio.cpp process when a listener leaves mid-stream (the same trade job cancel makes), so **the next request pays a model reload**. _(to verify: whether aborting `/v1/tasks/stream` alone stops the run, which would let us skip the kill.)_ **Errors before streaming starts:** | Status | When | | --- | --- | | `400` | unknown model or voice, or not a TTS model (same as `/api/speak`) | | `409` | `reason: "unsupported"`: the model can't stream on this build. `reason: "busy"`: a generation or another stream holds the GPU, with `retry_after_s` and `Retry-After` when there's an estimate | | `422` | bad body | ### `GET /api/speak/socket` (WebSocket) — phase 2 For agents that produce text incrementally, and for barge-in. One socket, many utterances: ```text → {"type":"config","model":"…","voice_id":"…","format":"pcm"} → {"type":"text","id":"u1","text":"Sure, I can help with that. ","flush":false} → {"type":"text","id":"u1","text":"Here's what I found.","flush":true} ← {"type":"start","id":"u1","sample_rate":24000} ← ← {"type":"done","id":"u1","ttft_ms":230} → {"type":"cancel","id":"u1"} // user interrupted the agent ``` The server buffers `text` until a sentence boundary or `flush: true`, then synthesises that sentence while more text arrives. Sentences queue in order. `cancel` drops everything queued for that id. This is the piece that makes "LLM tokens → speech" work without the client doing its own sentence split. ### Capability reporting `GET /api/models` reports `supports.streaming: boolean` per model (built). A build without `model_specs/` reports nothing as streaming. ## Concurrency There is one GPU and one resident model. A stream takes the same lock a job does. Rules: - A stream request that arrives while a job is running gets `409` with `retry_after_s` — not queued. Games and agents would rather know now and say something else than wait behind a 30-second music render. - A job submitted while a stream is running queues behind it, as jobs already do. - Only one stream at a time: a second concurrent request gets `409 busy`. _(Parallel streams on one resident model depend on upstream batching; not in v1.)_ - Model swaps: streaming a model that isn't loaded loads it first, and that load counts toward `ttft_ms`. Clients that care should call `POST /api/models/{id}/load` up front. ## MCP New tool: - `soundbox.speak_stream(text, model?, voice_id?, save?)` → returns when done, with `{ duration_s, ttft_ms, sound_id? }`. MCP tool results aren't a streaming audio channel, so this tool is mainly for agents that **play audio on the Mirli machine** (`play: true` routes the stream to the default output device server-side) or that want a saved `sound_id` with lower total latency. Agents that need the audio bytes as they arrive should use the HTTP route directly. The MCP doc will say so plainly rather than pretend otherwise. ## UI - **Speak panel:** when the selected model streams, the Generate button gets a companion **Preview** (▶) that plays as it generates through Web Audio (`AudioWorklet` fed from the SSE stream). Preview doesn't save; a "Keep" button after it finishes saves what you heard (same seed, `save: true` re-run, or keep the buffered PCM — _decide in implementation_). - **Model picker:** a small "streams" badge on models with `supports.streaming`. - **Voice page:** "Try this voice" uses streaming when available, so auditioning voices stops being a wait. - **Settings → API:** the endpoint and a copy-paste `curl` for streaming, next to the existing API key / port info. Out of scope for the UI: a live conversation mode. That's what the socket is for, from other apps. ## Client examples (ship with the docs) **curl** ```bash curl -N http://127.0.0.1:7777/api/speak/stream \ -H 'Content-Type: application/json' \ -d '{"model":"audiocpp-voxcpm2","text":"Stream this.","format":"sse"}' ``` **Browser / Electron** — `fetch` + `ReadableStream`, parse SSE, push PCM into an `AudioWorkletNode` ring buffer. **Python agent** — `httpx.stream(...)`, `sounddevice.RawOutputStream` with `format: "pcm"`. **Godot** — `HTTPClient` polling chunks into an `AudioStreamGenerator` playback. Fits the existing Godot editor plugin (`integrations/`). Each example goes in `docs/streaming-examples/` and is run against a real server before release — none get published untested. ## Implementation plan Steps 1 to 4 are built (`server/src/models/audiocppRuntime.ts` `streamTask`, `AudioCppModel.speakStream`, `JobManager.acquireExclusive`, `server/src/routes/speakStream.ts`, `server/test/speakStream.test.ts`). 1. **Runtime:** `AudioCppRuntime.stream(model, body, signal)` → `AsyncIterable` over upstream `/v1/audio/speech` SSE. Detect support from the binary; cache per binary path. 2. **Model layer:** `AudioCppModel.speakStream(text, opts)` sharing voice and request-option resolution with `speak()` (factor it out, don't copy). `supports.streaming` per family in the catalogue. 3. **Route:** `POST /api/speak/stream` in `server/src/routes/`, SSE + PCM writers, abort on `request.raw.on("close")`, GPU lock, optional save through the existing `dsp.processAndWrite` path. 4. **Tests:** fake runtime yielding chunks; assert SSE framing, PCM headers, cancel-on-disconnect releases the lock, 409 for non-streaming models. 5. **UI:** Preview button + worklet player; model badge. 6. **MCP tool**, **docs** (this page → user-facing; `API.md` + `ENDPOINTS.md` + `MCP.md` entries), **CHANGELOG**. 7. **Phase 2:** WebSocket with sentence buffering and barge-in. ## Open questions - Whether the first stream of a model can skip the task-route round trip (for example by reading the rate from `/v1/models` if a later build reports it). - The catalogue: VoxCPM2 and OmniVoice clone in audio.cpp but aren't marked `supports.voice_reference`, so Mirli won't attach a clip to them made for that model, and both list the wrong `sample_rate`. - Which bundled TTS families actually stream in our shipped binary, and their measured `ttft_ms` on a mid-range GPU and on CPU. - Whether a client abort upstream stops cleanly or needs the kill-and-reload. - Default chunk size: upstream's, or re-chunk to ~100 ms for steady game playback. - Auth: streaming inherits the existing API rules in `API.md` (localhost by default); confirm nothing extra is needed for the socket's `Origin` checks.