JavaScript SDK / Installation
Installation
@zeligate/zeli-avatar is the JavaScript and TypeScript SDK for a
hosted Zeli Avatar service. It has zero runtime dependencies: a browser
already ships WebRTC, WebSockets and fetch, which is everything
the session client uses.
Install
npm install @zeligate/zeli-avatarThe package is
@zeligate/zeli-avatar on npm,
with released versions, package metadata and installation files.
The package is published with TypeScript declarations, so editors resolve types
without a separate @types install.
Requirements
- A running Zeli avatar avatar server and its base URL, for example
https://zeli-avatar.zelibot.xyz. The URL must start withhttp://orhttps://, and the client throws aConfigurationErrorif it does not. - Network access from the runtime to the avatar server for both HTTP signalling and the WebRTC media connection.
- A credential. In a browser that is a short-lived session token, never a full API key. See Authentication.
Browsers
Nothing extra to install. The SDK uses only platform APIs:
| Platform API | Used for |
|---|---|
RTCPeerConnection | The inbound audio and video media plane. |
WebSocket | The control gateway, which carries talk, interrupt and events. |
fetch | Signalling, the avatar and voice catalogues, and management routes. |
Node
Node has fetch from v18 and a global WebSocket from v22, but it has no
WebRTC. Supply an implementation:
npm install @zeligate/zeli-avatar weriftimport { RTCPeerConnection } from "werift";
import { ZeliClient, type RTCPeerConnectionLike } from "@zeligate/zeli-avatar";
const client = new ZeliClient({
serverUrl: "https://zeli-avatar.zelibot.xyz",
apiKey: process.env.ZELI_API_KEY,
peerConnectionFactory: (config) =>
new RTCPeerConnection(config) as unknown as RTCPeerConnectionLike,
});On Node before v22, pass webSocketFactory as well. The package declares
"engines": { "node": ">=18" }.
Node has no MediaStream class, so
session.mediaStream is null there and
session.tracks is the whole story. See
Media.
Verify
import { ZeliClient, ZeliEvent } from "@zeligate/zeli-avatar";
const client = new ZeliClient({ serverUrl: "https://zeli-avatar.zelibot.xyz" });
console.log(Object.keys(ZeliEvent).length, "events available");The sibling package is zeli-avatar on PyPI. Client construction,
connect(), talk(), the event names and the error
hierarchy line up across the two. See
Installation (Python).
Next: the Quickstart.