Configure your install
Pick your package manager, framework, and memory scope. The install command and starter snippet update as you choose.
Core SDK·Wrap any agent loop with before / after manually.
Shared (space)·One belief state per namespace. Best for prototypes and multi-agent.
npm i beliefsimport Beliefs from 'beliefs'
const beliefs = new Beliefs({
apiKey: process.env.BELIEFS_KEY!,
namespace: 'my-app',
writeScope: 'space',
})
// Wrap your agent loop with before / after.
async function turn(userMessage: string) {
const context = await beliefs.before(userMessage)
// Run any LLM with context.prompt as the system prompt.
const result = await yourAgent(context.prompt, userMessage)
const delta = await beliefs.after(result)
return { result, clarity: delta.clarity }
}The ^0.7.0 range pulls in patches and new features without breaking changes. Pin tighter if you want.
Get 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_...Copy the key immediately. It is only shown once. If lost, revoke it and create a new one.
Memory scope, in detail
writeScope decides where new beliefs are stored, and therefore who else can read them.
| Scope | What it does | Use when |
|---|---|---|
'space' | One shared belief state per namespace. Every agent and conversation reads and writes the same world. | Prototypes, multi-agent collaboration, anything where shared context is the point. |
'thread' | Separate belief state per conversation. Bind with thread: 'id' or beliefs.withThread(id). | Chat apps, per-user memory, sessions that shouldn't leak into each other. |
'agent' | Durable scratchpad per agent, isolated from other agents in the same namespace. | Background workers and tool-running agents that keep private notes. |
The SDK defaults to writeScope: 'thread' (and requires a bound thread ID). For copy-paste verification, the configurator above starts on 'space', the simplest runnable setup. See Scoping for the full breakdown including contextLayers.
Verify it's working
After setting BELIEFS_KEY in your environment, run the snippet from the configurator (or any of the framework recipes). A successful first call returns a BeliefDelta with clarity set, no auth errors. If you see BetaAccessError, your key isn't on the allowlist. Request access via the waitlist.
Using a coding agent?
Give your agent the SDK reference so it can write correct code on the first try: thinkn.ai/llms.txt
Requirements
- Node.js 18+
- TypeScript 5+ (recommended)
The SDK is in private beta. Request access at thinkn.ai/waitlist.