Overview
ThecreateNavaiMobileBackendClient function creates a client for communicating with your NAVAI backend. It handles creating realtime client secrets, listing backend functions, and executing backend function calls.
Usage
Options
Base URL for the NAVAI backend API. Defaults to
http://localhost:3000 if not provided.Can also be set via env.NAVAI_API_URL.Environment variables object. Used to read
NAVAI_API_URL if apiBaseUrl is not provided.Custom fetch implementation. Defaults to global
fetch.API path for creating client secrets. Defaults to
/navai/realtime/client-secret.API path for listing functions. Defaults to
/navai/functions.API path for executing functions. Defaults to
/navai/functions/execute.Return Value
ReturnsNavaiMobileBackendClient object:
createClientSecret
(input?: CreateRealtimeClientSecretInput) => Promise<CreateRealtimeClientSecretResult>
Create a realtime client secret for WebRTC connection.
List available backend functions.
Execute a backend function.Returns the function result. Throws error if execution fails.
Examples
Basic Setup
Create Client Secret
List Backend Functions
Execute Backend Function
Custom API Paths
With Custom Fetch
Integration with Voice Session
Error Handling
Create Client Secret Errors
List Functions Errors
ThelistFunctions method never throws. Errors are returned as warnings:
Execute Function Errors
API Endpoints
The backend client expects these endpoints:POST /navai/realtime/client-secret
Create a realtime client secret. Request:GET /navai/functions
List available backend functions. Response:POST /navai/functions/execute
Execute a backend function. Request:Related
- createNavaiMobileVoiceSession - Voice session management
- createNavaiMobileAgentRuntime - Agent runtime with backend integration
- useMobileVoiceAgent - Complete hook integration
