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

# Suno Upload and extend audio

> Upload your own audio and continue it from a chosen point in the same style, producing a longer, seamless song; each request makes two songs.

`ai-music-api/upload-and-extend-audio` starts from the audio you upload (`upload_url`) and keeps writing in the original track's style and sound, producing a longer, seamless piece of music in two different versions. Use it to grow a demo, a snippet or an existing work into a full song.

* `upload_url` and `model` are all it needs; the lyrics (`lyrics` or `prompt`), `title` and `style` are optional.
* `continue_at` sets the second of the original track where the extension begins.
* With `instrumental: true` the extension has no vocals.

The songs can then be extended, covered, separated into stems, turned into music videos and more (`task_id` + `audio_id`).

## Setup

The Suno endpoints use an asynchronous task protocol: every endpoint creates its task with `POST /api/v1/jobs/createTask` (`model` selects the endpoint and the parameters go in `input`) and is queried with `GET /api/v1/jobs/recordInfo?taskId=`; with `callBackUrl` the result is pushed to that URL when the task finishes. See the [Suno introduction](https://docs.dreamto.ai/en/music/suno.md) for the flow, chaining tasks and how long files are kept. The base URL is `https://api.dreamto.ai`; send the API Key in the `Authorization: Bearer` header.

Every response has HTTP status 200; the `code` in the body tells the outcome: `200` is success, anything else an error (see the response examples of each endpoint).

| Endpoint | Purpose |
| - | - |
| [`POST /api/v1/jobs/createTask`](https://docs.dreamto.ai/en/api-reference/suno-upload-extend/create-task) | Create task |
| [`GET /api/v1/jobs/recordInfo?taskId=...`](https://docs.dreamto.ai/en/api-reference/suno-upload-extend/query-task) | Get task |
| [`POST callBackUrl`](https://docs.dreamto.ai/en/api-reference/suno-upload-extend/task-callback) | Task callback |

## Parameters

`model` is `ai-music-api/upload-and-extend-audio`; the parameters go in `input`. Requests that break a rule return `code: 422`; no task is created or charged.

| Field | Values |
| - | - |
| `upload_url` | Required: public `http` / `https` URL of the audio to extend, up to 8 minutes long |
| `model` | Required: `V6` / `V6_MINI` / `V6_WILD`, matching the version of the source music |
| `instrumental` | Optional, default `false`; `true` extends as an instrumental and then `lyrics`, `prompt` and `vocal_gender` are not allowed |
| `lyrics` | Optional lyrics of the extension, up to 5,000 characters; takes priority over `prompt` |
| `prompt` | Optional, used as the lyrics when `lyrics` is absent, up to 5,000 characters |
| `style` | Optional, up to 1,000 characters |
| `title` | Optional, up to 100 characters |
| `continue_at` | Optional second of the original track where the extension begins; greater than `0` and less than the track's length |
| `negative_tags` | Optional styles or traits to avoid |
| `vocal_gender` | Optional `m` / `f`; not allowed for instrumentals |
| `style_weight / weirdness_constraint / audio_weight` | Optional, `0`–`1` with at most 2 decimals |
| `variety` | Optional integer from `0` to `4`, default `1` |
| `persona_id / persona_model` | Optional Persona ID or Voice ID and its type (`style_persona` / `voice_persona`); with `voice_persona` it must be a ready voice of this account |

## Pricing

Billed per request: each succeeded task is charged once at the model price shown in the console. The balance is checked for that price when the task is created (`code: 402` when insufficient); invalid requests and failed tasks are not charged.

## Quick start

Create a task to get `data.taskId`, poll about every 10 seconds and read `response` once `state` is `success`; or pass `callBackUrl` to be called back when the task finishes. `$DREAMTO_API_KEY` is your API Key.

```bash cURL theme={null}
# 1. Create the task
curl -X POST "https://api.dreamto.ai/api/v1/jobs/createTask" \
  -H "Authorization: Bearer $DREAMTO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "ai-music-api/upload-and-extend-audio",
    "input": {
      "upload_url": "https://your-domain.com/audio/morning-coffee.mp3",
      "instrumental": false,
      "lyrics": "[Verse]\nSteam curls up from the morning cup\n[Chorus]\nGood morning, coffee, wake me up",
      "style": "Cheerful acoustic folk-pop",
      "title": "Good Morning, Coffee Extended",
      "continue_at": 20,
      "model": "V6"
    }
  }'

# 2. Query the task
curl "https://api.dreamto.ai/api/v1/jobs/recordInfo?taskId=7d3f0a9c41e85b2f6a1c9e04b8d27f53" \
  -H "Authorization: Bearer $DREAMTO_API_KEY"
```

```python Python theme={null}
import os
import time

import requests

BASE_URL = "https://api.dreamto.ai"
HEADERS = {"Authorization": f"Bearer {os.environ['DREAMTO_API_KEY']}"}

payload = {
    "model": "ai-music-api/upload-and-extend-audio",
    "input": {
        "upload_url": "https://your-domain.com/audio/morning-coffee.mp3",
        "instrumental": False,
        "lyrics": "[Verse]\nSteam curls up from the morning cup\n[Chorus]\nGood morning, coffee, wake me up",
        "style": "Cheerful acoustic folk-pop",
        "title": "Good Morning, Coffee Extended",
        "continue_at": 20,
        "model": "V6"
    }
}

created = requests.post(f"{BASE_URL}/api/v1/jobs/createTask", headers=HEADERS, json=payload, timeout=60).json()
if created["code"] != 200:
    raise SystemExit(f"{created['code']}: {created['msg']}")
task_id = created["data"]["taskId"]
while True:
    record = requests.get(f"{BASE_URL}/api/v1/jobs/recordInfo", headers=HEADERS, params={"taskId": task_id}, timeout=60).json()["data"]
    if record["state"] in ("success", "fail"):
        break
    time.sleep(10)
if record["state"] == "success":
    for track in record["response"]["data"]:
        print(track["id"], track["title"], track["audio_url"])
else:
    print(record["failCode"], record["failMsg"])
```

## Callback

Pass `callBackUrl` (a public `http` / `https` URL) when creating the task; when the task succeeds or fails DreamTo `POST`s the result there once ([callback format](https://docs.dreamto.ai/en/api-reference/suno-upload-extend/task-callback.md)): on success `code` is `200`, `data.callbackType` is `complete`, `data.task_id` is the task ID and `data.data` the result; on failure `code` is the failure code (not `200`), `msg` the reason, and `data` has only `callbackType` and `task_id`. DreamTo calls back once when the task finishes and sends no intermediate-stage (`text` / `first`) callbacks.

The request carries `X-DreamTo-Event: task.completed`, `X-DreamTo-Timestamp` (UTC, RFC 3339) and `X-DreamTo-Signature`:

```
X-DreamTo-Signature = hex( HMAC-SHA256( secret, X-DreamTo-Timestamp + "." + data.task_id + "." + status ) )
```

`status` is `success` when the task succeeded and `failed` when it failed. The secret is generated in the DreamTo console; without one no signature header is sent. Answer with any `2xx` to acknowledge; otherwise the callback is retried.

## Notes

* Each request makes two extended songs, listed in `response.data`; each has its own `id` (the `audio_id` of follow-up endpoints), `audio_url` (MP3), `stream_audio_url` (streaming), `image_url` (cover), lyrics in `prompt`, style `tags` and `duration` in seconds.
* This endpoint is always in custom mode; do not pass `custom_mode`.
* `upload_url` must be a publicly downloadable audio URL of up to 8 minutes; `model` should match the version the source music was made with.
* `continue_at` must be greater than `0` and less than the length of the uploaded audio; a value beyond the track's length fails when the task runs.
* `vocal_gender` only raises the likelihood of that voice and is not guaranteed.
* Generated files are kept for 14 days; download them in time.
* `taskId` is issued by DreamTo (32 hex digits) and can only be queried with an API Key of the same account; an unknown or expired task returns `code: 422` with `msg: recordInfo is null`.
* The body accepts only `model`, `callBackUrl` and `input`; undeclared `input` fields, wrong types and values that break a rule return `code: 422` with an English reason in `msg`; no task is created or charged.
* Every file link in a result (audio, cover image, video and so on) is a DreamTo download link (`/v1/tasks/{task_id}/artifacts/...`) that works without an API Key and supports `Range`; files are kept for 14 days after the task is created, so download them promptly.
* `param` echoes the create request, with `input` as a JSON string that needs a second parse; the credits used are not returned, and the charge is shown in the DreamTo console bills.
* `failCode` / `failMsg` of a failed task come from the model service (content moderation, a source audio that cannot be downloaded and so on); internal errors are reported as `failCode: "500"` with `failMsg: "Internal Error, Please try again later."`.


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