UG AI Engine for children
ย
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
ย
ย
๐๏ธ Core Architecture
The SDK is built around a centralย
Conversation Manager
ย that orchestrates several specialized managers to handle different aspects of the conversation lifecycle.- ๐งย
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.
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.
ย
ย
ย