New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

recallkit

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

recallkit

Later

latest
Source
npmnpm
Version
1.2.4
Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

RecallKit SDK

🧠 Plug & Play Memory for Your AI Apps

Add intelligent, persistent memory to any AI application with just one line of code. Works with any AI model - OpenAI, Anthropic, Claude, Gemini, or any other provider!

💡 How it works:

  • You: Use any AI model you prefer (OpenAI, Anthropic, etc.)
  • RecallKit: Uses Gemini internally to process and extract memories
  • Result: Your AI app gets persistent memory without vendor lock-in!

✨ Features

  • 🌟 Works with Any AI Model: Use OpenAI, Anthropic, Claude, or any provider you prefer
  • 🚀 Ultra-Simple API: Just call recall(result) after any AI interaction
  • 🧠 AI-Powered Memory Management: Automatically extracts and manages memories
  • 🔍 Smart Duplicate Detection: Prevents redundant memories with intelligent similarity checking
  • 💰 Cost-Effective: Smart chunking for long conversations to minimize API costs
  • 🛠️ Vercel AI SDK Integration: Built-in tools for seamless integration
  • 🔧 Easy Setup: Simple environment variable configuration

🚀 Quick Start

1. Installation

npm install recallkit-sdk ai
# Plus your preferred AI provider:
npm install @ai-sdk/openai    # for OpenAI
npm install @ai-sdk/anthropic # for Anthropic
npm install @ai-sdk/google    # for Google

2. Get Your API Keys

Required:

  • Google AI Key: Get it from Google AI Studio (RecallKit uses this internally)
  • Redis Database: Get free Redis from Upstash or Redis Cloud

Optional:

  • Your preferred AI provider: OpenAI, Anthropic, etc. (for your main AI model)

3. Basic Setup

import { RecallClient } from "recallkit-sdk";
import { generateText } from "ai";
import { openai } from "@ai-sdk/openai"; // or any provider you prefer

// RecallKit setup - uses Gemini internally for memory processing
const recall = new RecallClient({
  geminiApiKey: "your_gemini_api_key_here", // For RecallKit's internal use
  redis: {
    // Option 1: Redis URL (if you have a connection string)
    url: "redis://username:password@host:port",

    // Option 2: Individual credentials
    // host: "your-redis-host.com",
    // port: 6379,
    // username: "default", // or your username
    // password: "your_redis_password",
  },
  memoryNamespace: "my-app", // Separate memories by app/user
});

4. Basic Usage

// Use ANY AI model you prefer - OpenAI, Anthropic, Claude, etc.
const result = await generateText({
  model: openai("gpt-4o"), // 🎉 Use any model you want!
  // model: anthropic('claude-3-5-sonnet-20241022'),
  // model: google('gemini-1.5-pro'),
  prompt: "I love hiking in Colorado",
});

// RecallKit automatically processes memories (using Gemini internally)
await recall.recall(result, {
  userMessage: "I love hiking in Colorado",
});

5. Advanced Usage with AI Tools

// Your AI model can manage memories automatically with tools
const result = await generateText({
  model: openai("gpt-4o"), // 🎉 Still use any model you want!
  messages: [
    { role: "user", content: "I work at Google as a software engineer" },
  ],
  tools: recall.createMemoryTools(), // AI manages memories automatically!
});

// Memories are created/updated automatically by AI (processed with Gemini internally)
// Duplicates are automatically detected and prevented

🛠️ Next.js Integration

Perfect for Next.js API routes with any AI model:

// app/api/chat/route.ts
import { streamText } from "ai";
import { openai } from "@ai-sdk/openai"; // or any provider
import { RecallClient } from "recallkit-sdk";

const recall = new RecallClient({
  geminiApiKey: "your_gemini_api_key", // RecallKit internal use
  redis: {
    host: "your-redis-host.com",
    port: 6379,
    username: "default", // or your username
    password: "your_redis_password",
  },
  memoryNamespace: "chat-app",
});

export async function POST(request: Request) {
  const { messages } = await request.json();

  // Get memory context
  const memoryContext = await recall.getMemoryContext(
    messages[messages.length - 1].content
  );

  // Use any AI model you prefer
  const result = await streamText({
    model: openai("gpt-4o"), // 🎉 Your choice of model!
    messages: [
      {
        role: "system",
        content: `You are a helpful assistant with memory.${memoryContext}`,
      },
      ...messages,
    ],
    tools: recall.createMemoryTools(), // AI manages memories automatically
  });

  return result.toDataStreamResponse();
}

🧠 How It Works

  • Use Any AI Model: OpenAI, Anthropic, Claude, Gemini - your choice!
  • Call recall(result): RecallKit processes the conversation using Gemini internally
  • Smart Memory Extraction: AI automatically identifies important information to remember
  • Semantic Storage: Memories are stored in Redis with vector embeddings
  • Context Retrieval: Future conversations automatically include relevant memories

