straight-greece-72452
12/04/2025, 12:10 PMtall-airline-16756
12/04/2025, 12:10 PMtall-airline-16756
12/04/2025, 12:10 PM.env file and use it for TTS. Below are concise, runnable steps for both Python and Node.js.
1) Add the API key to .env
• Create/edit a .env in your project root and add:
ELEVEN_API_KEY=your_actual_api_key_here
• Make sure .env is in .gitignore.
2) Install the ElevenLabs plugin
• Python:
uv add "livekit-agents[elevenlabs]~=1.2"
• Node.js:
pnpm add @livekit/agents-plugin-elevenlabs@1.x
3) Use the key with the plugin (the plugin reads ELEVEN_API_KEY from the environment)
• Python example:
from livekit.agents import AgentSession
from livekit.plugins import elevenlabs
session = AgentSession(
tts=elevenlabs.TTS(
model="eleven_multilingual_v2",
voice_id="ODq5zmih8GrVes37Dizd"
),
# other components...
)
• Node.js example:
import * as elevenlabs from '@livekit/agents-plugin-elevenlabs';
import * as voice from '@livekit/agents'; // adjust import to your setup
const session = new voice.AgentSession({
tts: new elevenlabs.TTS({
voice: { id: "ODq5zmih8GrVes37Dizd" },
model: "eleven_multilingual_v2"
}),
// other components...
});
Notes:
• The plugin will automatically use ELEVEN_API_KEY from your environment.
• voice_id and model are optional; defaults exist if you don’t set them.
• If you want, I can show how to load .env in your runtime (e.g., python-dotenv or dotenv for Node) or provide a minimal example that sends text and receives audio. Which would you prefer? Sources: Secrets management | LiveKit docs | ElevenLabs TTS plugin guide | LiveKit Docsstraight-greece-72452
12/04/2025, 12:12 PMtall-airline-16756
12/04/2025, 12:12 PMELEVEN_API_KEY from the environment. If you set ELEVENLABS_API_KEY instead, the plugin won’t pick it up unless you explicitly pass that value in code. Would you like a quick example of loading .env into your runtime?
Sources: ElevenLabs TTS plugin guide | LiveKit Docs | Deploying to custom environments | LiveKit Docsstraight-greece-72452
12/04/2025, 12:12 PMtall-airline-16756
12/04/2025, 12:12 PMstraight-greece-72452
12/04/2025, 12:14 PM