文档

查询任务

查询 Flow Music 异步任务的执行状态、进度和生成结果

查询 Flow Music 异步任务的执行状态、进度和生成结果

请求示例

bash curl --request GET \ --url https://api.openveer.com/v1/music/tasks/task_01K8AYYM6R03TGZ3Q2P0TZVNPX?language=zh \ --header 'Authorization: Bearer <token>'

```python
import requests

task_id = "task_01K8AYYM6R03TGZ3Q2P0TZVNPX"
url = f"https://api.openveer.com/v1/music/tasks/{task_id}"

headers = {
"Authorization": "Bearer "
}

params = {
"language": "zh"
}

response = requests.get(url, headers=headers, params=params)

print(response.json())
```

``javascript const taskId = "task_01K8AYYM6R03TGZ3Q2P0TZVNPX"; const url =https://api.openveer.com/v1/music/tasks/${taskId}?language=zh`;

const headers = {
"Authorization": "Bearer "
};

fetch(url, {
method: "GET",
headers: headers
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error("Error:", error));
```

响应示例

json { "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" } ] } } }

json { "error": { "message": "task not found", "type": "invalid_request", "param": "task_id", "code": "task_not_found" } }

json { "error": { "message": "当前分组容量饱和,请稍后重试", "type": "rate_limit_error", "param": "", "code": "rate_limit_error" } }

鉴权

Authorization string
所有 Flow Music 接口都需要 Bearer Token 鉴权 获取 API Key: 访问 [API Key 管理页面](https://openveer.com) 获取 API Key 添加到请求头: ``` Authorization: Bearer YOUR_API_KEY ```

路径参数

task_id string
提交 Flow Music 任务后返回的任务 ID
注意
任务 ID 来自提交接口响应中的 `data[0].task_id`。

查询参数

language string
错误信息和部分提示文案的语言 可选值:`zh`、`en`、`ja`、`ko`

响应字段

code integer
响应状态码,成功时为 200
data object
任务详情 任务 ID
status string
任务状态:`pending`、`processing`、`completed`、`failed`
progress integer
任务进度,范围 0-100
cost number
实际扣费金额;任务失败时通常为 0
credits_cost number
实际消耗的 credits
result object
任务完成后的生成结果;不同 Flow Music 能力返回的字段不同

结果结构

音乐类任务

生成音乐、音乐延伸、片段替换、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` 中读取生成结果。