Owns one xAI realtime WebSocket connection (Xai.Realtime) on behalf of a
single Playground LiveView, forwarding audio chunks and events to it as
plain messages.
Runs under PhoenixKitAI.Realtime.Supervisor (a DynamicSupervisor
contributed via PhoenixKitAI.children/0) with restart: :temporary — a
dead session is not auto-restarted, the LiveView re-triggers "start voice"
itself.
Cleanup
Xai.Realtime.connect_tts/1 is called from init/1, so the WebSockex
connection links to this process, not the owning LiveView — a socket
crash only takes down the session. The reverse direction (LiveView goes
away) is handled by monitoring live_view_pid: LiveView's own
terminate/2 isn't reliably called without trap_exit, so closing the
connection is driven from here via the :DOWN message instead.
Summary
Functions
Returns a specification to start this module under a supervisor.
Close the realtime connection and stop the session.
Signal end of the current utterance.
Send text to be spoken.
Types
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
@spec close(pid()) :: :ok
Close the realtime connection and stop the session.
@spec finish(pid()) :: :ok
Signal end of the current utterance.
Send text to be spoken.
@spec start_link(start_opts()) :: GenServer.on_start()