Tutorial · Go · ~10 min
Separate Audio Stems in Go
Split full multitrack stems from any mix with a Go job — BS-RoFormer-class models behind one call.
What you will build
A small script that uploads a media file to the Source Separation API, polls the job until it finishes, and prints the output URL. The full job lifecycle is the same in every language — only the HTTP client differs.
1. Get an API key
Sign up at mlslabs.io and copy your key from the dashboard. Every request sends it in the X-API-Key header.
2. Submit the job
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
"time"
)
func main() {
var payload map[string]any
_ = json.Unmarshal([]byte(`{"input": "s3://bucket/song.wav", "stems": ["drums", "bass", "vocals", "other"]}`), &payload)
body, _ := json.Marshal(payload)
req, _ := http.NewRequest("POST", "https://api.mlslabs.io/v1/source-separation/jobs", bytes.NewReader(body))
req.Header.Set("X-API-Key", "YOUR_API_KEY")
req.Header.Set("Content-Type", "application/json")
resp, _ := http.DefaultClient.Do(req)
var job map[string]any
json.NewDecoder(resp.Body).Decode(&job)
resp.Body.Close()
for job["status"] != "succeeded" && job["status"] != "failed" {
time.Sleep(3 * time.Second)
r, _ := http.NewRequest("GET", job["url"].(string), nil)
r.Header.Set("X-API-Key", "YOUR_API_KEY")
r2, _ := http.DefaultClient.Do(r)
json.NewDecoder(r2.Body).Decode(&job)
r2.Body.Close()
}
fmt.Println("Output:", job["output_url"])
}3. Poll until it finishes
Jobs run asynchronously — you get a job URL back immediately, then poll status until it reaches succeeded or failed. Most jobs finish in seconds to a few minutes depending on input length.
4. Download the result
The output_url points at your rendered file in object storage. Pipe it straight into your pipeline: transcode the HDR master, upload the cleaned episode, or ship the SRT to your translation vendor.
Same job, any language
The request body is identical across languages — a JSON payload with input, options, and an optional webhook. Point the same payload at our webhook URL and you do not even need the polling loop.
FAQ
Common questions
Does the API run on my GPU?
No. Rendering happens on mlslabs GPU workers, so the script runs on any machine — a laptop, a Lambda, or a CI runner.
Can I swap the API key at runtime?
Yes — read it from an environment variable or secret store instead of hardcoding it.
What formats does the output support?
MP4, MOV and MKV for video APIs; WAV, MP3 and FLAC for audio APIs. Set the format in the job payload.