Skip to main content

Core Components

EstuaryManager

MonoBehaviour -- Singleton that owns the network connection and coordinates all Estuary components.

Namespace: Estuary

Accessing the Singleton

EstuaryManager.Instance

The singleton is created automatically via [RuntimeInitializeOnLoadMethod] or when you place the component on a GameObject in the scene. It persists across scene loads (DontDestroyOnLoad).

Inspector Fields

FieldTypeDefaultDescription
ConfigEstuaryConfigReference to your configuration asset
AutoConnectbooltrueConnect on Start() using the active character

Properties

PropertyTypeAccessDescription
InstanceEstuaryManagerstatic getSingleton instance
ConfigEstuaryConfigget/setConfiguration asset
ClientEstuaryClientgetLow-level Socket.IO client
IsConnectedboolgettrue when Socket.IO is connected
ConnectionStateConnectionStategetCurrent connection state
LiveKitStateLiveKitConnectionStategetCurrent LiveKit connection state
ActiveCharacterEstuaryCharactergetCurrently active character
CharactersIReadOnlyList<EstuaryCharacter>getAll registered characters

Methods

MethodReturnsDescription
ConnectAsync(EstuaryCharacter character = null)TaskConnect with the given character (or active character if null)
DisconnectAsync()TaskDisconnect from the server
RegisterCharacter(EstuaryCharacter character)voidRegister a character (called automatically by EstuaryCharacter.Start)
UnregisterCharacter(EstuaryCharacter character)voidUnregister a character
SetActiveCharacter(EstuaryCharacter character)voidSwitch the active character (disconnects and reconnects)
RequestLiveKitTokenAsync()TaskRequest a LiveKit token from the server
SendText(string text, bool? textOnly = null)voidSend a text message via the active character
SendTextAsync(string text, bool? textOnly = null)TaskSend a text message asynchronously

Events

EventSignatureDescription
OnConnectedAction<SessionInfo>Fired after successful connection and session_info
OnDisconnectedAction<string>Fired on disconnect (reason string)
OnConnectionStateChangedAction<ConnectionState>Fired when connection state changes
OnActiveCharacterChangedAction<EstuaryCharacter, EstuaryCharacter>Fired when the active character changes (previous, current)
OnLiveKitStateChangedAction<LiveKitConnectionState>Fired when LiveKit connection state changes
OnLiveKitReadyAction<string>Fired when LiveKit room is ready (room name)
OnBotAudioSourceCreatedAction<AudioSource>Fired when LiveKit creates the bot's AudioSource (for lip sync)
OnErrorAction<string>Fired on error events from the server
OnQuotaExceededAction<QuotaExceededData>Fired when API quota is exceeded

EstuaryClient

Low-level Socket.IO v4 client. You normally interact with EstuaryManager instead of this class directly.

Namespace: Estuary.Core

EstuaryClient implements the Socket.IO v4 protocol over a raw ClientWebSocket. It handles packet framing (type prefixes 04), namespace connection, JSON payloads, heartbeat ping/pong, and automatic reconnection.

Properties

PropertyTypeDescription
IsConnectedbooltrue when the socket is open and the namespace is connected
SessionIdstringServer-assigned session ID

Methods

MethodReturnsDescription
ConnectAsync(string url, string apiKey, string characterId, string playerId)TaskOpen the WebSocket and perform the Socket.IO handshake
DisconnectAsync()TaskClose the connection gracefully
SendTextAsync(string text, bool textOnly)TaskEmit a text event
StreamAudioAsync(byte[] pcm16, int sampleRate)TaskEmit a stream_audio event with base64-encoded PCM
StartVoiceModeAsync()TaskEmit start_voice
StopVoiceModeAsync()TaskEmit stop_voice
RequestLiveKitTokenAsync()TaskEmit livekit_token request
NotifyLiveKitJoinAsync()TaskEmit livekit_join
NotifyInterruptAsync(string messageId)TaskEmit client_interrupt
NotifyPlaybackCompleteAsync(string messageId)TaskEmit audio_playback_complete
UpdatePreferencesAsync(Dictionary<string, object> prefs)TaskEmit update_preferences
SendVideoFrameAsync(byte[] jpeg, string mimeType)TaskEmit video_frame with base64-encoded image
SendCameraImageAsync(byte[] jpeg, string text)TaskEmit camera_image
SendDevicePoseAsync(float[] matrix)TaskEmit device_pose
EnableLiveKitVideoAsync()TaskEmit enable_livekit_video
SubscribeSceneGraphAsync()TaskEmit subscribe_scene_graph
UnsubscribeSceneGraphAsync()TaskEmit unsubscribe_scene_graph

Events (Delegates)

EventSignatureDescription
OnSessionInfoAction<SessionInfo>session_info received
OnBotResponseAction<BotResponse>bot_response chunk received
OnBotVoiceAction<BotVoice>bot_voice audio chunk received
OnSttResponseAction<SttResponse>stt_response transcription received
OnInterruptAction<InterruptData>interrupt confirmation received
OnLiveKitTokenAction<string, string, string>livekit_token response (token, url, room)
OnLiveKitReadyActionlivekit_ready received
OnSceneGraphUpdateAction<SceneGraphUpdate>scene_graph_update received
OnRoomIdentifiedAction<RoomIdentified>room_identified received
OnQuotaExceededAction<QuotaExceededData>quota_exceeded received
OnErrorAction<string>error received
OnDisconnectedAction<string>Connection lost

EstuaryConfig

ScriptableObject -- Stores all configuration for the Estuary SDK.

Namespace: Estuary

Creating a Config Asset

In the Editor: Right-click in the Project window > Create > Estuary > Config.

In Code:

var config = EstuaryConfig.CreateForDevelopment("https://your-server.com", "your-api-key");

Fields

FieldTypeDefaultDescription
ServerUrlstring""Estuary server URL (e.g., https://api.estuary.ai)
ApiKeystring""API key for authentication
VoiceModeVoiceModeLiveKitVoice transport: WebSocket or LiveKit
RecordingSampleRateint16000Microphone sample rate in Hz
PlaybackSampleRateint24000TTS playback sample rate in Hz
AudioChunkDurationMsint100Audio chunk size in milliseconds
DebugLoggingboolfalseEnable verbose logging

Methods

MethodReturnsDescription
SetApiKeyRuntime(string apiKey)voidSet the API key at runtime (does not persist to asset)
CreateForDevelopment(string serverUrl, string apiKey)EstuaryConfigCreate an in-memory config (no asset required)