> ## Documentation Index
> Fetch the complete documentation index at: https://docs.usesatori.sh/llms.txt
> Use this file to discover all available pages before exploring further.

# AI with Long-Term Memory

> Give your AI applications persistent memory that remembers user preferences, context, and conversations across sessions

## What is Satori?

Satori is a memory layer for AI applications that enables your agents to remember information across conversations. Built on semantic search with vector embeddings, Satori automatically stores and retrieves relevant context to make your AI more personalized and context-aware.

<CardGroup cols={2}>
  <Card title="Quick Start" icon="rocket" href="/quickstart">
    Get your first memory working in under 5 minutes with the Vercel AI SDK
  </Card>

  <Card title="API Reference" icon="code" href="/api-reference/introduction">
    Explore the complete tRPC API for memory operations
  </Card>

  <Card title="How It Works" icon="brain" href="/concepts/how-it-works">
    Learn about embeddings, semantic search, and memory isolation
  </Card>

  <Card title="Examples" icon="lightbulb" href="/examples/chat-with-memory">
    See real-world implementations with complete code
  </Card>
</CardGroup>

## Key Features

<CardGroup cols={2}>
  <Card title="Semantic Search" icon="magnifying-glass">
    Find relevant memories using natural language queries powered by vector embeddings
  </Card>

  <Card title="Multi-Tenant Isolation" icon="shield">
    Built-in tenant isolation ensures your users' data stays completely separate
  </Card>

  <Card title="AI SDK Integration" icon="wand-magic-sparkles">
    Drop-in tools for Vercel AI SDK with automatic memory management
  </Card>

  <Card title="Type-Safe API" icon="check">
    End-to-end type safety with tRPC from your backend to frontend
  </Card>
</CardGroup>

## How It Works

```mermaid theme={null}
sequenceDiagram
    participant User
    participant App
    participant LLM
    participant Satori
    
    User->>App: "Remember I like TypeScript"
    App->>Satori: Search relevant memories
    Satori-->>App: Return context
    App->>LLM: Message + memory context
    LLM->>Satori: add_item tool call
    Satori-->>LLM: Memory saved
    LLM-->>User: "Got it! I'll remember that."
```

<Steps>
  <Step title="User sends a message">
    Your application receives input from the user
  </Step>

  <Step title="Fetch relevant context">
    Satori searches for relevant memories using semantic similarity
  </Step>

  <Step title="LLM processes with context">
    The AI model receives the message along with relevant memories
  </Step>

  <Step title="Save new information">
    The LLM uses tools to save important information for future conversations
  </Step>
</Steps>

## Installation

<CodeGroup>
  ```bash npm theme={null}
  npm install @usesatori/tools ai
  ```

  ```bash pnpm theme={null}
  pnpm add @usesatori/tools ai
  ```

  ```bash yarn theme={null}
  yarn add @usesatori/tools ai
  ```
</CodeGroup>

## Quick Example

```typescript theme={null}
import { streamText } from 'ai';
import { openai } from '@ai-sdk/openai';
import { memoryTools, getContext } from '@usesatori/tools';

// Create memory tools for a user
const tools = memoryTools({
  apiKey: process.env.SATORI_API_KEY!,
  baseUrl: 'https://api.usesatori.sh',
  userId: 'user-123',
});

// Pre-fetch relevant memories
const context = await getContext(
  {
    apiKey: process.env.SATORI_API_KEY!,
    baseUrl: 'https://api.usesatori.sh',
    userId: 'user-123',
  },
  userMessage
);

// Stream with memory
const result = await streamText({
  model: openai('gpt-4o'),
  system: `You are a helpful assistant with memory.
  
What you know about this user:
${context}

Use add_item to save important information.`,
  messages,
  tools,
});
```

<Tip>
  The LLM automatically decides when to save memories using the `add_item` tool. You don't need to manually parse or store information.
</Tip>

## Use Cases

<AccordionGroup>
  <Accordion title="Personalized AI Assistants">
    Build assistants that remember user preferences, work context, and conversation history to provide increasingly personalized responses over time.
  </Accordion>

  <Accordion title="Customer Support Bots">
    Enable support agents to access previous interactions, known issues, and customer preferences without asking repetitive questions.
  </Accordion>

  <Accordion title="Educational Tutors">
    Create tutors that track student progress, learning style preferences, and areas of difficulty to adapt teaching approaches.
  </Accordion>

  <Accordion title="Project Management Tools">
    Build tools that remember project context, team preferences, and historical decisions to provide better recommendations.
  </Accordion>
</AccordionGroup>

## Why Satori?

<CardGroup cols={3}>
  <Card title="Simple Integration" icon="plug">
    Works seamlessly with Vercel AI SDK and other frameworks
  </Card>

  <Card title="Production Ready" icon="server">
    Built on PostgreSQL with pgvector for reliable, scalable storage
  </Card>

  <Card title="Developer First" icon="code">
    Type-safe API, great DX, and comprehensive documentation
  </Card>
</CardGroup>

## Next Steps

<CardGroup cols={2}>
  <Card title="Follow the Quickstart" icon="play" href="/quickstart">
    Get your first memory working in 5 minutes
  </Card>

  <Card title="Learn Core Concepts" icon="book" href="/concepts/how-it-works">
    Understand how memory and embeddings work
  </Card>

  <Card title="Explore Examples" icon="code" href="/examples/chat-with-memory">
    See complete implementations you can copy
  </Card>

  <Card title="API Reference" icon="terminal" href="/api-reference/introduction">
    Dive into the complete API documentation
  </Card>
</CardGroup>
