CerebeCerebe Docs

TypeScript SDK

Install and use the Cerebe TypeScript SDK.

TypeScript SDK

The official TypeScript SDK for Cerebe. Zero dependencies — uses native fetch. Works in Node.js 18+, browsers, Deno, and Bun.

Installation

npm install @cerebe/sdk

Quick Start

import Cerebe from '@cerebe/sdk'

const client = new Cerebe({
  apiKey: 'ck_live_...',
})

// Store a memory
await client.memory.add({
  content: 'User prefers visual explanations',
  userId: 'user_123',
  sessionId: 'session_abc',
})

// Search memories
const results = await client.memory.search({
  query: 'What does the user prefer?',
  sessionId: 'session_abc',
})

Resources

client.memory        // Memory operations
client.knowledge     // Knowledge graph
client.storage       // File storage
client.metaLearning  // PLRE and pattern analysis
client.llm           // OpenAI-compatible chat

Error Handling

import Cerebe, { AuthenticationError, RateLimitError } from '@cerebe/sdk'

try {
  const result = await client.memory.search({ ... })
} catch (error) {
  if (error instanceof AuthenticationError) {
    console.log('Invalid API key')
  } else if (error instanceof RateLimitError) {
    console.log(`Retry after ${error.retryAfter}s`)
  }
}

Streaming (LLM)

// Coming soon: streaming for LLM responses
const response = await client.llm.chat({
  messages: [{ role: 'user', content: 'Hello' }],
  model: 'gpt-4o',
})

Configuration

ParameterEnvironment VariableDefault
apiKeyCEREBE_API_KEY— (required)
projectCEREBE_PROJECT""
baseUrlCEREBE_BASE_URLhttps://api.cerebe.ai
timeout30000 (ms)
maxRetries3

Browser Compatibility

The SDK works in browsers with no special configuration:

  • Uses native fetch (no Node.js dependencies)
  • User-Agent header automatically skipped in browser environments
  • Environment variables only read when process is available

Requirements

  • Node.js 18+ / modern browser / Deno / Bun
  • Zero runtime dependencies

On this page