ScenaroSession is the framework-agnostic core of the SDK. useScenaroSession is a thin
React binding over it — if you’re not using React (vanilla JS, Vue, Svelte…), use this class
directly.
Constructor
| Option | Type | Default | Description |
|---|---|---|---|
apiUrl | string | — | API base URL (or pass client) |
client | ScenaroClient | — | Pre-built client instance |
apiPathPrefix | string | '/v1' | Prepended to all endpoints |
storagePrefix | string | '' | Prefix for localStorage keys |
storage | StorageAdapter | null | localStorage | Custom storage adapter |
transport | Transport | LiveKitTransport | Internal, non-public interface — injectable for tests |
client nor apiUrl is provided.
State
All state is readable synchronously; changes are announced through events.| Getter | Type |
|---|---|
status | 'idle' | 'connecting' | 'connected' | 'reconnecting' | 'ended' |
agentState | 'idle' | 'listening' | 'thinking' | 'speaking' |
messages | ConversationMessage[] |
config | SessionConfig | null |
rawConfig | ConfigPayload | null — wire format (restore_state, tool wiring) |
conversationId | string | null |
room | unknown — engine extension (LiveKit today), see Transport extensions |
Methods
start
ScenaroError with code IDENTIFY_FAILED or SESSION_START_FAILED.
StartSessionOptions
| Field | Type | Default |
|---|---|---|
scenario | string | required |
language | string | scenario’s configured language |
inputMode / outputMode | 'audio' | 'text' | 'audio' |
microphone | boolean | true |
externalId | string | null | auto-generated |
resumeConversationId | string | — |
metadata | Record<string, unknown> | — |
tools | Record<string, ToolHandler> | {} |
end
status to 'ended'. The session
can be started again with start().
sendText / setMicrophoneEnabled
error event instead, so
fire-and-forget call sites don’t produce unhandled rejections.
destroy
ScenaroProvider does this automatically on unmount).
Events
Kebab-case event names, subscribed withon / off:
| Event | Payload |
|---|---|
status-change | SessionStatus |
agent-state | AgentState |
message | ConversationMessage |
config | SessionConfig |
session-end | { reason: string } — 'shutdown', 'agent_disconnected', 'transport_disconnected' |
error | ScenaroError |
Errors
start() throws; everything after connection emits on error instead.
SessionConfig
A curated view of the scenario config — backend plumbing (company_id, voice_stack,
timestamps, tool wiring) is deliberately not exposed.