๐Ÿ“š

JS Introduction

UG JS SDK 3.0


ย 
Last updated: 12 Oct 2025

๐Ÿš€ UG-Core SDK Documentation

This document provides an overview of theย ug-coreย JS SDK, a framework-agnostic JavaScript library for managing real-time, interactive avatar conversations. It is designed to be decoupled from any specific UI framework, allowing for integration into various environments, such as React, Vue, or Vanilla JavaScript projects.

Setup

Project repository โ†’ https://github.com/uglabs/ug-js-sdk
To set up your project locally - you can clone https://github.com/uglabs/ug-js-sdk
after cloning you can run npm run serve:demo to try out the SDK
ย 
Host: For Host URL, use: https://pug.stg.uglabs.app
API Key: To get a service account API key, go to https://pug-playground.stg.uglabs.app/service-accounts โ†’ click โ€œcreate service accountโ€ โ†’ enter itโ€™s name โ†’ copy the key
Federated ID: To get a player ID, go to https://pug-playground.stg.uglabs.app/players โ†’ click โ€œcreate playerโ€ โ†’ enter playerโ€™s external id โ†’ copy federated id of the player you created (appears at the end of the list)
ย 
Install locally
npm install github:uglabs/ug-js-sdk
ย 
ย 
notion image

๐Ÿ›๏ธ Core Architecture

The SDK is built around a centralย Conversation Managerย that orchestrates several specialized managers to handle different aspects of the conversation lifecycle.
notion image
  • ๐Ÿงžย Conversation Manager: The main entry point and central nervous system of the SDK. It initializes and coordinates all other managers, manages the overall conversation state (idle,ย playing,ย userSpeaking, etc.), and exposes a simple API for controlling the conversation.
  • ๐Ÿ—ฃ๏ธย Conversation Network: Manages the WebSocket connection to the backend, handling the sending and receiving of all conversation-related messages.
  • ๐ŸŽฉย User Input Manager: Captures user input. It uses aย VAD Managerย (Voice Activity Detection) to detect when the user is speaking and anย AudioRecorderย to capture microphone data. It can also handle text input.
  • ๐ŸŽชย Playback Manager: Manages the playback of the assistant's response. This includes playing audio (Audio Player), displaying subtitles (Subtitle Manager), and triggering avatar animations (Using Avatar Manager).

โœจ Key Features

๐Ÿ—ฃ๏ธ Interrupts (Barge-in) [WIP]

The SDK is designed for natural, fluid conversations. Users can interrupt the assistant at any time, just like in a real conversation. This is achieved through robustย Acoustic Echo Cancellation (AEC).
We leverage the browser's native AEC capabilities, which are often hardware-accelerated on modern mobile devices. In environments where hardware AEC is unavailable, a software-based solution is used, ensuring a seamless experience across all platforms.

๐Ÿคซ Smart Turn Detection [WIP]

No awkward silences or waiting for a push-to-talk button. The SDK uses Smart Turn Detection Model to intelligently detect when a user has started and, more importantly, finished speaking. This allows for a natural conversational flow, where the assistant responds precisely when the user has completed their thought.
ย 
ย 
ย