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/sdkQuick 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 chatError 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
| Parameter | Environment Variable | Default |
|---|---|---|
apiKey | CEREBE_API_KEY | — (required) |
project | CEREBE_PROJECT | "" |
baseUrl | CEREBE_BASE_URL | https://api.cerebe.ai |
timeout | — | 30000 (ms) |
maxRetries | — | 3 |
Browser Compatibility
The SDK works in browsers with no special configuration:
- Uses native
fetch(no Node.js dependencies) User-Agentheader automatically skipped in browser environments- Environment variables only read when
processis available
Requirements
- Node.js 18+ / modern browser / Deno / Bun
- Zero runtime dependencies