Skip to Content
🚀 Orga AI is in open beta.
ReferenceClient SDKsReact SDKTypes

Types

The React SDK re-uses most of its types from @orga-ai/core while adding React-specific surfaces for hooks and media helpers.


React‑specific Types

OrgaAIHookReturn

Shape of the object returned by useOrgaAI().

export interface OrgaAIHookReturn { // Session management startSession: (config?: SessionConfig) => Promise<void>; endSession: () => Promise<void>; // Media controls enableMic: () => Promise<void>; disableMic: (hardDisable?: boolean) => Promise<void>; toggleMic: () => Promise<void>; enableCamera: () => Promise<void>; disableCamera: (hardDisable?: boolean) => Promise<void>; toggleCamera: () => Promise<void>; // State connectionState: ConnectionState; aiAudioStream: MediaStream | null; userAudioStream: MediaStream | null; userVideoStream: MediaStream | null; conversationItems: ConversationItem[]; isCameraOn: boolean; isMicOn: boolean; conversationId: string | null; // Parameter management model: OrgaAIModel | null; voice: OrgaAIVoice | null; temperature: number | null; instructions: string | null; modalities: Modality[]; updateParams: (params: { model?: OrgaAIModel; voice?: OrgaAIVoice; temperature?: number; instructions?: string; modalities?: Modality[]; }) => void; }
FieldTypeDescription
startSession(config?: SessionConfig) => Promise<void>Starts a session and handles credential negotiation.
endSession() => Promise<void>Ends the current session and cleans up transport and media.
enableMic, disableMic, toggleMicFunctionsControl microphone state and permissions.
enableCamera, disableCamera, toggleCameraFunctionsControl camera stream state.
connectionStateConnectionState"disconnected" | "connecting" | "connected".
aiAudioStream, userAudioStream, userVideoStreamMediaStream | nullCurrent input/output streams managed by the SDK.
conversationItemsConversationItem[]Messages and transcripts in the active session.
isCameraOn, isMicOnbooleanFlags reflecting current device states.
conversationIdstring | nullID of the active conversation.
model, voice, temperature, instructions, modalitiesVarious core typesReflect the active session configuration.
updateParams(params) => voidDynamically update session configuration during a live connection.

IceCandidateEvent

Event wrapper emitted when ICE candidates update.

export type IceCandidateEvent = { candidate: RTCIceCandidate | null; };

Re‑exported Core Types

For convenience, the React SDK re‑exports many types from @orga-ai/core so you don’t need a second import.

TypeDescription
ConnectionStateConnection lifecycle states.
OrgaAIModelSupported model names.
OrgaAIVoiceSupported voice presets.
ModalityActive media types: "audio", "video".
ConversationItemRepresent individual conversation entries.
SessionConfigFull set of connection and session parameters.
OrgaAIHookCallbacksOptional callbacks fired during session lifecycle.
SessionCreatedEvent, ConversationCreatedEventEvent payloads delivered through DataChannels.
DataChannelEventLower‑level DataChannel event payload.
DataChannelEventTypes (enum)String constants identifying event types.

Foundational transport and event types originate in @orga-ai/core; they are re-exported here so a second import is rarely necessary.


Example Usage

import type { OrgaAIHookReturn, ConnectionState } from "@orga-ai/react"; import { useOrgaAI } from "@orga-ai/react"; export default function Example() { const { startSession, connectionState } = useOrgaAI() as OrgaAIHookReturn; return ( <div> <p>State: {connectionState}</p> <button onClick={() => startSession()}>Start</button> </div> ); }

This example shows how to use the provided types to safely infer method signatures and state values in a TypeScript React app.


Last updated on