# SAM Audio — Separate > Isolate any sound from an audio mixture by describing it in plain language. ## Overview - **Endpoint**: `https://queue.modelrunner.run/meta/sam-audio/separate` - **Model ID**: `meta/sam-audio/separate` - **Category**: audio-to-audio - **Kind**: inference - **Tags**: sam-audio, meta, audio-separation, source-separation, stem-separation, audio-to-audio, text-guided, audio-editing ## Pricing - **Price**: $0.001667 per output second ## 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/sam-audio/separate` 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/sam-audio/separate/requests//status", "response_url": "https://queue.modelrunner.run/meta/sam-audio/separate/requests/", "cancel_url": "https://queue.modelrunner.run/meta/sam-audio/separate/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 - **`prompt`** (`string`, _required_): Text prompt describing the sound to isolate. - **`audio_url`** (`string`, _required_): URL of the audio file to process (WAV, MP3, FLAC supported). - **`acceleration`** (`AccelerationEnum`, _optional_): The acceleration level to use, trading speed against quality. - Default: `"balanced"` - Options: `"fast"`, `"balanced"`, `"quality"` - **`chunk_overlap`** (`number`, _optional_): Overlap duration (seconds) between chunks for crossfade blending. - Default: `5` - Range: `0` to `30` - **`output_format`** (`OutputFormatEnum`, _optional_): Output audio format. - Default: `"wav"` - Options: `"wav"`, `"mp3"` - **`predict_spans`** (`boolean`, _optional_): Automatically predict temporal spans where the target sound occurs. - Default: `false` - **`max_chunk_duration`** (`number`, _optional_): Maximum audio duration (seconds) to process in a single pass. - Default: `60` - Range: `10` to `60` - **`reranking_candidates`** (`integer`, _optional_): Number of candidates to generate and rank. Values above 1 incur an additional charge per extra candidate. - Default: `1` - Range: `1` to `7` ### Output Schema _No `Output` schema properties are available._ ## Default Example **Input** ```json { "prompt": "dog barking", "audio_url": "https://media.modelrunner.ai/JbyO9TzNupSFoqNrlmaWe.mp3", "acceleration": "balanced", "chunk_overlap": 5, "output_format": "wav", "predict_spans": false, "max_chunk_duration": 60, "reranking_candidates": 1 } ``` **Output** ```json "https://media.modelrunner.ai/blBo7sWZaAZlIR05MpC2Q.wav" ``` ## 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/sam-audio/separate \ --header "Authorization: Key $MODEL_RUNNER_KEY" \ --header "Content-Type: application/json" \ --data '{ "prompt": "dog barking", "audio_url": "https://media.modelrunner.ai/JbyO9TzNupSFoqNrlmaWe.mp3", "acceleration": "balanced", "chunk_overlap": 5, "output_format": "wav", "predict_spans": false, "max_chunk_duration": 60, "reranking_candidates": 1 }') 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/sam-audio/separate", { input: { "prompt": "dog barking", "audio_url": "https://media.modelrunner.ai/JbyO9TzNupSFoqNrlmaWe.mp3", "acceleration": "balanced", "chunk_overlap": 5, "output_format": "wav", "predict_spans": false, "max_chunk_duration": 60, "reranking_candidates": 1 } }); console.log(result.data); ``` ### Python ```python import asyncio import modelrunner_ai async def main(): response = await modelrunner_ai.submit_async( "meta/sam-audio/separate", arguments={ "prompt": "dog barking", "audio_url": "https://media.modelrunner.ai/JbyO9TzNupSFoqNrlmaWe.mp3", "acceleration": "balanced", "chunk_overlap": 5, "output_format": "wav", "predict_spans": false, "max_chunk_duration": 60, "reranking_candidates": 1 } ) result = await response.get() print(result["output"]) asyncio.run(main()) ``` ## Additional Resources - [Playground](https://modelrunner.ai/models/meta/sam-audio/separate) - [OpenAPI Schema](https://modelrunner.ai/models/meta/sam-audio/separate/openapi.json) - [LLM Instructions](https://modelrunner.ai/models/meta/sam-audio/separate/llms.txt)