Skip to navigation

TypeScript SDK

@livingbrain/sdk — fully typed, works in Node and the browser.

Generated by Fern

Install

npm install @livingbrain/sdk

Requires Node 18+ (or any runtime with a global fetch).

Usage

import { LivingBrainClient } from "@livingbrain/sdk";
const client = new LivingBrainClient({
apiKey: process.env.LIVING_BRAIN_API_KEY!,
subjectId: "3f2b8c1e-7a4d-4e9b-9c2a-5d6e7f8a9b0c",
});
const brain = await client.brains.create({ name: "Research" });
await client.captures.capture({
brainId: brain.id,
body: { kind: "note", content: "Worth remembering." },
});
for await (const page of await client.workspace.listPages({ brainId: brain.id })) {
console.log(page.title);
}

Namespaces

NamespaceCovers
client.brainsCreate, list, update, delete brains; stats; daily briefs
client.capturesPush captures; manage ingest sources
client.workspacePages, buckets, connections, changes, search, score, profile
client.webhooksWebhook subscriptions
client.slackSlack installation, OAuth, and channel bindings
client.telegramTelegram bot connection

Types

Every request and response is typed, and types are exported for your own signatures:

import type { Page, Brain, ChangeEvent, Connection } from "@livingbrain/sdk";
function summarize(page: Page): string {
return `${page.title} (${page.status})`;
}

Errors

import { LivingBrain } from "@livingbrain/sdk";
try {
await client.workspace.getPage({ brainId, slug });
} catch (err) {
if (err instanceof LivingBrain.NotFoundError) return null;
throw err;
}

See Errors for the full table.

Request options

await client.brains.list({
maxRetries: 5,
timeoutInSeconds: 30,
abortSignal: controller.signal,
});

Raw responses

When you need headers or the status code, every method has a .withRawResponse() variant:

const { data, rawResponse } = await client.brains.list().withRawResponse();
console.log(rawResponse.headers.get("x-request-id"));

Custom fetch

Useful for proxies, instrumentation, or non-standard runtimes:

const client = new LivingBrainClient({
apiKey,
subjectId,
fetcher: async (args) => myInstrumentedFetch(args),
});