# Generate music

Source: https://provod.ai/en/docs/audio-music

The Music API at `https://api.provod.ai` runs generation as a background job. Send a [workspace API key](/en/docs/authentication) in `Authorization: Bearer $PROVOD_API_KEY` on every job request, including downloads. All `/v1/audio/music/jobs` endpoints also accept the `/api/v1` prefix in place of `/v1`.

*A Suno v6 job returns two downloadable MP3 tracks, at indexes 0 and 1, after it completes.*

## Choose a model

Use `GET /api/models?kind=audio` and select available models whose `audio.operations` contains `music`. You can also use `GET /v1/models?output_modalities=music`. Use the exact model ID and check its `audio.profiles` for supported request modes, duration, and output count.

## Create a job

`POST /v1/audio/music/jobs` accepts up to 1 MiB of JSON. The request shape depends on the selected profile. The examples below show the fields for each mode.

### Prompt

Use a short description of the track. `instrumental` defaults to `false`. Fixed-duration profiles accept an integer `duration_ms` from 3,000 to 600,000, within the model's range. Omit the field for automatic-duration models such as `suno/v6`.

Use a fresh `Idempotency-Key` for each new job. The optional header accepts 1–200 printable ASCII characters with no spaces. If the submission times out, retry with the same key and body. Reusing the key with a different body returns `409`. The commands use `curl` and `jq`. Replace the example key values before running them.

```bash
export PROVOD_API_KEY="sk_..."
export MUSIC_REQUEST_ID="music-demo-001"

curl --fail-with-body --silent --show-error \
  https://api.provod.ai/v1/audio/music/jobs \
  -H "Authorization: Bearer $PROVOD_API_KEY" \
  -H 'Content-Type: application/json' \
  -H "Idempotency-Key: $MUSIC_REQUEST_ID" \
  --data '{"model":"suno/v6","prompt":"Warm jazz trio with brushed drums","instrumental":true}' \
  -o music-job.json
```

### Custom lyrics

Use a profile with `customLyrics: true`, such as `suno/v6`. Send `lyrics.text` and both style arrays. `lyrics.title` and the top-level `instrumental` flag are optional.

```json
{
  "model": "suno/v6",
  "lyrics": {
    "text": "The lights come on across the bay",
    "title": "Across the Bay",
    "positiveStyles": ["acoustic folk"],
    "negativeStyles": ["distorted guitars"]
  },
  "instrumental": false
}
```

### Separate song description and lyrics

Choose a MiniMax Music profile with `inputModes[].kind: "prompt_lyrics"`. Send `prompt` and `lyrics.text` together. The profile selects the duration automatically and returns one 44.1 kHz MP3. See the catalog for the price per request.

Music 1.5, 2.0 and 2.5+ accept 10–2,000 characters in `prompt` and 10–3,500 in `lyrics.text`. Music 2.5 accepts an empty `prompt` and 1–3,500 characters in `lyrics.text`. The API counts Unicode code points separately and applies the profile's combined UTF-8 byte limit.

```json
{
  "model": "minimax/music-2.5",
  "prompt": "",
  "lyrics": {
    "text": "[Verse]\nThe lights come on across the bay"
  }
}
```

Use the model ID returned by the catalog. Omit `duration_ms` and `instrumental` for this profile.

### Composition plan

Use a profile with `compositionPlan: true`, such as `elevenlabs/music_v2_5`. Set `version` to `1` and send the song-wide styles and ordered sections. Each section lasts 3,000–120,000 ms, with a total limit of 600,000 ms and any narrower limits from the profile. Supply both style arrays and the `lyrics` array for each section. Use an empty `lyrics` array for an instrumental section.

```json
{
  "model": "elevenlabs/music_v2_5",
  "composition": {
    "version": 1,
    "positiveStyles": ["soft piano"],
    "negativeStyles": [],
    "sections": [
      {
        "name": "Intro",
        "durationMs": 12000,
        "positiveStyles": ["sparse"],
        "negativeStyles": [],
        "lyrics": []
      }
    ]
  }
}
```

## Check the job and download MP3s

A submission returns `202 Accepted` with `Cache-Control: no-store`. The JSON contains `id`, `object: "audio.music.job"`, `model`, `status`, `polling_url`, `output_count`, `outputs`, `charge`, `error_code`, `created_at`, and `completed_at`. Use the job ID or follow the relative `polling_url` on the same API origin.

