Beta Feature: The ElevenLabs integration uses Anam’s audio passthrough mode, which is currently in beta. APIs may change as we continue to improve the integration.
View Example
Full source code for the ElevenLabs conversational agent with Anam avatar.
How It Works
The integration uses Anam’s audio passthrough mode, where Anam renders an avatar that lip-syncs to audio you provide—without using Anam’s own AI or microphone input.
Quick Start
Prerequisites
- ElevenLabs account with a configured Conversational AI agent
- Anam account with API access
- Node.js or Bun runtime
Installation
Basic Integration
Here’s the core pattern for connecting ElevenLabs to Anam:Full Example
Project Structure
Server: Create Anam Session
Your server creates an Anam session token withenableAudioPassthrough: true:
config.ts
Client: ElevenLabs Module
Handle the WebSocket connection and microphone capture:elevenlabs.ts
Client: Main Integration
Wire everything together:client.ts
Configuration
Environment Variables
1
Get your API credentials
You’ll need credentials from both services:
| Service | Where to get it |
|---|---|
| Anam | lab.anam.ai → Settings → API Keys |
| ElevenLabs | elevenlabs.io → Agents |
2
Set environment variables
.env
ElevenLabs Agent Setup
When configuring your ElevenLabs agent, set the output audio format to match Anam’s expectations:| Setting | Value |
|---|---|
| Format | PCM 16-bit |
| Sample Rate | 16000 Hz |
| Channels | Mono |
Choosing an Avatar
Stock Avatars
Browse ready-to-use avatars in our gallery. Copy the avatar ID directly into your config.
Custom Avatars
Create your own personalized avatar in Anam Lab with custom appearance and style.
Audio Passthrough API
createAgentAudioInputStream()
Creates a stream for sending audio chunks to the avatar for lip-sync.Audio encoding format. Currently supports
pcm_s16le (16-bit signed little-endian PCM).Sample rate in Hz. Should match your ElevenLabs agent output (typically 16000).
Number of audio channels. Use
1 for mono.sendAudioChunk()
Send a base64-encoded audio chunk for lip-sync rendering.endSequence()
Signal that the current audio sequence has ended. This helps Anam optimize lip-sync timing and handle transitions.- ElevenLabs sends the
agent_responseevent (agent finished speaking) - ElevenLabs sends the
interruptionevent (user barged in)
Handling Interruptions
When a user speaks while the agent is talking (barge-in), ElevenLabs sends aninterruption event. Handle it by ending the current audio sequence:
Troubleshooting
Avatar lips not moving
Avatar lips not moving
- Verify audio format matches (PCM16, 16kHz, mono)
- Check that
sendAudioChunk()is receiving data - Ensure the audio input stream was created successfully
- Look for errors in browser console
Audio/lip-sync out of sync
Audio/lip-sync out of sync
- Call
endSequence()when agent responses complete - Ensure you’re handling interruptions correctly
- Check network latency to both services
No audio from agent
No audio from agent
- Verify your ElevenLabs agent is configured correctly
- Check the WebSocket connection is established
- Look for
audioevents in the message handler - Confirm your agent ID is correct
Microphone not working
Microphone not working
- Check browser permissions for microphone access
- Ensure
echoCancellationis enabled to prevent feedback - Verify the microphone is sending data at 16kHz
Session token errors
Session token errors
- Verify your
ANAM_API_KEYis valid - Check that
enableAudioPassthrough: trueis set in the session request - Ensure the avatar ID exists in your account
Use Cases
Customer Support
Customer Support
Deploy ElevenLabs’ powerful conversational AI with a friendly visual presence for customer service interactions.
Sales Demos
Sales Demos
Create engaging product demonstrations where an avatar explains features while responding to questions.
Virtual Receptionists
Virtual Receptionists
Greet visitors with a lifelike avatar powered by ElevenLabs’ natural voice synthesis.
Educational Content
Educational Content
Build interactive tutors that respond to student questions with expressive avatar animations.
Accessibility
Accessibility
Provide visual lip-sync cues for users who benefit from seeing speech, not just hearing it.
Resources
ElevenLabs Docs
Official ElevenLabs Conversational AI documentation
Demo Repository
Full source code for this integration
Avatar Gallery
Browse available stock avatars
Anam Lab
Create custom avatars for your brand

