Flow Music Replace
curl --request POST \
--url https://api.snapgen.org/v1/music/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"source_task_id": "<string>",
"source_index": 123,
"version": "<string>",
"start_s": 123,
"end_s": 123,
"instruction": "<string>",
"title": "<string>",
"seed": 123,
"webhook": "<string>",
"webhook_secret": "<string>"
}
'import requests
url = "https://api.snapgen.org/v1/music/generations"
payload = {
"model": "<string>",
"source_task_id": "<string>",
"source_index": 123,
"version": "<string>",
"start_s": 123,
"end_s": 123,
"instruction": "<string>",
"title": "<string>",
"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>',
source_task_id: '<string>',
source_index: 123,
version: '<string>',
start_s: 123,
end_s: 123,
instruction: '<string>',
title: '<string>',
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>',
'source_task_id' => '<string>',
'source_index' => 123,
'version' => '<string>',
'start_s' => 123,
'end_s' => 123,
'instruction' => '<string>',
'title' => '<string>',
'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 \"source_task_id\": \"<string>\",\n \"source_index\": 123,\n \"version\": \"<string>\",\n \"start_s\": 123,\n \"end_s\": 123,\n \"instruction\": \"<string>\",\n \"title\": \"<string>\",\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 \"source_task_id\": \"<string>\",\n \"source_index\": 123,\n \"version\": \"<string>\",\n \"start_s\": 123,\n \"end_s\": 123,\n \"instruction\": \"<string>\",\n \"title\": \"<string>\",\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 \"source_task_id\": \"<string>\",\n \"source_index\": 123,\n \"version\": \"<string>\",\n \"start_s\": 123,\n \"end_s\": 123,\n \"instruction\": \"<string>\",\n \"title\": \"<string>\",\n \"seed\": 123,\n \"webhook\": \"<string>\",\n \"webhook_secret\": \"<string>\"\n}"
response = http.request(request)
puts response.read_bodyFlow Music
Flow Music Replace
Regenerate a time range of a Flow Music clip. $0.09 per request.
POST
/
v1
/
music
/
generations
Flow Music Replace
curl --request POST \
--url https://api.snapgen.org/v1/music/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"source_task_id": "<string>",
"source_index": 123,
"version": "<string>",
"start_s": 123,
"end_s": 123,
"instruction": "<string>",
"title": "<string>",
"seed": 123,
"webhook": "<string>",
"webhook_secret": "<string>"
}
'import requests
url = "https://api.snapgen.org/v1/music/generations"
payload = {
"model": "<string>",
"source_task_id": "<string>",
"source_index": 123,
"version": "<string>",
"start_s": 123,
"end_s": 123,
"instruction": "<string>",
"title": "<string>",
"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>',
source_task_id: '<string>',
source_index: 123,
version: '<string>',
start_s: 123,
end_s: 123,
instruction: '<string>',
title: '<string>',
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>',
'source_task_id' => '<string>',
'source_index' => 123,
'version' => '<string>',
'start_s' => 123,
'end_s' => 123,
'instruction' => '<string>',
'title' => '<string>',
'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 \"source_task_id\": \"<string>\",\n \"source_index\": 123,\n \"version\": \"<string>\",\n \"start_s\": 123,\n \"end_s\": 123,\n \"instruction\": \"<string>\",\n \"title\": \"<string>\",\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 \"source_task_id\": \"<string>\",\n \"source_index\": 123,\n \"version\": \"<string>\",\n \"start_s\": 123,\n \"end_s\": 123,\n \"instruction\": \"<string>\",\n \"title\": \"<string>\",\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 \"source_task_id\": \"<string>\",\n \"source_index\": 123,\n \"version\": \"<string>\",\n \"start_s\": 123,\n \"end_s\": 123,\n \"instruction\": \"<string>\",\n \"title\": \"<string>\",\n \"seed\": 123,\n \"webhook\": \"<string>\",\n \"webhook_secret\": \"<string>\"\n}"
response = http.request(request)
puts response.read_bodyflow-music-replace regenerates a time range of one of your clips from an instruction. The whole song is re-rendered with that range replaced.
| Property | Value |
|---|---|
| Model ID | flow-music-replace |
| Endpoint | POST /v1/music/generations (asynchronous task) |
| Group | Flow Music |
| Input | A clip from one of your earlier tasks, a time range, and an instruction |
| Result | One clip in result.tracks |
| Price | $0.09 per request (9 credits) |
string
required
Set to
flow-music-replace.string
required
The
id of your earlier task that holds the source clip. It must be your own task, must have succeeded, and must come from a model listed in Source tracks.integer
default:"1"
Position of the source clip in that task’s
result.tracks, counting from 1 (up to 8).string
default:"lyria-3-pro"
Lyria version:
lyria-3-pro (Lyria 3 Pro) or lyria-3.5 (Lyria 3.5).number
required
Start of the range to regenerate, in seconds (from 0 to 3,600, decimals allowed).
number
required
End of the range, in seconds. Must be greater than
start_s and within the source length.string
required
What the new section should sound like, up to 2,000 characters, for example
Replace this part with a piano version.string
Title of the new clip, up to 120 characters.
integer
Random seed, from 0 to 4,294,967,295. The same seed and request give similar, not identical, results.
string
Optional public
https URL that receives one signed event when the task finishes. See Task webhooks.string
Required with
webhook: 16 to 256 characters, used to sign the delivery.Request rules
The gateway checks these before it reserves any balance:end_smust be greater thanstart_s.
Source tracks
The source task must be your own succeeded task from one of these models:flow-music, flow-music-extend, flow-music-replace, flow-music-cover, flow-music-upload.
Send the task id as source_task_id and pick the clip with source_index. Each Flow Music task returns one clip, so source_index is normally 1. Never send provider track or clip IDs. See Reference earlier tasks.
Request
curl https://api.snapgen.org/v1/music/generations \
-H "Authorization: Bearer $SNAPGEN_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "flow-music-replace",
"source_task_id": "task_2f8KcX1mQpR7vT0yZa9Lb3",
"start_s": 10,
"end_s": 20,
"instruction": "Replace this part with a piano version"
}'
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.
Result
One clip arrives inresult.tracks[0], with its audio_url; result.urls lists the same file. Use this task as the source of later Flow Music operations.
{
"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
}
]
}
Result URLs are kept for about 72 hours. Download the files you want to keep.
See Music generation tasks for the task lifecycle, result fields, webhooks, and errors.