Examples

Learn by example with real-world use cases and complete code samples.

Chat

Customer Support Bot

Build an intelligent support bot with memory and reasoning

Search

Semantic Search Engine

Create a powerful search with natural language understanding

RAG

Document Q&A System

Answer questions from your documentation automatically

Analytics

Sales Intelligence

Analyze deals and provide actionable insights

ML

E-commerce Recommendations

Personalized product recommendations with reasoning

Dev Tools

Code Assistant

Build a coding copilot with context awareness

Featured: Customer Support Bot

Build an intelligent support bot that remembers past conversations and reasons about customer issues:

What You'll Learn
This example demonstrates Memory Layer for context storage, Cognition Layer for reasoning, and how to build context-aware AI applications.
support-bot.tstypescript
import { CognitiveXClient } from '@cognitivex/sdk';

const client = new CognitiveXClient({
  apiKey: process.env.COGNITIVEX_API_KEY
});

async function handleCustomerQuery(
  customerId: string, 
  query: string
) {
  // Store the query in memory
  await client.memory.store({
    content: query,
    tags: ['customer-query', customerId],
    metadata: {
      customerId,
      timestamp: new Date().toISOString()
    }
  });

  // Search for relevant past interactions
  const pastContext = await client.memory.search({
    query,
    tags: [customerId],
    limit: 5
  });

  // Reason with full context
  const response = await client.cognition.reason({
    query,
    context: pastContext.map(c => c.id),
    reflection: true,
    systemPrompt: `You are a helpful customer support agent.
      Use past conversations to provide personalized help.`
  });

  return {
    answer: response.answer,
    reasoning: response.reasoning,
    sources: pastContext
  };
}

// Example usage
const result = await handleCustomerQuery(
  'user_123',
  'My order hasn\'t arrived yet'
);

console.log('Response:', result.answer);
console.log('Reasoning:', result.reasoning);
Cost Savings
With semantic caching enabled, similar customer queries cost 85% less. The first query costs ~$0.05, but subsequent similar queries are served from cache at no cost!

Quick Examples

Semantic Search

typescript
// Index documents
const docs = [
  "CognitiveX reduces AI costs by 85%",
  "Multi-LLM support for OpenAI, Anthropic, Google",
  "Enterprise-grade security with SOC2 compliance"
];

for (const doc of docs) {
  await client.memory.store({ content: doc });
}

// Search with natural language
const results = await client.memory.search({
  query: "cost savings",
  limit: 3
});

results.forEach(r => {
  console.log(r.content, '- Score:', r.score);
});

Multi-Step Reasoning

typescript
// Complex reasoning with reflection
const analysis = await client.cognition.reason({
  query: `Analyze Q4 sales data and recommend 
         strategies for Q1 growth`,
  reflection: true,
  temperature: 0.7
});

console.log('Analysis:', analysis.answer);
console.log('Thought process:', analysis.reasoning);
console.log('Confidence:', analysis.confidence);

GitHub Repository

100+ production-ready examples with tests and deployment configs

View on GitHub

Interactive Playground

Try CognitiveX in your browser without installing anything

Open Playground

Use Case Library

Customer Support

  • • Contextual chatbot
  • • Ticket classification
  • • Sentiment analysis

Sales & Marketing

  • • Lead qualification
  • • Content generation
  • • Personalization

Development

  • • Code review assistant
  • • Documentation generator
  • • Bug triage

Operations

  • • Log analysis
  • • Incident response
  • • Root cause analysis