| topic | agents |
|---|---|
| type | research |
| status | research-complete |
| last-validated | 2026-05-21 |
| original-query | Deep dive into ElevenLabs Agents (formerly Conversational AI) for building a voice agent with Zaal's Professional Voice Clone for The ZAO community (reconstructed) |
| tier | high |
Status: Research complete Date: 2026-04-11 Goal: Deep dive into ElevenLabs Agents (formerly Conversational AI) for building a voice agent with Zaal's Professional Voice Clone for The ZAO community Related: Doc 323 - ElevenLabs API Full Capabilities
| Decision | Recommendation |
|---|---|
| Agent platform | USE ElevenAgents - mature platform, sub-100ms TTS latency, full SDK for React/Next.js |
| Voice clone as agent voice | YES - Professional Voice Clone works directly as agent voice. Just select "Bettercallzaal" in agent config |
| LLM backend | USE Claude 3.5/3.7 Sonnet (supported natively) or custom LLM via OpenAI-compatible API |
| Knowledge base | USE RAG - upload ZAO docs, FAQ, member info. 20MB limit on Creator plan, ~500ms added latency |
| Deployment | USE React SDK (@elevenlabs/react) embedded in ZAO OS + signed URL auth for gated access |
| Spaces integration | POSSIBLE via Stream Video SDK's Vision Agents framework + ElevenLabs TTS plugin |
| Phone number | DEFER - SIP trunking available but not needed for community use case |
| Music playback | NOT YET - Music API integration with Agents "coming soon" per ElevenLabs |
User speaks -> ASR (Speech-to-Text) -> LLM (reasoning + tools) -> TTS (voice synthesis) -> User hears
Four coordinated components:
- Speech Recognition (ASR) - Fine-tuned STT model, ~150ms real-time latency
- Language Model (LLM) - Your choice of GPT-4o, Claude 3.7 Sonnet, Gemini 2.5 Flash, or custom
- Text-to-Speech (TTS) - Flash v2.5 at ~75ms latency, 5,000+ voices, 70+ languages
- Turn-Taking Model - Proprietary model that analyzes conversational cues ("um", "ah"), knows when to interrupt vs wait
| Provider | Models |
|---|---|
| Anthropic | Claude 3.7 Sonnet, Claude 3.5 Sonnet v1/v2, Claude 3 Haiku |
| OpenAI | GPT-4o, GPT-4o Mini, GPT-4 Turbo, GPT-3.5 Turbo |
| Gemini 2.5 Flash, Gemini 2.0 Flash/Lite, Gemini 1.5 Pro/Flash | |
| Custom | Any OpenAI-compatible API (Llama, DeepSeek, etc. via Groq/Together/Cloudflare) |
LLM Cascading: Agents can fall back through a sequence of models if one is unavailable. Default cascade: Gemini 2.5 Flash -> Gemini 2.0 Flash -> Claude 3.7 Sonnet -> GPT-4o.
Agents can handle voice, text, or both simultaneously. Define once, deploy as voice-only, voice+text, or chat-only. Users can switch mid-conversation (e.g., speak a question, type an email address).
YES, this works. After cloning your voice, you simply select it as the agent's voice in the dashboard or via API.
| Asset | Detail |
|---|---|
| Voice Clone | "Bettercallzaal" - Professional Voice Clone |
| Training Data | 1 hour 21 minutes (8 audio files, 842.9 MB) |
| Quality Tier | "Better" (Good=30min, Better=1hr, Best=2hr) |
| Language | English / American |
| Account | On Logesh's workspace (logesh@songam.space) |
| Model | Latency | Languages | Best For |
|---|---|---|---|
| Flash v2.5 | ~75ms | 32 languages | Real-time conversation (recommended) |
| Multilingual v2 | Higher | 29 languages | Premium quality, polished output |
| v3 | Not real-time | 70+ languages | Expressive/emotional (NOT for agents) |
Recommendation: Use Flash v2.5 for the agent voice to keep latency low. The Professional Voice Clone works with all models.
- Server Tools (Webhooks) - Call your Next.js API routes during conversation
- Client Tools - Execute JavaScript in the user's browser (React component updates)
- MCP Tools - Model Context Protocol servers providing tools and resources
- System Tools - Built-in: end call, language detection, agent transfer, transfer to number, skip turn, voicemail detection, DTMF tones
Connect your ZAO OS API routes as agent tools:
- HTTP Methods: GET, POST, PUT, PATCH
- URL: Your API endpoint (e.g.,
https://zaoos.com/api/members/lookup) - Parameters: Path, query, and body params - generated dynamically by the LLM based on conversation
- Content Types:
application/jsonorapplication/x-www-form-urlencoded - Auth Methods: OAuth2 Client Credentials, OAuth2 JWT, Basic Auth, Bearer Token, Custom Headers
Tool: "lookup_member"
URL: POST https://zaoos.com/api/agent/member-lookup
Body: { "name": "{name}" } // LLM fills from conversation
Response: member profile, respect score, role
Tool: "get_upcoming_events"
URL: GET https://zaoos.com/api/agent/events
Response: next fractal meeting, COC Concertz, ZAO Stock date
Tool: "check_respect_balance"
URL: POST https://zaoos.com/api/agent/respect
Body: { "fid": "{farcaster_id}" }
Response: OG Respect, ZOR Respect, total
Tool: "get_now_playing"
URL: GET https://zaoos.com/api/agent/now-playing
Response: current track, queue, who submitted it
Register tools that run in the user's React app:
clientTools: {
navigate_to_page: (params: { page: string }) => {
router.push(params.page);
return 'Navigated to ' + params.page;
},
show_member_profile: (params: { fid: number }) => {
openProfileDrawer(params.fid);
return 'Profile opened';
},
}Trigger workflows after a call ends - log conversation to Supabase, update member engagement metrics, send follow-up messages.
- Upload documents to the agent's knowledge base
- Documents are automatically indexed (embedding model: e5_mistral_7b_instruct)
- During conversation, user query is reformulated for optimal retrieval
- Semantic search finds relevant chunks
- Retrieved context is injected into the LLM prompt
- Agent responds with grounded, source-backed answers
| Plan | Limit |
|---|---|
| Free | 1 MB |
| Starter | 2 MB |
| Creator | 20 MB |
| Pro | 100 MB |
| Scale | 500 MB |
| Document | Contents | Priority |
|---|---|---|
| ZAO Complete Guide | Doc 050 - mission, pillars, membership, culture | P0 |
| ZAO Whitepaper | Doc 051 - Draft 4.5, tokenomics, governance | P0 |
| Member Directory | Names, roles, FIDs, specialties | P0 |
| FAQ | Common questions about joining, Respect, events | P0 |
| Event Calendar | COC Concertz, ZAO Stock, fractal meetings | P1 |
| Governance Rules | How proposals work, voting thresholds, Respect weights | P1 |
| Music Player Guide | How to submit songs, queue system, curation | P2 |
- RAG adds ~500ms latency per response
- Documents < 500 bytes go into prompt directly (no RAG needed)
- Can configure max chunks retrieved and vector distance thresholds
- Test thoroughly after adding docs - too much context can hurt quality
npm install @elevenlabs/react// src/components/agent/ZaoVoiceAgent.tsx
'use client';
import { ConversationProvider, useConversation } from '@elevenlabs/react';
function AgentUI() {
const conversation = useConversation({
onConnect: () => console.log('Connected to Zaal agent'),
onMessage: (msg) => console.log('Message:', msg),
onError: (err) => console.error('Agent error:', err),
});
const startConversation = async () => {
await navigator.mediaDevices.getUserMedia({ audio: true });
// Use signed URL for gated access
const res = await fetch('/api/agent/signed-url');
const { signedUrl } = await res.json();
await conversation.startSession({ signedUrl });
};
return (
<div>
<button onClick={startConversation}>Talk to Zaal AI</button>
<p>Status: {conversation.status}</p>
<p>{conversation.isSpeaking ? 'Speaking...' : 'Listening...'}</p>
</div>
);
}
// API route for signed URL (keeps API key server-side)
// src/app/api/agent/signed-url/route.ts
export async function GET() {
const response = await fetch(
`https://api.elevenlabs.io/v1/convai/conversation/get-signed-url?agent_id=${process.env.ELEVENLABS_AGENT_ID}`,
{ headers: { 'xi-api-key': process.env.ELEVENLABS_API_KEY! } }
);
const data = await response.json();
return NextResponse.json({ signedUrl: data.signed_url });
}Paste a <script> tag + custom element. No React code needed. But:
- Requires public agent (no auth)
- Limited styling control
- Not gated to ZAO members
- Buy a number or connect existing via Twilio, Telnyx, Plivo
- Agent answers calls automatically
- Supports outbound calling and batch calls
- Audio codecs: G711 8kHz or G722 16kHz
- Use case: "Call the ZAO hotline to talk to Zaal AI" - cool but not priority
- Full control, build completely custom UI
- WebRTC for voice (best echo cancellation), WebSocket for text-only
- Connection type auto-detected based on mode
- Create agent in ElevenLabs dashboard with Bettercallzaal voice
- Add knowledge base (ZAO docs, FAQ, member info)
- Configure server tools pointing to ZAO OS API routes
- Use React SDK with signed URL auth (gated behind ZAO membership)
- Deploy as a component in the ZAO OS sidebar or dedicated page
Yes, with engineering work. Two paths:
ZAO OS already uses Stream Video SDK for Spaces. Stream has an official ElevenLabs TTS integration via the Vision Agents framework:
# Vision Agents framework (Python server-side)
from vision_agents import Agent
from vision_agents.plugins import elevenlabs
tts = elevenlabs.TTS(
api_key=os.getenv("ELEVENLABS_API_KEY"),
voice_id="BETTERCALLZAAL_VOICE_ID",
model_id="eleven_multilingual_v2"
)
agent = Agent(tts=tts, llm=your_llm, stt=your_stt)
call = await agent.create_call("audio_room", "zao-spaces-room-id")
async with agent.join(call):
@agent.subscribe("participant_joined")
async def greet(event):
await agent.say("Welcome to the ZAO Spaces room!")
await agent.simple_response("Be a helpful co-host...")Limitation: Vision Agents is Python-based. Would need a separate Python service or serverless function alongside the Next.js app.
LiveKit has livekit-plugins-elevenlabs for TTS. Since Stream uses LiveKit internally for WebRTC, there may be a bridge. Less direct than Path A.
Use ElevenLabs WebRTC conversation output and pipe audio into a Stream call participant. Most complex, most flexible.
Bottom line: An agent CAN join Spaces rooms as a participant using Zaal's voice. Path A (Vision Agents) is the most direct since ZAO OS already uses Stream.
| Item | Included | Overage |
|---|---|---|
| Plan | $22/month ($11/mo on annual) | - |
| Conversational AI | 250 minutes/month | $0.12/minute |
| TTS Characters | 100,000 chars/month | ~$0.30/1k chars |
| Dubbing | 50 minutes/month | $0.60/minute |
| Transcription | Per usage | $0.40/hour |
Assuming ~50% of members try the agent, average 3-minute conversation:
- 94 members x 3 min = 282 minutes/month
- 250 included + 32 overage = $22 base + $3.84 overage = ~$26/month
- Add LLM costs (10-30% markup): ~$29-34/month total
If usage is lighter (20% of members, 2 min avg):
- 38 x 2 = 76 minutes - well within the 250 included
- $22/month flat
ElevenLabs passes through LLM costs. Using Claude 3.5 Sonnet or GPT-4o Mini keeps this low. Gemini 2.0 Flash is cheapest.
| Stage | Latency |
|---|---|
| Speech-to-Text (ASR) | ~150ms |
| LLM reasoning | 200-500ms (model dependent) |
| Text-to-Speech (Flash v2.5) | ~75ms |
| Network overhead | 50-100ms |
| Total round-trip | ~475-825ms |
- Use Flash v2.5 (not v3) for TTS - 75ms vs seconds
- Use Gemini 2.5 Flash or GPT-4o Mini for fastest LLM response
- RAG adds ~500ms - keep knowledge base focused
- WebRTC mode has better echo cancellation than WebSocket
- Minimize tool calls per turn (each adds network round-trip)
- Keep system prompt concise
Sub-second response time feels natural in conversation. The turn-taking model handles "um"s and pauses intelligently, so the agent doesn't cut people off.
Not natively supported yet. The Music API integration with Agents Platform is "coming soon" per ElevenLabs.
-
Client tool approach: Agent triggers a client-side tool that plays audio in the browser
clientTools: { play_song: (params: { trackUrl: string }) => { audioPlayer.play(params.trackUrl); return 'Playing track'; } }
-
Recommendation via text: Agent recommends songs, user clicks to play in ZAO OS player
-
TTS song intro: Agent speaks "Here's a song by [artist]..." then triggers playback via client tool
Future: When ElevenLabs ships Music API + Agents integration, the agent could generate and play AI music mid-conversation using Zaal's cloned singing voice.
Full support. The Professional Voice Clone maintains Zaal's vocal characteristics across all supported languages.
- Flash v2.5: 32 languages at 75ms latency
- Multilingual v2: 29 languages, premium quality
- Automatic language detection: agent detects what language the user speaks and responds in kind
English, Spanish, French, German, Japanese, Chinese, Korean, Portuguese, Italian, Arabic, Russian, Hindi, Indonesian, Dutch, Turkish, Polish, and 15+ more.
A Spanish-speaking member could talk to the agent in Spanish and hear Zaal's voice responding in Spanish - same vocal characteristics, different language. Powerful for global community building.
| Package | Use Case |
|---|---|
@elevenlabs/react |
React/Next.js apps (hooks + provider) |
@elevenlabs/client |
Vanilla JS/TS, base for frameworks |
| React Native SDK | iOS/Android mobile apps |
| Package | Use Case |
|---|---|
elevenlabs (pip) |
Server-side agent, scripts, bots |
elevenlabs[pyaudio] |
Real-time audio I/O |
| SDK | Platform |
|---|---|
| Swift SDK | iOS |
| Kotlin SDK | Android |
// Provider (wrap your app)
<ConversationProvider onConnect={} onError={} serverLocation="us">
// Hooks (use in components)
useConversation() // All-in-one (re-renders on any change)
useConversationControls() // Actions only (no re-renders)
useConversationStatus() // Connection status + messages
useConversationMode() // Speaking/listening state
useConversationInput() // Mute controls
// Dynamic tool registration
useConversationClientTool('toolName', handler)- WebRTC-based audio streaming (low latency, echo cancellation)
- Event-driven lifecycle (onConnect, onDisconnect, onMessage, onError, onModeChange, onVadScore)
- Audio visualization (getInputVolume, getOutputVolume, frequency data)
- Device switching mid-conversation
- Controlled mute state
- Text-only mode (skips mic permissions)
- Conversation overrides at runtime (change prompt, voice, language)
- Deutsche Telekom - 24/7 customer support agents handling large call volumes
- Klarna - Agentic support at scale
- Chess.com - Voice agents for player interaction
- Meta - Voice AI integration
- TrueCrime AI - Simulate guest speakers, re-enact testimonials with emotion
- Indie authors - AI narrators for audiobooks with expressive voices
- Language learning apps - Interactive dialogues with varying accents
- $500M Series D at $11B valuation
- $330M ARR, 175% YoY growth
- 41% of Fortune 500 as customers
- 1M+ hours of AI-generated audio
- 250,000+ agents built on the platform
One creator cloned their voice and built an AI teaching assistant that:
- Speaks in the creator's voice
- Answers student questions from a knowledge base
- Runs 24/7 without the creator being present
- Students reported it felt like talking to the actual teacher
This is the exact pattern for ZAO - Zaal's voice answering community questions 24/7.
Six agents are already configured on the ElevenLabs account (logesh@songam.space):
| Agent | Likely Purpose |
|---|---|
| bettercallzaal | Zaal's personal agent / demo |
| Farcaster | Farcaster-aware agent for social interactions |
| Buddo | Unknown - possibly a pet/companion agent |
| Songam Host | Music hosting agent for Songam platform |
| Pet App | Pet-related application agent |
| ADAM | Unknown - possibly an admin or assistant agent |
- The account already has multiple agents configured, so the workflow is proven
- "Farcaster" agent suggests social-media-aware agents are already being explored
- "Songam Host" is closest to the ZAO use case (music community hosting)
- We should review each agent's system prompt, tools, and knowledge base to understand what works
- Log into ElevenLabs dashboard and review each agent's configuration
- Check which voice each uses (likely Bettercallzaal for most)
- Review system prompts for reusable patterns
- Check if any have tools configured that we can adapt
- Consider consolidating into a single "ZAO Agent" with the best patterns from each
- Create new agent "ZAO Guide" in dashboard
- Select Bettercallzaal voice + Flash v2.5 model
- Choose Claude 3.5 Sonnet as LLM
- Write system prompt (ZAO mission, personality, boundaries)
- Upload knowledge base (ZAO Complete Guide, FAQ)
- Test in dashboard
- Add React SDK to ZAO OS (
@elevenlabs/react) - Build
ZaoVoiceAgentcomponent with signed URL auth - Gate behind membership check
- Deploy
- Build API routes:
/api/agent/member-lookup,/api/agent/events,/api/agent/respect - Configure as server tools in ElevenLabs dashboard
- Add client tools: navigate, open profile, play song
- Test tool calling with various conversation scenarios
- Set up Vision Agents Python service
- Configure ElevenLabs TTS with Bettercallzaal voice
- Connect to Stream Video SDK rooms
- Implement agent join/leave for Spaces rooms
- Add greeting, co-hosting, and Q&A capabilities
ELEVENLABS_API_KEY=sk_...
ELEVENLABS_AGENT_ID=agent_...
ELEVENLABS_VOICE_ID=... # Bettercallzaal voice ID- ElevenAgents Overview
- ElevenLabs Agents Platform
- React SDK Documentation
- Server Tools
- Knowledge Base / RAG
- Custom LLM Integration
- Next.js Quickstart
- Widget Customization
- SIP Trunking
- Conversational AI 2.0 Announcement
- Multimodal Conversational AI
- WebRTC Support
- Claude 3.7 Sonnet Integration
- Stream + ElevenLabs Integration
- Professional Voice Cloning
- ElevenLabs Pricing
- Pricing Breakdown (Flexprice)
- Pricing Review (Cekura)
- ElevenLabs Complete Guide 2026 (Medium)
- Latency Optimization
- Voice Cloning Deep Dive
- Python SDK
- LiveKit ElevenLabs Plugin
- Developer Trends 2026