跳转到主要内容
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": "替换为钢琴版本"
  }'
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": "替换为钢琴版本"
}

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: "替换为钢琴版本"
};

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": "余额不足",
    "type": "invalid_request",
    "param": "",
    "code": "quota_not_enough"
  }
}
{
  "error": {
    "message": "当前分组容量饱和,请稍后重试",
    "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": "替换为钢琴版本"
  }'
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": "替换为钢琴版本"
}

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: "替换为钢琴版本"
};

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": "余额不足",
    "type": "invalid_request",
    "param": "",
    "code": "quota_not_enough"
  }
}
{
  "error": {
    "message": "当前分组容量饱和,请稍后重试",
    "type": "rate_limit_error",
    "param": "",
    "code": "rate_limit_error"
  }
}

认证

Authorization
string
必填
所有接口均需要使用 Bearer Token 进行认证获取 API Key:访问 API Key 管理页面 获取您的 API Key使用时在请求头中添加:
Authorization: Bearer YOUR_API_KEY

请求参数

model
string
必填
模型名称,固定传 "flowmusic"(大小写不敏感)
clip_id
string
必填
源音乐 clip_id,来自已成功任务的 result.music[].clip_id
start_s
number
必填
替换开始时间(秒)
end_s
number
必填
替换结束时间(秒)
end_s 必须大于 start_s,且不能超过源 clip 时长。
instruction
string
必填
替换片段的编辑指令示例:"替换为钢琴版本"
title
string
替换后音乐标题
seed
integer
随机种子,用于复现或控制生成结果

响应

code
integer
响应状态码,成功时为 200
data
array
返回数据数组

使用场景

场景 1:把 10-20 秒替换为钢琴版本

{
  "model": "flowmusic",
  "clip_id": "abc123-def456",
  "start_s": 10,
  "end_s": 20,
  "instruction": "替换为钢琴版本"
}
查询任务结果片段替换为异步任务,提交后会返回 task_id。使用 获取任务状态 接口查询生成进度和结果。替换产物是新的 clip_id(整首歌重新输出,其中指定区间已被替换),后续操作请使用新 clip_id。

任务完成结果示例

查询返回示例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"
        }
      ]
    }
  }
}