Skip to main content

Events & Types

Events

The EstuaryClient emits the following events. Register handlers with client.on("event_name", handler).

All event handlers must be async functions.

Connection Events

EventCallback SignatureDescription
connectedasync (session: SessionInfo)Connection established and authenticated
disconnectedasync (reason: str)Disconnected from server
reconnectingasync (attempt: int)Attempting to reconnect
connection_state_changedasync (state: ConnectionState)Connection state transition
errorasync (error: Exception)General error
auth_errorasync (message: str)Authentication failed
quota_exceededasync (data: QuotaExceededData)Usage quota exceeded

Response Events

EventCallback SignatureDescription
bot_responseasync (response: BotResponse)Text response chunk from the character
bot_voiceasync (voice: BotVoice)Voice audio chunk from the character
stt_responseasync (response: SttResponse)Speech-to-text transcription result
interruptasync (data: InterruptData)Response was interrupted

Voice Events

EventCallback SignatureDescription
voice_startedasync ()Voice session started
voice_stoppedasync ()Voice session stopped
voice_errorasync (message: str)Voice-specific error
audio_receivedasync (audio: bytes)Decoded audio from LiveKit
livekit_connectedasync (room: str)LiveKit room connected
livekit_disconnectedasync ()LiveKit room disconnected

Vision Events

EventCallback SignatureDescription
camera_capture_requestasync (request: CameraCaptureRequest)Server requests a camera image

Memory Events

EventCallback SignatureDescription
memory_updatedasync (event: MemoryUpdatedEvent)New memories extracted (requires realtime_memory=True)

Agent-to-Agent Events

EventCallback SignatureDescription
agent_turn_textasync (event: AgentTurnText)Streaming text chunk from an agent turn
agent_turn_voiceasync (event: AgentTurnVoice)Streaming voice audio chunk from an agent turn
agent_turn_completeasync (event: AgentTurnComplete)An agent finished its turn
agent_conversation_completeasync (event: AgentConversationComplete)Agent-to-agent conversation finished

Enums

ConnectionState

from estuary_sdk import ConnectionState

ConnectionState.DISCONNECTED # "disconnected"
ConnectionState.CONNECTING # "connecting"
ConnectionState.CONNECTED # "connected"
ConnectionState.RECONNECTING # "reconnecting"
ConnectionState.ERROR # "error"

VoiceMode

from estuary_sdk import VoiceMode

VoiceMode.CONTINUOUS # VAD-based turn detection
VoiceMode.PUSH_TO_TALK # Manual start/stop recording

ErrorCode

from estuary_sdk import ErrorCode

ErrorCode.CONNECTION_FAILED # WebSocket connection failed
ErrorCode.AUTH_FAILED # Invalid API key
ErrorCode.CONNECTION_TIMEOUT # Connection timed out
ErrorCode.QUOTA_EXCEEDED # Usage limit reached
ErrorCode.VOICE_NOT_SUPPORTED # Voice not available
ErrorCode.VOICE_ALREADY_ACTIVE # start_voice() called twice
ErrorCode.VOICE_NOT_ACTIVE # Voice method called without start_voice()
ErrorCode.VOICE_START_FAILED # Voice session failed to start
ErrorCode.LIVEKIT_UNAVAILABLE # livekit package not installed
ErrorCode.NOT_CONNECTED # Method called before connect()
ErrorCode.REST_ERROR # REST API request failed
ErrorCode.UNKNOWN # Unclassified error

EstuaryError

from estuary_sdk import EstuaryError, ErrorCode

try:
await client.connect()
except EstuaryError as err:
print(err.code) # ErrorCode enum value
print(err.message) # Human-readable message
print(err.details) # Optional additional context