Skip to content

403 Forbidden Error with EU Residency Endpoint for TTS #625

@KidesLeo

Description

@KidesLeo

Description

I am encountering a 403 Forbidden error when attempting to use the ElevenLabs Text-to-Speech (TTS) service with the EU data residency endpoint. I am using the livekit-plugins-elevenlabs Python library, which wraps the ElevenLabs Python SDK.

  • What I was trying to achieve: I am trying to use the ElevenLabs TTS service with my application hosted in the EU, so I am using the EU data residency endpoint: https://api.eu.residency.elevenlabs.io/.

  • What happened instead: My application receives a 403 Forbidden error when it attempts to connect to the TTS service. The error occurs during the WebSocket handshake for streaming synthesis.

  • Relevant parameters or configurations:

Code example

Steps to reproduce:

  1. Configure the elevenlabs.TTS plugin from the livekit-plugins-elevenlabs library.
  2. Set the base_url parameter to https://api.eu.residency.elevenlabs.io/.
  3. Attempt to synthesize speech using the streaming interface.

Expected behavior:

The TTS service should accept the connection and stream the synthesized audio data back to my application.

Actual behavior:

The connection is rejected with a 403 Forbidden error during the WebSocket handshake.

Code example

I am using the livekit-plugins-elevenlabs library, and the configuration for the elevenlabs.TTS object is as follows:

  # Configuration of the TTS object
  tts = elevenlabs.TTS(
      api_key="API_KEY",
      base_url="https://api.eu.residency.elevenlabs.io/",
      model="eleven_turbo_v2_5",
      voice_id="VOICE_ID",
      # ... 
   )
  

Additional context

Dependencies:

   elevenlabs==2.15.0
   livekit-agents==1.2.8
   livekit-plugins-elevenlabs==1.2.8

Related issues: I have not found any related issues.

  • Possible workaround: I have tried to force the library to use the non-streaming HTTP endpoint by setting auto_mode=False, but the error persists.
  • Speech-to-Text (STT) services are working correctly with the same API key.

Here is the traceback from my application:

 aiohttp.client_exceptions.WSServerHandshakeError: 403, message='Invalid response status',
 url='wss://api.eu.residency.elevenlabs.io/text-to-speech/DJR3iLTFoK76RjR7KFUy/multi-stream-input?model_id=eleven_flash_v2_5&output_format=
 mp3_22050_32&language_code=ar&enable_ssml_parsing=true&inactivity_timeout=180&sync_alignment=true&auto_mode=true'

The above exception was the direct cause of the following exception:

 Traceback (most recent call last):
   File ".../python/.venv/lib/python3.13/site-packages/livekit/agents/tts/tts.py", line 357, in _main_task
     await self._run(output_emitter)
   File ".../python/.venv/lib/python3.13/site-packages/livekit/plugins/elevenlabs/tts.py", line 360, in _run
     raise APIConnectionError("could not connect to ElevenLabs") from e
 livekit.agents._exceptions.APIConnectionError: could not connect to ElevenLabs (body=None, retryable=True)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions