Flow Music
curl --request POST \
--url https://api.snapgen.org/v1/music/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"version": "<string>",
"title": "<string>",
"sound_prompt": "<string>",
"lyrics": "<string>",
"bpm": 123,
"length": 123,
"seed": 123,
"webhook": "<string>",
"webhook_secret": "<string>"
}
'import requests
url = "https://api.snapgen.org/v1/music/generations"
payload = {
"model": "<string>",
"version": "<string>",
"title": "<string>",
"sound_prompt": "<string>",
"lyrics": "<string>",
"bpm": 123,
"length": 123,
"seed": 123,
"webhook": "<string>",
"webhook_secret": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: '<string>',
version: '<string>',
title: '<string>',
sound_prompt: '<string>',
lyrics: '<string>',
bpm: 123,
length: 123,
seed: 123,
webhook: '<string>',
webhook_secret: '<string>'
})
};
fetch('https://api.snapgen.org/v1/music/generations', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.snapgen.org/v1/music/generations",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model' => '<string>',
'version' => '<string>',
'title' => '<string>',
'sound_prompt' => '<string>',
'lyrics' => '<string>',
'bpm' => 123,
'length' => 123,
'seed' => 123,
'webhook' => '<string>',
'webhook_secret' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.snapgen.org/v1/music/generations"
payload := strings.NewReader("{\n \"model\": \"<string>\",\n \"version\": \"<string>\",\n \"title\": \"<string>\",\n \"sound_prompt\": \"<string>\",\n \"lyrics\": \"<string>\",\n \"bpm\": 123,\n \"length\": 123,\n \"seed\": 123,\n \"webhook\": \"<string>\",\n \"webhook_secret\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.snapgen.org/v1/music/generations")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"<string>\",\n \"version\": \"<string>\",\n \"title\": \"<string>\",\n \"sound_prompt\": \"<string>\",\n \"lyrics\": \"<string>\",\n \"bpm\": 123,\n \"length\": 123,\n \"seed\": 123,\n \"webhook\": \"<string>\",\n \"webhook_secret\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.snapgen.org/v1/music/generations")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"<string>\",\n \"version\": \"<string>\",\n \"title\": \"<string>\",\n \"sound_prompt\": \"<string>\",\n \"lyrics\": \"<string>\",\n \"bpm\": 123,\n \"length\": 123,\n \"seed\": 123,\n \"webhook\": \"<string>\",\n \"webhook_secret\": \"<string>\"\n}"
response = http.request(request)
puts response.read_bodyFlow Music
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.
POST
/
v1
/
music
/
generations
Flow Music
curl --request POST \
--url https://api.snapgen.org/v1/music/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"version": "<string>",
"title": "<string>",
"sound_prompt": "<string>",
"lyrics": "<string>",
"bpm": 123,
"length": 123,
"seed": 123,
"webhook": "<string>",
"webhook_secret": "<string>"
}
'import requests
url = "https://api.snapgen.org/v1/music/generations"
payload = {
"model": "<string>",
"version": "<string>",
"title": "<string>",
"sound_prompt": "<string>",
"lyrics": "<string>",
"bpm": 123,
"length": 123,
"seed": 123,
"webhook": "<string>",
"webhook_secret": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: '<string>',
version: '<string>',
title: '<string>',
sound_prompt: '<string>',
lyrics: '<string>',
bpm: 123,
length: 123,
seed: 123,
webhook: '<string>',
webhook_secret: '<string>'
})
};
fetch('https://api.snapgen.org/v1/music/generations', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.snapgen.org/v1/music/generations",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model' => '<string>',
'version' => '<string>',
'title' => '<string>',
'sound_prompt' => '<string>',
'lyrics' => '<string>',
'bpm' => 123,
'length' => 123,
'seed' => 123,
'webhook' => '<string>',
'webhook_secret' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.snapgen.org/v1/music/generations"
payload := strings.NewReader("{\n \"model\": \"<string>\",\n \"version\": \"<string>\",\n \"title\": \"<string>\",\n \"sound_prompt\": \"<string>\",\n \"lyrics\": \"<string>\",\n \"bpm\": 123,\n \"length\": 123,\n \"seed\": 123,\n \"webhook\": \"<string>\",\n \"webhook_secret\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.snapgen.org/v1/music/generations")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"<string>\",\n \"version\": \"<string>\",\n \"title\": \"<string>\",\n \"sound_prompt\": \"<string>\",\n \"lyrics\": \"<string>\",\n \"bpm\": 123,\n \"length\": 123,\n \"seed\": 123,\n \"webhook\": \"<string>\",\n \"webhook_secret\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.snapgen.org/v1/music/generations")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"<string>\",\n \"version\": \"<string>\",\n \"title\": \"<string>\",\n \"sound_prompt\": \"<string>\",\n \"lyrics\": \"<string>\",\n \"bpm\": 123,\n \"length\": 123,\n \"seed\": 123,\n \"webhook\": \"<string>\",\n \"webhook_secret\": \"<string>\"\n}"
response = http.request(request)
puts response.read_bodyflow-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 |
Style or sound description, up to 2,000 characters, for example
upbeat pop music with piano. Send sound_prompt, lyrics, or both.Lyrics, up to 3,000 characters.
flow-music-lyrics can write them.Random seed, from 0 to 4,294,967,295. The same seed and request give similar, not identical, results.
Optional public
https URL that receives one signed event when the task finishes. See Task webhooks.Request rules
The gateway checks these before it reserves any balance:- Send
sound_prompt,lyrics, or both.
Request
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
}'
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
}'
202 with a task object and a Location: /v1/tasks/{id}
header. Poll GET /v1/tasks/{id} every 10 to 20
seconds until status is succeeded or failed.
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"])
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);
Result
One clip inresult.tracks[0], with its audio_url and, when the provider
returns them, wav_url and duration_seconds. result.urls lists the audio
file.
{
"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’sid 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 | Continues the clip from a chosen second by up to 164 seconds. | $0.09 |
flow-music-replace | Regenerates a time range from an instruction. | $0.09 |
flow-music-cover | Rearranges the whole clip in a new style. | $0.09 |
flow-music-stems | Splits vocals and instrumental into a ZIP archive. | $0.09 |
flow-music-download | Exports the clip as MP3 or WAV. | $0.03 |
flow-music-video | Renders the clip into an MP4 video. | $0.03 |
Result URLs are kept for about 72 hours. Download the files you want to
keep. See Music generation tasks for
task references, webhooks, and errors.