Hooks
Documentation for useOrgaAI, including return values and usage examples.
useOrgaAI
Access Orga SDK methods and state in your components.
Import
import { useOrgaAI } from '@orga-ai/sdk-react-native';
Returns
|
Name |
Type |
Description |
|---|---|---|
|
|
|
Starts a new session with optional configuration. Use to initiate an AI conversation. |
|
|
|
Ends the current session, stopping all media streams and connections. |
|
|
|
Enables the microphone for audio input. |
|
|
|
Disables the microphone, muting audio input. |
|
|
|
Toggles the microphone’s state (on/off). |
|
|
|
Enables the camera for video input. |
|
|
|
Disables the camera, stopping video input. |
|
|
|
Toggles the camera’s state (on/off). |
|
|
|
Switches between front and back cameras. |
|
|
|
The current connection state (e.g., "disconnected", "connecting", "connected"). |
|
|
|
The AI’s audio stream, or null if not available. |
|
|
|
The user’s video stream, or null if not available. |
|
|
|
Array of conversation items, including user speech and AI responses. |
|
|
|
Indicates whether the camera is currently enabled. |
|
|
|
Indicates whether the microphone is currently enabled. |
|
|
|
The current camera position (e.g., "front", "back"). |
|
|
|
The unique ID of the current conversation, or null if no conversation is active. |
|
|
|
The selected AI model, or default model if not set. |
|
|
|
The selected voice for AI responses, or default voice if not set. |
|
|
|
The sampling temperature for AI responses, or null if not set. |
|
|
|
Custom instructions for the AI, or null if not set. |
|
|
|
Array of enabled modalities (e.g., audio, video). |
|
|
|
Updates session parameters (e.g., model, voice, temperature). |
Usage
const { startSession, endSession, videoStream } = useOrgaAI();
export default function HomeScreen() {
const {
startSession,
endSession,
userVideoStream,
connectionState,
isMicOn,
toggleMic,
toggleCamera,
updateParams,
} = useOrgaAI();
const handleStart = async () => {
await startSession({
onSessionConnected: () => console.log('Connected!'),
});
updateParams({ model: 'orga-1-beta', voice: 'alloy' });
};
return (
<View>
<Text>Connection: {connectionState}</Text>
<Text>Mic: {isMicOn ? 'On' : 'Off'}</Text>
<Button title="Toggle Mic" onPress={toggleMic} />
<Button title="Start Session" onPress={handleStart} />
<Button title="End Session" onPress={endSession} />
</View>
);
}