Types

This section documents the types and constants used by the Orga React SDK, providing type safety and configuration options for developers. These types are used in OrgaAI.init, useOrgaAI, and other SDK features.

Constants

Constants define fixed values used throughout the SDK, such as available models, voices, and video constraints.

Name

Type

Description

ORGAAI_MODELS

readonly ["orga-1-beta"]

Array of supported AI models. Currently includes "orga-1-beta". Used in OrgaAIConfig and SessionConfig.

MODALITIES_ENUM

{ VIDEO: "video"; AUDIO: "audio" }

Enum-like object defining supported modalities ("video", "audio"). Used to construct the Modality type.

ORGAAI_VOICES

readonly ["alloy", "ash", "ballad", "coral", "echo", "fable", "onyx", "nova", "sage", "shimmer"]

Array of supported AI voice options. Used in OrgaAIConfig and SessionConfig.

ORGAAI_TEMPERATURE_RANGE

{ min: number; max: number }

Defines the valid range for the temperature parameter (0.0 to 1.0). Used to configure AI response randomness.

MIN_MAX_IDEAL_VIDEO_CONSTRAINTS

{ low: MediaTrackConstraints; medium: MediaTrackConstraints; high: MediaTrackConstraints }

Defines video quality constraints (low, medium, high) for width, height, and frame rate. Used in getMediaConstraints.

DataChannelEventTypes

enum { USER_SPEECH_TRANSCRIPTION: string; ASSISTANT_RESPONSE_COMPLETE: string; SESSION_UPDATE: string }

Enum of data channel event types for WebRTC communication (e.g., "conversation.item.input_audio_transcription.completed"). Used in DataChannelEvent.

Configuration Types

Types related to SDK and session configuration

Name

Type

Description

OrgaAIModel

"orga-1-beta"

Union type of supported AI models, derived from ORGAAI_MODELS Used in OrgaAIConfig, SessionConfig, and OrgaAIHookReturn.

Modality

"audio" | "video"

Union type of supported modalities, derived from MODALITIES_ENUM. Specifies interaction modes (audio, video) in OrgaAIConfig, SessionConfig, and OrgaAIHookReturn

OrgaAIVoice

"alloy" | "ash" | "ballad" | "coral" | "echo" | "fable" | "onyx" | "nova" | "sage" | "shimmer"

Union type of supported AI voices, derived from ORGAAI_VOICES. Used in OrgaAIConfig, SessionConfig, and OrgaAIHookReturn.

OrgaAIConfig

interface { logLevel?: "debug" | "info" | "warn" | "error" | "disabled";

timeout?: number;

sessionConfigEndpoint?: string;

fetchSessionConfig?: () => Promise<{ ephemeralToken: string; iceServers: RTCIceServer[] }>;

model?: OrgaAIModel;

voice?: OrgaAIVoice;

temperature?: number;

enableTranscriptions?: boolean;

instructions?: string;

modalities?: Modality[] }

Configuration for OrgaAI.init. Defines SDK settings, including logging, authentication, and session defaults.

SessionConfig

interface { enableTranscriptions?: boolean;

videoQuality?: "low" | "medium" | "high";

timeout?: number;

voice?: OrgaAIVoice;

model?: OrgaAIModel;

temperature?: number;

instructions?: string;

modalities?: Modality[];

onSessionStart?: () => void;

onSessionEnd?: () => void;

onError?: (error: Error) => void;

onConnectionStateChange?: (state: ConnectionState) => void; onSessionConnected?: () => void;

onConversationMessageCreated?: (item: ConversationItem) => void }

Configuration for useOrgaAI.startSession. Overrides OrgaAIConfig defaults and includes event callbacks.

Session Types

Types related to session state and media handling

Name

Type

Description

ConnectionState

RTCPeerConnection["connectionState"]

WebRTC connection state (e.g., "new", "connecting", "connected"). Derived from react-native-webrtc. Used in OrgaAIHookReturn.connectionState and SessionConfig callbacks.

MediaConstraints

interface { audio: boolean;

video: { width: number; height: number;

frameRate: number; } }

Constraints for media streams, used in getMediaConstraints to configure audio and video settings.

Event Types

Types related to WebRTC events and conversation data.

Name

Type

Description

IceCandidateEvent

interface { candidate: RTCIceCandidate | null }

Represents a WebRTC ICE candidate event. Used in WebRTC connection setup.

DataChannelEvent

interface { event: string; message?: string; [key: string]: any }

Represents a WebRTC data channel event, with event types defined in DataChannelEventTypes.

ConversationItem

interface { conversationId: string;

sender: "user" | "assistant";

content: { type: "text"; message: string }; voiceType?: OrgaAIVoice;

modelVersion?: OrgaAIModel;

timestamp?: string }

Represents a single conversation item (e.g., user speech or AI response). Returned via useOrgaAI.conversationItems.

OrgaAIHookCallbacks

interface { onSessionStart?: () => void; onSessionEnd?: () => void;

onSessionConnected?: () => void;

onError?: (error: Error) => void; onConnectionStateChange?: (state: ConnectionState) => void; onConversationMessageCreated?: (item: ConversationItem) => void }

Callbacks for session events, used in SessionConfig and OrgaAIHookReturn.

WebRTC Types

Types related to WebRTC integration.

Name

Type

Description

RTCIceServer

interface { urls: string | string[]; username?: string; credential?: string }

Configuration for WebRTC ICE servers, used in OrgaAIConfig.fetchSessionConfig.

Hook Return Type

Type returned by the useOrgaAI hook

Name

Type

Description

OrgaAIHookReturn

interface { startSession: (config?: SessionConfig) => Promise<void>;

endSession: () => Promise<void>;

enableMic: () => Promise<void>;

disableMic: () => Promise<void>;

toggleMic: () => Promise<void>;

enableCamera: () => Promise<void>;

disableCamera: () => Promise<void>;

toggleCamera: () => Promise<void>;

connectionState: ConnectionState;

aiAudioStream: MediaStream | null;

userVideoStream: MediaStream | null;

conversationItems: ConversationItem[];

isCameraOn: boolean;

isMicOn: boolean;

conversationId: string | null;

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; hasPermissions?: () => Promise<boolean> }

Return type of the useOrgaAI hook, providing methods and state for session management, media controls, and configuration.