Skip to main content
@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 dynamic import() 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" />. Each request calls resolve, runs as the resolved user, and stays in the resolved workspace. Only the routes a conversation needs are exposed; Cancel and workspace Pause are refused.

Framework adapters

The adapters wrap any web-standard handler, including createChatHandler:
The Node middleware streams bodies and SSE, works after a body parser, and aborts when the client disconnects. Pass the 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.

Compatibility

Clients and servers are compatible within the same major version. See Going to production.