// Store with full optionsawait client.memory.add({
content:'Learned quadratic formula today',
sessionId:'sess_123',
type:'episodic',
importance:0.9,
entityId:'user_42',
metadata:{ subject:'math'},})// Search with filtersconst results =await client.memory.search({
query:'math concepts',
sessionId:'sess_123',
types:['episodic','semantic'],
minImportance:0.5,
limit:10,})// Harvest memories from conversationawait client.memory.harvest({
sessionId:'sess_123',
transcript:'User: I find visual explanations helpful...',
entityId:'user_42',})
Knowledge — client.knowledge
Method
Description
ingest(params)
Add content to the knowledge graph
query(params)
Query the knowledge graph
entities(opts?)
List entities
visualize(params)
Get graph visualization data
await client.knowledge.ingest({
content:'Photosynthesis converts light energy to chemical energy',
entityId:'biology_101',
source:'textbook',})const graph =await client.knowledge.query({
query:'photosynthesis',
depth:3,
limit:20,})
Storage — client.storage
Method
Description
upload(params)
Upload a file (base64)
presignedUpload(params)
Get a presigned URL for direct upload
get(uploadId)
Get file metadata
getUrl(uploadId)
Get ephemeral download URL
fileUrl(fileId)
Get download URL by file ID
checkHash(hash)
Deduplication check
analyzeContent(params)
Analyze file content type
extract(params)
Extract content from a URL
// Get presigned upload URLconst{ data }=await client.storage.presignedUpload({
fileName:'essay.pdf',
fileType:'application/pdf',
fileSize:102400,
contentHash:'sha256_abc123',
tenantId:'tenant_1',})// Upload directly to the presigned URL, then analyzeawait client.storage.analyzeContent({
uploadId: data.upload_id,
context:'student_homework',})
Meta-Learning — client.metaLearning
Method
Description
analyze(params)
Analyze learning patterns
profile(userId)
Get learner profile
plreTransition(params)
Trigger PLRE phase transition
plreState(params)
Get current PLRE state
// Get learning profileconst profile =await client.metaLearning.profile('user_42')// Get PLRE stateconst state =await client.metaLearning.plreState({
userId:'user_42',
sessionId:'sess_123',})
Agents — client.agents
Method
Description
ingestTrace(params)
Store agent execution trace
setWorkingMemory(params)
Set session working memory
getWorkingMemory(sessionId)
Get session working memory
// Ingest an agent traceawait client.agents.ingestTrace({
content:'Called search tool with query "quadratic formula"',
sessionId:'sess_123',
metadata:{ tool:'search', latency_ms:120},})// Set working memory with TTLawait client.agents.setWorkingMemory({
content:'Current task: help user with algebra homework',
sessionId:'sess_123',
ttlSeconds:3600,})
Sessions — client.sessions
Method
Description
list()
List all sessions
get(sessionId)
Get session details
update(params)
Update cognitive state
delete(sessionId)
Delete a session
cleanup()
Clean up expired sessions
Graph — client.graph
Method
Description
traverse(params)
Traverse from a starting entity
temporal(entityId, asOfDate)
Temporal entity view
neighbors(entityId)
Get immediate neighbors
Error Handling
import Cerebe,{
AuthenticationError,
RateLimitError,
NotFoundError,
ValidationError,
ServerError,}from'@cerebe/sdk'try{await client.memory.get('mem_nonexistent')}catch(error){if(error instanceofNotFoundError){console.log('Memory not found')}elseif(error instanceofRateLimitError){console.log(`Rate limited, retry after ${error.retryAfter}s`)}elseif(error instanceofAuthenticationError){console.log('Invalid API key')}}
Error Class
HTTP Status
Description
AuthenticationError
401
Invalid or missing API key
NotFoundError
404
Resource not found
ValidationError
400, 422
Invalid request parameters
RateLimitError
429
Rate limit exceeded
ServerError
5xx
Server-side error
Retries
The SDK automatically retries on:
429 (Rate Limited) — respects Retry-After header
5xx (Server Error) — exponential backoff with jitter
Set maxRetries: 0 to disable retries.
TypeScript Types
All request parameters and response types are fully typed. Import them directly: