lively-coat-10905
11/26/2025, 1:37 PMtall-airline-16756
11/26/2025, 1:37 PMtall-airline-16756
11/26/2025, 1:38 PMmodel="eleven_turbo_v2_5" to model_id="eleven_turbo_v2_5". The plugin expects `model_id`; using model can cause initialization failures that look like a closed WebSocket.
1. Verify your API key
• Ensure ELEVEN_API_KEY is set, correct, and accessible to your process (print or log a masked value to confirm it's being loaded).
1. Confirm the voice supports Arabic
• The voice ID you provided may not support language="ar". Test with a known Arabic-capable voice or temporarily remove language to see if the connection succeeds.
1. Test connectivity to ElevenLabs
• From the same machine run a quick network test:
◦ curl -v https://api.elevenlabs.io
◦ Confirm no firewall/proxy is blocking outbound TLS to api.elevenlabs.io
1. Turn up logging and capture the ElevenLabs plugin logs
• Keep enable_logging=True. Capture the full debug logs around the WebSocket open/close to see whether the server sends a close frame or the client closes.
1. Update the plugin
• Run: pip install --upgrade livekit-plugins-elevenlabs to ensure you have the latest WebSocket handling fixes.
1. Add retry/fallback (optional)
• If intermittent network or voice incompatibility is suspected, wrap ElevenLabs in a FallbackAdapter with a secondary TTS to avoid repeated failures during testing.
If you try the model_id fix and the connectivity/voice checks and still see the same error, please share:
• The exact livekit-plugins-elevenlabs version (pip show livekit-plugins-elevenlabs)
• The trimmed debug log lines immediately before the "websocket closed unexpectedly" message
• Whether you’re behind a proxy or corporate firewall
I’ll use that to guide the next step. Would you like instructions for checking the plugin version and collecting the debug logs?
Sources: ElevenLabs TTS plugin guide | LiveKit Docs | Events and error handling | LiveKit docslively-coat-10905
11/26/2025, 1:40 PMGET / HTTP/1.1
Host: api.elevenlabs.io
User-Agent: curl/8.13.0
Accept: /* Request completely sent off < HTTP/1.1 404 Not Found < date: Wed, 26 Nov 2025 133908 GMT < server: uvicorn < Content-Length: 22 < content-type: application/json < access-control-allow-origin: * < access-control-allow-headers: * < access-control-allow-methods: POST, PATCH, OPTIONS, DELETE, GET, PUT < access-control-max-age: 600 < strict-transport-security: max-age=31536000; includeSubDomains < x-trace-id: c2274c4616c6ed7f06b6acb6369de28b < x-region: us-central1 < Via: 1.1 google, 1.1 google < Alt-Svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000 < {"detail":"Not Found"}* Connection #0 to host api.elevenlabs.io left intact
tall-airline-16756
11/26/2025, 1:40 PMmodel_id change
• Confirm your TTS config now uses model_id="eleven_turbo_v2_5" (not model). Paste the exact TTS snippet if you want me to check.
2) Test the ElevenLabs synth endpoint with your API key
• Run this (replace <KEY> and a voice id you have) and paste the response:
curl -s -o /dev/null -w "%{http_code}\n" -X POST "https://api.elevenlabs.io/v1/text-to-speech/G1qujbcurbblbamyltgl" \ -H "xi-api-key: <KEY>" \ -H "Content-Type: application/json" \ -d "{\"text\":\"مرحبا\"}"
• Expected: 200 or 201 (not 401/403). If you get 401/403, the key is invalid or missing scopes.
3) Share plugin version and trimmed debug lines
• Run: pip show livekit-plugins-elevenlabs
Paste the Version value.
• From your agent logs, copy 8–12 lines immediately before the "websocket closed unexpectedly" warning (include any stack frames from the elevenlabs plugin).
What I’ll do once you share those: confirm the config, verify the API key/endpoint response, check for known version bugs, and point to the exact next fix (voice compatibility, auth, or plugin update).thousands-needle-14336
11/26/2025, 1:42 PMlively-coat-10905
11/26/2025, 1:42 PMtall-airline-16756
11/26/2025, 1:42 PMTypeError: TTS.__init__() got an unexpected keyword argument 'model_id'. That means the version of the ElevenLabs TTS plugin you're using does not accept model_id. Two ways to proceed:
Options
• Keep your current plugin version: revert to the original parameter name model="eleven_turbo_v2_5" in your TTS constructor.
• Upgrade the plugin: install a version that supports model_id and keep model_id="eleven_turbo_v2_5".
Please run these two commands and paste the outputs so I can recommend the best next step: 1) pip show livekit-plugins-elevenlabs 2) pip list | grep livekit
If you prefer to try one quick change now, either:
• Revert to:
tts=elevenlabs.TTS(
api_key=os.getenv("ELEVEN_API_KEY"),
voice_id="G1qujbcurbblbamyltgl",
model="eleven_turbo_v2_5",
language="ar",
enable_ssml_parsing=False,
apply_text_normalization="auto",
enable_logging=True,
)
or
• Upgrade and then use `model_id`:
pip install --upgrade livekit-plugins-elevenlabs
Also keep in mind the monthly token/quota point you mentioned — if the API key quota is exhausted the WebSocket can close. After you share the plugin version outputs, I’ll confirm which change is best and next troubleshooting steps (voice compatibility, quota check, or full debug log parsing).lively-coat-10905
11/26/2025, 1:45 PMtall-airline-16756
11/26/2025, 1:46 PMmodel_id, voice_id, or language. Use the parameter names this plugin expects.
Please update your TTS config to this form (matches v1.3.5):
tts = elevenlabs.TTS(
api_key=os.getenv("ELEVEN_API_KEY"),
voice="G1qujbcurbblbamyltgl",
model_id="eleven_turbo_v2_5",
language_code="ar",
enable_ssml_parsing=False,
apply_text_normalization="auto",
enable_logging=True,
)
Next steps to resolve the WebSocket closures:
• Confirm the API key quota: verify the ElevenLabs key monthly/request limits and usage; exhausted quota will close connections. Increase quota or use a key with sufficient allowance.
• Test direct synth call with your key and voice (replace <KEY>):
curl -s -o /dev/null -w "%{http_code}\n" -X POST "https://api.elevenlabs.io/v1/text-to-speech/G1qujbcurbblbamyltgl" -H "xi-api-key: <KEY>" -H "Content-Type: application/json" -d "{\"text\":\"مرحبا\"}" Expected 200/201. 401/403 = auth issue; 429 = quota limit.
• Ensure the voice supports Arabic. If the voice doesn’t support ar, switch to a confirmed Arabic-capable voice for testing.
• Keep enable_logging=True and capture the debug log lines immediately before the "websocket closed unexpectedly" message if the problem persists.
If you’d like, paste the curl HTTP status you get from the synth test and the 8–12 log lines before the websocket warning; I’ll help interpret them and recommend the exact next action.
Sources: ElevenLabs TTS plugin guide | LiveKit Docs | Models | LiveKit Docslively-coat-10905
11/26/2025, 1:49 PMtall-airline-16756
11/26/2025, 1:49 PMTTS.__init__() got an unexpected keyword argument 'voice') and that you set the ElevenLabs key to unlimited. You're on livekit-plugins-elevenlabs 1.3.5, so use the parameters that version expects.
Please update your TTS config to this exact form:
tts = elevenlabs.TTS(
api_key=os.getenv("ELEVEN_API_KEY"),
voice_id="G1qujbcurbblbamyltgl",
model="eleven_multilingual_v2",
language="ar",
enable_ssml_parsing=False,
apply_text_normalization="auto",
)
Notes and next checks:
• Use voice_id, model, and language (these match v1.3.5). Do not pass voice, model_id, or enable_logging — those cause the TypeError.
• Use model="eleven_multilingual_v2" for Arabic; other models may not support ar.
• Even with "unlimited" set, confirm the key returns 200/201 when testing the synth endpoint (this rules out quota/auth issues):
curl -s -o /dev/null -w "%{http_code}\n" -X POST "https://api.elevenlabs.io/v1/text-to-speech/G1qujbcurbblbamyltgl" \ -H "xi-api-key: <KEY>" \ -H "Content-Type: application/json" \ -d '{"text":"مرحبا","model_id":"eleven_multilingual_v2"}'
• Expected: 200/201. If you get 401/403 -> key/auth problem; 429 -> quota/rate-limit.
If that config still yields "websocket closed unexpectedly," paste:
• The HTTP status from the curl test above
• 8–12 log lines immediately before the websocket warning
I’ll interpret them and tell you the exact next step.
Sources: ElevenLabs TTS plugin guide | LiveKit Docs | ElevenLabs TTS | LiveKit Docstall-airline-16756
11/26/2025, 1:51 PMcurl -s -o $null -w "%{http_code}`n" -X POST "https://api.elevenlabs.io/v1/text-to-speech/G1qujbcurbblbamyltgl" `
-H "xi-api-key: YOUR_KEY_HERE" `
-H "Content-Type: application/json" `
-d '{"text":"مرحبا","model_id":"eleven_multilingual_v2"}'
Windows cmd:
curl -s -o nul -w "%%{http_code}%%\n" -X POST "https://api.elevenlabs.io/v1/text-to-speech/G1qujbcurbblbamyltgl" ^
-H "xi-api-key: YOUR_KEY_HERE" ^
-H "Content-Type: application/json" ^
-d "{\"text\":\"مرحبا\",\"model_id\":\"eleven_multilingual_v2\"}"
What I need next:
• The HTTP status code returned (e.g., 200, 401, 429).
• If it’s not 200/201, paste the response body (remove or mask the API key).
I’ll interpret the result and give the exact next step (auth/quota/voice compatibility).lively-coat-10905
11/26/2025, 1:56 PMtall-airline-16756
11/26/2025, 1:56 PM& curl.exe -s -o $null -w "%{http_code}`n" -X POST "https://api.elevenlabs.io/v1/text-to-speech/G1qujbcurbblbamyltgl" `
-H "xi-api-key: YOUR_KEY_HERE" `
-H "Content-Type: application/json" `
-d '{"text":"مرحبا","model_id":"eleven_multilingual_v2"}'
Option B — use PowerShell built-in Invoke-RestMethod:
$response = Invoke-RestMethod -Uri "https://api.elevenlabs.io/v1/text-to-speech/G1qujbcurbblbamyltgl" `
-Method POST `
-Headers @{"xi-api-key"="YOUR_KEY_HERE"; "Content-Type"="application/json"} `
-Body '{"text":"مرحبا","model_id":"eleven_multilingual_v2"}' -ErrorAction Stop
$response | ConvertTo-Json
If Invoke-RestMethod throws an error, run this to capture status and body:
try {
Invoke-RestMethod -Uri "https://api.elevenlabs.io/v1/text-to-speech/G1qujbcurbblbamyltgl" -Method POST -Headers @{"xi-api-key"="YOUR_KEY_HERE"; "Content-Type"="application/json"} -Body '{"text":"مرحبا","model_id":"eleven_multilingual_v2"}' -ErrorAction Stop
Write-Output "200"
} catch {
$status = $_.Exception.Response.StatusCode.Value__
$body = (New-Object System.IO.StreamReader($_.Exception.Response.GetResponseStream())).ReadToEnd()
Write-Output $status
Write-Output $body
}
Mask your API key when pasting results. Send me the numeric HTTP status (and body if not 200/201) and I’ll tell you the exact next step.tall-airline-16756
11/26/2025, 2:00 PM$headers = @{ "xi-api-key" = "NEW_KEY"; "Content-Type" = "application/json" }
$body = '{"text":"مرحبا","model_id":"eleven_multilingual_v2"}'
try {
$resp = Invoke-RestMethod -Uri "https://api.elevenlabs.io/v1/text-to-speech/G1qujbcurbblbamyltgl" -Method POST -Headers $headers -Body $body -ErrorAction Stop
Write-Output "200"
} catch {
$r = $_.Exception.Response
$status = $r.StatusCode.Value__
$reader = New-Object System.IO.StreamReader($r.GetResponseStream())
$respBody = $reader.ReadToEnd()
Write-Output $status
Write-Output $respBody
}
Share the numeric status (and response body if not 200). I’ll interpret it and give the exact next step (auth/quota/voice compatibility).lively-coat-10905
11/26/2025, 2:02 PMtall-airline-16756
11/26/2025, 2:02 PM$h=@{"xi-api-key"="NEW_KEY"}
Invoke-RestMethod -Uri "https://api.elevenlabs.io/v1/voices" -Method GET -Headers $h | ConvertTo-Json
• Copy a returned voice_id from that response.
2) Test synth with a returned voice_id and multilingual model:
$h=@{"xi-api-key"="NEW_KEY"; "Content-Type"="application/json"}
$body='{"text":"مرحبا","model_id":"eleven_multilingual_v2"}'
Invoke-RestMethod -Uri "https://api.elevenlabs.io/v1/text-to-speech/RETURNED_VOICE_ID" -Method POST -Headers $h -Body $body
• If you get 200/201 the voice works for Arabic. If 401/403 → auth; 429 → quota; 404 → voice not available to your key.
3) Update your LiveKit TTS config (v1.3.5) to use that valid voice_id and model:
tts = elevenlabs.TTS(
api_key=os.getenv("ELEVEN_API_KEY"),
voice_id="RETURNED_VOICE_ID",
model="eleven_multilingual_v2",
language="ar",
enable_ssml_parsing=False,
apply_text_normalization="auto",
)
4) If synth still fails with websocket closes, capture the 8–12 log lines immediately before the websocket warning and paste them here, plus:
• The HTTP status from the synth test above
• The plugin version (you already shared 1.3.5 — keep that)
If you want, paste the voices JSON here (mask the key) and I’ll point to an Arabic-capable voice to use.