片段替换
- 替换音乐中的某个时间片段,其余部分保持不变,异步任务
- 用
clip_id引用源音频,用start_s与end_s框出区间 - 产出是新的 clip_id,整首重新输出
认证
All endpoints authenticate with a Bearer token.
Get an API key: open the console and create one.
Add it to the request header:
Authorization: Bearer YOUR_OAIRoute_KEY请求参数
模型名称,固定传 flowmusic,大小写不敏感。
源音乐 clip_id,取自成功任务的 result.music[].clip_id。
替换开始时间,单位秒。
替换结束时间,单位秒。须大于 start_s,且不超过源 clip 时长。
替换片段的编辑指令,例如「替换为钢琴版本」。
替换后音乐标题。
随机种子,用于复现或控制生成结果。
The model name, always flowmusic, case-insensitive.
The source music clip_id, taken from result.music[].clip_id of a successful task.
Replacement start time in seconds.
Replacement end time in seconds. Must be greater than start_s and no longer than the source clip.
The edit instruction for the replaced segment, e.g. "replace with a piano version".
The title of the replaced music.
A random seed for reproducing or steering the output.
与「删除片段」的区别
| 项目 | 删除 | 替换 |
|---|---|---|
| 区间处理 | 直接去掉,前后接上 | 用新内容填上 |
| 接缝 | 可能突兀 | 相对自然 |
| 需要指令 | 不需要 | instruction 必填 |
想换掉一段不满意的间奏,用替换。想整体缩短,用删除。
替换产物是整首重新输出,不是只吐出被替换的那一段。所以拿到的 clip_id 是一个新值,后续操作要用新的,不是原来的。
| Item | Remove | Replace |
|---|---|---|
| Range handling | Cut out, the two sides joined | Filled with new content |
| Seam | Possibly abrupt | Relatively natural |
| Needs an instruction | No | instruction required |
Use replace to swap out a bridge you don't like. Use remove to shorten the whole thing.
The replace output is the whole track re-rendered, not just the replaced segment. So the clip_id you get is a new value; later operations use the new one, not the original.
响应
状态码,成功为 200。
任务状态,初始提交时为 submitted。
任务唯一标识,用于查询状态与结果。
The status code; 200 on success.
The task status; submitted at initial submission.
The unique task identifier, used to query status and results.
取结果
轮询 GET /v1/music/tasks/{task_id},间隔 3 到 5 秒,直到状态变为 completed 或 failed。
完成后从 data.result.music[] 取新的 clip_id 与 audio_url。
Poll GET /v1/music/tasks/{task_id} every 3 to 5 seconds until the status becomes completed or failed.
On completion, take the new clip_id and audio_url from data.result.music[].
错误
| HTTP | code | 说明 |
|---|---|---|
| 400 | invalid_request | 参数校验失败,例如 end_s must be greater than start_s |
| 429 | rate_limit_error | 当前分组容量饱和,需稍后重试 |
| HTTP | code | Notes |
|---|---|---|
| 400 | invalid_request | Parameter validation failed, e.g. end_s must be greater than start_s |
| 429 | rate_limit_error | Current group capacity is saturated; retry later |
For more status codes and retry guidance see Error codes and rate limits; for troubleshooting steps on common errors see the FAQ.
使用示例
提交一个任务并拿到 task_id:
提交成功只表示任务已受理。真正的产物要拿返回的 task_id 去任务查询接口轮询,status 变成 completed 之后才有结果。
Submit a task and get a task_id:
A successful submission only means the task was accepted. To get the actual output, poll the task query endpoint with the returned task_id; results appear only after status becomes completed.