Integrations

Persistent Memory for Vercel AI SDK - Unison Integration

Give Vercel AI SDK agents persistent team memory: contextMd into the system prompt, conversation ingest after each generation.

unison-ai-sdk

Learn how to give Vercel AI SDK agents persistent team memory with Unison.

Official adapter

The fastest path is @unisonlabs/ai-sdk — a middleware that recalls brain memory before each call and persists the turn after:

npm i @unisonlabs/ai-sdk ai
import { generateText, wrapLanguageModel } from 'ai';
import { unisonMemory } from '@unisonlabs/ai-sdk';
import { openai } from '@ai-sdk/openai';

const model = wrapLanguageModel({
  model: openai('gpt-4o'),
  middleware: unisonMemory({ sessionId: 'user-123' }), // reads UNISON_TOKEN
});

await generateText({ model, prompt: 'What did we decide about auth?' });

unisonMemory() accepts { sessionId, token?, apiUrl?, k?, recall?, persist? } — recall before the call and persist after both happen automatically, so it works the same with generateText and streamText. For multi-user products, mint a brain:act-as service key and pass an actor per user so each gets an isolated private namespace (details).

On this page