Get started
Quickstart
From a realm key to a live chat room and a streamed AI answer in a few minutes.
By the end of this page a server posts into a chat room, a browser reads it live, and an AI answer streams to both. You need a realm key from the Console (Access → Mint key).
Install the SDK
One package holds the library and the
openpulseCLI. It is not on the public npm registry: access comes with a registry token for it, which goes in your.npmrc.Shell # .npmrc@OpenPulseProtocol:registry=https://npm.pkg.github.compnpm add @openpulse/sdk@npm:@OpenPulseProtocol/openpulse-sdkAdd your realm key
The key starts with
opw1.and belongs on your server only.Shell export OPENPULSE_REALM_KEY=opw1.…pnpm exec openpulse doctor --wire # checks the key and the connectionPost from your server
connect()reads the key, picks the nearest edge and returns one shared session. A lane is opened on first use.server.ts import { connect, defineExtension } from '@openpulse/sdk'export const Message = defineExtension<{ from: string; text: string }>({ schema: 'app.message@v1', codec: { parse: (v) => v as { from: string; text: string } },})const pulse = await connect()await pulse.chat('support-42').publish(Message, { from: '@helpdesk', text: 'Hi, how can we help?' })Read it live in the browser
Browsers never see the realm key. Your backend hands out a short-lived seat (see tenants and seats) and the SDK renews it.
browser.ts import { connect } from '@openpulse/sdk/browser'import { Message } from './messages'const pulse = await connect({ getToken: () => fetch('/api/pulse/seat', { method: 'POST' }).then((r) => r.json()),})pulse.chat('support-42').subscribe(Message, (msg) => render(msg))Stream an AI answer
Write model output to a run. Every reader gets it live, reconnects resume where they left off, and the whole answer counts as one message.
TypeScript const run = await pulse.run()for await (const text of model.stream(prompt)) { await run.write({ kind: 'text_delta', text })}await run.end()