Skip to main content
For version 0.7.0 of @hamsa-ai/voice-agents-sdk.

Constructor

Code from before public keys passes an API key first: new HamsaVoiceAgent(API_KEY, options). It still works. See Migrate.

start() options

start() returns a promise that resolves once the call has started. If the call can’t start, error fires, or the promise rejects when nothing listens for error. userId, preferHeadphonesForIosDevices, connectionDelay and disableWakeLock are still accepted, so older code keeps working, but they have no effect.

Methods

The call

Microphone and volume

Analytics

getConnectionStats(), getAudioLevels(), getPerformanceMetrics(), getParticipants(), getTrackStats() and getCallAnalytics(). See Read call statistics.

Events

LiveKit objects

The SDK runs on LiveKit. If you build on LiveKit yourself, for example with its React components:

Page tools

Each function in tools: How to set up the web tool, read its arguments, return an answer and handle failures: Web tools.

Errors

HamsaApiError extends Error with messageKey, status, params and retryAfter. The keys and what they mean: If a call fails to start.

Exports

HamsaVoiceAgent is also a named export. The SDK also re-exports LiveKit’s Room, RemoteParticipant, RemoteTrack, RemoteTrackPublication, LocalTrack and RpcInvocationData types. Event handlers are typed: agent.on("callStarted", ({ jobId }) => ...) knows jobId is a string.