Skip to content

DocsGet started

OpenPulse

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).

  1. Install the SDK

    One package holds the library and the openpulse CLI. It is published on GitHub Packages under OpenPulseProtocol, not on the public npm registry, so installing it takes the registry token that comes with your access. Point the scope at GitHub Packages in your project's .npmrc and keep the token in an environment variable, never in the file.

    Shell
    # .npmrc@OpenPulseProtocol:registry=https://npm.pkg.github.com//npm.pkg.github.com/:_authToken=${NODE_AUTH_TOKEN}
    Shell
    export NODE_AUTH_TOKEN=…   # your registry tokenpnpm add @openpulse/sdk@npm:@OpenPulseProtocol/openpulse-sdk
  2. Add your realm key

    The key starts with opw2. and belongs on your server only.

    Shell
    export OPENPULSE_REALM_KEY=opw2.…pnpm exec openpulse doctor --wire   # checks the key and the connection
  3. Post from your server

    connect() reads the key, connects to the edge and returns one shared session. A lane is opened on first use.

    A message type is a schema name and a parser, kept in one file that the server and the browser both read.

    messages.ts
    export type Message = { from: string; text: string }export const message = {  schema: 'app.message@v1',  codec: { parse: (v: unknown) => v as Message },}
    server.ts
    import { connect, defineExtension } from '@openpulse/sdk'import { message, type Message } from './messages'const Chat = defineExtension<Message>(message)const pulse = await connect()await pulse.chat('support-42').publish(Chat, { from: '@helpdesk', text: 'Hi, how can we help?' })
  4. 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, defineExtension, seatFrom } from '@openpulse/sdk/browser'import { message, type Message } from './messages'const Chat = defineExtension<Message>(message)const pulse = await connect({ getToken: seatFrom('/api/pulse/seat') })pulse.chat('support-42').subscribe(Chat, (msg) => render(msg))
  5. 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()

Next#