Browser SDK
The browser SDK is an npm package with no dependencies, and types included. Create a publishable token and allow your page's origin as described in the widget guide.
sh
npm install @vatio-ai/sdkjs
import { Vatio } from "@vatio-ai/sdk";
const options = { workspace: "acme", token: "vatpub_REPLACE_ME" };
const chat = await Vatio.chat(options);
const messages = new Map();
function receive(message) {
messages.set(message.id, message);
// Render messages ordered by ID in your UI, escaping untrusted content.
}
chat.on("message", receive);
chat.on("typing", (typing) => { /* Update your typing indicator. */ });
chat.on("status", (status) => { /* Update your connection indicator. */ });
chat.on("error", (error) => console.error(error.code, error.message));
for (const message of await chat.history()) receive(message);
await chat.send("What does Acme do?");
// Call chat.close() when this view unmounts.Without a bundler
Any npm CDN serves the same module:
html
<script type="module">
import { Vatio } from "https://cdn.jsdelivr.net/npm/@vatio-ai/sdk/+esm";
</script>Pin the major the ordinary way — "@vatio-ai/sdk": "^2.0.0". The SDK used to ship from a versioned URL (cdn.vatio.ai/v1/sdk.js) for exactly this reason, and a semver range says it better: a breaking change is a new major you upgrade to when you choose, not a second URL to notice.
Next: the reference for every method and option, and the limits every page hits.
