curl --request POST \
--url https://api.apimart.ai/v1/music/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "flowmusic",
"title": "My Song",
"sound_prompt": "upbeat pop music with piano",
"bpm": "120",
"length": 60
}'
import requests
url = "https://api.apimart.ai/v1/music/generations"
payload = {
"model": "flowmusic",
"title": "My Song",
"sound_prompt": "upbeat pop music with piano",
"bpm": "120",
"length": 60
}
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";
const payload = {
model: "flowmusic",
title: "My Song",
sound_prompt: "upbeat pop music with piano",
bpm: "120",
length: 60
};
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_01K8AYYM6R03TGZ3Q2P0TZVNPX"
}
]
}
{
"error": {
"message": "sound_prompt and lyrics cannot both be empty",
"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"
}
}
Flow Music
生成音乐
Flow Music 文字生成音乐。支持风格提示词 / 歌词 / BPM / 时长控制,每次请求生成一首音乐
POST
/
v1
/
music
/
generations
curl --request POST \
--url https://api.apimart.ai/v1/music/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "flowmusic",
"title": "My Song",
"sound_prompt": "upbeat pop music with piano",
"bpm": "120",
"length": 60
}'
import requests
url = "https://api.apimart.ai/v1/music/generations"
payload = {
"model": "flowmusic",
"title": "My Song",
"sound_prompt": "upbeat pop music with piano",
"bpm": "120",
"length": 60
}
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";
const payload = {
model: "flowmusic",
title: "My Song",
sound_prompt: "upbeat pop music with piano",
bpm: "120",
length: 60
};
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_01K8AYYM6R03TGZ3Q2P0TZVNPX"
}
]
}
{
"error": {
"message": "sound_prompt and lyrics cannot both be empty",
"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 \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "flowmusic",
"title": "My Song",
"sound_prompt": "upbeat pop music with piano",
"bpm": "120",
"length": 60
}'
import requests
url = "https://api.apimart.ai/v1/music/generations"
payload = {
"model": "flowmusic",
"title": "My Song",
"sound_prompt": "upbeat pop music with piano",
"bpm": "120",
"length": 60
}
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";
const payload = {
model: "flowmusic",
title: "My Song",
sound_prompt: "upbeat pop music with piano",
bpm: "120",
length: 60
};
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_01K8AYYM6R03TGZ3Q2P0TZVNPX"
}
]
}
{
"error": {
"message": "sound_prompt and lyrics cannot both be empty",
"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"
}
}
认证
所有接口均需要使用 Bearer Token 进行认证获取 API Key:访问 API Key 管理页面 获取您的 API Key使用时在请求头中添加:
Authorization: Bearer YOUR_API_KEY
请求参数
模型名称,固定传
"flowmusic"(大小写不敏感)音乐风格或声音描述提示词示例:
"upbeat pop music with piano"sound_prompt 与 lyrics 不可同时为空(至少传一个)。每次请求仅生成一首音乐。生成音乐标题
BPM(每分钟节拍数),必须 ≥ 1示例:
"120"生成时长(秒)支持范围:
1 ~ 240 秒随机种子,用于复现结果
相同的请求下传相同的 seed 值,会生成类似的结果,但不保证完全一致。
响应
响应状态码,成功时为 200
使用场景
场景 1:纯风格提示词生成
{
"model": "flowmusic",
"title": "My Song",
"sound_prompt": "upbeat pop music with piano",
"bpm": "120",
"length": 60
}
场景 2:歌词 + 风格成曲
{
"model": "flowmusic",
"title": "坚持",
"lyrics": "[Verse 1]\n黑夜再长也会天亮\n...",
"sound_prompt": "energetic rock with electric guitar",
"length": 120
}
查询任务结果音乐生成为异步任务,提交后会返回
task_id。使用 获取任务状态 接口查询生成进度和结果。任务完成结果示例
查询返回示例(GET /v1/music/tasks/{task_id}):
{
"code": 200,
"data": {
"id": "task_01KWXVB61E28THHFBSYXWA4FAJ",
"status": "completed",
"progress": 100,
"created": 1783413184,
"completed": 1783413236,
"actual_time": 52,
"cost": 0.048,
"credits_cost": 0.48,
"result": {
"music": [
{
"clip_id": "a41aade4-993e-4d28-b56f-d97e7ef7167c",
"title": "Regression Song",
"duration_seconds": "181.70666667",
"create_time": "2026-07-07T08:33:32.854073Z",
"lyrics": "[Verse 1]\nWaking up to the morning light,\n...",
"lyrics_id": "c302d603-81b6-552f-8122-e512928d6aa1",
"lyrics_timing_markers": [[10, 12], [212, 36]],
"audio_url": "https://cdn.apimart.ai/audio/flowmusic_a41aade4.m4a",
"wav_url": "https://cdn.apimart.ai/audio/flowmusic_a41aade4.wav",
"image_url": "https://cdn.apimart.ai/image/flowmusic_a41aade4_cover.jpg"
}
]
}
}
}
⌘I