生成音乐
- Flow Music 的主生成接口,异步任务
- 与 Suno 共用同一个端点,靠
model字段区分 - 单次请求出 1 首
认证
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,大小写不敏感。
注意:同一个端点也承载 Suno,那边填 suno。两者靠这个字段分流。
音乐风格与音色描述提示词。例如「明快的流行乐,带钢琴前奏」。
sound_prompt 与 lyrics 至少传一个,不能同时为空。
歌词正文。可以先调「生成歌词」接口拿到再回填。
与 sound_prompt 至少传一个。
生成音乐的标题。
每分钟节拍数。类型是字符串,例如 "120",数值须不小于 1。
生成时长,取值 1 到 240,单位秒。
复现用的随机种子,任意字符串。相同请求与相同 seed 结果相似,但不保证完全一致。
Always flowmusic, case-insensitive.
Note: the same endpoint also serves Suno, where you pass suno. This field routes between them.
The music style and timbre description prompt, e.g. "upbeat pop with a piano intro".
At least one of sound_prompt and lyrics must be provided; they can't both be empty.
The lyrics text. You can call the "Generate lyrics" endpoint first and feed the result back.
At least one of this and sound_prompt is required.
The title of the generated music.
Beats per minute. The type is a string, e.g. "120", and the value must be at least 1.
Generation length, 1 to 240, in seconds.
A random seed for reproducibility, any string. The same request with the same seed gives similar results, though not guaranteed identical.
提交响应
状态码,成功为 200。
任务状态,提交成功时为 submitted。
任务唯一标识,用于后续查询。
The status code; 200 on success.
The task status; submitted on successful submission.
The unique task identifier, used for later queries.
任务查询响应
用 GET /v1/music/tasks/{task_id} 查询。
任务 ID。
已完成时为 completed。
进度百分比。
创建时间,Unix 秒。
完成时间,Unix 秒。
实际耗时,单位秒。
费用,美元。
积分消耗。
生成的音乐列表。
Query with GET /v1/music/tasks/{task_id}.
The task ID.
completed when done.
Progress percentage.
Creation time, in Unix seconds.
Completion time, in Unix seconds.
Actual duration in seconds.
Cost in US dollars.
Credits consumed.
The list of generated music.
music[] 元素字段
音频片段 UUID。
曲目标题。
时长,字符串形式的浮点秒数,例如 "184.2"。
ISO 8601 时间戳。
该曲使用的歌词文本。
歌词 UUID。
时间标记,二元组数组,形如 [[10,12],[212,36]],元素为整数对。
音频地址,.m4a 格式。
WAV 格式地址。
封面图地址,.jpg 格式。
The audio clip UUID.
The track title.
Duration as a floating-point number in string form, e.g. "184.2".
An ISO 8601 timestamp.
The lyrics text used for this track.
The lyrics UUID.
Timing markers, an array of integer pairs such as [[10,12],[212,36]].
The audio URL, in .m4a format.
The WAV-format URL.
The cover image URL, in .jpg format.
与 Suno 的差异
| 项目 | Flow Music | Suno |
|---|---|---|
model 取值 | flowmusic | suno |
| 提示词字段 | sound_prompt | prompt |
| 时长字段 | length(秒,1–240) | duration(秒,10–360) |
| 节拍控制 | bpm | 无 |
| 结果时长字段 | duration_seconds(字符串) | duration(数字) |
| 歌词时间轴 | lyrics_timing_markers | 无 |
| 追加格式 | 额外给 wav_url | 无 |
| Item | Flow Music | Suno |
|---|---|---|
model value | flowmusic | suno |
| Prompt field | sound_prompt | prompt |
| Length field | length (seconds, 1–240) | duration (seconds, 10–360) |
| Tempo control | bpm | None |
| Result duration field | duration_seconds (string) | duration (number) |
| Lyrics timeline | lyrics_timing_markers | None |
| Extra format | An additional wav_url | None |
错误
| HTTP | type | code | message |
|---|---|---|---|
| 400 | invalid_request | invalid_request | sound_prompt 与 lyrics 不能同时为空 |
| 429 | rate_limit_error | rate_limit_error | 当前分组容量饱和,请稍后重试 |
duration_seconds 是字符串不是数字。直接做算术会得到字符串拼接的结果,需要先 float() 或 Number() 转换。
| HTTP | type | code | message |
|---|---|---|---|
| 400 | invalid_request | invalid_request | sound_prompt and lyrics can't both be empty |
| 429 | rate_limit_error | rate_limit_error | Current group capacity is saturated; retry later |
duration_seconds is a string, not a number. Doing arithmetic on it concatenates strings instead; convert with float() or Number() first.
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.