@opengeni/sdk is an ESM-only TypeScript client. It uses standard fetch and streams, so it runs in Node 18+, Bun, Deno, browsers, and edge runtimes.
CommonJS hosts
Load the SDK with dynamicimport() inside an async function:
Entry points
For the default embed, see Embed manually.
OpenGeniClient
og.asUser(externalUserId, { source }) returns a client that acts as one of your users. A user with no membership in the workspace is added on their first request with conversation permissions (the key needs members:manage).
In a chat UI, wire Stop to
pauseSession. Messages sent while paused queue until resumeSession. cancelSession permanently stops the session and its children.
The complete method list is in packages/sdk/README.md.
Workspace member inventory
listWorkspaceMembers() returns an array and requires workspace:read. The raw HTTP route returns { members }.
createSessionProxyHandler
createSessionProxyHandler(client, options) returns a web-standard (request: Request) => Promise<Response>. Mount it at a catch-all route such as /api/opengeni/* and render <OpenGeniChat baseUrl="/api/opengeni" /> or SessionApp. Each request calls resolve, runs as the resolved user, and stays in the resolved workspace: every Opengeni route in that workspace is forwarded, and Opengeni’s permissions decide what it may do. Outside the workspace only the bootstrap reads (workspaces, access/me, config/client) and the user’s own inbox (inbox and inbox/items/{id} limited to the workspace, inbox/settings) answer.
Framework adapters
The adapters wrap any web-standard handler, includingcreateChatHandler:
Opengeni facade from @opengeni/sdk/chat so resolve can return your own ids; with a plain OpenGeniClient, resolve must return { user, workspaceId }. Don’t replace the proxy with a passthrough that forwards any path under the organization key.
Chat facade
The facade is text-only. See Keep your existing chat UI.