# Demucs > Split a song into the instrumental and the isolated vocal in a single call, priced by compute time rather than per minute of audio. ## Overview - **Endpoint**: `https://queue.modelrunner.run/meta/demucs` - **Model ID**: `meta/demucs` - **Category**: audio-to-audio - **Kind**: inference - **Tags**: demucs, htdemucs, meta, stem-separation, source-separation, audio-separation, vocal-remover, vocal-isolation, instrumental, acapella, karaoke, audio-to-audio, music ## Pricing - **Estimated Price**: $0.0184565 average per output ## Request Lifecycle This model runs on the ModelRunner **asynchronous queue API** — a single POST does not return the output. Every call requires an `Authorization: Key $MODEL_RUNNER_KEY` header. Run three steps: 1. **Submit** — `POST https://queue.modelrunner.run/meta/demucs` with a JSON body holding the input fields at the top level. The body may also include a reserved top-level `metadata` object — a flat string map (max 16 keys, key ≤64 / value ≤512 chars) stored on the request for your own tagging. It is never sent to the model; filter your request history with `GET https://queue.modelrunner.run/requests?metadata=` (exact key=value matches, AND-ed). The response carries request handles only (no output yet): ```json { "status": "IN_QUEUE", "request_id": "<21-char id>", "status_url": "https://queue.modelrunner.run/meta/demucs/requests//status", "response_url": "https://queue.modelrunner.run/meta/demucs/requests/", "cancel_url": "https://queue.modelrunner.run/meta/demucs/requests//cancel" } ``` 2. **Poll status** — `GET ` until `status` is `COMPLETED`. Possible values are `IN_QUEUE`, `IN_PROGRESS`, `COMPLETED`, `FAILED`, `CANCELLED`. A `FAILED` request responds with HTTP 400 and an `error` field. 3. **Read result** — `GET `. Returns the finished request, including the generated `output`: ```json { "id": "", "status": "COMPLETED", "output": ..., "input": ... } ``` The JavaScript and Python SDKs below perform steps 2–3 for you. In any language without an SDK (Swift, Go, Kotlin, etc.) you must implement the polling loop and the final result fetch yourself — see the cURL example for the full flow. ### Input Schema - **`audio`** (`string`, _required_): URL of the audio file to separate. This is built for a full-band music mix with the lead vocal present - a solo vocal, or a track that is already instrumental, has nothing to split. Decoding is ffmpeg-backed, so wav, mp3, flac and ogg/vorbis all work. There is no length limit: both runtime and price grow with the duration of the track, because this endpoint bills by second of compute. - **`model`** (`ModelEnum`, _optional_): Which separation network runs. htdemucs (the default) is the first Hybrid Transformer Demucs, trained on MusDB plus 800 songs. htdemucs_ft is its fine-tuned version: separation will take 4 times more time but might be a bit better, and because this endpoint bills compute time it costs roughly four times as much too. htdemucs_6s adds guitar and piano as internal sources, but the result here is still the same vocal/instrumental pair. hdemucs_mmi is the earlier Hybrid Demucs v3, retrained on the same data. mdx_q and mdx_extra_q are quantized versions of the older models - a smaller download, and quality can be slightly worse. Every value supports the vocal split, so the choice only trades quality against time and cost. - Default: `"htdemucs"` - Options: `"htdemucs"`, `"htdemucs_ft"`, `"htdemucs_6s"`, `"hdemucs_mmi"`, `"mdx_q"`, `"mdx_extra_q"` - **`shifts`** (`integer`, _optional_): How many random-shift passes to average. Each extra shift re-runs the whole separation on a shifted copy of the input and averages the results, which can steady a split that sounds unstable - and multiplies both the runtime and, because this endpoint bills compute time, the price. 1 (a single pass) is the default and is right for almost every track; 2 is the highest value accepted here. - Default: `1` - Range: `1` to `2` - **`clip_mode`** (`ClipModeEnum`, _optional_): What to do when a separated track goes past full scale. rescale (the default) scales the whole signal down so nothing clips; clamp allows hard clipping; none leaves the samples untouched. - Default: `"rescale"` - Options: `"rescale"`, `"clamp"`, `"none"` - **`mp3_bitrate`** (`integer`, _optional_): Bitrate in kbps for MP3 output. Higher means better quality and a larger file. Has no effect unless output_format is mp3. - Default: `320` - Range: `64` to `320` - **`output_format`** (`OutputFormatEnum`, _optional_): Container the two returned files are encoded in. mp3 (the default) is the smallest; flac is lossless and compressed; wav is lossless and uncompressed. Both files always come back in the same format. - Default: `"mp3"` - Options: `"mp3"`, `"flac"`, `"wav"` ### Output Schema _No `Output` schema properties are available._ ## Default Example **Input** ```json { "audio": "https://media.modelrunner.ai/PaQdzfOxdsluPtzQcXZDm.wav", "model": "htdemucs", "shifts": 1, "clip_mode": "rescale", "mp3_bitrate": 320, "output_format": "mp3" } ``` **Output** ```json [ "https://media.modelrunner.ai/mNhEfLc88IwRA0YGNaxpI.octet-stream", "https://media.modelrunner.ai/OSNrLEvB6z6fEPrdmL0OH.octet-stream" ] ``` ## Usage Examples ### cURL The queue API is asynchronous: submit the request, poll `status_url` until it is `COMPLETED`, then read the result from `response_url`. Requires `jq`. ```bash # 1. Submit the request (returns request handles, not the output) SUBMIT=$(curl --silent --request POST \ --url https://queue.modelrunner.run/meta/demucs \ --header "Authorization: Key $MODEL_RUNNER_KEY" \ --header "Content-Type: application/json" \ --data '{ "audio": "https://media.modelrunner.ai/PaQdzfOxdsluPtzQcXZDm.wav", "model": "htdemucs", "shifts": 1, "clip_mode": "rescale", "mp3_bitrate": 320, "output_format": "mp3" }') STATUS_URL=$(echo "$SUBMIT" | jq -r '.status_url') RESPONSE_URL=$(echo "$SUBMIT" | jq -r '.response_url') # 2. Poll until the request leaves the queue / in-progress state while true; do STATUS=$(curl --silent --url "$STATUS_URL" \ --header "Authorization: Key $MODEL_RUNNER_KEY" | jq -r '.status') echo "Status: $STATUS" case "$STATUS" in COMPLETED) break ;; FAILED|CANCELLED) echo "Request $STATUS"; exit 1 ;; esac sleep 1 done # 3. Read the finished request, including the generated output curl --silent --url "$RESPONSE_URL" \ --header "Authorization: Key $MODEL_RUNNER_KEY" ``` ### JavaScript ```javascript import { modelrunner } from "@modelrunner/client"; const result = await modelrunner.subscribe("meta/demucs", { input: { "audio": "https://media.modelrunner.ai/PaQdzfOxdsluPtzQcXZDm.wav", "model": "htdemucs", "shifts": 1, "clip_mode": "rescale", "mp3_bitrate": 320, "output_format": "mp3" } }); console.log(result.data); ``` ### Python ```python import asyncio import modelrunner_ai async def main(): response = await modelrunner_ai.submit_async( "meta/demucs", arguments={ "audio": "https://media.modelrunner.ai/PaQdzfOxdsluPtzQcXZDm.wav", "model": "htdemucs", "shifts": 1, "clip_mode": "rescale", "mp3_bitrate": 320, "output_format": "mp3" } ) result = await response.get() print(result["output"]) asyncio.run(main()) ``` ## Additional Resources - [Playground](https://modelrunner.ai/models/meta/demucs) - [OpenAPI Schema](https://modelrunner.ai/models/meta/demucs/openapi.json) - [LLM Instructions](https://modelrunner.ai/models/meta/demucs/llms.txt) - [GitHub](https://github.com/facebookresearch/demucs) - [License](https://github.com/facebookresearch/demucs/blob/main/LICENSE) - [Paper](https://arxiv.org/abs/2211.08553)