添加伴奏
curl --request POST \
--url https://apibox.erweima.ai/api/v1/generate/add-instrumental \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"uploadUrl": "https://example.com/music.mp3",
"title": "轻松钢琴",
"negativeTags": "重金属, 激进鼓声",
"tags": "轻松钢琴, 环境音乐, 平静",
"callBackUrl": "https://api.example.com/callback",
"lyrics": "[Verse] 夜晚城市 灯火辉煌",
"vocalGender": "m",
"styleWeight": 0.61,
"weirdnessConstraint": 0.72,
"audioWeight": 0.65,
"variety": 1,
"model": "V6"
}
'import requests
url = "https://apibox.erweima.ai/api/v1/generate/add-instrumental"
payload = {
"uploadUrl": "https://example.com/music.mp3",
"title": "轻松钢琴",
"negativeTags": "重金属, 激进鼓声",
"tags": "轻松钢琴, 环境音乐, 平静",
"callBackUrl": "https://api.example.com/callback",
"lyrics": "[Verse] 夜晚城市 灯火辉煌",
"vocalGender": "m",
"styleWeight": 0.61,
"weirdnessConstraint": 0.72,
"audioWeight": 0.65,
"variety": 1,
"model": "V6"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
uploadUrl: 'https://example.com/music.mp3',
title: '轻松钢琴',
negativeTags: '重金属, 激进鼓声',
tags: '轻松钢琴, 环境音乐, 平静',
callBackUrl: 'https://api.example.com/callback',
lyrics: '[Verse] 夜晚城市 灯火辉煌',
vocalGender: 'm',
styleWeight: 0.61,
weirdnessConstraint: 0.72,
audioWeight: 0.65,
variety: 1,
model: 'V6'
})
};
fetch('https://apibox.erweima.ai/api/v1/generate/add-instrumental', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://apibox.erweima.ai/api/v1/generate/add-instrumental",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'uploadUrl' => 'https://example.com/music.mp3',
'title' => '轻松钢琴',
'negativeTags' => '重金属, 激进鼓声',
'tags' => '轻松钢琴, 环境音乐, 平静',
'callBackUrl' => 'https://api.example.com/callback',
'lyrics' => '[Verse] 夜晚城市 灯火辉煌',
'vocalGender' => 'm',
'styleWeight' => 0.61,
'weirdnessConstraint' => 0.72,
'audioWeight' => 0.65,
'variety' => 1,
'model' => 'V6'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://apibox.erweima.ai/api/v1/generate/add-instrumental"
payload := strings.NewReader("{\n \"uploadUrl\": \"https://example.com/music.mp3\",\n \"title\": \"轻松钢琴\",\n \"negativeTags\": \"重金属, 激进鼓声\",\n \"tags\": \"轻松钢琴, 环境音乐, 平静\",\n \"callBackUrl\": \"https://api.example.com/callback\",\n \"lyrics\": \"[Verse] 夜晚城市 灯火辉煌\",\n \"vocalGender\": \"m\",\n \"styleWeight\": 0.61,\n \"weirdnessConstraint\": 0.72,\n \"audioWeight\": 0.65,\n \"variety\": 1,\n \"model\": \"V6\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://apibox.erweima.ai/api/v1/generate/add-instrumental")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"uploadUrl\": \"https://example.com/music.mp3\",\n \"title\": \"轻松钢琴\",\n \"negativeTags\": \"重金属, 激进鼓声\",\n \"tags\": \"轻松钢琴, 环境音乐, 平静\",\n \"callBackUrl\": \"https://api.example.com/callback\",\n \"lyrics\": \"[Verse] 夜晚城市 灯火辉煌\",\n \"vocalGender\": \"m\",\n \"styleWeight\": 0.61,\n \"weirdnessConstraint\": 0.72,\n \"audioWeight\": 0.65,\n \"variety\": 1,\n \"model\": \"V6\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://apibox.erweima.ai/api/v1/generate/add-instrumental")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"uploadUrl\": \"https://example.com/music.mp3\",\n \"title\": \"轻松钢琴\",\n \"negativeTags\": \"重金属, 激进鼓声\",\n \"tags\": \"轻松钢琴, 环境音乐, 平静\",\n \"callBackUrl\": \"https://api.example.com/callback\",\n \"lyrics\": \"[Verse] 夜晚城市 灯火辉煌\",\n \"vocalGender\": \"m\",\n \"styleWeight\": 0.61,\n \"weirdnessConstraint\": 0.72,\n \"audioWeight\": 0.65,\n \"variety\": 1,\n \"model\": \"V6\"\n}"
response = http.request(request)
puts response.read_body{
"code": 200,
"msg": "success",
"data": {
"taskId": "5c79****be8e"
}
}Generate Music
添加伴奏
通过为上传的音频文件添加伴奏元素,生成现有音乐曲目的伴奏版本
POST
/
api
/
v1
/
generate
/
add-instrumental
添加伴奏
curl --request POST \
--url https://apibox.erweima.ai/api/v1/generate/add-instrumental \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"uploadUrl": "https://example.com/music.mp3",
"title": "轻松钢琴",
"negativeTags": "重金属, 激进鼓声",
"tags": "轻松钢琴, 环境音乐, 平静",
"callBackUrl": "https://api.example.com/callback",
"lyrics": "[Verse] 夜晚城市 灯火辉煌",
"vocalGender": "m",
"styleWeight": 0.61,
"weirdnessConstraint": 0.72,
"audioWeight": 0.65,
"variety": 1,
"model": "V6"
}
'import requests
url = "https://apibox.erweima.ai/api/v1/generate/add-instrumental"
payload = {
"uploadUrl": "https://example.com/music.mp3",
"title": "轻松钢琴",
"negativeTags": "重金属, 激进鼓声",
"tags": "轻松钢琴, 环境音乐, 平静",
"callBackUrl": "https://api.example.com/callback",
"lyrics": "[Verse] 夜晚城市 灯火辉煌",
"vocalGender": "m",
"styleWeight": 0.61,
"weirdnessConstraint": 0.72,
"audioWeight": 0.65,
"variety": 1,
"model": "V6"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
uploadUrl: 'https://example.com/music.mp3',
title: '轻松钢琴',
negativeTags: '重金属, 激进鼓声',
tags: '轻松钢琴, 环境音乐, 平静',
callBackUrl: 'https://api.example.com/callback',
lyrics: '[Verse] 夜晚城市 灯火辉煌',
vocalGender: 'm',
styleWeight: 0.61,
weirdnessConstraint: 0.72,
audioWeight: 0.65,
variety: 1,
model: 'V6'
})
};
fetch('https://apibox.erweima.ai/api/v1/generate/add-instrumental', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://apibox.erweima.ai/api/v1/generate/add-instrumental",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'uploadUrl' => 'https://example.com/music.mp3',
'title' => '轻松钢琴',
'negativeTags' => '重金属, 激进鼓声',
'tags' => '轻松钢琴, 环境音乐, 平静',
'callBackUrl' => 'https://api.example.com/callback',
'lyrics' => '[Verse] 夜晚城市 灯火辉煌',
'vocalGender' => 'm',
'styleWeight' => 0.61,
'weirdnessConstraint' => 0.72,
'audioWeight' => 0.65,
'variety' => 1,
'model' => 'V6'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://apibox.erweima.ai/api/v1/generate/add-instrumental"
payload := strings.NewReader("{\n \"uploadUrl\": \"https://example.com/music.mp3\",\n \"title\": \"轻松钢琴\",\n \"negativeTags\": \"重金属, 激进鼓声\",\n \"tags\": \"轻松钢琴, 环境音乐, 平静\",\n \"callBackUrl\": \"https://api.example.com/callback\",\n \"lyrics\": \"[Verse] 夜晚城市 灯火辉煌\",\n \"vocalGender\": \"m\",\n \"styleWeight\": 0.61,\n \"weirdnessConstraint\": 0.72,\n \"audioWeight\": 0.65,\n \"variety\": 1,\n \"model\": \"V6\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://apibox.erweima.ai/api/v1/generate/add-instrumental")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"uploadUrl\": \"https://example.com/music.mp3\",\n \"title\": \"轻松钢琴\",\n \"negativeTags\": \"重金属, 激进鼓声\",\n \"tags\": \"轻松钢琴, 环境音乐, 平静\",\n \"callBackUrl\": \"https://api.example.com/callback\",\n \"lyrics\": \"[Verse] 夜晚城市 灯火辉煌\",\n \"vocalGender\": \"m\",\n \"styleWeight\": 0.61,\n \"weirdnessConstraint\": 0.72,\n \"audioWeight\": 0.65,\n \"variety\": 1,\n \"model\": \"V6\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://apibox.erweima.ai/api/v1/generate/add-instrumental")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"uploadUrl\": \"https://example.com/music.mp3\",\n \"title\": \"轻松钢琴\",\n \"negativeTags\": \"重金属, 激进鼓声\",\n \"tags\": \"轻松钢琴, 环境音乐, 平静\",\n \"callBackUrl\": \"https://api.example.com/callback\",\n \"lyrics\": \"[Verse] 夜晚城市 灯火辉煌\",\n \"vocalGender\": \"m\",\n \"styleWeight\": 0.61,\n \"weirdnessConstraint\": 0.72,\n \"audioWeight\": 0.65,\n \"variety\": 1,\n \"model\": \"V6\"\n}"
response = http.request(request)
puts response.read_body{
"code": 200,
"msg": "success",
"data": {
"taskId": "5c79****be8e"
}
}模型版本
- 当前模型:
V6(默认)、V6_WILD、V6_MINI - 已废弃模型:
V5_5、V5、V4_5PLUS、V4_5ALL、V4_5、V4 - 废弃值仅为向后兼容保留,新接入请使用 V6 系列模型。
使用指南
- 此接口通过添加伴奏元素来增强现有的音频曲目
- 接受上传的音频文件,并根据您的规格生成伴奏版本
- 上传的音频必须可公开访问且采用支持的格式(MP3、WAV等)
参数详情
- 提供源音频(
uploadUrl)并填写下列必填字段即可生成,其余字段均为选填。 - 必需字段:
uploadUrl、title、negativeTags、tags、callBackUrl - uploadUrl:必须是有效的、可公开访问的音频文件URL
- title:用作生成的伴奏曲目的标题
- tags:描述伴奏曲目所需的风格、情绪和乐器
- negativeTags:要从生成的伴奏中排除的音乐风格或特征
可选参数
以下字段是此接口可用的可选控制:
- lyrics(string):歌词内容。可选。V6 系列最多 5000 字符。
- vocalGender(string):任何人声元素的首选性别。允许的值:
m(男性)、f(女性) - styleWeight(number):范围0-1的风格权重(建议两位小数)
- weirdnessConstraint(number):范围0-1的创意/新颖性约束(建议两位小数)
- audioWeight(number):范围0-1的音频一致性相对权重(建议两位小数)
- variety(number):生成结果的多样性。范围 0–4 的整数,默认 1。
0关闭,1普通(默认),2高,3额外,4最大。 - model(string):用于生成的模型版本。当前值:
V6(默认)、V6_WILD、V6_MINI。已废弃:V5_5、V5、V4_5PLUS、V4_5ALL、V4_5、V4。
开发者注意事项
- 回调过程有三个阶段:
text(文本生成)、first(第一轨道完成)、complete(所有轨道完成) - 在某些情况下,
text和first阶段可能被跳过,直接返回complete - 详细回调格式请参见添加伴奏回调
- 使用获取音乐生成详情监控任务进度
授权
🔑 API 认证说明
所有接口都需要通过 Bearer Token 方式进行认证。
获取 API Key
- 访问 API Key 管理页面 获取您的 API Key
使用方式
在请求头中添加:
Authorization: Bearer YOUR_API_KEY
⚠️ 注意:
- 请妥善保管您的 API Key,不要泄露给他人
- 如果怀疑 API Key 泄露,请立即在管理页面重置
请求体
application/json
要添加伴奏的上传音乐文件的URL。必须是系统可以访问的有效音频文件URL。上传的音频应该采用支持的格式(MP3、WAV等)。
示例:
"https://example.com/music.mp3"
音乐曲目的标题。这将作为生成的伴奏曲目的标题。
示例:
"轻松钢琴"
要从生成的伴奏中排除的音乐风格或特征。用于避免伴奏版本中的特定风格或乐器。
示例:
"重金属, 激进鼓声"
伴奏的音乐风格和特征。描述伴奏曲目所需的风格、情绪和乐器。
示例:
"轻松钢琴, 环境音乐, 平静"
当伴奏生成完成时接收任务完成通知的URL。回调过程分为三个阶段:text、first、complete。在某些情况下,text和first阶段可能被跳过,直接返回complete。
示例:
"https://api.example.com/callback"
歌词内容。可选。V6、V6_MINI、V6_WILD 最多 5000 字符。 生成曲目的歌词。
示例:
"[Verse] 夜晚城市 灯火辉煌"
任何人声元素的首选性别。可选。允许的值:m(男性)、f(女性)。
可用选项:
m, f 示例:
"m"
风格权重。可选。范围:0-1。建议保留两位小数。
必填范围:
0 <= x <= 1必须是以下数值的倍数 0.01示例:
0.61
创意/新颖性约束。可选。范围:0-1。建议保留两位小数。
必填范围:
0 <= x <= 1必须是以下数值的倍数 0.01示例:
0.72
音频一致性与其他控制的相对权重。可选。范围:0-1。建议保留两位小数。
必填范围:
0 <= x <= 1必须是以下数值的倍数 0.01示例:
0.65
控制生成结果的多样性和风格差异程度。可选。范围 0–4 的整数,默认值为 1。
0:off(exact style),完全关闭,严格用同一风格1:normal(balanced variety),默认值,在稳定性和多样性之间保持平衡2:high(distinct styles),生成风格差异明显的结果3:extra(bold exploration),提供更高程度的变化,鼓励大胆探索不同风格4:max(unreasonably varied),最大程度增加多样性,生成结果可能具有非常明显的风格差异
必填范围:
0 <= x <= 4必须是以下数值的倍数 1示例:
1
AI 模型版本。默认值:V6。
V6:当前标准模型,推荐默认使用。V6_WILD:当前实验性、创造性更强的模型。V6_MINI:当前轻量模型。- 已废弃:
V5_5、V5、V4_5PLUS、V4_5ALL、V4_5、V4。这些值仅为向后兼容保留,新接入请使用 V6 系列模型。
可用选项:
V6, V6_WILD, V6_MINI, V5_5, V5, V4_5PLUS, V4_5ALL, V4_5, V4 示例:
"V6"
响应
请求成功
状态码说明
- ✅ 200 - 请求成功
- ⚠️ 400 - 参数错误
- ⚠️ 401 - 没有访问权限
- ⚠️ 404 - 请求方式或者路径错误
- ⚠️ 405 - 调用超过限制
- ⚠️ 413 - 主题或者prompt过长
- ⚠️ 429 - 积分不足
- ⚠️ 430 - 您的调用频率过高。请稍后再试。
- ⚠️ 455 - 网站维护
- ❌ 500 - 服务器异常
可用选项:
200, 400, 401, 404, 405, 413, 429, 430, 455, 500 示例:
200
当 code != 200 时,展示错误信息
示例:
"success"
Show child attributes
Show child attributes
