thinkn
  • Product
    Manifesto
    The reason we exist
    Founder Studioprivate beta
    Make better product decisions faster
    Belief SDKinvite only
    Add belief states to your AI system
    Request Access →Join the private beta waitlist
  • Docs
  • Pricing
  • FAQ
  • Docs
  • Pricing
  • FAQ
Sign In
Welcome
  • Start Here
  • Install
  • Quickstart
  • FAQ
  • Why beliefs
start/install.mdx

Install

Configure your stack and grab the install command + boilerplate. Pick package manager, framework, and memory scope.

Configure your install

Pick your package manager, framework, and memory scope. The install command and starter snippet update as you choose.

Framework
Memory scope

Core SDK·Wrap any agent loop with before / after manually.
Shared (space)·One belief state per namespace. Best for prototypes and multi-agent.

installbash
npm i beliefs
lib/beliefs.tsts
import 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

  1. Log in at thinkn.ai
  2. Go to Profile > API Keys (/profile/api-keys)
  3. Click Create Key, give it a name, and copy the bel_live_... value
  4. 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.

ScopeWhat it doesUse 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.

PreviousStart Here
NextQuickstart

On this page

  • Configure your install
  • Get your API key
  • Memory scope, in detail
  • Verify it's working
  • Requirements