Install
1npm i beliefsGet Your API Key
- Log in at thinkn.ai
- Go to Profile > API Keys (
/profile/api-keys) - Click Create Key, give it a name, and copy the
bel_live_...value - Add it to your environment:
1# .env (do not commit this file)
2BELIEFS_KEY=bel_live_...Pick a Scope
The SDK defaults to writeScope: 'thread', which is ideal for chat and session memory but requires a bound thread ID. For the fastest copy-paste verification, start with writeScope: 'space'.
Quick Verification
1import Beliefs from 'beliefs'
2
3const beliefs = new Beliefs({
4 apiKey: process.env.BELIEFS_KEY,
5 namespace: 'install-check',
6 writeScope: 'space',
7})
8
9// Assert a belief
10await beliefs.add('The sky is blue', { confidence: 0.99 })
11
12// Read the state
13const world = await beliefs.read()
14console.log(world.beliefs) // [{ text: 'The sky is blue', confidence: 0.99, ... }]Thread-scoped apps
If you want per-conversation memory, keep the default writeScope: 'thread' and bind a thread with thread: 'conversation-id' or beliefs.withThread(threadId).
Copy the key immediately — it is only shown once. If lost, revoke it and create a new one.
Using a coding agent?
Give your agent the SDK reference so it can write correct code on the first try: https://thinkn.ai/llms.txt
Framework Adapters
Built-in adapters for automatic belief extraction — no extra packages needed:
1import { beliefsMiddleware } from 'beliefs/vercel-ai'
2import { beliefsHooks } from 'beliefs/claude-agent-sdk'| Adapter | Import | Docs |
|---|---|---|
| Vercel AI SDK | beliefs/vercel-ai | Guide |
| Claude Agent SDK | beliefs/claude-agent-sdk | Guide |
Adapters are optional — you can always use the core SDK directly with beliefs.before() / beliefs.after(). See the Quickstart.
Requirements
- Node.js 18+
- TypeScript 5+ (recommended)
The SDK is in private beta. Request access at thinkn.ai/waitlist.