# Music

Create songs, instrumentals and loops as asynchronous jobs. Music has its own prompts and options, separate from spoken text.

`POST /v1/music/generations`

`GET /v1/music/generations/{job_id}`

`DELETE /v1/music/generations/{job_id}`

`GET /v1/music/generations/{job_id}/artifacts/{index}`

## Create a music job

POST /v1/music/generations requires model, prompt and an Idempotency-Key. Choose a music model and read its supported duration and lyrics options from the catalog.

- prompt describes the composition and is limited to 2,000 characters. lyrics_prompt can contain up to 5,000 characters. Supply lyrics when the model requires them.
- Use a supported duration_seconds value. Models with provider_default_duration choose the duration themselves; omit duration_seconds for those models.
- Speech voices and speech response formats belong to /v1/audio/speech. Music returns a media.job with HTTP 202. The job format is specific to uRouter.

### Music

```text
curl --fail-with-body "https://urouter.net/gateway/v1/music/generations" \
  -H "Authorization: Bearer $UROUTER_API_KEY" \
  -H 'Content-Type: application/json' \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
  "model": "YOUR_MUSIC_MODEL_ID",
  "prompt": "A quiet instrumental piano loop.",
  "duration_seconds": 60
}'
```

## Poll, then download

Poll GET /v1/music/generations/{job_id} until result_state is ready. Execution, settlement and delivery can finish at different times.

- Download each results[].download_path with the same account’s API key. Prefix paths beginning with /v1 with /gateway when using this site’s origin.
- Save the audio before result_expires_at. Use its content_type and returned filename rather than assuming MP3.
- DELETE on the job path requests cancellation. It does not guarantee that generation stopped or that a charge was reversed.
