Dashboard|

Cencori SDK

The official Cencori SDK for Node.js and TypeScript. Simple, type-safe API for chat, images, embeddings, memory, and more.

Installation

npm install cencori

Initialization

import { Cencori } from 'cencori';
 
const cencori = new Cencori({
  apiKey: 'csk_...',
});

Chat Completions

const response = await cencori.ai.chat({
  model: 'gpt-4o',
  messages: [
    { role: 'system', content: 'You are a helpful assistant.' },
    { role: 'user', content: 'Hello!' },
  ],
});
 
console.log(response.content);
console.log(response.usage); // { promptTokens, completionTokens, totalTokens }

Streaming

const stream = cencori.ai.chatStream({
  model: 'claude-opus-4',
  messages: [{ role: 'user', content: 'Tell me a story' }],
});
 
for await (const chunk of stream) {
  process.stdout.write(chunk.delta);
}

Image Generation

const response = await cencori.ai.generateImage({
  prompt: 'A futuristic city at sunset',
  model: 'gpt-image-1.5',
  size: '1024x1024',
  quality: 'hd',
});
 
console.log(response.images[0].url);

Embeddings

const response = await cencori.ai.embeddings({
  model: 'text-embedding-3-small',
  input: 'Hello world',
});
 
console.log(response.embeddings[0]);

Memory (Context Store)

await cencori.memory.store({
  namespace: 'docs',
  content: 'Refund policy allows returns within 30 days',
  metadata: { category: 'policy' },
});
 
const results = await cencori.memory.search({
  namespace: 'docs',
  query: 'what is our refund policy?',
  limit: 5,
});
 

To answer questions from your own documents with citations, use knowledge bases: upload files with cencori.knowledge.addFileSource(), then pass knowledgeBases to cencori.ai.chat().

Available Methods

MethodDescription
cencori.ai.chat()Chat completions
cencori.ai.chatStream()Streaming chat
cencori.ai.generateImage()Image generation
cencori.ai.embeddings()Vector embeddings
cencori.ai.chat({ knowledgeBases })Answers grounded in your knowledge bases, with citations
cencori.knowledge.addFileSource()Upload a PDF, DOCX or other document to a knowledge base
cencori.memory.store()Store memory (namespace store)
cencori.memory.search()Semantic search (namespace store)
cencori.telemetry.reportWebRequest()Report web traffic to dashboard

Scoped memory (per-user, cross-session)

The namespace store above is for RAG corpora. For remembering end users across sessions, use the scoped memory surface — full reference at Memory API:

// Any model: recall() → inject-ready string; remember() persists the exchange.
const context = await cencori.memory.recall(userId, message);
// ...your own model call with `context` as a system message...
await cencori.memory.remember(userId, { user: message, assistant: reply });
 
// Scopes: session (ephemeral) · user (default) · workspace (+ workspaceId) · org.
// Batch writes, forget-by-filter, GDPR export, and async write receipts:
await cencori.memory.writeBatch({ userId, memories: [{ content: 'Prefers dark mode' }] });
await cencori.memory.forgetByFilter({ userId, before: '2026-01-01T00:00:00Z' });
const dump = await cencori.memory.export({ userId });
const receipt = await cencori.memory.writeStatus(res.memory.write_request_id);