Elevenlabs Music v2
集成
模型 id
elevenlabs/music/v2
# Run the model; wait up to 20 s for the finished result in the same call
curl -X POST "https://api.doitong.ru/v1/run/elevenlabs/music/v2?wait=20" \
-H "Authorization: Bearer $DOITONG_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"prompt": "A red fox trots through fresh snow at sunrise, soft golden light, shallow depth of field"
}'
# Still "queued" or "running"? Poll with the id from the response:
curl "https://api.doitong.ru/v1/requests/REQUEST_ID?wait=20" \
-H "Authorization: Bearer $DOITONG_API_KEY"
const API = "https://api.doitong.ru/v1";
const headers = {
"Authorization": "Bearer " + process.env.DOITONG_API_KEY,
"Content-Type": "application/json",
};
// Run the model; wait up to 20 s for the finished result in the same call
let res = await fetch(API + "/run/elevenlabs/music/v2?wait=20", {
method: "POST",
headers,
body: JSON.stringify({
"prompt": "A red fox trots through fresh snow at sunrise, soft golden light, shallow depth of field"
}),
});
let request = await res.json();
if (!res.ok) throw new Error(request.error.code + ": " + request.error.message);
// Not finished yet: long-poll until it is
while (request.status === "queued" || request.status === "running") {
res = await fetch(API + "/requests/" + request.id + "?wait=20", { headers });
request = await res.json();
}
if (request.status !== "succeeded") throw new Error(JSON.stringify(request.error));
console.log(request.outputs.map((o) => o.url), request.cost.credits + " API credits ($" + request.cost.usd + ")");
import os
import requests
API = "https://api.doitong.ru/v1"
headers = {"Authorization": "Bearer " + os.environ["DOITONG_API_KEY"]}
payload = {
"prompt": "A red fox trots through fresh snow at sunrise, soft golden light, shallow depth of field",
}
# Run the model; wait up to 20 s for the finished result in the same call
r = requests.post(API + "/run/elevenlabs/music/v2", params={"wait": 20}, json=payload, headers=headers)
request = r.json()
if not r.ok:
raise RuntimeError(request["error"]["code"] + ": " + request["error"]["message"])
# Not finished yet: long-poll until it is
while request["status"] in ("queued", "running"):
request = requests.get(API + "/requests/" + request["id"], params={"wait": 20}, headers=headers).json()
if request["status"] != "succeeded":
raise RuntimeError(request["error"])
print([o["url"] for o in request["outputs"]], request["cost"]["credits"], "API credits", "$" + request["cost"]["usd"])
# 1. Connect once (Claude Code; Cursor, VS Code, Claude Desktop: https://doitong.com/zh/developers/docs/mcp)
claude mcp add --transport http doitong-models https://api.doitong.ru/v1/mcp \
--header "Authorization: Bearer $DOITONG_API_KEY"
# 2. Your agent calls the "run" tool with:
{
"model_id": "elevenlabs/music/v2",
"input": {
"prompt": "A red fox trots through fresh snow at sunrise, soft golden light, shallow depth of field"
}
}
通过 Doitong API 调用 Elevenlabs Music v2 模型(elevenlabs/music/v2)。智能体文档:https://doitong.com/zh/developers/models/elevenlabs/music/v2.md
POST https://api.doitong.ru/v1/run/elevenlabs/music/v2?wait=20
Authorization: Bearer $DOITONG_API_KEY
Content-Type: application/json
{
"prompt": "A red fox trots through fresh snow at sunrise, soft golden light, shallow depth of field"
}
如果响应状态为 "queued" 或 "running",请轮询 GET https://api.doitong.ru/v1/requests/REQUEST_ID?wait=20,直到状态变为 "succeeded";文件位于 outputs[].url。使用相同请求体 POST https://api.doitong.ru/v1/quote/elevenlabs/music/v2,可在运行前返回确切价格。
与示例类似的文件: $1.20 1,200 API 积分 · ≈ ₽129.10 运行前会测量你的文件 在此页面运行
你的新 API 密钥。 它仅在此时显示,并且已填入下方的代码和 API 密钥字段中。请妥善保密:切勿将其放入在浏览器中运行的代码。
构建请求
控件根据模型架构生成。更改控件时,代码和价格会同步更新。
POST
/run/elevenlabs/music/v2?wait=20
报价 → $1.20
# Run the model; wait up to 20 s for the finished result in the same call
curl -X POST "https://api.doitong.ru/v1/run/elevenlabs/music/v2?wait=20" \
-H "Authorization: Bearer $DOITONG_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"prompt": "A red fox trots through fresh snow at sunrise, soft golden light, shallow depth of field"
}'
# Still "queued" or "running"? Poll with the id from the response:
curl "https://api.doitong.ru/v1/requests/REQUEST_ID?wait=20" \
-H "Authorization: Bearer $DOITONG_API_KEY"
const API = "https://api.doitong.ru/v1";
const headers = {
"Authorization": "Bearer " + process.env.DOITONG_API_KEY,
"Content-Type": "application/json",
};
// Run the model; wait up to 20 s for the finished result in the same call
let res = await fetch(API + "/run/elevenlabs/music/v2?wait=20", {
method: "POST",
headers,
body: JSON.stringify({
"prompt": "A red fox trots through fresh snow at sunrise, soft golden light, shallow depth of field"
}),
});
let request = await res.json();
if (!res.ok) throw new Error(request.error.code + ": " + request.error.message);
// Not finished yet: long-poll until it is
while (request.status === "queued" || request.status === "running") {
res = await fetch(API + "/requests/" + request.id + "?wait=20", { headers });
request = await res.json();
}
if (request.status !== "succeeded") throw new Error(JSON.stringify(request.error));
console.log(request.outputs.map((o) => o.url), request.cost.credits + " API credits ($" + request.cost.usd + ")");
import os
import requests
API = "https://api.doitong.ru/v1"
headers = {"Authorization": "Bearer " + os.environ["DOITONG_API_KEY"]}
payload = {
"prompt": "A red fox trots through fresh snow at sunrise, soft golden light, shallow depth of field",
}
# Run the model; wait up to 20 s for the finished result in the same call
r = requests.post(API + "/run/elevenlabs/music/v2", params={"wait": 20}, json=payload, headers=headers)
request = r.json()
if not r.ok:
raise RuntimeError(request["error"]["code"] + ": " + request["error"]["message"])
# Not finished yet: long-poll until it is
while request["status"] in ("queued", "running"):
request = requests.get(API + "/requests/" + request["id"], params={"wait": 20}, headers=headers).json()
if request["status"] != "succeeded":
raise RuntimeError(request["error"])
print([o["url"] for o in request["outputs"]], request["cost"]["credits"], "API credits", "$" + request["cost"]["usd"])
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "run",
"arguments": {
"model_id": "elevenlabs/music/v2",
"input": {
"prompt": "A red fox trots through fresh snow at sunrise, soft golden light, shallow depth of field"
},
"wait_seconds": 20
}
}
}
关于 Elevenlabs Music v2
根据最长 4100 个字符的文本 `prompt` 或结构化 `composition_plan` 创建音乐。配合提示词使用时,`music_length_ms` 将时长设为 3000 到 600000 ms,`force_instrumental` 会移除人声。`output_format` 选择编解码器、采样率和比特率,包括 MP3 和 PCM 选项。`seed` 仅适用于作曲方案。
参数
名称类型
默认值允许值
描述
prompt可选
类型string | null
≤ 4,100 个字符
所需音乐的文本描述。
composition_plan可选
类型object
按片段组织的音乐编排计划。
composition_plan.chunks必填
类型object[]
1 – 30 items
用于生成的有序片段,最多 30 个片段,总时长为 3000 ms 至 600000 ms。
composition_plan.chunks[].text必填
类型string
片段生成文本,最多 30 行,每行最多 200 个字符。歌词可包含花括号中的内联指示,例如 {scratching},也可以在可选的方括号开头部分名称(例如 [Verse 1])之后提供。该部分名称必须包含 1–100 个字符。
composition_plan.chunks[].duration_ms必填
类型integer
3,000 – 120,000
片段长度(以毫秒为单位),范围为 3000 ms 至 120000 ms。
composition_plan.chunks[].positive_styles必填
类型string[]
该片段所需的风格和音乐指示;第一片段的选择影响最大,因为它们决定歌曲的整体流派和基调。后续片段可以发展音乐、增加细节或改变方向;使用英文描述效果最佳。
composition_plan.chunks[].negative_styles可选
类型string[]
该片段中要避免的音乐风格和指示;仅在明确排除时指定条目,否则将列表留空通常是合适的默认设置。
composition_plan.chunks[].context_adherence可选
类型enum
lowmediumhigh
上下文遵循度用于平衡创作自由与相邻片段之间的一致性:选择高值以保持一致,或选择低值以允许更多创意偏离。
composition_plan.chunks[].audio_reference可选
类型object
该片段的风格条件音频片段;若要塑造整首歌曲,请在第一个片段中提供。由于其参考内容会影响后续每个片段,因此放置在此处的影响最大。
music_length_ms可选
类型integer | null
3,000 – 600,000
可选的歌曲时长(以毫秒为单位),范围为 3000 ms 至 600000 ms;仅在使用提示词时适用。省略时,模型会根据提示词确定时长。
force_instrumental可选
类型boolean
默认值false
仅器乐控制,仅在使用提示词时可用。设置为 true 可保证输出器乐;false 则根据提示词允许输出器乐或非器乐音乐。
seed可选
类型integer | null
音乐生成初始化种子,仅可与 `composition_plan` 一起使用,以提高具有相同参数和种子的多次运行之间的一致性。不能保证结果完全复现。
output_format可选
类型enum
默认值mp3_48000_192
mp3_22050_32mp3_24000_48mp3_44100_32mp3_44100_64mp3_44100_96mp3_44100_128mp3_44100_192mp3_48000_128mp3_48000_192mp3_48000_240mp3_48000_320pcm_8000pcm_16000pcm_22050pcm_24000pcm_32000
另外 9 个
pcm_44100pcm_48000ulaw_8000alaw_8000opus_48000_32opus_48000_64opus_48000_96opus_48000_128opus_48000_192使用 codec_sample_rate_bitrate 模式选择生成音频的格式。Twilio 音频输入通常使用 μ-law,也写作 mu-law 或近似写作 u-law;MP3 示例为 mp3_22050_32,表示采样率为 22.05 kHz、比特率为 32 kbs。
必填
输出
GET /requests/req_8k2m4q7x1z9c3v5b6n0p2r4t
{
"id": "req_8k2m4q7x1z9c3v5b6n0p2r4t",
"object": "request",
"model": "elevenlabs/music/v2",
"status": "succeeded",
"created_at": "2026-10-20T12:00:00Z",
"started_at": "2026-10-20T12:00:02Z",
"completed_at": "2026-10-20T12:00:09Z",
"queue_position": null,
"cost": {
"credits": 1200,
"usd": "1.20",
"charged": 1200,
"refunded": 0
},
"input": {
"prompt": "A red fox trots through fresh snow at sunrise, soft golden light, shallow depth of field"
},
"output": {
"audio": {
"url": "https://content.doitong.com/dev-api/2026/10/20/req_8k2m4q7x1z9c3v5b6n0p2r4t/0-output.mp3",
"content_type": "audio/mpeg",
"file_name": "0-output.mp3",
"file_size": 1843200
}
},
"outputs": [
{
"type": "audio",
"url": "https://content.doitong.com/dev-api/2026/10/20/req_8k2m4q7x1z9c3v5b6n0p2r4t/0-output.mp3",
"content_type": "audio/mpeg",
"file_size": 1843200,
"duration": 12,
"stored": true
}
],
"error": null,
"metrics": {
"inference_seconds": 6.8
},
"urls": {
"self": "https://api.doitong.ru/v1/requests/req_8k2m4q7x1z9c3v5b6n0p2r4t",
"cancel": "https://api.doitong.ru/v1/requests/req_8k2m4q7x1z9c3v5b6n0p2r4t/cancel"
}
}
你的文件,由你选择每个 outputs[].url 都是存储中的副本:可永久保存(按 GB-月付费),也可免费保存 7 天,由账户设置或 ?storage= 决定。
每个模型的结构相同图像、视频和音频均包含 type、url、content_type、width、height 和 duration。output 是模型自身的结果对象。
输出字段
- audio
- object {url, content_type, file_name, file_size}编码为 MP3 音频的生成音乐文件。
其他 Elevenlabs Music 变体
更多模型:文本生成音乐
对于 AI 代理:此页面的 Markdown 版本位于 https://doitong.com/zh/developers/models/elevenlabs/music/v2.md. 所有模型和指南: https://doitong.com/developers/llms.txt