Quick Start

Get up and running with CognitiveX in 5 minutes. This guide will walk you through your first API call.

5 min
Setup Time
3 steps
To First Query
85%
Cost Savings

Step 1: Get Your API Key

First, sign up at app.cognitivex.ai and get your API key from the dashboard.

Security First
Keep your API key secure and never commit it to version control. Use environment variables instead.

Step 2: Initialize the Client

Create a new file and initialize the CognitiveX client:

index.tstypescript
import { CognitiveXClient } from '@cognitivex/sdk';

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

Step 3: Store Knowledge

Store some knowledge in the Memory Layer:

typescript
// Store knowledge with automatic embedding
const stored = await client.memory.store({
  content: "CognitiveX provides multi-LLM support with 85% cost reduction.",
  tags: ["features", "pricing"],
  metadata: {
    category: "product-info",
    version: "1.0"
  }
});

console.log('Stored with ID:', stored.id);

Step 4: Retrieve with Reasoning

Query your knowledge with the Cognition Layer:

typescript
// Retrieve with reasoning
const result = await client.cognition.reason({
  query: "What are the key features of CognitiveX?",
  reflection: true, // Enable reasoning capture
  context: [stored.id] // Use stored knowledge
});

console.log('Answer:', result.answer);
console.log('Reasoning:', result.reasoning);

Complete Example

Here's the complete code in one file:

example.tstypescript
import { CognitiveXClient } from '@cognitivex/sdk';

async function main() {
  // Initialize client
  const client = new CognitiveXClient({
    apiKey: process.env.COGNITIVEX_API_KEY
  });

  // Store knowledge
  const stored = await client.memory.store({
    content: "CognitiveX provides multi-LLM support with 85% cost reduction.",
    tags: ["features", "pricing"]
  });

  console.log('✓ Stored:', stored.id);

  // Retrieve with reasoning
  const result = await client.cognition.reason({
    query: "What are the key features?",
    reflection: true,
    context: [stored.id]
  });

  console.log('✓ Answer:', result.answer);
  console.log('✓ Reasoning:', result.reasoning);
  console.log('✓ Confidence:', result.confidence);
}

main().catch(console.error);
Pro Tip
Enable reflection mode to capture the AI's thought process. This is essential for debugging, compliance, and understanding how decisions are made.

Next Steps