{"id":4611,"library":"livekit-plugins-elevenlabs","title":"LiveKit ElevenLabs Plugin","description":"livekit-plugins-elevenlabs is a Python plugin for the LiveKit Agent Framework, providing seamless integration for voice synthesis (TTS) and speech-to-text (STT) using ElevenLabs' API. It enables real-time, multimodal AI agents to interact with users through high-quality ElevenLabs voices. The library receives frequent updates, often alongside releases of the core `livekit-agents` framework.","status":"active","version":"1.5.2","language":"en","source_language":"en","source_url":"https://github.com/livekit/agents","tags":["livekit","elevenlabs","tts","stt","voice synthesis","speech-to-text","agents","plugins","realtime-audio","voice-ai"],"install":[{"cmd":"pip install livekit-plugins-elevenlabs","lang":"bash","label":"Basic Installation"},{"cmd":"pip install \"livekit-agents[elevenlabs]\"","lang":"bash","label":"Install as LiveKit Agents extra"}],"dependencies":[{"reason":"This package is a plugin for the LiveKit Agent Framework and requires livekit-agents for core functionality.","package":"livekit-agents","optional":false},{"reason":"While not a direct PyPI dependency, this plugin interacts with the ElevenLabs API and users will typically require an ElevenLabs API key.","package":"elevenlabs","optional":false}],"imports":[{"note":"Plugins are typically imported from the `livekit.plugins` namespace.","wrong":"from livekit_plugins_elevenlabs import TTS","symbol":"TTS","correct":"from livekit.plugins import elevenlabs\nelevenlabs.TTS(...)"},{"note":"Plugins are typically imported from the `livekit.plugins` namespace.","wrong":"from livekit_plugins_elevenlabs import STT","symbol":"STT","correct":"from livekit.plugins import elevenlabs\nelevenlabs.STT(...)"}],"quickstart":{"code":"import asyncio\nimport os\nfrom dotenv import load_dotenv\nfrom livekit.agents import JobContext, WorkerOptions, cli, Agent, AgentSession\nfrom livekit.agents.voice import VoicePipeline\nfrom livekit.plugins import elevenlabs, openai # Assuming openai for LLM, can be replaced\n\nload_dotenv()\n\nasync def entrypoint(ctx: JobContext):\n    await ctx.connect()\n\n    # Configure ElevenLabs TTS and STT with API key from environment variable\n    elevenlabs_tts = elevenlabs.TTS(\n        api_key=os.environ.get('ELEVENLABS_API_KEY', '')\n    )\n    elevenlabs_stt = elevenlabs.STT(\n        api_key=os.environ.get('ELEVENLABS_API_KEY', ''),\n        model_id=\"scribe_v2_realtime\" # Explicitly specify STT model\n    )\n\n    # Initialize an AgentSession with ElevenLabs for speech and OpenAI for LLM (example)\n    session = AgentSession(\n        tts=elevenlabs_tts,\n        stt=elevenlabs_stt,\n        llm=openai.LLM(\n            api_key=os.environ.get('OPENAI_API_KEY', ''),\n            model=\"gpt-4-turbo\", \n            instructions=\"You are a helpful voice AI assistant.\"\n        )\n    )\n\n    await session.start(\n        room=ctx.room,\n        agent=Agent(instructions=\"You are a helpful voice AI assistant using ElevenLabs for speech.\")\n    )\n\n    # Agent generates an initial greeting using ElevenLabs TTS\n    await session.generate_reply(instructions=\"Hello! I am a voice assistant powered by LiveKit and ElevenLabs. How can I help you today?\")\n\nif __name__ == \"__main__\":\n    # Set LiveKit and ElevenLabs API keys as environment variables for a runnable example\n    # export LIVEKIT_URL=\"wss://your-livekit-instance.cloud\"\n    # export LIVEKIT_API_KEY=\"your_livekit_api_key\"\n    # export LIVEKIT_API_SECRET=\"your_livekit_api_secret\"\n    # export ELEVENLABS_API_KEY=\"your_elevenlabs_api_key\"\n    # export OPENAI_API_KEY=\"your_openai_api_key\"\n    cli.run_app(\n        WorkerOptions(\n            entrypoint_fnc=entrypoint,\n            num_workers=1 \n        )\n    )\n","lang":"python","description":"This quickstart demonstrates how to create a basic LiveKit voice agent using `livekit-plugins-elevenlabs` for both Text-to-Speech (TTS) and Speech-to-Text (STT) capabilities. It assumes you have `livekit-agents` and `python-dotenv` installed, and `LIVEKIT_URL`, `LIVEKIT_API_KEY`, `LIVEKIT_API_SECRET`, and `ELEVENLABS_API_KEY` (and `OPENAI_API_KEY` if using OpenAI LLM) set as environment variables. The agent connects to a LiveKit room, uses ElevenLabs for voice interaction, and can be extended with an LLM for conversational AI."},"warnings":[{"fix":"Avoid using `eleven_v3` with `livekit.plugins.elevenlabs.TTS` for real-time streaming. Consider using other supported ElevenLabs models or implementing a custom, non-streaming workaround if `eleven_v3` is essential, though this will incur higher latency. Refer to the LiveKit documentation and ElevenLabs API specifications for compatible models.","message":"The ElevenLabs `eleven_v3` TTS model is currently not supported via the `livekit-plugins-elevenlabs` WebSocket endpoint. Attempts to use it will result in 403 errors, as `eleven_v3` does not support multi-stream WebSockets.","severity":"breaking","affected_versions":"All versions up to 1.5.2 (and potentially future versions if API remains unchanged)"},{"fix":"Update `AgentSession` initialization to use the `turn_handling` parameter with a `TurnHandlingOptions` dictionary instead of individual keyword arguments like `min_endpointing_delay` or `allow_interruptions`. Old arguments still work but will emit deprecation warnings and will be removed in future major versions. Consult the `livekit-agents` changelog for full details.","message":"The `livekit-agents` framework, which `livekit-plugins-elevenlabs` integrates with, deprecated several keyword arguments for `AgentSession`'s endpointing and interruption settings in `v1.5.0`. These are now consolidated under the `TurnHandlingOptions` dictionary.","severity":"deprecated","affected_versions":"livekit-agents >= 1.5.0"}],"env_vars":null,"last_verified":"2026-04-12T00:00:00.000Z","next_check":"2026-07-11T00:00:00.000Z"}