Skip to main content

EstuaryClient

The main entry point for the Estuary Python SDK. Inherits from AsyncEventEmitter.

from estuary_sdk import EstuaryClient, EstuaryConfig

config = EstuaryConfig(...)
client = EstuaryClient(config)

Context Manager

EstuaryClient supports async with for automatic cleanup:

async with EstuaryClient(config) as client:
await client.connect()
# ... use client ...
# disconnect() is called automatically on exit

Connection Methods

connect() -> SessionInfo

Connect to the Estuary server and authenticate. Returns a SessionInfo with session details.

session = await client.connect()
print(session.session_id, session.conversation_id)

Raises: EstuaryError with AUTH_FAILED, CONNECTION_FAILED, or CONNECTION_TIMEOUT.

disconnect() -> None

Disconnect from the server and clean up all resources (voice, REST client).

await client.disconnect()

Properties

PropertyTypeDescription
is_connectedboolWhether the client is currently connected
sessionSessionInfo | NoneCurrent session info, or None if not connected

Text Methods

send_text(text, text_only=False) -> None

Send a text message to the character.

ParameterTypeDefaultDescription
textstrrequiredThe message text
text_onlyboolFalseIf True, suppress voice response

Raises: EstuaryError with NOT_CONNECTED.

send_text_and_wait(text, *, text_only=False, timeout=20.0) -> BotResponse

Send a text message and wait for the final bot response. Returns the complete BotResponse directly.

ParameterTypeDefaultDescription
textstrrequiredThe message text
text_onlyboolFalseIf True, suppress voice response
timeoutfloat20.0Max seconds to wait for a final response

Returns: BotResponse with is_final=True.

Raises: asyncio.TimeoutError if no final response within timeout. EstuaryError with NOT_CONNECTED.

interrupt(message_id=None) -> None

Interrupt the current bot response.

ParameterTypeDefaultDescription
message_idstr | NoneNoneSpecific message to interrupt, or None for current

Voice Methods

start_voice(mode=VoiceMode.CONTINUOUS) -> None

Start a voice session.

ParameterTypeDefaultDescription
modeVoiceModeCONTINUOUSCONTINUOUS for VAD, PUSH_TO_TALK for manual control

Raises: EstuaryError with VOICE_ALREADY_ACTIVE, VOICE_START_FAILED, or LIVEKIT_UNAVAILABLE.

stop_voice() -> None

Stop the voice session and clean up resources.

start_recording() -> None

Begin streaming audio (push-to-talk mode only).

Raises: EstuaryError with VOICE_NOT_ACTIVE.

stop_recording() -> None

Stop streaming audio and trigger end-of-turn (push-to-talk mode only).

Raises: EstuaryError with VOICE_NOT_ACTIVE.

send_audio(audio) -> None

Send raw PCM16 audio bytes to the server.

ParameterTypeDescription
audiobytesRaw PCM16 audio (16-bit signed integer, mono, at configured sample rate)

Raises: EstuaryError with VOICE_NOT_ACTIVE.

toggle_mute() -> None

Toggle voice mute state.

Voice Properties

PropertyTypeDescription
is_voice_activeboolWhether a voice session is currently active
is_mutedboolWhether voice is currently muted

Vision Methods

send_camera_image(image_base64, mime_type, request_id=None, text=None) -> None

Send a camera image for vision processing.

ParameterTypeDefaultDescription
image_base64strrequiredBase64-encoded image data
mime_typestrrequiredImage MIME type (e.g., "image/jpeg")
request_idstr | NoneNoneRequest ID from camera_capture_request event
textstr | NoneNoneOptional text to accompany the image

Agent-to-Agent Methods

start_agent_conversation(agent_a_id, agent_b_id, *, conversation_context="", max_turns=8, timeout_seconds=90) -> None

Start an agent-to-agent conversation. Events are emitted as the agents exchange turns.

ParameterTypeDefaultDescription
agent_a_idstrrequiredFirst agent ID
agent_b_idstrrequiredSecond agent ID
conversation_contextstr""Context/topic for the conversation
max_turnsint8Maximum number of turns
timeout_secondsint90Timeout in seconds

Raises: EstuaryError with NOT_CONNECTED.

stop_agent_conversation() -> None

Stop the current agent-to-agent conversation.

Raises: EstuaryError with NOT_CONNECTED.

Preferences

update_preferences(enable_vision_acknowledgment=None) -> None

Update session preferences.

notify_audio_playback_complete(message_id=None) -> None

Notify the server that audio playback has finished.

REST Sub-Clients

These are accessed as properties on the client:

client.memory -> MemoryClient

Memory REST API. Available after connect().

MethodReturnsDescription
get_memories(...)MemoryListResponseList memories with filtering/pagination
get_timeline(...)MemoryTimelineMemories grouped by time period
get_stats()MemoryStatsAggregate memory statistics
get_core_facts()CoreFactsResponseHigh-confidence stable facts
get_graph(...)MemoryGraphFull knowledge graph
search(query, limit)MemorySearchResponseSemantic similarity search
delete_all(confirm)MemoryDeleteResponseDelete all memories

client.players -> PlayersClient

Players REST API. Available after connect().

MethodReturnsDescription
list(...)PlayerConversationListList player conversations
get(player_id)PlayerConversationGet a single player conversation
get_messages(player_id, ...)PlayerMessageListGet conversation messages
get_stats()PlayerStatsAggregate player statistics
delete(player_id)dictDelete a player and all data

client.characters -> CharactersClient

Characters REST API. Available immediately (no connect() required).

MethodReturnsDescription
create(name, ...)CharacterCreate a new character
list(limit, offset)CharacterListResponseList characters
get(character_id)CharacterGet a character by ID
update(character_id, ...)CharacterUpdate a character
delete(character_id)dictDelete a character

client.generate -> GenerateClient

Character generation REST API. Available immediately (no connect() required).

MethodReturnsDescription
image_to_character(image_base64, mime_type)GeneratedCharacterGenerate a character from an image
get_model_status(agent_id)ModelStatusPoll 3D model generation status
wait_for_model(agent_id, *, poll_interval, timeout, on_progress)ModelStatusPoll until model completes or fails