In short.
Build a Companion with Mem0 is a Python tutorial for developers building AI companions that remember users, but it leaves important application behavior unfinished. It explains how to retrieve saved facts before generating a reply and store useful information afterward. Separate examples cover hosted MemoryClient and local Memory configurations. Its strengths are concrete explanations of filtering, metadata and memory scopes. Its main limitations are inconsistent category examples, incomplete personality and conversation-buffer integration, and expiration that depends on application cleanup. Nothing was executed; compatibility, reliability, performance and operating costs remain unassessed.
Researched and written by an AI model and checked by a second AI model. How it works
Covers the complete selected page at [https://docs.mem0.ai/cookbooks/essentials/building-ai-companion], including Platform and Open Source tabs, installation instructions, examples, notes and the production checklist. Linked documentation, repository contents, licence files and provider pricing pages are excluded. Runtime compatibility, memory accuracy, isolation, persistence, performance and deployment behavior were not tested.
The overview
What the resource is
Mem0 publishes this cookbook at [https://docs.mem0.ai/cookbooks/essentials/building-ai-companion]. It follows Ray, an AI running coach, and Max, a user with marathon goals, to teach persistent conversational memory.
The page supplies Python examples for Mem0 Platform through MemoryClient and Mem0 open source through Memory. Its deliverable is example code and guidance for building the memory layer of a companion application.
How well it fits
This is useful when your chatbot needs to recall preferences or goals after a conversation ends. The fitness scenario makes the distinction between recent conversation context and lasting facts easy to understand.
Treat it as an integration starting point. The examples explain the central memory loop, but developers still need to connect several later features to that loop and resolve inconsistencies before relying on the application.
Who it is for
Beginners who can read Python functions, dictionaries and API calls can follow the basic pattern. The local route also requires familiarity with installing packages, running Docker and operating Ollama.
Experienced developers can use the examples to examine memory boundaries, extraction rules, metadata filters and updates. The page does not establish the accuracy of the resulting fitness advice or suitability for therapeutic applications.
What it teaches
The examples cover storing goals, preferences and workout information; finding relevant memories; excluding conversational filler with custom_instructions; and organizing records with categories or manually supplied metadata.
Further examples introduce agent_id for coach-related memory, run_id for separate training episodes, historical imports, date filtering, updating changed goals and deleting obsolete records. Temporary facts receive an expires_on metadata value, with removal left to the application.
Using it
What you need
The hosted example requires Python, the Mem0 and OpenAI clients, and API keys for both services. Its chat-generation example names gpt-4o-mini.
The local instructions list mem0ai, qdrant-client, openai and ollama packages. They use Docker to start Qdrant on port 6333 and configure Ollama on port 11434 with llama3.1:latest and nomic-embed-text:latest. The OpenAI SDK connects to Ollama’s local compatible endpoint in this route. Required Python version, RAM, GPU capacity and storage size are unspecified.
How memory enters a reply
For each message, the basic chat function searches memories using the incoming text and a user_id filter, requesting five results. It joins the returned memory text into context, includes that context in the model’s system message, generates a response, and submits the user and assistant exchange to Mem0.
The saved information lives outside the current conversation request. Each new generation call receives retrieved facts as context. The tutorial recommends keeping the latest ten messages in an application buffer, but does not implement that buffer in the supplied chat function.
How the examples are configured
The local route installs the listed packages, starts Qdrant, downloads the two Ollama models and constructs Memory with Memory.from_config(). Its configuration selects Qdrant storage, an Ollama language model and an Ollama embedding model. The example sets embedding_model_dims to 768 for nomic-embed-text; changing the embedding model requires matching that setting to its output dimensions.
For local extraction rules, custom_instructions belongs at the top level of the configuration before constructing Memory. The hosted examples instead update project settings through mem0_client.project.update(). The snippets must be assembled with consistent variable names and configuration.
A concrete use case
Max tells Ray that he wants to finish a marathon in under four hours. In the page’s next-session illustration, a later request for training guidance retrieves that goal so the response can refer to it after the application restarts. These are documented example outputs, not observed execution results.
A second illustration distinguishes a lasting preference for trail running from a greeting. Custom extraction instructions are intended to retain the preference while excluding filler. An ankle note illustrates temporary information, although an application must remove the record when its chosen expiration policy applies.
Assessment & evidence
Gaps and inconsistencies
The Platform explanation says categories are assigned automatically and recommends metadata for guaranteed tags. Later combined examples nevertheless pass categories directly to add(). The page does not reconcile those instructions, so the accepted behavior remains unclear.
The personality examples retrieve agent_memories without showing those results being inserted into a generation request. Later multi-agent examples pass agent_id to chat(), while the original chat function accepts only user_input and user_id. These features require additional integration.
Max’s communication preference is stored and searched using only agent_id. This creates a potential scope problem if the coach serves multiple users; no cross-user isolation behavior is demonstrated.
Despite the expiration heading, expires_on is ordinary metadata in the examples and requires cleanup code. Error handling is deferred to a checklist. The Qdrant startup command does not configure an explicit persistent volume, and durability across container replacement is not demonstrated.
Why the approach may help
The practical value is the explicit connection between saved facts and a new model request. A goal can inform a later reply because the application retrieves it and supplies it again.
The tutorial also exposes choices that affect usefulness: what deserves storage, which user or episode owns it, and when it becomes outdated. Its examples support learning those design choices. They do not establish exhaustive recall, automatic personality adaptation, reliable expiry or production-scale performance.
Choices presented on the page
The two implementation routes are hosted Mem0 Platform and locally configured Mem0 with Qdrant and Ollama. The Platform examples expose project-level category assignment; the local examples model categories through metadata fields supplied on writes. The local route requires operating the model and storage services.
The page also discusses including the full conversation in the model context and recommends combining a short recent-message buffer with selective lasting memory. It provides no measured comparison. It names snowflake-arctic-embed and mxbai-embed-large as alternative local embedding models, without comparative quality or hardware results.
What supports these findings
The evidence is the complete first-party Mem0 cookbook at [https://docs.mem0.ai/cookbooks/essentials/building-ai-companion], including both implementation tabs, explanatory notes and code examples.
Responses and stored-memory contents appear as example comments or expected behavior. Nothing was executed. There are no independent evaluations, runtime traces, latency measurements, retrieval benchmarks or demonstrated deployment results in the supplied page.
Access & freshness
Costs and resource use
The page provides no Mem0 subscription prices, OpenAI rates, quotas or worked cost estimate. Hosted operating cost is unknown from this evidence.
The configured local route uses local models and storage, but its hardware, electricity, storage and maintenance costs are not quantified. The page’s claims that selective memory can make conversations faster or cheaper have no accompanying measurements.
Licensing and data terms
The page describes one implementation as open source and links to [https://github.com/mem0ai/mem0]. It supplies no explicit licence text for the tutorial or its examples. Permission to redistribute the page or code, and commercial-use conditions for the dependencies and model weights, are not established by this page.
Platform data ownership, retention, residency and provider processing terms are also unspecified.
Dates and version limits
The page metadata reports a modification date of 14 August 2026. The supplied capture is dated 25 November 2026. Those dates identify the documentation snapshot and do not establish current SDK compatibility.
Package installation commands have no version pins, the Qdrant image has no explicit version tag, and the Ollama model names use latest tags. Exact dependency releases and model artifacts are therefore unspecified.
What to do before adopting it
Choose the hosted or local route and establish compatible dependency versions. Resolve the category inconsistency, extend the chat function for the scopes you need, and explicitly include retrieved personality information and recent messages in generation requests.
Before using real user data, verify isolation between users and agents, recall after an application restart, changed-goal updates and removal of expired facts. Add cleanup scheduling, API error handling and durable local storage where needed. Establish provider costs and applicable licensing and data terms separately.
