TypeScript SDK
The official BIE client for Node.js and the browser. Handles polling, error shapes, and webhook registration so you can focus on what to do with the intelligence.
Install
npm install @bie/sdk # or pnpm add @bie/sdk # or yarn add @bie/sdk
Initialize
import { BIEClient } from '@bie/sdk'
const bie = new BIEClient(process.env.BIE_API_KEY!)The client accepts an optional second argument, baseUrl, for self-hosted deployments. Defaults to https://bieintel.com/api/v1.
analyze(events, options)
The one-shot pattern. Send events, wait, receive intelligence. Polls under the hood with exponential backoff.
const result = await bie.analyze([
{ actor_id: 'user_1', content: 'love the update', timestamp: '2026-04-01T10:00:00Z' },
{ actor_id: 'user_2', content: 'the new layout is confusing', timestamp: '2026-04-01T11:00:00Z' },
])
console.log(result.plain_summary)
console.log(result.plain_recommendations)ingest(events, options)
Returns immediately with a session ID. Use this when you want to handle polling yourself or deliver via webhook.
const session = await bie.ingest(events, { deployment_id: 'cx_chatbot_prod' })
console.log(`Session ${session.session_id} created`)waitForIntelligence(sessionId, timeoutMs?)
Polls the intelligence endpoint until status is complete or the timeout is reached.
const intelligence = await bie.waitForIntelligence(session.session_id, 60_000)
getSession(sessionId)
Fetches a session without waiting. Useful for webhook-driven flows where you already know the session is complete.
const session = await bie.getSession(sessionId)
if (session.status === 'complete') {
console.log(session.plain_summary)
}registerWebhook(url, events?)
const webhook = await bie.registerWebhook('https://yourapp.com/webhooks/bie')
// Save webhook.secret, it will never be returned again
console.log(webhook.id, webhook.secret)Error handling
Non-2xx responses throw a BIEError with status, code, and message fields.
import { BIEError } from '@bie/sdk'
try {
await bie.analyze(events)
} catch (err) {
if (err instanceof BIEError) {
console.error(err.status, err.code, err.message)
}
}