Elevenlabs Music V2.5
elevenlabs/music-v2.5
价格
elevenlabs/music-v2.5 每分钟(不足一分钟按一分钟)
| 单价 | $0.860 |
|---|
模型介绍撰写中
该模型的详细指南正在准备中。下方的价格、参数与 API 文档已可查阅。
提交生成任务
https://api.hiapi.ai/v1/tasks 请求头
Authorizationstring必填账号 API Key,所有请求必填。示例:Bearer YOUR_HIAPI_API_KEY。获取 API Key
Content-Typestring可选请求体固定按 JSON 解析;如携带,仅接受 application/json(可带 charset),其他取值返回 415。示例:application/json。
Idempotency-Keystring可选幂等键,最长 255 字节。同账户同键的重试只创建一次任务,重放返回首次 taskId。
网络超时或客户端自动重试时,同键只创建一次任务、不会重复扣费(幂等范围 = API Key 所属账户)。建议用业务侧唯一标识做键(如 "order-42");同键重放返回首次 taskId,键在首次提交 24 小时后过期。详细的场景矩阵见统一异步接口介绍页。
请求体
modelstring必填当前固定值:elevenlabs/music-v2.5
routestring可选当前固定值:default
inputobject必填
elevenlabs/music-v2.5 和线路 default 的业务参数对象,见下方参数表。
seedinteger可选min 0max 2147483647Composition plan mode only. Same seed and parameters give more consistent, not identical, results.
modelstring可选默认值: "elevenlabs/music-v2.5"Model name
elevenlabs/music-v2.5promptstring可选minLength 1maxLength 4100pattern \SDescribe genre, mood, instruments, vocals, structure and lyrics. Supply a prompt or a composition plan, not both.
output_formatstring可选默认值: "mp3_48000_192"codec_samplerate_bitrate, for example mp3_48000_192.
mp3_22050_32mp3_24000_48mp3_44100_32mp3_44100_64mp3_44100_96mp3_44100_128mp3_44100_192mp3_48000_128显示全部(17 项)
mp3_48000_192mp3_48000_240mp3_48000_320pcm_8000pcm_16000pcm_22050pcm_24000pcm_32000pcm_44100pcm_48000ulaw_8000alaw_8000opus_48000_32opus_48000_64opus_48000_96opus_48000_128opus_48000_192music_length_msinteger可选默认值: 60000min 3000max 600000Length of the generated music in milliseconds, 3,000 to 600,000. Prompt mode only. Defaults to 60,000 (1 minute).
composition_planobject可选
Chunk-by-chunk plan. 1 to 30 chunks, total duration 3,000 to 600,000 ms. Supply a composition plan or a prompt, not both.
chunksarray必填minItems 1maxItems 30
Array [ object ]
数组元素
textstring必填minLength 1Optional [Section name] followed by lyric lines; inline directions in {curly braces}. Up to 30 lines of 200 characters.
duration_msinteger必填min 3000max 120000audio_referenceobject可选
end_msinteger可选Defaults to 30,000 ms after start_ms or the end of the clip. The window is at most 30,000 ms.
start_msinteger可选默认值: 0min 0strengthstring可选lowmediumhighxhighaudio_urlstring必填Audio clip whose style conditions this chunk. The reference on the first chunk influences the whole song.
negative_stylesarray可选Array [ string ]
positive_stylesarray必填Styles and musical directions for this chunk, English works best. The first chunk sets the overall tone.
Array [ string ]
context_adherencestring可选lowmediumhighforce_instrumentalboolean可选默认值: falseGuarantee an instrumental result without vocals. Prompt mode only.
callbackobject可选
终态通知配置;为空则不回调,由调用方自行查询。详见下方回调说明。
创建任务时提供 callback.url,任务终态时 HiAPI 主动 POST 通知你的服务,可免去轮询。回调请求体与任务详情数据结构同构;签名校验、投递重试与幂等说明见统一异步接口介绍页的回调说明。
urlstring必填callback 存在时必填;任务终态后向该 URL 发起 POST,须为合法 http(s) URL。
whenstring可选默认值: "final"当前仅支持 final,即 success / fail 均回调。
finalstoragestring可选默认值: "temp"产物存储档位:temp(默认,保留约 7 天)或 persistent(长期保存,按大小计费)。余额不足或超出存储上限会静默降级为 temp;实际生效档位见任务详情响应。
temppersistent请求示例
# 提交异步任务,成功立即返回 taskId(不等待生成完成)
curl -X POST "https://api.hiapi.ai/v1/tasks" \
-H "Authorization: Bearer $HIAPI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "elevenlabs/music-v2.5",
"input": {
"model": "elevenlabs/music-v2.5",
"output_format": "mp3_48000_192",
"music_length_ms": 60000,
"force_instrumental": false
}
}' const res = await fetch("https://api.hiapi.ai/v1/tasks", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.HIAPI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
model: "elevenlabs/music-v2.5",
input: {
"model": "elevenlabs/music-v2.5",
"output_format": "mp3_48000_192",
"music_length_ms": 60000,
"force_instrumental": false
}
}),
});
const task = await res.json();
// { code: 200, message: "success", data: { taskId } } import os, requests
res = requests.post(
"https://api.hiapi.ai/v1/tasks",
headers={"Authorization": f"Bearer {os.environ['HIAPI_API_KEY']}"},
json={
"model": "elevenlabs/music-v2.5",
"input": {
"model": "elevenlabs/music-v2.5",
"output_format": "mp3_48000_192",
"music_length_ms": 60000,
"force_instrumental": false
}
},
)
print(res.json()) # { code, message, data: { taskId } } 200 OK
{
"code": 200,
"message": "success",
"data": {
"taskId": "tk-hiapi-01HZTQ8BX2N3GM3YFK4Z9D7VQR"
}
} 400 Bad Request
{
"code": 400,
"message": "invalid request",
"data": null,
"error_code": "INVALID_REQUEST"
} 获取任务详情
https://api.hiapi.ai/v1/tasks/:id 响应字段
taskIdstring必填任务 ID,前缀固定 tk-hiapi-。
modelstring必填解析后的模型全名。用 route 参数提交的任务返回 base@线路(如 gpt-image-2/text-to-image@ext);否则与创建时传入的模型名一致。
routestring可选仅当任务用显式 route 参数提交时出现,回显提交时的原值。
statusstring必填任务状态。
queued 已入队,尚未开始。
handling 处理中。
archiving 处理完成,产物准备中。
success 终态:完成,产物可用(返回 output)。
fail 终态:失败(返回 error)。
提交后按 status 判断:success 或 fail 为终态,其余为非终态,建议按 1~3 秒间隔轮询直至终态。成功终态后从 output[].url 下载产物,并在 expireAt 前完成下载或转存;需要长期保留时在创建任务时使用 storage: "persistent"。
creatednumber必填任务创建时间(Unix 秒)。
completednumber必填进入终态的 Unix 秒;非终态固定为 0。
outputarray可选
仅 status == success 时出现。产物列表,始终为数组,同一任务可能同时返回多个 type(如 video + first_frame)。
Array [ object ]
数组元素
urlstring必填资源 URL,可直接下载。
typestring必填当前可能值:video、image、audio、first_frame、last_frame、thumbnail,后续可能会扩展。
expireAtnumber必填资源可访问截止时间(Unix 秒);过期前请完成下载或转存。
errorobject可选
仅 status == fail 时出现。
codestring必填业务错误码。
messagestring必填错误描述。
响应示例
成功
{
"code": 200,
"message": "success",
"data": {
"taskId": "tk-hiapi-01HZTQ8BX2N3GM3YFK4Z9D7VQR",
"model": "happyhorse-1-0",
"status": "success",
"created": 1777282033,
"completed": 1777282099,
"output": [
{
"url": "https://cdn.hiapi.ai/tasks/.../video.mp4",
"type": "video",
"expireAt": 1777886899
}
]
}
} 处理中(非终态)
{
"code": 200,
"message": "success",
"data": {
"taskId": "tk-hiapi-...",
"model": "happyhorse-1-0",
"status": "archiving",
"created": 1777282033,
"completed": 0
}
} 失败
{
"code": 200,
"message": "success",
"data": {
"taskId": "tk-hiapi-...",
"model": "happyhorse-1-0",
"status": "fail",
"created": 1777282033,
"completed": 1777282099,
"error": {
"code": "TASK_FAILED",
"message": "task failed"
}
}
}