mem0-vercel-ai-sdk

Integrates Mem0 persistent memory into Vercel AI SDK applications via wrapped models and standalone utilities.

Updated Jun 29, 2026
One-click install
npx skills add https://github.com/nhatnguyen1122/Agent-Memory-Eval --skill mem0-vercel-ai-sdk-nhatnguyen1122
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: mem0-vercel-ai-sdk
Source: https://github.com/nhatnguyen1122/Agent-Memory-Eval/tree/main/mem0/skills/mem0-vercel-ai-sdk
Command: npx skills add https://github.com/nhatnguyen1122/Agent-Memory-Eval --skill mem0-vercel-ai-sdk-nhatnguyen1122

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires @mem0/vercel-ai-provider, ai, and includes references (resource) components.

What problem does it solve? LLM calls made through the Vercel AI SDK are stateless by default, so applications lose user context between sessions. This Skill guides the setup of @mem0/vercel-ai-provider to automatically retrieve and store memories during generateText and streamText calls. ## Core Features & Use Cases - Wrapped Model Pattern: Use createMem0 to wrap OpenAI, Anthropic, Google, Groq, or Cohere models so memory retrieval and storage happen automatically around each LLM call. - Standalone Utilities: Control the memory lifecycle manually with retrieveMemories, getMemories, searchMemories, and addMemories for custom prompt injection. - Use Case: Build a Next.js chat API route where each user's preferences are remembered across sessions, with memories injected as a system prompt and conversations stored back to Mem0 asynchronously. ## Quick Start Ask the AI to add Mem0 memory to your Vercel AI SDK app using createMem0 with your user_id and MEM0_API_KEY environment variable.

Frequently Asked Questions about mem0-vercel-ai-sdk

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add memory to a Vercel AI SDK app?

Install @mem0/vercel-ai-provider and call createMem0 to get a provider that wraps your LLM model. Pass the wrapped model to generateText or streamText with a user_id, and memories are retrieved and stored automatically around each call.

What is the difference between retrieveMemories, getMemories, and searchMemories?

retrieveMemories returns a formatted system prompt string ready for the system parameter. getMemories returns the raw memory array for programmatic processing. searchMemories returns the full API response including relations, scores, and metadata.

Which LLM providers does @mem0/vercel-ai-provider support?

It supports OpenAI (default), Anthropic, Google, Groq, and Cohere, selected via the provider option in createMem0. Each provider requires its corresponding API key environment variable, such as OPENAI_API_KEY or ANTHROPIC_API_KEY.

Does @mem0/vercel-ai-provider work with Vercel AI SDK v4?

No, it requires Vercel AI SDK v5 because it implements the LanguageModelV2 and ProviderV2 interfaces. It is not compatible with AI SDK v3 or v4.

Why are my memories not scoped to the right user?

Memories require an entity identifier such as user_id, agent_id, app_id, or run_id passed in the config. Without one, memories cannot be scoped, so retrieval and storage will not be tied to a specific user or session.