You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Build interactive AI agents with real-time audio capabilities using ElevenLabs Conversational AI.
162
+
163
+
### Basic Usage
164
+
165
+
```python
166
+
from elevenlabs.client import ElevenLabs
167
+
from elevenlabs.conversational_ai.conversation import Conversation, ClientTools
168
+
from elevenlabs.conversational_ai.default_audio_interface import DefaultAudioInterface
169
+
170
+
client = ElevenLabs(api_key="YOUR_API_KEY")
171
+
172
+
# Create audio interface for real-time audio input/output
173
+
audio_interface = DefaultAudioInterface()
174
+
175
+
# Create conversation
176
+
conversation = Conversation(
177
+
client=client,
178
+
agent_id="your-agent-id",
179
+
requires_auth=True,
180
+
audio_interface=audio_interface,
181
+
)
182
+
183
+
# Start the conversation
184
+
conversation.start_session()
185
+
186
+
# The conversation runs in background until you call:
187
+
conversation.end_session()
188
+
```
189
+
190
+
### Custom Event Loop Support
191
+
192
+
For advanced use cases involving context propagation, resource reuse, or specific event loop management, `ClientTools` supports custom asyncio event loops:
193
+
194
+
```python
195
+
import asyncio
196
+
from elevenlabs.conversational_ai.conversation import ClientTools
197
+
198
+
asyncdefmain():
199
+
# Get the current event loop
200
+
custom_loop = asyncio.get_running_loop()
201
+
202
+
# Create ClientTools with custom loop to prevent "different event loop" errors
0 commit comments