Create and control realtime assistant-ui voice sessions, state, controls, and helpers.
API Reference
createVoiceSession
- options{ abortSignal?: AbortSignal; }
- { abortSignal?: AbortSignal; }
- abortSignal?AbortSignal
- AbortSignal
- abortedboolean
- onabort((this:AbortSignal,ev:Event)=>any)|null
- reasonany
- throwIfAborted() => void
- addEventListener{ <K>(type: K, listener: (this: AbortSignal, ev: AbortSignalEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; (type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; }
- removeEventListener{ <K>(type: K, listener: (this: AbortSignal, ev: AbortSignalEventMap[K]) => any, options?: boolean | EventListenerOptions): void; (type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; }
- dispatchEvent(event: Event) => boolean
The **`dispatchEvent()`** method of the EventTarget sends an Event to the object, (synchronously) invoking the affected event listeners in the appropriate order. The normal event processing rules (including the capturing and optional bubbling phase) also apply to events dispatched manually with dispatchEvent(). MDN Reference
- setup(helpers: VoiceSessionHelpers) => Promise<VoiceSessionControls>
RealtimeVoiceAdapter
- connect(options: { abortSignal?: AbortSignal; }) => RealtimeVoiceAdapter.Session
useVoiceControls
const useVoiceControls: () => { connect: () => void; disconnect: () => void; mute: () => void; unmute: () => void; };useVoiceState
const useVoiceState: () => VoiceSessionState | undefined;useVoiceVolume
const useVoiceVolume: () => number;VoiceSessionControls
- disconnect() => void
- mute() => void
- unmute() => void
- sendText?((text: string) => void | Promise<void>) | undefined
Delivers typed text to the provider. The session exposes `sendText` once these controls resolve and repeats its running status when they land after it, so status listeners can re-read the session; the runtime records the typed turn itself.
VoiceSessionHelpers
- setStatus(status: RealtimeVoiceAdapter.Status) => void
- end(reason: "finished" | "cancelled" | "error", error?: unknown) => void
- emitTranscript(item: RealtimeVoiceAdapter.TranscriptItem) => void
- emitMode(mode: RealtimeVoiceAdapter.Mode) => void
- emitVolume(volume: number) => void
- isDisposed() => boolean
VoiceSessionState
- statusRealtimeVoiceAdapter.Status
- Status
- type"starting" | "running"
- isMutedboolean
- modeRealtimeVoiceAdapter.Mode
- canSendTextboolean
Whether the running session takes typed text. While true, `append` routes a plain text user message into the session and the thread composer can send.