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
  • Hack Guide
  • Introduction
  • Install
  • Quickstart
  • FAQ
  • The Problem
  • Memory vs Beliefs
  • Drift
  • Examples
start/install.mdx

Install

Add beliefs to your project.

Install

1npm i beliefs

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_...

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'
AdapterImportDocs
Vercel AI SDKbeliefs/vercel-aiGuide
Claude Agent SDKbeliefs/claude-agent-sdkGuide

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.

PreviousIntroduction
NextQuickstart

On this page

  • Install
  • Get Your API Key
  • Pick a Scope
  • Quick Verification
  • Framework Adapters
  • Requirements