Quick Start
Get from zero to a streamed answer in three steps.
-
Install the SDK
Terminal window npm install @riseanalytics/finn-sdkTerminal window pnpm add @riseanalytics/finn-sdkTerminal window yarn add @riseanalytics/finn-sdk -
Connect and ask a question
import { FinnClient } from '@riseanalytics/finn-sdk';const finn = new FinnClient({url: process.env.FINN_URL, // e.g. https://finn.example.comapiKey: process.env.FINN_API_KEY, // your static API key});await finn.connect();const turn = finn.sendMessage('How many active members do I have?');// Tokens stream in as Finn answers.for await (const chunk of turn) {process.stdout.write(chunk.text);}const result = await turn.completed;console.log('\nconversationId:', result.conversationId);await finn.disconnect(); -
Run it
Terminal window FINN_URL=https://finn.example.com FINN_API_KEY=your-key node index.mjs
Just want the answer?
Section titled “Just want the answer?”If you don’t need live tokens, use ask() — it does the loop for you and
resolves once with the full answer:
const { text } = await finn.ask('How many active members do I have?');console.log(text);See Sending messages & streaming for
the difference between ask() and sendMessage().
What just happened
Section titled “What just happened”new FinnClient({ url, apiKey })created a client (nothing connects yet).connect()opened the WebSocket and authenticated with your API key.sendMessage(...)returned aMessageTurn— an async-iterable you loop over to read tokens as they arrive.turn.completedresolved with the finalTurnResult, including theconversationIdyou’d reuse for a follow-up.
Next steps
Section titled “Next steps”- Connecting & auth — every connection option, API-key rotation, and lifecycle events.
- Sending messages & streaming — the streaming model in depth, plus interrupting a turn.
- Conversations & follow-ups — keep context across turns.