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
| Field | Type | Default | Description |
|---|---|---|---|
Config | EstuaryConfig | — | Reference to your configuration asset |
AutoConnect | bool | true | Connect on Start() using the active character |
Properties
| Property | Type | Access | Description |
|---|---|---|---|
Instance | EstuaryManager | static get | Singleton instance |
Config | EstuaryConfig | get/set | Configuration asset |
Client | EstuaryClient | get | Low-level Socket.IO client |
IsConnected | bool | get | true when Socket.IO is connected |
ConnectionState | ConnectionState | get | Current connection state |
LiveKitState | LiveKitConnectionState | get | Current LiveKit connection state |
ActiveCharacter | EstuaryCharacter | get | Currently active character |
Characters | IReadOnlyList<EstuaryCharacter> | get | All registered characters |
Methods
| Method | Returns | Description |
|---|---|---|
ConnectAsync(EstuaryCharacter character = null) | Task | Connect with the given character (or active character if null) |
DisconnectAsync() | Task | Disconnect from the server |
RegisterCharacter(EstuaryCharacter character) | void | Register a character (called automatically by EstuaryCharacter.Start) |
UnregisterCharacter(EstuaryCharacter character) | void | Unregister a character |
SetActiveCharacter(EstuaryCharacter character) | void | Switch the active character (disconnects and reconnects) |
RequestLiveKitTokenAsync() | Task | Request a LiveKit token from the server |
SendText(string text, bool? textOnly = null) | void | Send a text message via the active character |
SendTextAsync(string text, bool? textOnly = null) | Task | Send a text message asynchronously |
Events
| Event | Signature | Description |
|---|---|---|
OnConnected | Action<SessionInfo> | Fired after successful connection and session_info |
OnDisconnected | Action<string> | Fired on disconnect (reason string) |
OnConnectionStateChanged | Action<ConnectionState> | Fired when connection state changes |
OnActiveCharacterChanged | Action<EstuaryCharacter, EstuaryCharacter> | Fired when the active character changes (previous, current) |
OnLiveKitStateChanged | Action<LiveKitConnectionState> | Fired when LiveKit connection state changes |
OnLiveKitReady | Action<string> | Fired when LiveKit room is ready (room name) |
OnBotAudioSourceCreated | Action<AudioSource> | Fired when LiveKit creates the bot's AudioSource (for lip sync) |
OnError | Action<string> | Fired on error events from the server |
OnQuotaExceeded | Action<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 0–4), namespace connection, JSON payloads, heartbeat ping/pong, and automatic reconnection.
Properties
| Property | Type | Description |
|---|---|---|
IsConnected | bool | true when the socket is open and the namespace is connected |
SessionId | string | Server-assigned session ID |
Methods
| Method | Returns | Description |
|---|---|---|
ConnectAsync(string url, string apiKey, string characterId, string playerId) | Task | Open the WebSocket and perform the Socket.IO handshake |
DisconnectAsync() | Task | Close the connection gracefully |
SendTextAsync(string text, bool textOnly) | Task | Emit a text event |
StreamAudioAsync(byte[] pcm16, int sampleRate) | Task | Emit a stream_audio event with base64-encoded PCM |
StartVoiceModeAsync() | Task | Emit start_voice |
StopVoiceModeAsync() | Task | Emit stop_voice |
RequestLiveKitTokenAsync() | Task | Emit livekit_token request |
NotifyLiveKitJoinAsync() | Task | Emit livekit_join |
NotifyInterruptAsync(string messageId) | Task | Emit client_interrupt |
NotifyPlaybackCompleteAsync(string messageId) | Task | Emit audio_playback_complete |
UpdatePreferencesAsync(Dictionary<string, object> prefs) | Task | Emit update_preferences |
SendVideoFrameAsync(byte[] jpeg, string mimeType) | Task | Emit video_frame with base64-encoded image |
SendCameraImageAsync(byte[] jpeg, string text) | Task | Emit camera_image |
SendDevicePoseAsync(float[] matrix) | Task | Emit device_pose |
EnableLiveKitVideoAsync() | Task | Emit enable_livekit_video |
SubscribeSceneGraphAsync() | Task | Emit subscribe_scene_graph |
UnsubscribeSceneGraphAsync() | Task | Emit unsubscribe_scene_graph |
Events (Delegates)
| Event | Signature | Description |
|---|---|---|
OnSessionInfo | Action<SessionInfo> | session_info received |
OnBotResponse | Action<BotResponse> | bot_response chunk received |
OnBotVoice | Action<BotVoice> | bot_voice audio chunk received |
OnSttResponse | Action<SttResponse> | stt_response transcription received |
OnInterrupt | Action<InterruptData> | interrupt confirmation received |
OnLiveKitToken | Action<string, string, string> | livekit_token response (token, url, room) |
OnLiveKitReady | Action | livekit_ready received |
OnSceneGraphUpdate | Action<SceneGraphUpdate> | scene_graph_update received |
OnRoomIdentified | Action<RoomIdentified> | room_identified received |
OnQuotaExceeded | Action<QuotaExceededData> | quota_exceeded received |
OnError | Action<string> | error received |
OnDisconnected | Action<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
| Field | Type | Default | Description |
|---|---|---|---|
ServerUrl | string | "" | Estuary server URL (e.g., https://api.estuary.ai) |
ApiKey | string | "" | API key for authentication |
VoiceMode | VoiceMode | LiveKit | Voice transport: WebSocket or LiveKit |
RecordingSampleRate | int | 16000 | Microphone sample rate in Hz |
PlaybackSampleRate | int | 24000 | TTS playback sample rate in Hz |
AudioChunkDurationMs | int | 100 | Audio chunk size in milliseconds |
DebugLogging | bool | false | Enable verbose logging |
Methods
| Method | Returns | Description |
|---|---|---|
SetApiKeyRuntime(string apiKey) | void | Set the API key at runtime (does not persist to asset) |
CreateForDevelopment(string serverUrl, string apiKey) | EstuaryConfig | Create an in-memory config (no asset required) |