curl --request GET \
--url https://api.apimart.ai/v1/music/tasks/task_01K8AYYM6R03TGZ3Q2P0TZVNPX?language=zh \
--header 'Authorization: Bearer <token>'
import requests
task_id = "task_01K8AYYM6R03TGZ3Q2P0TZVNPX"
url = f"https://api.apimart.ai/v1/music/tasks/{task_id}"
headers = {
"Authorization": "Bearer <token>"
}
params = {
"language": "zh"
}
response = requests.get(url, headers=headers, params=params)
print(response.json())
const taskId = "task_01K8AYYM6R03TGZ3Q2P0TZVNPX";
const url = `https://api.apimart.ai/v1/music/tasks/${taskId}?language=zh`;
const headers = {
"Authorization": "Bearer <token>"
};
fetch(url, {
method: "GET",
headers: headers
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error("Error:", error));
{
"code": 200,
"data": {
"id": "task_01K8AYYM6R03TGZ3Q2P0TZVNPX",
"status": "completed",
"progress": 100,
"created": 1783413241,
"completed": 1783413352,
"actual_time": 111,
"cost": 0.06,
"credits_cost": 0.6,
"result": {
"music": [
{
"clip_id": "a41aade4-993e-4d28-b56f-d97e7ef7167c",
"title": "My Song",
"duration_seconds": "181.70666667",
"audio_url": "https://cdn.apimart.ai/audio/flowmusic_a41aade4.m4a",
"wav_url": "https://cdn.apimart.ai/audio/flowmusic_a41aade4.wav"
}
]
}
}
}
{
"error": {
"message": "task not found",
"type": "invalid_request",
"param": "task_id",
"code": "task_not_found"
}
}
{
"error": {
"message": "当前分组容量饱和,请稍后重试",
"type": "rate_limit_error",
"param": "",
"code": "rate_limit_error"
}
}
Flow Music
查询任务
查询 Flow Music 异步任务的执行状态、进度和生成结果
GET
/
v1
/
music
/
tasks
/
{task_id}
curl --request GET \
--url https://api.apimart.ai/v1/music/tasks/task_01K8AYYM6R03TGZ3Q2P0TZVNPX?language=zh \
--header 'Authorization: Bearer <token>'
import requests
task_id = "task_01K8AYYM6R03TGZ3Q2P0TZVNPX"
url = f"https://api.apimart.ai/v1/music/tasks/{task_id}"
headers = {
"Authorization": "Bearer <token>"
}
params = {
"language": "zh"
}
response = requests.get(url, headers=headers, params=params)
print(response.json())
const taskId = "task_01K8AYYM6R03TGZ3Q2P0TZVNPX";
const url = `https://api.apimart.ai/v1/music/tasks/${taskId}?language=zh`;
const headers = {
"Authorization": "Bearer <token>"
};
fetch(url, {
method: "GET",
headers: headers
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error("Error:", error));
{
"code": 200,
"data": {
"id": "task_01K8AYYM6R03TGZ3Q2P0TZVNPX",
"status": "completed",
"progress": 100,
"created": 1783413241,
"completed": 1783413352,
"actual_time": 111,
"cost": 0.06,
"credits_cost": 0.6,
"result": {
"music": [
{
"clip_id": "a41aade4-993e-4d28-b56f-d97e7ef7167c",
"title": "My Song",
"duration_seconds": "181.70666667",
"audio_url": "https://cdn.apimart.ai/audio/flowmusic_a41aade4.m4a",
"wav_url": "https://cdn.apimart.ai/audio/flowmusic_a41aade4.wav"
}
]
}
}
}
{
"error": {
"message": "task not found",
"type": "invalid_request",
"param": "task_id",
"code": "task_not_found"
}
}
{
"error": {
"message": "当前分组容量饱和,请稍后重试",
"type": "rate_limit_error",
"param": "",
"code": "rate_limit_error"
}
}
curl --request GET \
--url https://api.apimart.ai/v1/music/tasks/task_01K8AYYM6R03TGZ3Q2P0TZVNPX?language=zh \
--header 'Authorization: Bearer <token>'
import requests
task_id = "task_01K8AYYM6R03TGZ3Q2P0TZVNPX"
url = f"https://api.apimart.ai/v1/music/tasks/{task_id}"
headers = {
"Authorization": "Bearer <token>"
}
params = {
"language": "zh"
}
response = requests.get(url, headers=headers, params=params)
print(response.json())
const taskId = "task_01K8AYYM6R03TGZ3Q2P0TZVNPX";
const url = `https://api.apimart.ai/v1/music/tasks/${taskId}?language=zh`;
const headers = {
"Authorization": "Bearer <token>"
};
fetch(url, {
method: "GET",
headers: headers
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error("Error:", error));
{
"code": 200,
"data": {
"id": "task_01K8AYYM6R03TGZ3Q2P0TZVNPX",
"status": "completed",
"progress": 100,
"created": 1783413241,
"completed": 1783413352,
"actual_time": 111,
"cost": 0.06,
"credits_cost": 0.6,
"result": {
"music": [
{
"clip_id": "a41aade4-993e-4d28-b56f-d97e7ef7167c",
"title": "My Song",
"duration_seconds": "181.70666667",
"audio_url": "https://cdn.apimart.ai/audio/flowmusic_a41aade4.m4a",
"wav_url": "https://cdn.apimart.ai/audio/flowmusic_a41aade4.wav"
}
]
}
}
}
{
"error": {
"message": "task not found",
"type": "invalid_request",
"param": "task_id",
"code": "task_not_found"
}
}
{
"error": {
"message": "当前分组容量饱和,请稍后重试",
"type": "rate_limit_error",
"param": "",
"code": "rate_limit_error"
}
}
鉴权
所有 Flow Music 接口都需要 Bearer Token 鉴权获取 API Key:访问 API Key 管理页面 获取 API Key添加到请求头:
Authorization: Bearer YOUR_API_KEY
路径参数
提交 Flow Music 任务后返回的任务 ID
任务 ID 来自提交接口响应中的
data[0].task_id。查询参数
错误信息和部分提示文案的语言可选值:
zh、en、ja、ko响应字段
响应状态码,成功时为 200
结果结构
音乐类任务
生成音乐、音乐延伸、片段替换、Cover 改编、词曲分离、上传音频、下载音频和视频渲染通常返回result.music 数组。
{
"result": {
"music": [
{
"clip_id": "a41aade4-993e-4d28-b56f-d97e7ef7167c",
"audio_url": "https://cdn.apimart.ai/audio/flowmusic_a41aade4.m4a",
"wav_url": "https://cdn.apimart.ai/audio/flowmusic_a41aade4.wav",
"video_url": "https://cdn.apimart.ai/video/flowmusic_a41aade4.mp4",
"file_url": "https://cdn.apimart.ai/audio/flowmusic_a41aade4_stems.zip"
}
]
}
}
歌词任务
生成歌词返回result.lyrics 数组。
{
"result": {
"lyrics": [
{
"title": "Bleached",
"lyrics": "[Intro]\n(Check)\n(One two)\n..."
}
]
}
}
使用说明
Flow Music 提交接口都是异步任务。提交成功后先获取
task_id,再调用本接口轮询任务状态;当 status 为 completed 时,从 result 中读取生成结果。⌘I