
Company News
Socket Partners with Replit to Block Malicious Packages in AI-Powered Development
Replit is integrating Socket Firewall into its AI-powered development experience to help protect builders from malicious open source packages.
@unith-ai/core-client
Advanced tools
Core TypeScript SDK for building digital human experiences with Unith AI
An SDK library for building complex digital human experiences using javascript/typescript that run on Unith AI.
Before proceeding with using this library, you're expected to have an account on Unith AI, create a digital human and take note of your API key. You can create an account here in minutes!
Install the package in your project through package manager.
npm install @unith-ai/core-client
# or
yarn add @unith-ai/core-client
# or
pnpm install @unith-ai/core-client
If using microphoneProvider: "azure", install the Azure Speech SDK:
npm install microsoft-cognitiveservices-speech-sdk
The SDK is dynamically imported only when the Azure provider is used, so it won't affect bundle size if you use a different provider like eleven_labs.
This library is designed for use in plain JavaScript applications or to serve as a foundation for framework-specific implementations. Before integrating it, verify if a dedicated library exists for your particular framework. That said, it's compatible with any project built on JavaScript.
First, initialize the Conversation instance:
const conversation = await Conversation.startDigitalHuman(options);
This will establish a WebSocket connection and initialize the digital human with realtime audio & video streaming capabilities.
The options passed to startDigitalHuman specify how the session is established:
const conversation = await Conversation.startDigitalHuman({
orgId: "your-org-id",
headId: "your-head-id",
element: document.getElementById("video-container"), // HTML element for video output
apiKey: "your-api-key",
allowWakeLock: true,
username: "test-user",
...callbacks,
});
"azure" | "eleven_labs"boolean (default: false)string Custom data to be used for analytics.string Custom identifier for user..sendMessage method with your transcript as microphone doesn't automatically commit / send users text to our AI.speaking) and trigger the stop response method (.stopResponse)."ON" | "OFF" | "PROCESSING" Shows current status of microphone.ElevenLabsOptions - Custom options to customize behavior of ElevenLabs STT provider
BooleanNumberNumberNumberNumberBoolean - This disables ElevenLabs dynamic speech recognition language detection and uses the language specified during digital human creation.Register callbacks to handle various events:
Boolean Unique Identifier for the users session.ConnectHeadType Object with data about the digital human.
String Digital human head nameString[] Array with phrases set during digital human creation.String Language code setup during digital human creation.String Static image url for digital human.Boolean True if microphone access was granted, FalseString Unique session identifier for a conversation."connecting" | "connected" | "disconnecting" | "disconnected" Shows current websocket connection status.Date Timestamp when message was received/sent"user" | "ai" Shows who the message came from.String Message textBoolean Flag that you can use to control visibility of message. Sometimes, message comes before the video response starts playing. In such cases, this is usually false. Listen the onSpeakingStart event to change visibility when the video response starts playing.String[] A list of suggested query strings.keepSession method to extend the customers session.Retrieve the idle background video URL for use in welcome screens or widget mode:
const videoUrl = await Conversation.getBackgroundVideo({
orgId: "your-org-id",
headId: "your-head-id",
});
Start the conversation session and begin audio & video playback:
await conversation.startSession();
This method should be called after user interaction to ensure audio context is properly initialized, especially on mobile browsers.
Send a text message to the digital human:
conversation.sendMessage("Hello, how are you?");
Toggles microphone status between ON/OFF.
conversation.toggleMicrophone();
Get status of microphone. Can be ON/OFF/PROCESSING
conversation.getMicrophoneStatus();
Sends keep-alive event to prevent session timeout. Trigger this when you receive the onTimeoutWarning event to prevent session from timing out.
conversation.keepSession();
This clears both audio and video queues and returns the digital human to idle state.
Toggle the mute status of the audio output:
const volume = await conversation.toggleMute();
console.log("New volume:", volume); // 0 for muted, 1 for unmuted
Get the current user's ID:
const userId = conversation.getUserId();
Stops the ongoing response and notifies you via two callbacks:
onStoppingStart() - Called immediately when stop is initiated.onStoppingEnd() - Called once the current response is stopped.await conversation.stopResponse();
End the conversation session and clean up resources:
await conversation.endSession();
This closes the WebSocket connection, releases the wake lock, and destroys audio/video outputs.
Always handle errors appropriately:
try {
const conversation = await Conversation.startDigitalHuman({
orgId: "your-org-id",
headId: "your-head-id",
element: videoElement,
onError: ({ message, endConversation, type }) => {
if (type === "toast") {
// Show toast notification
showToast(message);
if (endConversation) {
// Restart the session
restartSession();
}
} else if (type === "modal") {
// Show modal dialog
showModal(message);
}
},
});
} catch (error) {
console.error("Failed to start digital human:", error);
}
Full TypeScript types are included:
Please refer to the README.md file in the root of this repository.
FAQs
Core TypeScript SDK for building digital human experiences with Unith AI
The npm package @unith-ai/core-client receives a total of 146 weekly downloads. As such, @unith-ai/core-client popularity was classified as not popular.
We found that @unith-ai/core-client demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Replit is integrating Socket Firewall into its AI-powered development experience to help protect builders from malicious open source packages.

Security News
npm confirmed a tooling bug incorrectly marked several one-character packages as security holders and said it was working on a rollback.

Research
/Security News
Newer packages in this compromise use native extensions and .pth loaders to execute JavaScript stealers in developer environments.