Skip to Content
Embedding

Embed SDK quickstart

Add a published avatar to your site and start a conversation from your own interface.

Embed the player (@avatarstudio/embed)

Publish an experience

Publish a revision in Avatar Studio. Copy the slug from the /s/{slug} link and add your site's origin, such as https://example.com, to the publication's allowed_origins.

Prepare the integration

For TypeScript or React, add @avatarstudio/embed to your app’s NeuroStudio workspace dependencies. Use the address of the Studio where you published your experience and replace the example slug with your own.

Add the player and start a conversation

Add the mount point and button to your page. Load the TypeScript module with your app’s bundler.

index.html
<div id="avatar-host" style="width: 100%; height: 480px"></div>
<button id="avatar-talk" type="button" disabled>Start conversation</button>
<script type="module" src="/src/avatar.ts"></script>
avatar.ts
import { mount } from "@avatarstudio/embed";

const talk = document.querySelector<HTMLButtonElement>("#avatar-talk")!;
const embed = mount({
  platformUrl: "https://avatarstudio.dev.digitallegends.ru",
  token: "your-publication-slug",
  container: "#avatar-host",
});

const offReady = embed.on("ready", () => { talk.disabled = false; });
const start = () => embed.startListening();
talk.addEventListener("click", start);
const offTranscript = embed.on("transcript", (payload) => console.log(payload));

// Call this when removing the player.
export function disposeAvatar() {
  talk.removeEventListener("click", start);
  talk.disabled = true;
  offReady();
  offTranscript();
  embed.destroy();
}

The button becomes available when the player is ready. The browser may ask for microphone permission when you press it.

See the generated Embed SDK reference for mount options and player methods.

Use stopListening() to turn off the microphone, sendText(text) to send a message, and interrupt() or reset() to interrupt the avatar or start a fresh conversation. See client tools for tool handlers and the embed protocol for managing kiosk visits and viewport changes.

Manage sessions directly (@avatarstudio/client)

Use the HTTP client when you run your own player or need to manage the LiveKit session lifecycle directly.

session.ts
import { createSession, getSessionState, closeSession } from "@avatarstudio/client";

const platformUrl = "https://avatars.digitallegends.ru";
const session = await createSession({
  deploymentId: "your-publication-slug",
  platformUrl,
});

// Connect to LiveKit using session.url and session.token.
if (session.closeToken) {
  const state = await getSessionState({ closeToken: session.closeToken, platformUrl });
  console.log("Queued:", state.queued, state.position);
  await closeSession({ closeToken: session.closeToken, platformUrl });
}