Official TypeScript/JavaScript SDK for Cognipeer Console - A multi-tenant SaaS platform for AI and Agentic services.
- 🤖 Chat Completions - OpenAI-compatible chat API with streaming support
- 📊 Embeddings - Text vectorization for semantic search
- 🗄️ Vector Operations - Manage vector databases (Pinecone, Chroma, Qdrant, etc.)
- 📁 File Management - Upload and manage files with markdown conversion
- 🔍 Agent Tracing - Observability for agent executions
- 🧠 Memory Stores - Persist, search, and recall scoped memories
- 🌐 OpenTelemetry Exporter - Send OTel spans directly to Cognipeer OTLP endpoint
- 🛡️ Guardrails - Evaluate content with tenant guardrail policies
- 🔒 Type-Safe - Full TypeScript support with comprehensive types
- ⚡ Modern - ESM and CommonJS support, works in Node.js and browsers
npm install @cognipeer/console-sdkyarn add @cognipeer/console-sdkpnpm add @cognipeer/console-sdkimport { ConsoleClient } from '@cognipeer/console-sdk';
// Initialize the client
const client = new ConsoleClient({
apiKey: 'your-api-key',
baseURL: 'https://your-console.example.com/api/client/v1', // Optional, defaults to production
});
// Chat completion
const response = await client.chat.completions.create({
model: 'gpt-4',
messages: [
{ role: 'system', content: 'You are a helpful assistant.' },
{ role: 'user', content: 'Hello!' },
],
});
console.log(response.choices[0].message.content);
// Streaming chat
const stream = await client.chat.completions.create({
model: 'gpt-4',
messages: [{ role: 'user', content: 'Tell me a story' }],
stream: true,
});
for await (const chunk of stream) {
process.stdout.write(chunk.choices[0]?.delta?.content || '');
}
// Create embeddings
const embeddings = await client.embeddings.create({
model: 'text-embedding-3-small',
input: 'Hello, world!',
});
console.log(embeddings.data[0].embedding);
// Vector operations
await client.vectors.upsert('my-provider', 'my-index', {
vectors: [
{
id: 'vec1',
values: [0.1, 0.2, 0.3],
metadata: { text: 'Hello world' },
},
],
});
const results = await client.vectors.query('my-provider', 'my-index', {
query: {
vector: [0.1, 0.2, 0.3],
topK: 5,
},
});
// File upload
const file = await client.files.upload('my-bucket', {
fileName: 'document.pdf',
data: 'data:application/pdf;base64,JVBERi0xLjQK...',
convertToMarkdown: true,
});
// Memory
const store = await client.memory.stores.create({
name: 'Support Memory',
vectorProviderKey: 'pinecone-main',
embeddingModelKey: 'text-embedding-3-small',
});
await client.memory.add(store.key, {
content: 'User prefers concise billing explanations.',
scope: 'user',
scopeId: 'user_123',
tags: ['billing', 'preferences'],
source: 'manual',
});
const recall = await client.memory.recall(store.key, {
query: 'user communication preferences',
scope: 'user',
scopeId: 'user_123',
});
console.log(recall.context);Full documentation is available at cognipeer.github.io/console-sdk
If you need the platform itself, deployment guidance, tenant architecture, provider setup, or raw HTTP API semantics, use the Cognipeer Console docs.
- Getting Started
- Working with Console
- Console API Mapping
- Chat API
- Embeddings API
- Guardrails API
- Memory API
- Vector API
- Files API
- Tracing API
- Examples
const client = new ConsoleClient({
apiKey: string; // Required: Your API token
baseURL?: string; // Optional: API base URL (default: https://api.cognipeer.com/api/client/v1)
timeout?: number; // Optional: Request timeout in ms (default: 60000)
maxRetries?: number; // Optional: Max retry attempts (default: 3)
fetch?: typeof fetch; // Optional: Custom fetch implementation
});client.chat.completions.create(params)- Create chat completion (streaming supported)
client.embeddings.create(params)- Create embeddings
client.vectors.providers.list(query?)- List vector providersclient.vectors.providers.create(data)- Create vector providerclient.vectors.indexes.list(providerKey)- List indexesclient.vectors.indexes.create(providerKey, data)- Create indexclient.vectors.indexes.get(providerKey, indexId)- Get index detailsclient.vectors.indexes.update(providerKey, indexId, data)- Update indexclient.vectors.indexes.delete(providerKey, indexId)- Delete indexclient.vectors.upsert(providerKey, indexId, data)- Upsert vectorsclient.vectors.query(providerKey, indexId, query)- Query vectorsclient.vectors.delete(providerKey, indexId, ids)- Delete vectors
client.files.buckets.list()- List bucketsclient.files.buckets.get(bucketKey)- Get bucket detailsclient.files.list(bucketKey, query?)- List filesclient.files.upload(bucketKey, data)- Upload file
client.prompts.list(query?)- List prompt templatesclient.prompts.get(key, options?)- Get prompt (supportsversion/environment)client.prompts.render(key, options?)- Render prompt with dataclient.prompts.listVersions(key)- List version historyclient.prompts.getDeployments(key)- Get environment deployment states and historyclient.prompts.deploy(key, options)- Runpromote/plan/activate/rollbackclient.prompts.compare(key, fromVersionId, toVersionId)- Compare two versions
client.tracing.ingest(data)- Ingest tracing session
client.memory.stores.list(query?)- List memory storesclient.memory.stores.create(data)- Create a memory storeclient.memory.stores.get(storeKey)- Get store detailsclient.memory.stores.update(storeKey, data)- Update a memory storeclient.memory.stores.delete(storeKey)- Delete a memory storeclient.memory.add(storeKey, data)- Add a memory itemclient.memory.addBatch(storeKey, memories)- Add memory items in batchclient.memory.list(storeKey, query?)- List memory itemsclient.memory.get(storeKey, memoryId)- Get a memory itemclient.memory.update(storeKey, memoryId, data)- Update a memory itemclient.memory.delete(storeKey, memoryId)- Delete a memory itemclient.memory.deleteBulk(storeKey, query?)- Delete memory items by scope, scopeId, or tagsclient.memory.search(storeKey, data)- Semantic search within a storeclient.memory.recall(storeKey, data)- Build compact context from stored memories
import { CognipeerOTelSpanExporter } from '@cognipeer/console-sdk';
import { NodeTracerProvider } from '@opentelemetry/sdk-trace-node';
import { SimpleSpanProcessor } from '@opentelemetry/sdk-trace-base';
const exporter = new CognipeerOTelSpanExporter({
apiKey: process.env.COGNIPEER_API_KEY!,
baseURL: process.env.COGNIPEER_BASE_URL || 'https://api.cognipeer.com',
});
const provider = new NodeTracerProvider();
provider.addSpanProcessor(new SimpleSpanProcessor(exporter));
provider.register();The exporter forwards spans to /api/client/v1/traces using OTLP/HTTP JSON.
client.guardrails.evaluate(data)- Evaluate text against a guardrail
Check out the examples directory for more detailed usage:
We welcome contributions! Please see our Contributing Guide for details.
MIT © Cognipeer
- 📧 Email: support@cognipeer.com
- 📖 Documentation: cognipeer.github.io/console-sdk
- 🐛 Issues: GitHub Issues