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_KEYis required alongside your SambaNova key. See How Mem0 uses SambaNova for which calls go where. - Python 3.10 or later. The
langchainandlangchain-sambanovareleases pinned by the example repository require 3.10, sopip install -r requirements.txtfails 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.
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.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
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 asquickstart.py and run it with python quickstart.py.
openai_base_urlis the key Mem0 reads to redirect the OpenAI-compatible client. Spelling itbase_urlraisesTypeError: __init__() got an unexpected keyword argument 'base_url'.- The
embedderblock deliberately has noopenai_base_url, so it targetshttps://api.openai.com/v1. Do not set anOPENAI_BASE_URLenvironment 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.[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
Install dependencies
Set environment variables
Create a.env file in the project directory with both keys:
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. Typeexit to quit.
Troubleshooting
command not found: python
command not found: python
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.pip install fails on the langchain requirement
pip install fails on the langchain requirement
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 chat loop starts, then fails on the first message
The chat loop starts, then fails on the first message
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.
AuthenticationError: Error code: 401
AuthenticationError: Error code: 401
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.Memory writes and lookups fail against the embeddings endpoint
Memory writes and lookups fail against the embeddings endpoint
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.OPENAI_API_KEY errors even though you are using SambaNova
OPENAI_API_KEY errors even though you are using SambaNova
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.TypeError: __init__() got an unexpected keyword argument 'base_url'
TypeError: __init__() got an unexpected keyword argument 'base_url'
Mem0’s OpenAI-compatible provider config uses
openai_base_url, not base_url. Rename the key inside the llm config block.Requests go to OpenAI even though openai_base_url points at SambaNova
Requests go to OpenAI even though openai_base_url points at SambaNova
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.Memories are empty every time you restart
Memories are empty every time you restart
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.Recall returns nothing on the second turn
Recall returns nothing on the second turn
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.Vector dimensions do not match after changing embedders
Vector dimensions do not match after changing embedders
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.
