Skip to main content
Mem0 is a memory engine designed to maintain contextual conversations, ensuring users don’t have to repeat themselves and that your agents provide consistent, continuous responses. It offers an adaptive memory solution tailored for teams who want to manage everything on their own infrastructure. You retain full control over the stack, data, and customizations.

Prerequisites

Before starting, ensure you have:
  • A SambaCloud account and API key.
  • An OpenAI API key. Mem0 needs an embedding model in addition to a chat model, and SambaNova embeddings are available on SambaStack only. On SambaCloud you must supply the embedder from another provider, so OPENAI_API_KEY is required alongside your SambaNova key. See How Mem0 uses SambaNova for which calls go where.
  • Python 3.10 or later. The langchain and langchain-sambanova releases pinned by the example repository require 3.10, so pip install -r requirements.txt fails on 3.9.
  • No vector store to install or run. Mem0 defaults to Qdrant in local embedded mode and writes to a directory on your machine.
macOS ships with Python 3.9 and exposes it as python3 rather than python. Check your version with python3 --version. If it is below 3.10, install a supported version with pyenv, uv, or brew install python@3.12 before continuing.

How Mem0 uses SambaNova

Mem0 makes three different kinds of calls, and each one resolves to a provider independently. Knowing which is which explains why you need two keys.
If you leave the llm block out of your Mem0 config, Mem0 does not fall back to SambaNova. It defaults to provider: "openai" with the model gpt-4.1-nano-2025-04-14 and reads OPENAI_API_KEY, so your memory extraction silently runs on OpenAI instead. Set the llm block explicitly, as shown below, to keep that work on SambaNova.

Quickstart

This quickstart is self-contained. It stores a memory, recalls it on a later turn, and feeds it back into the prompt, without cloning anything.

Install Mem0

Pin the version. Mem0’s configuration schema changes between major versions, and the config below is written against the 1.x schema. mem0ai installs the openai client as a dependency, so you do not need to install it separately.

Set your API keys

Store and recall a memory

Save the following as quickstart.py and run it with python quickstart.py.
Two details in that config matter more than they look:
  • openai_base_url is the key Mem0 reads to redirect the OpenAI-compatible client. Spelling it base_url raises TypeError: __init__() got an unexpected keyword argument 'base_url'.
  • The embedder block deliberately has no openai_base_url, so it targets https://api.openai.com/v1. Do not set an OPENAI_BASE_URL environment variable, because Mem0’s embedder reads it and would send embedding requests to SambaNova, which does not serve them on SambaCloud.

Confirm it worked

The first turn has nothing to recall. The second turn is the proof: the memory extracted from turn one comes back and reaches the prompt.
The exact wording of the extracted memories and of both replies varies between runs. What confirms the integration works is that the second [recalled] block is not empty. To list everything stored for a user, append the following to quickstart.py, which reuses the memory object and USER_ID defined above:
on_disk is set to True on purpose. Mem0’s local Qdrant store defaults to on_disk: False, and in that mode it deletes the store directory every time you construct a Memory object, so memories do not survive a restart. Setting on_disk: True keeps them across runs.

Run the example application

The sambanova/integrations repository has a longer example that wraps the same add and search loop in an interactive REPL.

Clone the repository

Create a virtual environment

Confirm the environment uses a supported version before installing:

Install dependencies

Set environment variables

Create a .env file in the project directory with both keys:
Alternatively, export the variables directly in your terminal:

Run the script

This script initializes a Mem0 memory client connected to SambaNova and starts an interactive chat loop, so you can see memory persist across turns by asking follow-up questions. Type exit to quit.
The example sets its embedding model to E5-Mistral-7B-Instruct, which was removed from SambaCloud on April 6, 2026 and is available on SambaStack only. With a SambaCloud key, every memory write and lookup fails. Substituting a different SambaNova embedding model does not help, because SambaCloud does not currently serve an embeddings endpoint.To run the example against SambaCloud, edit main.py to use a non-SambaNova embedder. Replace the embedder block with the OpenAI embedder from the Quickstart above and set embedding_model_dims to 1536 to match text-embedding-3-small; the example currently sets it to 4096 for E5-Mistral. Otherwise, point the example at a SambaStack deployment that serves the embeddings endpoint.The example also omits the llm block, so its memory extraction runs on OpenAI rather than SambaNova. Add the llm block from the Quickstart to keep it on SambaNova.
The script prints a banner and then waits for input:
The prompt appears before any model call is made, so reaching it confirms only that the dependencies imported. Configuration and key problems surface on your first message, not at startup. The full source code and additional examples are available in the Mem0 integration example on GitHub.

Troubleshooting

macOS does not provide a python executable, only python3. Use python3 -m venv .venv to create the environment. After you activate it with source .venv/bin/activate, python works as expected inside the environment.
The pinned langchain and langchain-sambanova releases require Python 3.10 or later. Check the interpreter inside your activated environment with python --version, and rebuild the environment with a supported interpreter if it reports 3.9.
The prompt appears before any model call happens, so an unusable configuration is not visible until you send your first message. That turn makes three calls in order: a memory search against the embeddings endpoint, a chat completion, then a memory write that uses both again. The embeddings call is first, so it is the one that usually fails first. Read the error text to see which endpoint rejected the request.
One of the two keys is unset or wrong. Read the message body to tell which: a 401 that points you at platform.openai.com came from the embedder, so check OPENAI_API_KEY. Any other 401 came from the chat or memory LLM call, so check SAMBANOVA_API_KEY and copy it again from your SambaCloud portal.Because the first thing each turn does is a memory search, the embedder is the first call to fail, so an OpenAI 401 can appear even when your SambaNova key is fine. The example’s main.py also calls os.environ.setdefault, so it substitutes a placeholder rather than failing at startup and the error only surfaces on the first message. The Quickstart reads keys with os.environ[...] instead, which fails immediately when a key is missing.
SambaNova embeddings are available on SambaStack only, and E5-Mistral-7B-Instruct was removed from SambaCloud on April 6, 2026. A SambaCloud key cannot reach that endpoint. Configure a non-SambaNova embedder as shown in the Quickstart, or use a SambaStack deployment.
Expected. Mem0 needs an embedder, and SambaCloud does not serve embeddings, so the embedder runs on OpenAI and reads OPENAI_API_KEY. Both keys must be set. If you also left the llm block out of your config, Mem0’s memory LLM defaults to OpenAI as well and reads the same key.
Mem0’s OpenAI-compatible provider config uses openai_base_url, not base_url. Rename the key inside the llm config block.
Check that the llm block is present and that provider is openai with openai_base_url set to https://api.sambanova.ai/v1. Mem0 rejects provider: "sambanova" with Unsupported LLM provider, because it reaches SambaNova through the OpenAI-compatible client rather than a dedicated provider.
Mem0’s local Qdrant store defaults to on_disk: False, and in that mode it deletes the store directory when you construct a Memory object. Set on_disk to True in the vector_store config to persist memories across runs.
A memory write runs the conversation through the memory LLM to extract facts, so a turn that contains no durable fact produces no memory. Confirm what was stored with memory.get_all(user_id=USER_ID). Also check that search and add use the same user_id, since memories are scoped per user.
embedding_model_dims in the vector_store config must match the embedding model’s output size: 1536 for text-embedding-3-small, 4096 for E5-Mistral-7B-Instruct. After changing embedders, delete the local store directory so the collection is recreated at the new size.

Mem0 documentation

For more information about Mem0, see the official Mem0 documentation.