> ## Documentation Index
> Fetch the complete documentation index at: https://docs.soundpiece.co/llms.txt
> Use this file to discover all available pages before exploring further.

# Remix a track

> Make new variations of a track, with or without vocals, in a new style and optionally with new lyrics

`create.remix_track` takes a track you already have, with or without vocals, and makes new variations of it in the style your `prompt` describes. Add `lyrics` to have the result sing new words. Use it to re-style a track in another genre, to get fresh versions of a music bed, or to personalise a song with new lyrics (a name, a brand, an occasion).

***

## What you get back

The prompt always sets the style. Whether the result has vocals, and what they sing, follows from the source and from whether you send `lyrics`:

| | Source with vocals | Source without vocals |
| - | - | - |
| **With `lyrics`** | The result sings your lyrics. | The result sings your lyrics. |
| **Without `lyrics`** | The result keeps the source's own vocals. | The result stays instrumental. |

***

## The request

| Field | Required | What it is |
| - | - | - |
| `source` | yes | The track to remix: `{"url": "https://..."}`, an HTTPS link [on a public address](https://docs.soundpiece.co/errors.md#source-url-refused-422) to a WAV, MP3 or FLAC file, with or without vocals, from 1 second to 5 minutes long. |
| `prompt` | yes | The style to take the source toward, up to 1,024 characters, e.g. `"cinematic, electronic"` or `"acoustic folk, warm, female vocal"`. |
| `lyrics` | no | New words for the result to sing, up to 3,000 characters, with section markers such as `[Verse]` and `[Chorus]`. Leave it out to keep the source's own vocals (or none). |
| `n_variations` | no | How many different variations to make, from 1 to 3. Defaults to 1. |
| `loudness` | no | Normalise every variation to a target loudness, at no extra cost. Leave it out to get them as produced. See [Loudness](https://docs.soundpiece.co/loudness.md). |
| `idempotency_key` | yes | A UUID that identifies this job. The [reference client](https://docs.soundpiece.co/client.md) fills it in for you. |
| `callback_url` | no | An HTTPS address to receive a [webhook](https://docs.soundpiece.co/webhooks.md) when the work is finished. |

Every field, with its exact rules: [submit](https://docs.soundpiece.co/api-reference/create/remix_track/submit.md) and [poll](https://docs.soundpiece.co/api-reference/create/remix_track/poll.md) in the API Reference.

***

## Example

This re-styles a track into two cinematic variations, keeping its own vocals (if it has any), and saves them. It uses the [reference client](https://docs.soundpiece.co/client.md); save `soundpiece.py` or `soundpiece.mjs` next to it first.

```python remix.py theme={null}
import soundpiece

remix = soundpiece.run("create.remix_track", {
    "source": {"url": "https://example.com/audio/song.mp3"},
    "prompt": "cinematic, electronic",
    "n_variations": 2,
})

for number, output in enumerate(remix["outputs"], start=1):
    soundpiece.download(output["url"], f"remix-{number}.flac")
    print(f"Saved remix-{number}.flac ({output['duration']:.0f} s)")
```

```javascript remix.mjs theme={null}
import { run, download } from "./soundpiece.mjs";

const remix = await run("create.remix_track", {
  source: { url: "https://example.com/audio/song.mp3" },
  prompt: "cinematic, electronic",
  n_variations: 2,
});

for (const [index, output] of remix.outputs.entries()) {
  await download(output.url, `remix-${index + 1}.flac`);
  console.log(`Saved remix-${index + 1}.flac (${Math.round(output.duration)} s)`);
}
```

```bash cURL theme={null}
#!/usr/bin/env bash
# Submit, wait and download by hand. Needs curl, jq and uuidgen.
set -euo pipefail
API=https://api.soundpiece.co/v1
AUTH="Authorization: Bearer $SOUNDPIECE_API_KEY"

# 1. Submit. Sending this exact body again (same idempotency_key) is safe.
body=$(jq -n --arg key "$(uuidgen)" '{
  idempotency_key: $key,
  source: { url: "https://example.com/audio/song.mp3" },
  prompt: "cinematic, electronic",
  n_variations: 2
}')
response=$(curl --silent --show-error --max-time 30 --request PUT "$API/create.remix_track" \
  --header "$AUTH" --header "Content-Type: application/json" --data "$body")
result=$(jq -e .remixed_track <<<"$response") || { echo "$response"; exit 1; }
id=$(jq -r .id <<<"$result")

# 2. Wait. Each call returns as soon as the work is finished, or after 20 seconds.
while [ "$(jq -r .status <<<"$result")" = processing ]; do
  response=$(curl --silent --show-error --max-time 30 "$API/create.remix_track?id=$id&wait=true" \
    --header "$AUTH")
  result=$(jq -e .remixed_track <<<"$response") || { echo "$response"; exit 1; }
done

# 3. Download each variation, or show what went wrong.
if [ "$(jq -r .status <<<"$result")" = failed ]; then
  jq .error <<<"$result"
  exit 1
fi
number=0
for url in $(jq -r '.outputs[].url' <<<"$result"); do
  number=$((number + 1))
  curl --silent --show-error --fail --output "remix-$number.flac" "$url"
  echo "Saved remix-$number.flac"
done
```

***

## The result

`run` returns the finished `remixed_track` object, with one entry in `outputs` per variation:

```json theme={null}
{
  "id": "op_01ks2qmt3wk17f3g9h0j2m5n8p",
  "status": "ready",
  "created_at": "2026-11-26T09:15:02Z",
  "idempotency_key": "b8c9d0e1-f2a3-4b4c-9d5e-6f7a8b9c0d1e",
  "prompt": "cinematic, electronic",
  "lyrics": null,
  "n_variations": 2,
  "outputs": [
    { "url": "https://cdn.soundpiece.co/...signed...", "expires_at": "2026-11-26T09:31:40Z", "duration": 156.4 },
    { "url": "https://cdn.soundpiece.co/...signed...", "expires_at": "2026-11-26T09:31:40Z", "duration": 171.9 }
  ],
  "error": null
}
```

| Field | What it means |
| - | - |
| `prompt`, `lyrics`, `n_variations` | What you asked for. `lyrics` is `null` when you didn't send any. The source URL is never echoed. |
| `loudness` | Present only if you asked for normalisation (not in this example). |
| `outputs[].url` | A signed link to one variation, as a FLAC file (44.1 kHz). It needs no API key. |
| `outputs[].expires_at` | When the link stops working. Poll the operation again for a fresh one. |
| `outputs[].duration` | The variation's length in seconds. |
| `outputs[].loudness` | Present only if you asked for normalisation: `lufs`, `true_peak_dbtp` and `compressed`, measured on that variation. |

***

## Choosing parameters

* **Prompt.** Describe where to take the track: genre, mood, tempo, instruments and voice, as comma-separated tags or a short phrase, e.g. `"Dreamy, melancholic synthwave, mid-tempo"`.
* **Lyrics or not?** Leave `lyrics` out to keep what the source has: its own vocals, or none. Send them to have the result sing new words, whether or not the source has vocals:

  ```json theme={null}
  {
    "source": { "url": "https://example.com/audio/song.mp3" },
    "prompt": "acoustic folk, warm, female vocal",
    "lyrics": "[Verse]\nMorning light on the harbour wall\n\n[Chorus]\nHappy birthday, Sam, this song is for you"
  }
  ```

  Put each section marker (`[Intro]`, `[Verse]`, `[Chorus]`, `[Bridge]`, `[Outro]`, `[Instrumental]`) on its own line, and each sung line on its own line under it.
* **Source.** Any WAV, MP3 or FLAC from 1 second to 5 minutes, with or without vocals.
* **`n_variations`.** Each variation is a different take on the same request. Ask for two or three when you want to choose; each costs the same as one.
* **Loudness.** Off unless you include the block. See the [loudness normalisation guide](https://docs.soundpiece.co/guides/adapt/normalise_loudness.md#choosing-a-target-by-destination) for which target to pick.

***

## Errors

**When you submit** (the request is refused, nothing is charged):

| Status | `type` | Why |
| - | - | - |
| `422` | `string_too_short` / `string_too_long` | `prompt` is empty or over 1,024 characters, or `lyrics` is empty or over 3,000. (Leave `lyrics` out rather than sending an empty one.) |
| `422` | `missing` | `source` or `prompt` is missing. |
| `422` | `source_url_scheme` / `source_url_host` / `source_url_unresolvable` / `source_url_not_public` | The source's URL isn't `https`, has no host, has a host that can't be found, or resolves to an address that isn't public. See [source URL refused](https://docs.soundpiece.co/errors.md#source-url-refused-422). |
| `422` | `source_too_large` | The source's server says the file is over 50 MB. (When it doesn't say, the size is checked during processing instead.) |
| `422` | `idempotency_key_reused` | The key was already used for a different endpoint. |
| `402` | `insufficient_credits` | Your balance is below 4 credits per variation. |

**While processing** (the operation finishes as `failed`, with an `error.code`):

| Code | Why |
| - | - |
| `tos_violation` | The prompt, lyrics or source were rejected by our content policy. |
| `source_unreachable` | The source URL couldn't be fetched. |
| `source_format_unsupported` | The file isn't WAV, MP3 or FLAC audio. |
| `source_too_short` | The audio is shorter than 1 second. |
| `source_too_long` | The audio is longer than 5 minutes. |
| `source_too_large` | The file is larger than 50 MB. |
| `internal_error`, `generation_timeout` | Something went wrong on our side. Resubmit with the same idempotency key. |

**Source limits for this endpoint:** WAV, MP3 or FLAC, from 1 second to 5 minutes long, and at most 50 MB.

See [Errors](https://docs.soundpiece.co/errors.md) for the response shapes, and for the errors every endpoint can return (`401`, `403`, `429`).

***

## Cost

**4 credits per variation**, so `n_variations: 2` costs 8. Normalisation costs nothing extra. Resending a request with the same idempotency key is not charged again.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.