mem0ai/mem0 · error · ValueError

Unsupported Llm provider: {provider_name}

Error message

Unsupported Llm provider: {provider_name}

What it means

Thrown by LlmFactory.create when the provider_name string is not a key in LlmFactory.provider_to_class. Mem0 only instantiates LLM backends registered in this dict (openai, anthropic, azure_openai, gemini, groq, together, deepseek, minimax, xai, ollama, lmstudio, vllm, litellm, aws_bedrock, sarvam, langchain, and the *_structured variants), so any other string is rejected before any client is built.

Source

Thrown at mem0/utils/factory.py:80

    @classmethod
    def create(cls, provider_name: str, config: Optional[Union[BaseLlmConfig, Dict]] = None, **kwargs):
        """
        Create an LLM instance with the appropriate configuration.

        Args:
            provider_name (str): The provider name (e.g., 'openai', 'anthropic')
            config: Configuration object or dict. If None, will create default config
            **kwargs: Additional configuration parameters

        Returns:
            Configured LLM instance

        Raises:
            ValueError: If provider is not supported
        """
        if provider_name not in cls.provider_to_class:
            raise ValueError(f"Unsupported Llm provider: {provider_name}")

        class_type, config_class = cls.provider_to_class[provider_name]
        llm_class = load_class(class_type)

        # Handle configuration
        if config is None:
            # Create default config with kwargs
            config = config_class(**kwargs)
        elif isinstance(config, dict):
            # Merge dict config with kwargs
            config = {**config, **kwargs}
            config = config_class(**config)
        elif isinstance(config, BaseLlmConfig):
            # Convert base config to provider-specific config if needed
            if config_class != BaseLlmConfig:
                # Convert to provider-specific config
                config_dict = {
                    "model": config.model,

View on GitHub (pinned to 001c235229)

Solutions

  1. Fix the provider string to an exact key of LlmFactory.provider_to_class — check with LlmFactory.get_supported_providers()
  2. For Azure OpenAI use 'azure_openai' (or 'azure_openai_structured'), for Anthropic use 'anthropic', for AWS use 'aws_bedrock'
  3. For a provider mem0 does not ship, route it through the 'litellm' or 'langchain' provider instead of an unsupported name
  4. For a custom class, call LlmFactory.register_provider(name, class_path, config_class) before create()

Example fix

// before
config = {
  "llm": {"provider": "azure", "model": "gpt-4o", "config": {...}}
}
memory = Memory.from_config(config)

# after
config = {
  "llm": {"provider": "azure_openai", "model": "gpt-4o", "config": {...}}
}
memory = Memory.from_config(config)
Defensive patterns

Strategy: validation

Validate before calling

from mem0.utils.factory import LlmFactory
provider = cfg['llm']['provider']
if provider not in LlmFactory.provider_to_class:
    raise ConfigError(f"unknown llm provider {provider!r}; valid: {LlmFactory.get_supported_providers()}")

Type guard

def is_known_llm_provider(p: str) -> bool:
    from mem0.utils.factory import LlmFactory
    return isinstance(p, str) and p in LlmFactory.provider_to_class

Try / catch

try:
    memory = Memory.from_config(config)
except ValueError as e:
    if 'Unsupported Llm provider' in str(e):
        raise ConfigError(str(e)) from e
    raise

Prevention

When it happens

Trigger: Calling Memory.from_config() with config.dict({'llm': {'provider': '<name>'}}) where <name> is misspelled or unregistered; passing MemoryConfig(llm={'provider': 'azure'}) instead of 'azure_openai'; passing 'gpt-4o' (a model name) instead of a provider name; calling LlmFactory.create('claude') instead of 'anthropic'.

Common situations: Typo in the provider key in a YAML/JSON config; using a model name where a provider name is expected; using a provider name that exists in the hosted platform but not in the OSS factory (e.g. 'azure' vs 'azure_openai', 'vertexai' vs the registered names); case sensitivity ('OpenAI' vs 'openai').

Related errors


AI-assisted analysis of mem0ai/mem0@001c235229 (2026-08-15). Data as JSON: /api/errors/74a2aaab87134dbb. Report an issue: GitHub.