Web SDK

@glytos/web puts a conversation with your agent in your page - voice over WebRTC, or text as a chat. Both are in the one package; use whichever you need. It handles the microphone, the connection and the transcript stream.

npm install @glytos/web

The two-step flow

The SDK never sees your API key. Your server mints a short-lived web-call token; the page uses it.

On your server, mint a token naming the agent, and return it to your page:

import { Glytos } from '@glytos/node';

const glytos = new Glytos({ apiKey: process.env.GLYTOS_API_KEY! });
const { token, ws_url } = await glytos.calls.webToken({ workflow_uuid: agentUuid });
// return { token, ws_url } to your page

In the page, start the call with it:

import { GlytosWebCall } from '@glytos/web';

const call = new GlytosWebCall({ token, wsUrl: ws_url });

call.on('status', status => console.log(status));
call.on('transcript', message => console.log(message.role, message.text));

await call.start();

Mint the token on your server. Putting an API key in the page hands anyone who views source the ability to spend your credit.

Ending a call

call.stop();

Chat

The same package embeds a text chat. Mint a short-lived chat token on your server (POST /api/v1/chat/token) and hand it to the page:

import { GlytosChat } from '@glytos/web';

const chat = new GlytosChat({ token });

chat.on('token', t => append(t.delta));   // streamed deltas
chat.on('message', m => render(m));       // a complete message
chat.on('error', e => console.error(e));

await chat.start();               // opens the conversation, emits the greeting
await chat.stream('Hello!');      // streamed reply
await chat.send('And this?');     // buffered reply

Attachments, images and resuming

// Attach a file to this conversation only (it does not join the knowledge base)
await chat.uploadFile(fileFromInput, fileFromInput.name);

// Send an image with a turn; a text-only model ignores it
await chat.send('What is on this label?', { images: [dataUri] });

// Persist the conversation id and resume it later
localStorage.setItem('glytos_chat', chat.sessionId ?? '');
const resumed = new GlytosChat({ token, sessionUuid: saved });

Per-turn instructions are deliberately not available here: this runs in a visitor's browser, so such a field would let anyone rewrite your agent's behaviour on your own site. Use a server SDK for that - see Chat.

Requirements

A voice call needs the page served over HTTPS - browsers only grant microphone access on a secure origin - and the user must grant microphone permission when prompted. Chat has neither requirement.

Web SDK · Glytos Docs