# Stream Music

`GET https://api.vultrinference.com/v1/music/{id}/stream`

The song as it renders: the job's `stream_url`, there while it is `pending` or `in_progress` on a model whose `/v1/music/models` entry has `streaming.progressive: true`. The answer is WAV (for minimax-music3 32 kHz, 16-bit, stereo, whatever `response_format` asked for) from its first byte, then follows the render live; the first audio arrives seconds in. Its header's sizes promise the `duration` asked for, the most the model can produce, since the real length is not known until the end; the stored output has its exact length.

A listener who connects late, even just after the job completed, hears it from the start: the stream is kept for 10 minutes after it ends. The response ends when the song does and cannot say why, so read the job when it ends: `completed`, or `failed`/`cancelled` (the audio heard is then not a whole song). If the job is retried after a server failure the stream starts over and a listener partway through is let go; connect again. Send your API key.

## Path parameters

- `id` (string, required): The music job's ID, `music_` followed by 24 hex characters.

## Query parameters

- `index` (integer): The output, as `outputs[]` will number it. [default 0, at least 0]

## Responses

- `200`: The song, as it renders
- `401`: The API key is missing, unknown or not active. Send it as Authorization: Bearer <key>. (error-payload)
- `404`: Not found, expired, or no output at that index (error-payload)
- `409`: The model does not stream, or the job finished and its stream is no longer kept (read content) (error-payload)

## Example

```bash
curl https://api.vultrinference.com/v1/music/{id}/stream \
  -H "Authorization: Bearer $VULTR_INFERENCE_API_KEY"
```

```python
import os
import requests

response = requests.get(
    "https://api.vultrinference.com/v1/music/{id}/stream",
    headers={"Authorization": f"Bearer {os.environ['VULTR_INFERENCE_API_KEY']}"},
)
print(response.status_code)
```

```javascript
const response = await fetch("https://api.vultrinference.com/v1/music/{id}/stream", {
  headers: {
    Authorization: `Bearer ${process.env.VULTR_INFERENCE_API_KEY}`,
  },
});
console.log(response.status);
```
