Setting the file. One moment.
Subchapter 6.1
references/installation.mdMarkdown2 KBView on GitHub
Set credentials on the server. Do not expose the ElevenLabs API key in browser code.
For local development, expose the server publicly before creating the Speech Engine resource:
ngrok http 3001
export PUBLIC_WS_URL="wss://your-ngrok-domain.ngrok.app/ws"The browser token endpoint uses the same ELEVENLABS_SPEECH_ENGINE_ID.
Server dependencies:
npm install @elevenlabs/elevenlabs-js dotenvIf the server uses Express for the token endpoint:
npm install express
npm install -D tsx @types/expressBrowser clients:
npm install @elevenlabs/react
# or, for vanilla browser JavaScript:
npm install @elevenlabs/clientAlways use @elevenlabs/elevenlabs-js, @elevenlabs/react, or @elevenlabs/client. Do not use the deprecated elevenlabs npm package.
Server dependencies:
pip install elevenlabs python-dotenvIf building the token endpoint in Flask:
pip install flaskUse the async SDK for Speech Engine servers:
from elevenlabs import AsyncElevenLabs
client = AsyncElevenLabs()ngrok http 3001 is running and points to the Speech Engine server port.wss://.../ws ws_url / wsUrl./ws.startSession(...).overrides.agent.firstMessage.on_disconnect / onDisconnect if unexpected WebSocket drops need handling.debug: true is enabled while developing so transcript and lifecycle issues are visible.wss:// WebSocket URL.SpeechEngineAttachment.close() or the Python server process stops cleanly.AbortSignal values to downstream async work to cancel interrupted responses.