Why Gemini internally? RecallKit uses Gemini for consistent, cost-effective memory processing while letting you use any model for your main application.

📖 Complete Example

import { generateText } from "ai";
import { openai } from "@ai-sdk/openai"; // Use any provider!
import { RecallClient } from "recallkit-sdk";

const recall = new RecallClient({
  geminiApiKey: "your_gemini_api_key", // RecallKit internal
  redis: {
    url: "redis://username:password@host:port", // or use individual fields
  },
  memoryNamespace: "my-app",
});

async function chatWithMemory(userMessage: string) {
  // 1. Get relevant memories
  const memoryContext = await recall.getMemoryContext(userMessage);

  // 2. Generate AI response with ANY model
  const result = await generateText({
    model: openai("gpt-4o"), // 🎉 Your choice!
    // model: anthropic('claude-3-5-sonnet-20241022'),
    // model: google('gemini-1.5-pro'),
    system: `You are a helpful assistant with memory.${memoryContext}`,
    prompt: userMessage,
  });

  // 3. RecallKit processes memories with Gemini internally
  await recall.recall(result, { userMessage });

  return result.text;
}

// Usage
const response = await chatWithMemory("I love hiking in Colorado");
console.log(response); // AI response with memory context

⚙️ Configuration Options

You can customize RecallKit behavior:

const recall = new RecallClient({
  // Required
  geminiApiKey: "your_gemini_api_key",
  redis: {
    // Option 1: Redis URL
    url: "redis://username:password@host:port",

    // Option 2: Individual credentials (choose one approach)
    // host: "your-redis-host.com",
    // port: 6379,
    // username: "default", // Redis username
    // password: "your_redis_password",
    // database: 0, // Redis database number (optional)

    // Optional: Advanced Redis options
    // options: {
    //   connectTimeout: 10000,
    //   commandTimeout: 5000,
    //   tls: false, // Enable for secure connections
    // },
  },

  // Optional
  memoryNamespace: "my-app", // Separate memories by app/user
  embeddingModel: "text-embedding-004", // Google embedding model
  summaryModel: "gemini-1.5-flash", // Model for memory extraction
  debug: true, // Enable debug logging

  // Memory options
  memoryOptions: {
    maxRelatedMemories: 10, // Max memories per search
    minConfidenceThreshold: 0.7, // Similarity threshold
    autoDeleteAfterDays: 30, // Auto-cleanup old memories
  },
});

🗄️ Redis Setup

Free Options:

const recall = new RecallClient({
  geminiApiKey: "your_gemini_api_key",
  redis: {
    url: "redis://default:your_password@your-host.upstash.io:6379",
  },
});

2. Redis Cloud (30MB Free)

const recall = new RecallClient({
  geminiApiKey: "your_gemini_api_key",
  redis: {
    host: "redis-12345.cloud.redislabs.com",
    port: 12345,
    username: "default",
    password: "your_password",
  },
});

3. Local Redis (Development)

const recall = new RecallClient({
  geminiApiKey: "your_gemini_api_key",
  redis: {
    host: "localhost",
    port: 6379,
    // username: "default", // if auth enabled
    // password: "your_password", // if auth enabled
  },
});

🎨 Advanced Features

  • Smart Duplicate Detection: Prevents redundant memories
  • Long Conversation Handling: Cost-effective processing of large chats
  • Custom Prompts: Customize memory extraction for your use case
  • Memory Tools: Let AI manage its own memories with built-in tools
  • Semantic Search: Find relevant memories using vector similarity

🚫 Error Handling

Comprehensive error handling with specific error types:

import {
  ConfigurationError,
  RedisConnectionError,
  MemoryProcessingError,
} from "recallkit-sdk";

try {
  await recall.recall(result);
} catch (error) {
  if (error instanceof ConfigurationError) {
    console.error("Config issue:", error.missingField);
  } else if (error instanceof RedisConnectionError) {
    console.error("Redis connection failed:", error.message);
  } else if (error instanceof MemoryProcessingError) {
    console.error("Memory processing failed:", error.memoryId);
  }
}

📖 Examples

🏗️ Architecture

RecallClient → AI Tools → Smart Memory Management
     ↓              ↓              ↓
Memory Search → Duplicate Check → Storage

Advanced API (Complex Use Cases)

RecallKit → MemoryProcessor → MemoryAgent → Redis
    ↓            ↓              ↓          ↓
Config → Extract Memories → Analyze → Store

🤝 Contributing

We welcome contributions! Please see our Contributing Guide for details.

📄 License

MIT License - see LICENSE file for details.

🆘 Support

Made with ❤️ for the AI developer community

Add memory to your AI apps in minutes, not hours.

Keywords

recallkit

FAQs

Package last updated on 03 Aug 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts