APIMaster.ai

APIMaster ElevenLabs API

使用 APIMaster API Key,以 `Authorization: Bearer` 標頭驗證。下列端點位於 `/v1/elevenlabs`,參數參考連結指向 ElevenLabs。

使用 APIMaster API Key,以 Authorization: Bearer 標頭驗證。下列端點位於 /v1/elevenlabs,參數參考連結指向 ElevenLabs。

上傳端點依本機檔案計量,目前不接受遠端音訊 URL 或轉錄 webhook。聲音設計需要至少 100 字元的試聽文字。音樂和音效需要指定時長。即時對話透過 APIMaster WebSocket 建立,閘道管理上游憑證。提交音訊後傳送 response.create,等待 response.done。

模型與端點

功能 模型 ID 上游端點 常用參數
語音合成與對白 eleven_v4, eleven_v4_turbo, eleven_v3, eleven_v3_conversational, eleven_multilingual_v2, eleven_flash_v2_5, eleven_flash_v2, eleven_turbo_v2_5, eleven_turbo_v2 POST /v1/elevenlabs/text-to-speech/{voice_id} · POST /v1/elevenlabs/text-to-dialogue text · model_id · voice_settings · language_code · output_format · inputs[].voice_id · inputs[].text
檔案轉錄 scribe_v3, scribe_v2, scribe_v2_medical POST /v1/elevenlabs/speech-to-text model_id · file · language_code · diarize · timestamps_granularity · keyterms · transcript_edit
即時轉錄 scribe_v3_live, scribe_v2_realtime WSS /v1/elevenlabs/speech-to-text/realtime model_id · audio_format · commit_strategy · audio_base_64 · commit
變聲 eleven_multilingual_sts_v2, eleven_english_sts_v2 POST /v1/elevenlabs/voice-changer/{voice_id} audio · model_id · remove_background_noise · voice_settings · output_format
聲音設計 eleven_ttv_v3, eleven_multilingual_ttv_v2 POST /v1/elevenlabs/text-to-voice/design model_id · voice_description · text · guidance_scale · seed
音效 eleven_text_to_sound_v3, eleven_text_to_sound_v2 POST /v1/elevenlabs/sound-generation model_id · text · duration_seconds · loop · prompt_influence
音樂 music_v2_5, music_v2, music_v1 POST /v1/elevenlabs/music model_id · prompt · composition_plan · music_length_ms · force_instrumental
即時對話 eleven_realtime_v1_mini, eleven_realtime_v1_max WSS /v1/elevenlabs/realtime model · input_audio_buffer.append · response.create
影音配音 dubbing_v2, dubbing_v1 POST /v1/elevenlabs/dubbing/project model_id · file · source_language · target_language · project_id

參數與回應

  • 語音合成的 voice_id 選擇音色,model_id 選擇模型。language_code 指定語言,voice_settings 調整語音表現。多人對白在每個 inputs 項目中各自指定文字和音色。
  • 檔案轉錄使用 file 上傳音訊。diarize 可標注說話者,timestamps_granularity 決定時間戳精細度。即時轉錄傳送 Base64 編碼的 PCM 區塊,以 commit 提交片段並等候 committed_transcript。
  • 變聲保留輸入的節奏與表演,voice_id 指定目標音色。聲音設計回傳三條試聽。手動輸入 text 至少 100 字元。
  • 音效的 duration_seconds 接受 0.5–30 秒。音樂使用 prompt 或 composition_plan。使用 prompt 時可用 music_length_ms 指定長度,force_instrumental 可指定純演奏。
  • 配音先取得 project_id,查詢專案及目標語言狀態,完成後從 outputs.lossless_audio 下載音軌。

使用範例

curl https://apimaster.ai/v1/elevenlabs/text-to-speech/JBFqnCBsd6RMkjVDRZzb \
  -H "Authorization: Bearer $APIMASTER_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{"model_id":"eleven_v4","text":"Hello from ElevenLabs."}' \
  --output speech.mp3

curl https://apimaster.ai/v1/elevenlabs/speech-to-text \
  -H "Authorization: Bearer $APIMASTER_API_KEY" \
  -F 'model_id=scribe_v3' -F 'file=@speech.mp3' \
  -F 'diarize=true' -F 'timestamps_granularity=word'

curl https://apimaster.ai/v1/elevenlabs/music \
  -H "Authorization: Bearer $APIMASTER_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{"model_id":"music_v2_5","prompt":"Soft piano jingle","music_length_ms":3000,"force_instrumental":true}' \
  --output jingle.mp3

curl https://apimaster.ai/v1/elevenlabs/dubbing/project \
  -H "Authorization: Bearer $APIMASTER_API_KEY" \
  -F 'model_id=dubbing_v2' -F 'file=@speech.mp3' \
  -F 'source_language=en' -F 'target_language=es'

curl "https://apimaster.ai/v1/elevenlabs/dubbing/project/$PROJECT_ID" \
  -H "Authorization: Bearer $APIMASTER_API_KEY"

curl "https://apimaster.ai/v1/elevenlabs/dubbing/project/$PROJECT_ID/language/$LANGUAGE_ID" \
  -H "Authorization: Bearer $APIMASTER_API_KEY"

請求格式與限制

合成、對話、聲音設計、音效和音樂使用 application/json,本文上限 4 MiB。將 output_format 放在查詢字串中。多人對話支援 eleven_v4 和 eleven_v3。在合成、對話、變聲、音樂或音訊隔離的路徑末尾加上 /stream,即可分段接收回應。

上傳使用 multipart/form-data,每次只傳一個檔案。變聲和音訊隔離使用 audio,轉錄、對齊、分軌和配音使用 file。原始單聲道 16 kHz 16 位元小端序 PCM 可用 file_format=pcm_s16le_16。

音樂長度為 3,000–600,000 毫秒。使用 prompt 時填寫 music_length_ms。使用 composition_plan 時須為每段設定 duration_ms 並維持固定段落長度。

即時對話範例

安裝 websocket-client 並設定 APIMASTER_API_KEY。收到 session.created 後即可傳送輸入。可從 response.audio.delta 或 response.output_audio.delta 播放音訊,並從 response.done 讀取本輪狀態與用量。

import json
import os
from urllib.parse import urlsplit, urlunsplit

from websocket import create_connection

base = urlsplit("https://apimaster.ai/v1")
url = urlunsplit(("wss", base.netloc, base.path.rstrip("/") + "/elevenlabs/realtime",
                  "model=eleven_realtime_v1_mini", ""))
socket = create_connection(
    url, header={"Authorization": "Bearer " + os.environ["APIMASTER_API_KEY"]},
    timeout=30,
)
try:
    assert json.loads(socket.recv())["type"] == "session.created"
    socket.send(json.dumps({
        "type": "conversation.item.create",
        "item": {"type": "message", "role": "user",
                 "content": [{"type": "input_text", "text": "Say hello."}]},
    }))
    socket.send(json.dumps({"type": "response.create"}))
    while True:
        event = json.loads(socket.recv())
        if event["type"] == "error":
            raise RuntimeError(event["error"])
        if event["type"] == "response.done":
            print(event["response"]["status"], event["response"].get("usage"))
            break
finally:
    socket.close()

獨立音訊端點

計費與相容性

語音合成按字元計量,其他音訊功能使用各自的時長單位。即時對話同時計連線分鐘與 token。聲音設計的三條試聽只按試聽文字扣一次點數。官方計畫於 2027-01-31 移除 music_v1,於 2027-03-01 移除 eleven_text_to_sound_v2。

官方定價