# Custom endpoint reference

This page describes custom endpoints: the presets, the body template, how a
response is read, which hosts count as local, and the HTTP routes. To add
one, see [Send generation to another server](https://mirli.app/docs/endpoints/index.md).

## Presets

Presets for servers you run:

| Preset | Request | Notes |
|---|---|---|
| **LocalAI — ACE-Step music** | `POST /v1/sound-generation` | Sends `model_id`, `caption`, `lyrics`, `instrumental`, `bpm`, `keyscale` and `duration_seconds`. LocalAI's ACE-Step example uses `model` instead; a server that rejects `model_id` needs it renamed. |
| **LocalAI — sound effects** | `POST /v1/sound-generation` | ElevenLabs-shaped: `model_id`, `text`, `duration_seconds`. |
| **OpenAI-compatible speech (/v1/audio/speech)** | `POST /v1/audio/speech` | For LocalAI, OpenAI-compatible servers and most proxies. Asks for `response_format: "wav"`, so ffmpeg is not needed. |
| **Another Mirli — music**, **— sound effects**, **— speech** | `POST /api/render` | A Mirli on another machine. Sends `"keep": false`. |

Presets for hosted providers. Each uses your own account, the provider bills
it for every render including **Test**, and Mirli takes no cut. Each preset
links to the provider's price page. They were written from each provider's
API reference in November 2026.

| Preset | Request | Notes |
|---|---|---|
| **ElevenLabs — sound effects (your account)** | `POST https://api.elevenlabs.io/v1/sound-generation` | Up to 30 seconds. Answers in MP3, so ffmpeg is needed. On a plan that allows it, `output_format=wav_44100` in the URL gives WAV. |
| **ElevenLabs — music (your account)** | `POST https://api.elevenlabs.io/v1/music` | From 3 seconds to Mirli's limit of 5 minutes per render (ElevenLabs allows 10). MP3. Sends no lyrics; vocals are described in the prompt. |
| **ElevenLabs — speech (your account)** | `POST https://api.elevenlabs.io/v1/text-to-speech/{{voice}}` | Voices are ElevenLabs voice IDs, which go in the URL. The preset holds the ID from ElevenLabs' own example. MP3. |
| **fal — ACE-Step music (your account)** | `POST https://fal.run/fal-ai/ace-step/prompt-to-audio` | Answers with JSON that links to a WAV; the response path `audio.url` points at it. fal writes the tags and lyrics from the prompt. |

Servers that expose the same path don't always agree on the body: one
`/v1/audio/music` implementation takes `prompt` and `duration_seconds`,
another `input` and `duration`. That is why the body is a template.

## Templates

The body template is JSON with placeholders, for example:

```json
{
  "model": "ace-step-turbo",
  "bpm": {{bpm}},
  "keyscale": "{{key}}",
  "caption": "lofi, {{prompt}}",
  "duration_seconds": {{duration}}
}
```

Where a placeholder sits decides what it becomes:

| Placement | Example | Becomes |
|---|---|---|
| Bare | `{{bpm}}` | The JSON value: a number, `true`, `false` or `null`. |
| The whole string | `"{{key}}"` | The JSON value too, so the template stays valid JSON in an editor. |
| Inside a longer string | `"lofi, {{prompt}}"` | Text inserted into the string. |

- A field whose value comes out `null` is left out of the request. When a
  prompt names no key, `keyscale` is not sent.
- Values are JSON-encoded when inserted, so a quote or brace in a prompt
  cannot break the request.
- An unknown variable is rejected on save, with the list of valid names.
- Only `{{voice}}` and `{{language}}` may go in the URL, URL-encoded. A prompt
  or voice clip in a URL would end up in every proxy's access log.
- The composer shows only the controls the template uses: no `{{seed}}`, no
  seed control; `{{lyrics}}`, a lyrics box.

## Variables

| Variable | Value |
|---|---|
| `prompt` | The description from the composer. |
| `negative_prompt` | What to avoid, if the composer has one. |
| `lyrics` | Lyrics for a vocal track, or null. |
| `instrumental` | `true` when there are no lyrics. |
| `duration`, `duration_ms` | The requested length in seconds or milliseconds. |
| `bpm` | A tempo written in the prompt ("90 BPM"), or null. |
| `key` | A key written in the prompt ("A minor", "Ebm", "F# maj"), normalised to "Eb minor" form, or null. The note letter must be upper case. |
| `seed`, `steps`, `cfg` | Sampler settings, when set. |
| `text` | The line to speak (speech). |
| `voice` | The chosen voice, or the first in the endpoint's list (speech). |
| `voice_ref_b64` | A cloned voice's reference clip as base64 WAV (speech), or null. |
| `language` | A language code, if one was chosen (speech). |

## Responses

The response body is expected to be the audio:

| Format | How it is read |
|---|---|
| WAV | Decoded directly, detected by its header, whatever the `Content-Type` says. |
| `audio/pcm`, `audio/L16` | 16-bit mono at the endpoint's `pcm_sample_rate`, 24 kHz by default. Settable over the API only; the form has no field for it. |
| MP3, FLAC, Opus, AAC and others | Decoded with ffmpeg if it is on `PATH`. Otherwise the error says so. |

When **Response path (JSON only)** is set, such as `data.0.b64_json` or
`audio`, the value at that path can be:

| Value | How it is read |
|---|---|
| base64 audio | Decoded. A `data:audio/...;base64,` prefix is stripped. |
| A link to the audio file | Downloaded without the key, since it is usually on a CDN rather than the keyed host. fal and Replicate answer this way. |
| An object with a `url` | Read as a link. fal's answer has this shape. |

fal's answer, for example, looks like this:

```json
{
  "url": "https://example.com/audio.wav",
  "content_type": "audio/wav"
}
```

## Local and off-network hosts

An endpoint whose URL is not on this machine or the local network is marked
**Off-network** in the list, and the form and the model's description say
so. The prompt assistant and artwork each have an External mode that sends
their own requests the same way. The hostname decides; these count as local:

- `localhost` and loopback
- private IPv4 ranges: `127.*`, `10.*`, `172.16–31.*`, `192.168.*`,
  `169.254.*`
- the `100.64–127.*` range and `.ts.net` names that Tailscale uses
- IPv6 local addresses
- names without a dot, such as `homeserver`
- names ending in `.local`, `.lan`, `.home`, `.internal` or `.home.arpa`

A public name that resolves to a LAN address counts as off-network.

## Limits

| Limit | Value |
|---|---|
| Timeout | 10 minutes. A long music render on a busy GPU can take several minutes, and an early timeout would throw away a finished track. Cancelling the job aborts the request. |
| Progress | None streamed. The job shows "Waiting for <NAME>" until the response arrives. |
| Editing | No extend, cover, repaint, stem splitting or voice conversion; those need a local model. |
| Scope | Per profile, stored in that profile's `settings.json` under `audio_endpoints`. |
| Ids | Lower-case letters, digits and hyphens, up to 48 characters. |

## HTTP API

| Method | Path | Description |
|---|---|---|
| `GET` | `/api/endpoints` | Returns `{ endpoints, presets, variables }`. Keys appear only as `api_key_set`. |
| `PUT` | `/api/endpoints/:id` | Creates or replaces one endpoint. Omitting `api_key` keeps the saved key while the URL's origin is unchanged; `""` clears it. |
| `DELETE` | `/api/endpoints/:id` | Removes it. Sounds made with it stay in the library. |
| `POST` | `/api/endpoints/test` | The same body as `PUT`, plus optional `id` (a saved endpoint whose key to use) and `prompt`. Returns `{ duration_s, sample_rate, channels }`. |
