Prototype and compare Perso Interactive integrations across SvelteKit, Vanilla JS, and TypeScript demos.
Get Started • Sample Apps • Type Definitions • Quick Look
Provides Perso Interactive Web SDK and demo apps.
- Sveltekit
- VanlliaJS
- Typescript
-
Install
nodejs(+v20) and Installpnpm:nvm install 20
npm install -g pnpm
-
Install dependencies once at the repo root:
pnpm install
-
Start any demo with the dedicated script (each command runs from the repo root):
- SvelteKit app:
pnpm svelte
- Vanilla app:
pnpm vanilla
- TypeScript app:
pnpm typescript
- SvelteKit app:
-
apps/svelte (
@perso-interactive-sdk-web/app-svelte)
Before running, fill inpersoInteractiveApiKeyand API server information insrc/lib/constant.ts, then runpnpm svelte. Session creation is handled insrc/routes/session/+server.ts.// .env PERSO_INTERACTIVE_API_KEY = "YOUR API KEY"; // or // constant.ts export const persoInteractiveApiKey = "YOUR API KEY";
-
apps/vanilla (
@perso-interactive-sdk-web/app-vanilla)
An HTML/JS demo powered by Vite. Runpnpm vanillato see the basic UI and SDK integration. -
apps/typescript (
@perso-interactive-sdk-web/app-typescript)
TypeScript version of the Vanilla demo. Runpnpm typescriptto see the same UI with type support.
The SDK ships a global type definition file at perso-interactive-sdk.d.ts, which exposes the PersoInteractive namespace (session helpers, ChatState, ChatTool, error classes, etc.). To use it in any TypeScript app:
Create or update an ambient declaration (e.g., src/app.d.ts) with a triple-slash reference to the SDK d.ts.
// `app.d.ts` or `global.d.ts`
/// <reference types="/perso-interactive-sdk.d.ts" />If you are using perso-interactive-sdk.d.ts in your project, copy the file and write reference at the top of app.d.ts or global.d.ts to gain typing access to PersoInteractive.
Exports
PersoUtil: thin wrappers over the REST endpoints (getLLMs,getModelStyles,getBackgroundImages,getTTSs,getSTTs,getPrompts,getDocuments,getMcpServers,getSessionInfo,sessionEvent). All helpers accept(apiServerUrl, apiKey)and return parsed JSON with SDK-specific typings.createSessionId/getIntroMessage: shared helpers that encapsulate the auth headers and payload format needed before the web client callsPersoInteractive.createSession.ApiError: an error subclass thrown when the HTTP response is not2xx. It carriesstatus,code,detail, andattrfields coming from the Perso API so you can map failures to user-friendly responses.
- Collect the Perso Interactive API server URL and API key from the operator.
- Call
PersoInteractive.getAllSettingsto fetch LLM, TTS/STT, model style, prompt, document, background, toolcalling and MCP server options for the UI. - When the user clicks START, invoke
createSessionIdwith the selected options (plus optional padding, voice chat toggle, and client tool selections), thencreateSessionto bind the media stream to a<video>element. - Subscribe to chat logs and chat states to render transcripts, voice/speech controls, and availability indicators. Use client tools for app-specific actions and handle SDK errors via the provided callbacks.
// 1. Initialize SDK
const apiServerUrl = "https://live-api.perso.ai";
const apiKey = "YOUR API KEY";
// 2. Fetch features and config setting
const configs = {
llm_type: await getLLMs(apiServerUrl, apiKey),
tts_type: await getTTSs(apiServerUrl, apiKey),
stt_type: await getSTTs(apiServerUrl, apiKey),
model_style: await getModelStyles(apiServerUrl, apiKey),
background_image: await getBackgroundImages(apiServerUrl, apiKey),
mcp_servers: await getMcpServers(apiServerUrl, apiKey),
prompt: await getPrompts(apiServerUrl, apiKey),
document: await getDocuments(apiServerUrl, apiKey),
background_imge,
};
// 3. Create session id
const response = await fetch(`${apiServerUrl}/api/v1/session/`, {
body: JSON.stringify({
capability: ["LLM", "STF_WEBRTC"],
...configs
padding_left,
padding_top,
padding_height,
}),
headers: {
"PersoLive-APIKey": apiKey,
"Content-Type": "application/json",
},
method: "POST",
});
let json = await response.json();
const sessionId = json.session_id;
return sessionId;// 3. Create PersoInteractive WebRTC Session Info
const session = await PersoInteractive.createSession(
apiServerUrl,
sessionId,
chatbotWidth,
chatbotHeight,
enableVoiceChat,
introMessage ?? "", // [Get] getPrompts(...)
clientTools ?? [] // Refer to the following reference
);// 1. Initialize SDK
const apiServerUrl = "https://live-api.perso.ai";
const apiKey = "YOUR API KEY";
// 2. Fetch features and get session id
const sessionId = await PersoInteractive.createSessionId(apiServerUrl, apiKey, {
using_stf_webrtc: true,
model_style, // [Get] getModelStyles(...)
prompt, // [Get] getPrompts(...)
llm_type, // [Get] getLLMs(...)
tts_type, // [Get] getTTSs(...)
stt_type, // [Get] getSTTs(...)
document, // [Get] getDocuments(...)
background_image, // [Get] getBackgroundImages(...)
mcp_servers, // [Get] getMcpServers(...)
padding_left,
padding_top,
padding_height,
});
// 3. Create PersoInteractive WebRTC Session Info
const session = await PersoInteractive.createSession(
apiServerUrl,
sessionId,
chatbotWidth,
chatbotHeight,
enableVoiceChat,
introMessage ?? "", // [Get] getPrompts(...)
clientTools ?? [] // Refer to the following reference
);
...reference) Tool calling example
Perso Interactive SDK for Web is commercial software. Contact our sales team.
