curl --request POST \
--url https://api.apimart.ai/v1/music/generations/lyricsFlowMusic \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "flowmusic",
"prompt": "一首关于坚持的摇滚歌曲"
}'
import requests
url = "https://api.apimart.ai/v1/music/generations/lyricsFlowMusic"
payload = {
"model": "flowmusic",
"prompt": "一首关于坚持的摇滚歌曲"
}
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/lyricsFlowMusic";
const payload = {
model: "flowmusic",
prompt: "一首关于坚持的摇滚歌曲"
};
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_01KWXVCX91HYHSTHZ0NC1SRFW1"
}
]
}
{
"error": {
"message": "model is required",
"type": "invalid_request",
"param": "",
"code": "model_required"
}
}
{
"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 根据提示词生成歌词。结果可回填到生成音乐接口的 lyrics 字段
POST
/
v1
/
music
/
generations
/
lyricsFlowMusic
curl --request POST \
--url https://api.apimart.ai/v1/music/generations/lyricsFlowMusic \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "flowmusic",
"prompt": "一首关于坚持的摇滚歌曲"
}'
import requests
url = "https://api.apimart.ai/v1/music/generations/lyricsFlowMusic"
payload = {
"model": "flowmusic",
"prompt": "一首关于坚持的摇滚歌曲"
}
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/lyricsFlowMusic";
const payload = {
model: "flowmusic",
prompt: "一首关于坚持的摇滚歌曲"
};
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_01KWXVCX91HYHSTHZ0NC1SRFW1"
}
]
}
{
"error": {
"message": "model is required",
"type": "invalid_request",
"param": "",
"code": "model_required"
}
}
{
"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/lyricsFlowMusic \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "flowmusic",
"prompt": "一首关于坚持的摇滚歌曲"
}'
import requests
url = "https://api.apimart.ai/v1/music/generations/lyricsFlowMusic"
payload = {
"model": "flowmusic",
"prompt": "一首关于坚持的摇滚歌曲"
}
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/lyricsFlowMusic";
const payload = {
model: "flowmusic",
prompt: "一首关于坚持的摇滚歌曲"
};
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_01KWXVCX91HYHSTHZ0NC1SRFW1"
}
]
}
{
"error": {
"message": "model is required",
"type": "invalid_request",
"param": "",
"code": "model_required"
}
}
{
"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"(大小写不敏感)生成歌词的提示词,≤ 3000 字符建议描述歌曲主题、风格、情绪等,以获得更贴合的歌词示例:
"一首关于坚持的摇滚歌曲"响应
响应状态码,成功时为 200
使用场景
场景 1:按主题生成歌词
{
"model": "flowmusic",
"prompt": "一首关于坚持的摇滚歌曲"
}
场景 2:歌词回填成曲
先生成歌词,完成后取result.lyrics[0] 的 title 和 lyrics,回填到生成音乐接口:
{
"model": "flowmusic",
"title": "坚持",
"lyrics": "[Verse 1]\n黑夜再长也会天亮\n...",
"sound_prompt": "energetic rock with electric guitar"
}
查询任务结果歌词生成为异步任务,提交后会返回
task_id。使用 获取任务状态 接口查询生成进度和结果。任务完成结果示例
查询返回示例(GET /v1/music/tasks/{task_id}):
{
"code": 200,
"data": {
"id": "task_01KWXVCX91HYHSTHZ0NC1SRFW1",
"status": "completed",
"progress": 100,
"created": 1783413241,
"completed": 1783413284,
"actual_time": 43,
"cost": 0.016,
"credits_cost": 0.16,
"result": {
"lyrics": [
{
"title": "Bleached",
"lyrics": "[Intro]\n(Check)\n(One two)\n\n[Verse 1]\nThe birds are..."
}
]
}
}
}
⌘I