mem0ai/mem0 · error · ValueError
`model` parameter is required
Error message
`model` parameter is required
What it means
Raised by LangchainEmbedding.__init__ when the embedder config has no `model` value. Unlike other Mem0 embedding providers that default to a hosted model name, the Langchain integration has no default: the model IS a Langchain `Embeddings` object the user must supply. The constructor fails fast at instantiation time, before any network call.
Source
Thrown at mem0/embeddings/langchain.py:17
from typing import Literal, Optional
from mem0.configs.embeddings.base import BaseEmbedderConfig
from mem0.embeddings.base import EmbeddingBase
try:
from langchain.embeddings.base import Embeddings
except ImportError:
raise ImportError("langchain is not installed. Please install it using `pip install langchain`")
class LangchainEmbedding(EmbeddingBase):
def __init__(self, config: Optional[BaseEmbedderConfig] = None):
super().__init__(config)
if self.config.model is None:
raise ValueError("`model` parameter is required")
if not isinstance(self.config.model, Embeddings):
raise ValueError("`model` must be an instance of Embeddings")
self.langchain_model = self.config.model
def embed(self, text, memory_action: Optional[Literal["add", "search", "update"]] = None):
"""
Get the embedding for the given text using Langchain.
Args:
text (str): The text to embed.
memory_action (optional): The type of embedding to use. Must be one of "add", "search", or "update". Defaults to None.
Returns:
list: The embedding vector.
"""
return self.langchain_model.embed_query(text)View on GitHub (pinned to 001c235229)
Solutions
- Pass a Langchain Embeddings instance as the model, e.g. LangchainEmbedding(BaseEmbedderConfig(model=OpenAIEmbeddings(openai_api_key=...)))
- If configuring via dict/YAML, include the instantiated Embeddings object under the model key (object, not a string name)
- If you meant to use a hosted provider instead, switch the embedding provider config to openai/ollama/etc. rather than langchain
Example fix
// before embedder = LangchainEmbedding(BaseEmbedderConfig()) # ValueError: `model` parameter is required # after from langchain_openai import OpenAIEmbeddings embedder = LangchainEmbedding(BaseEmbedderConfig(model=OpenAIEmbeddings(model="text-embedding-3-small")))
Defensive patterns
Strategy: validation
Validate before calling
from mem0.configs.embeddings.base import BaseEmbedderConfig
from mem0.embeddings.langchain import LangchainEmbedding
cfg = BaseEmbedderConfig()
if getattr(cfg, "model", None) is None:
raise SystemExit("langchain embedder requires an Embeddings instance in config.model")
embedder = LangchainEmbedding(cfg) Type guard
from langchain.embeddings.base import Embeddings
def has_langchain_model(cfg) -> bool:
return getattr(cfg, "model", None) is not None and isinstance(cfg.model, Embeddings) Try / catch
try:
embedder = LangchainEmbedding(config)
except ValueError as e:
# config construction error: report which parameter is wrong and stop
raise ConfigurationError(str(e)) from e Prevention
- Always construct the Embeddings object first and pass it as model
- Treat langchain differently from hosted providers: model is an object, never a string
- Add a config smoke test that instantiates every configured provider at startup
When it happens
Trigger: Calling LangchainEmbedding() or LangchainEmbedding(BaseEmbedderConfig()) with no `model` field, or building a config dict/YAML for Memory() that names the langchain provider but omits the model key.
Common situations: Copy-pasting a config template from another provider (e.g. openai) where model is a string default; migrating from an older mem0 version where the langchain embedder behaved differently; assuming `model` means a model name string.
Related errors
- `model` must be an instance of Embeddings
- Langchain embedder provider requires an initialized Langchai
- LM Studio embed_batch() returned {len(embeddings)} embedding
- Ollama embed() returned no embeddings for model '{self.confi
- Ollama embed() returned {len(embeddings)} embeddings for {le
AI-assisted analysis of mem0ai/mem0@001c235229 (2026-08-15).
Data as JSON: /api/errors/d0cfd95f01a1388a.
Report an issue: GitHub.