Skip to content

Quick Start

Get Configure Memory integrated into your app in 5 minutes.

Prerequisites

  • Node.js 18+ (or provide a fetch polyfill)
  • Configure API key (get one at configure.dev)

Installation

bash
npm install @configure/memory-sdk
bash
yarn add @configure/memory-sdk
bash
pnpm add @configure/memory-sdk

Step 1: Initialize the Client

typescript
import { MemoryClient } from '@configure/memory-sdk';

const client = new MemoryClient('your-api-key');

Step 2: Authenticate a User

Configure Memory uses phone-based OTP authentication:

typescript
// Send OTP to user's phone
await client.auth.sendOtp('+14155551234');

// User receives SMS with 6-digit code
// Verify the code to get token and userId
const { token, userId } = await client.auth.verifyOtp('+14155551234', '123456');

// Store these - you'll need them for all subsequent calls
console.log('User authenticated:', userId);

Step 3: Get User's Memory Profile

The Memory Profile is the user's centralized context store:

typescript
const profile = await client.memory.getProfile(token, userId);

console.log('User name:', profile.user?.name);
console.log('Connected tools:', profile.connected_tools);
console.log('Saved memories:', profile.apps_data?.myapp?.prefs_delta);

Step 4: Save a Memory

typescript
await client.memory.remember(token, userId, 'favorite_color', 'blue');
await client.memory.remember(token, userId, 'timezone', 'America/Los_Angeles');

Step 5: Use Streaming Chat

The streaming chat endpoint is where the magic happens. It:

  • Automatically injects relevant user context
  • Can access connected tools (Gmail, Calendar, etc.)
  • Extracts and saves memories from the conversation
typescript
let fullResponse = '';

await client.streaming.chatStream(
  token,
  userId,
  'What meetings do I have this week?',
  [], // conversation history
  {
    appName: 'MyApp',
    appDescription: 'Personal assistant that helps with scheduling'
  },
  {
    onToken: (token) => {
      fullResponse += token;
      process.stdout.write(token); // Stream to console
    },
    onDone: (toolsAccessed) => {
      console.log('\n--- Response complete ---');
      console.log('Tools used:', toolsAccessed);
    },
    onToolsAccessed: (tools) => {
      console.log('Accessing:', tools.join(', '));
    },
    onError: (error) => {
      console.error('Error:', error);
    }
  }
);

Complete Example

Complete working example:

typescript
import { MemoryClient } from '@configure/memory-sdk';

async function main() {
  // Initialize
  const client = new MemoryClient(process.env.CONFIGURE_API_KEY!);

  // Authenticate (in production, get phone from user input)
  const phone = '+14155551234';
  await client.auth.sendOtp(phone);
  
  // In production, get code from user input
  const code = '123456';
  const { token, userId } = await client.auth.verifyOtp(phone, code);

  // Get user's memory
  const profile = await client.memory.getProfile(token, userId);
  console.log('Welcome back,', profile.user?.name || 'friend');

  // Save a preference
  await client.memory.remember(token, userId, 'greeting_style', 'casual');

  // Chat with memory context
  await client.streaming.chatStream(
    token,
    userId,
    'Hello! What do you know about me?',
    [],
    { appName: 'MyApp', appDescription: 'Friendly assistant' },
    {
      onToken: (t) => process.stdout.write(t),
      onDone: () => console.log('\n'),
    }
  );
}

main().catch(console.error);

Further Reading

Environment Variables

For production, use environment variables:

bash
# .env
CONFIGURE_API_KEY=your-api-key
typescript
const client = new MemoryClient(process.env.CONFIGURE_API_KEY!);

TypeScript Support

The SDK is fully typed. Import types as needed:

typescript
import type {
  MemoryProfile,
  ConversationMessage,
  StreamCallbacks,
  ToolType,
} from '@configure/memory-sdk';

AI Memory Infrastructure