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

# Flow Music

> Generate a track from a style prompt, lyrics, or both with Flow Music (Google Lyria 3 Pro or Lyria 3.5). $0.09 per request.

`flow-music` generates one track with Flow Music, which runs Google Lyria. Describe the sound in `sound_prompt`, supply `lyrics`, or both, and optionally set the tempo and length. Each request returns exactly one clip, which later Flow Music operations can extend, rework, split, export, or render as a video.

| Property | Value |
| - | - |
| Model ID | `flow-music` |
| Endpoint | `POST /v1/music/generations` (asynchronous task) |
| Group | Flow Music |
| Input | Text: a style prompt, lyrics, or both |
| Versions | `lyria-3-pro` (default) or `lyria-3.5` |
| Length | 1 to 240 seconds |
| Result | One clip in `result.tracks` |
| Price | \$0.09 per request (9 credits), for either version |

Confirm live rates on the [SnapGen models page](https://snapgen.org/models). Failed tasks are not charged.

<ParamField body="model" type="string" required>
  Set to `flow-music`.
</ParamField>

<ParamField body="version" type="string" default="lyria-3-pro">
  Lyria version: `lyria-3-pro` (Lyria 3 Pro) or `lyria-3.5` (Lyria 3.5).
</ParamField>

<ParamField body="title" type="string">
  Title of the new clip, up to 120 characters.
</ParamField>

<ParamField body="sound_prompt" type="string">
  Style or sound description, up to 2,000 characters, for example `upbeat pop music with piano`. Send `sound_prompt`, `lyrics`, or both.
</ParamField>

<ParamField body="lyrics" type="string">
  Lyrics, up to 3,000 characters. [`flow-music-lyrics`](/api-manual/audio/flow-music-lyrics) can write them.
</ParamField>

<ParamField body="bpm" type="integer">
  Tempo in beats per minute, from 1 to 300.
</ParamField>

<ParamField body="length" type="integer">
  Length of the track in seconds, from 1 to 240.
</ParamField>

<ParamField body="seed" type="integer">
  Random seed, from 0 to 4,294,967,295. The same seed and request give similar, not identical, results.
</ParamField>

<ParamField body="webhook" type="string">
  Optional public `https` URL that receives one signed event when the task finishes. See [Task webhooks](/api-reference/webhooks).
</ParamField>

<ParamField body="webhook_secret" type="string">
  Required with `webhook`: 16 to 256 characters, used to sign the delivery.
</ParamField>

## Request rules

The gateway checks these before it reserves any balance:

* Send `sound_prompt`, `lyrics`, or both.

## Request

```bash theme={null}
curl https://api.snapgen.org/v1/music/generations \
  -H "Authorization: Bearer $SNAPGEN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "flow-music",
    "title": "Morning Drive",
    "sound_prompt": "Upbeat pop with bright piano and handclaps",
    "length": 60
  }'
```

To sing your own words with Lyria 3.5, add lyrics and select the version:

```bash theme={null}
curl https://api.snapgen.org/v1/music/generations \
  -H "Authorization: Bearer $SNAPGEN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "flow-music",
    "version": "lyria-3.5",
    "title": "Longest Night",
    "sound_prompt": "Anthemic rock ballad, big drums, soaring guitar",
    "lyrics": "[Verse 1]\nEven the longest night turns to dawn\n[Chorus]\nWe rise again",
    "bpm": 80,
    "length": 120
  }'
```

The response is HTTP `202` with a task object and a `Location: /v1/tasks/{id}`
header. Poll [`GET /v1/tasks/{id}`](/api-reference/task-status) every 10 to 20
seconds until `status` is `succeeded` or `failed`.

<CodeGroup>
  ```python Python theme={null}
  import json
  import os
  import time
  from urllib.request import Request, urlopen

  API = "https://api.snapgen.org/v1"
  AUTH = {"Authorization": f"Bearer {os.environ['SNAPGEN_API_KEY']}"}

  submit = Request(
      f"{API}/music/generations",
      data=json.dumps({
          "model": "flow-music",
          "title": "Morning Drive",
          "sound_prompt": "Upbeat pop with bright piano and handclaps",
          "length": 60,
      }).encode(),
      headers={**AUTH, "Content-Type": "application/json"},
  )
  with urlopen(submit) as response:
      task = json.load(response)

  while task["status"] in ("queued", "processing"):
      time.sleep(15)
      with urlopen(Request(f"{API}/tasks/{task['id']}", headers=AUTH)) as response:
          task = json.load(response)

  if task["status"] != "succeeded":
      raise RuntimeError(task["error"])
  print(task["result"]["tracks"][0]["audio_url"])
  ```

  ```javascript Node.js theme={null}
  const API = "https://api.snapgen.org/v1";
  const auth = { Authorization: `Bearer ${process.env.SNAPGEN_API_KEY}` };

  const submitted = await fetch(`${API}/music/generations`, {
    method: "POST",
    headers: { ...auth, "Content-Type": "application/json" },
    body: JSON.stringify({
      model: "flow-music",
      title: "Morning Drive",
      sound_prompt: "Upbeat pop with bright piano and handclaps",
      length: 60,
    }),
  });
  if (!submitted.ok) throw new Error(await submitted.text());
  let task = await submitted.json();

  while (task.status === "queued" || task.status === "processing") {
    await new Promise((resolve) => setTimeout(resolve, 15_000));
    task = await (await fetch(`${API}/tasks/${task.id}`, { headers: auth })).json();
  }
  if (task.status !== "succeeded") throw new Error(JSON.stringify(task.error));
  console.log(task.result.tracks[0].audio_url);
  ```
</CodeGroup>

## Result

One clip in `result.tracks[0]`, with its `audio_url` and, when the provider
returns them, `wav_url` and `duration_seconds`. `result.urls` lists the audio
file.

```json theme={null}
{
  "urls": [
    "https://cdn.example.com/music/morning-drive.m4a"
  ],
  "tracks": [
    {
      "index": 1,
      "id": "a41aade4-993e-4d28-b56f-d97e7ef7167c",
      "audio_url": "https://cdn.example.com/music/morning-drive.m4a",
      "wav_url": "https://cdn.example.com/music/morning-drive.wav",
      "duration_seconds": 60.2
    }
  ]
}
```

## Next steps

Pass this task's `id` as `source_task_id` to another Flow Music model. Each
edit returns a new clip, so chain the latest task for the next step.

| Model | Does | Price |
| - | - | - |
| [`flow-music-extend`](/api-manual/audio/flow-music-extend) | Continues the clip from a chosen second by up to 164 seconds. | \$0.09 |
| [`flow-music-replace`](/api-manual/audio/flow-music-replace) | Regenerates a time range from an instruction. | \$0.09 |
| [`flow-music-cover`](/api-manual/audio/flow-music-cover) | Rearranges the whole clip in a new style. | \$0.09 |
| [`flow-music-stems`](/api-manual/audio/flow-music-stems) | Splits vocals and instrumental into a ZIP archive. | \$0.09 |
| [`flow-music-download`](/api-manual/audio/flow-music-download) | Exports the clip as MP3 or WAV. | \$0.03 |
| [`flow-music-video`](/api-manual/audio/flow-music-video) | Renders the clip into an MP4 video. | \$0.03 |

<Note>
  Result URLs are kept for about 72 hours. Download the files you want to
  keep. See [Music generation tasks](/api-reference/music-generations) for
  task references, webhooks, and errors.
</Note>
