ElevenLabs

elevenlabs/eleven-v4-turbo

文字转语音

38 / 5,000

38 个字符 · 预计冻结 $0.00152

更多设置(7 项)

范围:0 – 4294967295

生成结果演示示例登录后试用

$0.04 / 千字符 · 按文本实际字符数计费

0:00 / 0:00
下载音频
示例 · 由以下输入生成

[excited] Hello! Welcome to Eleven v4.

价格

单价 $0.04 / 千字符

按输入文本字符数计费,每 1,000 字符计价,按实际长度折算(空格、标点和标签都计入)。

每次请求按本次文本的字符数临时冻结相应费用(每 1,000 字符 $0.04,按 Unicode 字符计数,最少按 1 个字符计;最长文本最多 $0.20;请求带有未声明的字段,或其他超过 64 个字符的自由文本时,冻结 $0.20),按实际用量扣费,通常在一分钟内完成:多余部分退回,超出部分从余额扣除,余额可能因此变为负数;余额为负时新请求暂停,充值后先抵扣欠款。

例如:100 个字符冻结 $0.004,1,000 个字符冻结 $0.04。

余额需不低于 $0.01,且足以支付本次冻结。

生成失败不收费。

API 接入

用这个模型 ID 提交生成请求。

POST/v1/model-tasks
elevenlabs/eleven-v4-turbo
请求体
{
  "model": "elevenlabs/eleven-v4-turbo",
  "input": {
    "apply_text_normalization": "auto",
    "output_format": "mp3_44100_128",
    "similarity_boost": 0.75,
    "stability": 0.5,
    "text": "[excited] Hello! Welcome to Eleven v4.",
    "timestamps": false,
    "voice": "Rachel"
  }
}

输入 Schema

参数类型是否必填默认值
textstring必填—
apply_text_normalizationstring可选auto
language_codestring可选—
output_formatstring可选mp3_44100_128
seedinteger可选—
similarity_boostnumber可选0.75
stabilitynumber可选0.5
timestampsboolean可选false
voicestring可选Rachel

返回结果

接口会返回生成结果,或返回可轮询的异步任务;具体响应方式与结果字段见下方示例和 Schema。

异步任务
提交响应
HTTP 202
/v1/model-tasksapplication/json
{
  "id": "task_example",
  "model": "elevenlabs/eleven-v4-turbo",
  "status": "queued"
}
状态响应
HTTP 200
/v1/model-tasks/{id}application/json
{
  "id": "task_example",
  "model": "elevenlabs/eleven-v4-turbo",
  "status": "completed",
  "output": {
    "audio": {
      "url": "https://api.musespan.com/v1/model-tasks/task_example/artifacts/0"
    }
  }
}
文件下载
HTTP 200
/v1/model-tasks/{id}/artifacts/{index}生成的音频(如 audio/mpeg)

任务完成后,output 里的文件地址就指向此接口,序号从 0 开始。下载时要带上同一个 API Key(Authorization 请求头)。

错误响应
HTTP 400
/v1/model-tasksapplication/json
{
  "error": {
    "code": "invalid_input",
    "message": "The input does not match this model's input schema. Check the model's API documentation.",
    "type": "invalid_request_error"
  }
}

调用示例

异步任务提交后返回任务 ID,轮询至 status 为 completed 后,按返回结果获取生成内容。API Key 在控制台获取。

# Use a new directory for each new generation. Rerunning here continues this task.
set -eu
test -s model-task-id.txt || python3 -c "import uuid; print(uuid.uuid4())" > model-task-id.txt
REQUEST_ID=$(cat model-task-id.txt)
# Idempotent: resending the same bytes with the same ID never charges twice.
curl --fail-with-body --retry 3 --retry-connrefused --request POST 'https://api.musespan.com/v1/model-tasks' \
  --header "Authorization: Bearer $MUSESPAN_API_KEY" \
  --header "X-Request-Id: $REQUEST_ID" \
  --header "Content-Type: application/json" \
  --data '{"model":"elevenlabs/eleven-v4-turbo","input":{"apply_text_normalization":"auto","output_format":"mp3_44100_128","similarity_boost":0.75,"stability":0.5,"text":"[excited] Hello! Welcome to Eleven v4.","timestamps":false,"voice":"Rachel"}}'
# Poll every 5 seconds for up to 25 minutes until status is completed or failed.
# Still queued (with queue_position) 5 minutes after submission: failed with queue_timeout, not charged.
# No result 15 minutes after acceptance (or no confirmation 15 minutes after submission): failed with generation_timeout, not charged.
# Any failure is final: generate again in a new directory (a new X-Request-Id).
# A 404 means the POST did not arrive: rerun this script to resend it with the same ID.
curl --fail-with-body 'https://api.musespan.com/v1/model-tasks/'"$REQUEST_ID"'' --header "Authorization: Bearer $MUSESPAN_API_KEY"