Skip to main content
POST
/
v1
/
music
/
generations
/
replaceFlowMusic
curl --request POST \
  --url https://api.apimart.ai/v1/music/generations/replaceFlowMusic \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "model": "flowmusic",
    "clip_id": "abc123-def456",
    "start_s": 10,
    "end_s": 20,
    "instruction": "Replace with a piano version"
  }'
import requests

url = "https://api.apimart.ai/v1/music/generations/replaceFlowMusic"

payload = {
    "model": "flowmusic",
    "clip_id": "abc123-def456",
    "start_s": 10,
    "end_s": 20,
    "instruction": "Replace with a piano version"
}

headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
const url = "https://api.apimart.ai/v1/music/generations/replaceFlowMusic";

const payload = {
  model: "flowmusic",
  clip_id: "abc123-def456",
  start_s: 10,
  end_s: 20,
  instruction: "Replace with a piano version"
};

const headers = {
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
};

fetch(url, {
  method: "POST",
  headers: headers,
  body: JSON.stringify(payload)
})
  .then(response => response.json())
  .then(data => console.log(data))
  .catch(error => console.error('Error:', error));
{
  "code": 200,
  "data": [
    {
      "status": "submitted",
      "task_id": "task_01KWXVHGTG5JM33S8FG1K90YQ6"
    }
  ]
}
{
  "error": {
    "message": "end_s must be greater than start_s",
    "type": "invalid_request",
    "param": "",
    "code": "invalid_request"
  }
}
{
  "error": {
    "message": "Insufficient balance",
    "type": "invalid_request",
    "param": "",
    "code": "quota_not_enough"
  }
}
{
  "error": {
    "message": "Current group capacity is saturated, please retry later",
    "type": "rate_limit_error",
    "param": "",
    "code": "rate_limit_error"
  }
}
curl --request POST \
  --url https://api.apimart.ai/v1/music/generations/replaceFlowMusic \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "model": "flowmusic",
    "clip_id": "abc123-def456",
    "start_s": 10,
    "end_s": 20,
    "instruction": "Replace with a piano version"
  }'
import requests

url = "https://api.apimart.ai/v1/music/generations/replaceFlowMusic"

payload = {
    "model": "flowmusic",
    "clip_id": "abc123-def456",
    "start_s": 10,
    "end_s": 20,
    "instruction": "Replace with a piano version"
}

headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
const url = "https://api.apimart.ai/v1/music/generations/replaceFlowMusic";

const payload = {
  model: "flowmusic",
  clip_id: "abc123-def456",
  start_s: 10,
  end_s: 20,
  instruction: "Replace with a piano version"
};

const headers = {
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
};

fetch(url, {
  method: "POST",
  headers: headers,
  body: JSON.stringify(payload)
})
  .then(response => response.json())
  .then(data => console.log(data))
  .catch(error => console.error('Error:', error));
{
  "code": 200,
  "data": [
    {
      "status": "submitted",
      "task_id": "task_01KWXVHGTG5JM33S8FG1K90YQ6"
    }
  ]
}
{
  "error": {
    "message": "end_s must be greater than start_s",
    "type": "invalid_request",
    "param": "",
    "code": "invalid_request"
  }
}
{
  "error": {
    "message": "Insufficient balance",
    "type": "invalid_request",
    "param": "",
    "code": "quota_not_enough"
  }
}
{
  "error": {
    "message": "Current group capacity is saturated, please retry later",
    "type": "rate_limit_error",
    "param": "",
    "code": "rate_limit_error"
  }
}

Authentication

Authorization
string
required
All endpoints require Bearer Token authenticationGet your API Key:Visit the API Key management page to get your API KeyAdd it to the request header:
Authorization: Bearer YOUR_API_KEY

Request Parameters

model
string
required
Model name, must be "flowmusic" (case-insensitive)
clip_id
string
required
Source music clip_id, from a successful task’s result.music[].clip_id
start_s
number
required
Replacement start time (seconds)
end_s
number
required
Replacement end time (seconds)
end_s must be greater than start_s and cannot exceed the source clip’s duration.
instruction
string
required
Editing instruction for the replaced sectionExample: "Replace with a piano version"
title
string
Title of the music after replacement
seed
integer
Random seed, used to reproduce or control the generation result

Response

code
integer
Response status code, 200 on success
data
array
Array of returned data

Use Cases

Scenario 1: Replace seconds 10-20 with a piano version

{
  "model": "flowmusic",
  "clip_id": "abc123-def456",
  "start_s": 10,
  "end_s": 20,
  "instruction": "Replace with a piano version"
}
Query Task ResultsSection replacement is an asynchronous task; a task_id is returned after submission. Use the Get Task Status endpoint to query generation progress and results. The replacement output is a new clip_id (the whole song is re-rendered with the specified segment replaced); use the new clip_id for subsequent operations.

Completed Task Result Example

Query response example (GET /v1/music/tasks/{task_id}):
{
  "code": 200,
  "data": {
    "id": "task_01KWXVHGTG5JM33S8FG1K90YQ6",
    "status": "completed",
    "progress": 100,
    "created": 1783413392,
    "completed": 1783413454,
    "actual_time": 62,
    "cost": 0.048,
    "credits_cost": 0.48,
    "result": {
      "music": [
        {
          "clip_id": "9508d1fe-633e-464b-8a40-c6368e5464fa",
          "title": "Untitled (Replaced)",
          "duration_seconds": "181.58933333",
          "create_time": "2026-07-07T08:37:13.864452Z",
          "lyrics": "[Verse 1]\nWaking up to the morning light,\n...",
          "lyrics_id": "c302d603-81b6-552f-8122-e512928d6aa1",
          "lyrics_timing_markers": [[10, 12], [71, 15]],
          "audio_url": "https://cdn.apimart.ai/audio/flowmusic_9508d1fe.m4a",
          "wav_url": "https://cdn.apimart.ai/audio/flowmusic_9508d1fe.wav",
          "image_url": "https://cdn.apimart.ai/image/flowmusic_9508d1fe_cover.jpg"
        }
      ]
    }
  }
}