Package Exports
- @usesatori/tools
Readme
@usesatori/tools
Memory tools for the Vercel AI SDK. Give your AI persistent memory across conversations.
📚 Full Documentation | 🚀 Quickstart Guide | 📖 API Reference
Installation
npm install @usesatori/tools aiQuick Start
import { streamText } from 'ai';
import { openai } from '@ai-sdk/openai';
import { memoryTools, getMemoryContext } from '@usesatori/tools';
// Create memory tools scoped to a user
const tools = memoryTools({
apiKey: process.env.SATORI_API_KEY!,
baseUrl: 'https://api.satori.dev',
userId: 'user-123',
});
// Pre-fetch relevant memories for context
const memoryContext = await getMemoryContext(
{
apiKey: process.env.SATORI_API_KEY!,
baseUrl: 'https://api.satori.dev',
userId: 'user-123',
},
userMessage,
{ limit: 5 }
);
// Use with AI SDK
const result = await streamText({
model: openai('gpt-4o'),
system: `You are a helpful assistant with memory.
What you know about this user:
${memoryContext}
Use add_memory to save important information the user shares.`,
messages,
tools,
});Available Tools
The memoryTools() function returns two tools that the LLM can use:
add_memory
Save information to memory. The LLM decides when something is worth remembering.
// LLM will call this automatically when appropriate
tools.add_memory({ memory: "User prefers dark mode" })delete_memory
Remove a specific memory by ID.
tools.delete_memory({ memoryId: "memory-uuid" })Note: For retrieval, use
getMemoryContext()to pre-fetch relevant memories and inject them into your system prompt. This hybrid approach is more reliable than having the LLM decide when to search.
Direct Client Access
For more control, use the MemoryClient directly:
import { MemoryClient } from '@usesatori/tools';
const client = new MemoryClient({
apiKey: process.env.SATORI_API_KEY!,
baseUrl: 'https://api.satori.dev',
userId: 'user-123',
});
// Store a memory
await client.addMemory('User loves TypeScript');
// Search memories
const memories = await client.searchMemories('programming languages');
// Get all memories
const allMemories = await client.getAllMemories();
// Delete a memory
await client.deleteMemory('memory-id');Configuration
| Option | Type | Required | Description |
|---|---|---|---|
apiKey |
string | Yes | Your Satori API key |
baseUrl |
string | Yes | Satori server URL |
userId |
string | Yes | User identifier for memory isolation |
Getting an API Key
- Sign up at satori.dev
- Go to Dashboard → API Keys
- Create a new key
For more details, see the Authentication Guide.
Learn More
- Complete Documentation - Full guides and API reference
- How It Works - Understanding memory and embeddings
- Quickstart Guide - Get started in 5 minutes
License
MIT