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-TW/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-TW/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 點數 · ≈ ₽128.78 您的檔案會在執行前計量 在此頁面執行
您的新 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` 僅適用於 composition plan。
參數
名稱類型
預設值允許值
說明
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
情境遵循度會在創意自由與鄰近區塊的一致性之間取得平衡:選擇 high 以保持一致,或選擇 low 以允許更多創意偏離。
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-TW/developers/models/elevenlabs/music/v2.md. 所有模型與指南: https://doitong.com/developers/llms.txt