mem0-vercel-ai-sdk

Integrates persistent memory into Vercel AI SDK applications using the @mem0/vercel-ai-provider package.

1|Updated Jan 13, 2022
One-click install
npx skills add https://github.com/jayho-k/TIL --skill mem0-vercel-ai-sdk-jayho-k
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: mem0-vercel-ai-sdk
Source: https://github.com/jayho-k/TIL/tree/main/AI/mem0/code/mem0_code_analize/mem0/skills/mem0-vercel-ai-sdk
Command: npx skills add https://github.com/jayho-k/TIL --skill mem0-vercel-ai-sdk-jayho-k

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve? Adding long-term memory to LLM applications built with the Vercel AI SDK requires manual retrieval, prompt injection, and storage logic. This Skill guides Claude to set up @mem0/vercel-ai-provider so memories are automatically retrieved and stored during generateText and streamText calls. ## Core Features & Use Cases - Wrapped Model Setup: Configure createMem0 to wrap OpenAI, Anthropic, Google, Groq, or Cohere models with automatic memory retrieval and storage. - Standalone Memory Utilities: Generate code using retrieveMemories, getMemories, searchMemories, and addMemories for full manual control over the memory lifecycle. - Framework Integration: Produce working examples for Next.js API routes, streaming responses, structured output with generateObject, and multi-provider configurations. - Use Case: A developer building a Next.js chatbot asks Claude to add per-user memory; the Skill produces an API route that retrieves relevant memories, injects them as a system prompt, streams the response, and stores the conversation back to Mem0. ## Quick Start Ask Claude to add Mem0 memory to your Vercel AI SDK app, for example: set up mem0 with streamText in my Next.js API route.

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 ai, then call createMem0() to get a provider that wraps your model. Pass the wrapped model to generateText or streamText with a user_id, and memories are retrieved and stored automatically.

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. Select one via createMem0({ provider: "anthropic" }) and set the matching API key environment variable. Use "google" rather than the unsupported "gemini" alias.

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

No. The package implements LanguageModelV2 and ProviderV2 interfaces, which require Vercel AI SDK v5. It is not compatible with AI SDK v3 or v4.

Why are memories not scoped to my users in mem0?

Memories require an entity identifier such as user_id, agent_id, app_id, or run_id in the config. Without one, retrieval and storage cannot be scoped, so always pass user_id when creating the model or calling utility functions.

Does memory storage slow down LLM responses?

No. In the wrapped model flow, addMemories fires as a non-blocking background call without await, so the LLM response is not delayed. Failures are logged but do not affect the returned response.