Poll `GET /v1/audio/music/jobs/{id}` while the status is `pending` or `in_progress`. Stop at `completed` or `failed`. On failure, read `error_code`. When present, `charge` contains a decimal string `amount` and its `currency`.

```bash
JOB_ID=$(jq -er '.id' music-job.json)

curl --fail-with-body --silent --show-error \
  -H "Authorization: Bearer $PROVOD_API_KEY" \
  "https://api.provod.ai/v1/audio/music/jobs/$JOB_ID" \
  -o music-status.json

jq '{status, outputs, charge, error_code}' music-status.json
```

On completion, `outputs` lists all confirmed tracks in increasing `index` order. Each entry includes `index`, `content_type`, `byte_length`, `sample_rate_hz`, `channels`, and a relative `content_url`. Suno v6 returns tracks `0` and `1` under a single request charge.

`GET /v1/audio/music/jobs/{id}/content?outputIndex=0` streams the first track. Use `outputIndex=1` for the second. The default is `0`. The alias `index` accepts the same values. If you send both parameters, they must agree. The response includes `Content-Type: audio/mpeg`, `Content-Length`, `Cache-Control: private, no-store`, and `Content-Disposition: attachment; filename="music-<id>-<index>.mp3"`.

After `completed`, download each entry in `outputs`:

```bash
jq -er '.outputs[] | [.index, .content_url] | @tsv' music-status.json |
while read -r index url; do
  curl --fail --silent --show-error \
    -H "Authorization: Bearer $PROVOD_API_KEY" \
    "https://api.provod.ai$url" \
    -o "music-$JOB_ID-$index.mp3" || exit 1
done
```

## List jobs

`GET /v1/audio/music/jobs` returns music jobs created through the public API in the current workspace. The `200 OK` body has `object: "list"`, `data`, and `next_cursor`. Set `limit` to 1–100 (default 20). Optionally filter by `status` and exact `model`. Pass `next_cursor` as `cursor` with the same filters for the next page. A `null` cursor marks the last page.

## HTTP errors

| Status | Meaning                                                                  |
| ------ | ------------------------------------------------------------------------ |
| `400`  | Invalid parameters, index, or model profile for the request.             |
| `401`  | Missing or invalid API key.                                              |
| `402`  | Insufficient workspace balance.                                          |
| `403`  | A management key was used, or `FIRST_TOP_UP_REQUIRED`.                   |
| `404`  | Model, job, or track unavailable. A track may still be processing.       |
| `409`  | The same `Idempotency-Key` was used with a different body.               |
| `413`  | The JSON body exceeds 1 MiB.                                             |
| `429`  | The API key spending limit was reached (`API_KEY_SPEND_LIMIT_EXCEEDED`). |
| `503`  | Music generation or pricing is temporarily unavailable.                  |

## Client MCP

Connect your client to `https://api.provod.ai/mcp` and authorize the workspace. `models_explore` lists available image, video, and music models by default. Set `kind: "music"` or `kind: "audio"` to see music models only. For example, `q: "suno"` finds `suno/v6` when available.

Call `generate_music` with `model` at the top level and one of the request modes above. Supply the mode fields and applicable `instrumental`, `duration_ms`, and `idempotency_key` at the top level or inside `params`. For example:

```json
{
  "model": "suno/v6",
  "params": {
    "prompt": "Warm jazz trio with brushed drums",
    "instrumental": true,
    "idempotency_key": "mcp-music-demo-001"
  }
}
```

`generate_music` requires workspace permission `images:write` and allows four submissions per minute by default. It returns `{ outcome: "submitted", results: [generation] }`. Pass the returned job ID as `jobId` to `job_status`. Follow `poll_after_seconds` while active, or use `job_status` with `sync: true` or `jobs_wait` for a bounded wait. `job_display`, `show_generation_by_ids`, and `show_generations` return full generation records. In `show_generations` use `type: "music"` to filter history, or omit `type` for mixed history.

Read the full record's `outputs[]` to retrieve every track. A completed Suno v6 generation has separate entries for `0` and `1`. The compact `jobs_wait` result provides the first track only.

* `outputs[].downloadUrl` downloads the track directly without a Bearer header. The signed URL expires after 15 minutes. Call an authenticated generation read tool to refresh it.
* Pass `outputs[].resourceUri` (`provod://generation/music/{id}/{index}`) to `resources/read` for the base64-encoded MP3. Each resource read is capped at 25 MiB and requires `images:read`.
* `GET /mcp/artifacts/music/{id}/{index}` streams an MP3 with a Bearer credential and `images:read` in the selected workspace.
