mem0ai/mem0 · error · ValueError

Unknown provider in model: {model}

Error message

Unknown provider in model: {model}

What it means

Raised by extract_provider() when no explicit_provider is given and the model ID does not word-boundary-match any allowlisted provider token (e.g. a model string without a recognizable provider infix). AWSBedrockLLM routes requests per provider (inference params, converse vs invoke), so it must map the model to one; failure aborts init.

Source

Thrown at mem0/llms/aws_bedrock.py:37

PROVIDERS = [
    "ai21", "amazon", "anthropic", "cohere", "meta", "mistral", "stability", "writer",
    "deepseek", "gpt-oss", "perplexity", "snowflake", "titan", "command", "j2", "llama",
    "minimax",
]


def extract_provider(model: str, explicit_provider: Optional[str] = None) -> str:
    """Extract provider from model identifier, or return explicit_provider when set."""
    if explicit_provider:
        if explicit_provider not in PROVIDERS:
            raise ValueError(
                f"Unknown provider_override '{explicit_provider}'. Valid providers: {', '.join(PROVIDERS)}"
            )
        return explicit_provider
    for provider in PROVIDERS:
        if re.search(rf"\b{re.escape(provider)}\b", model):
            return provider
    raise ValueError(f"Unknown provider in model: {model}")


class AWSBedrockLLM(LLMBase):
    """
    AWS Bedrock LLM integration for Mem0.

    Supports all available Bedrock models with automatic provider detection.
    """

    def __init__(self, config: Optional[Union[AWSBedrockConfig, BaseLlmConfig, Dict]] = None):
        """
        Initialize AWS Bedrock LLM.

        Args:
            config: AWS Bedrock configuration object
        """
        # Convert to AWSBedrockConfig if needed
        if config is None:

View on GitHub (pinned to 001c235229)

Solutions

  1. Set provider_override in the config to the correct allowlisted provider so detection is not needed (e.g. provider_override: 'anthropic' for a fine-tune of a Claude model)
  2. Fix the model ID — for fine-tunes keep the base provider prefix: anthropic.my-model-xyz
  3. Use the full model ARN if the plain ID is ambiguous
  4. Upgrade mem0ai if you need a provider token added to the allowlist

Example fix

// before
{"model": "my-finetune-123"}  # ValueError: Unknown provider in model

# after
{"model": "my-finetune-123", "provider_override": "anthropic"}
Defensive patterns

Strategy: type-guard

Validate before calling

import re
PROVIDERS = ["ai21","amazon","anthropic","cohere","meta","mistral","stability","writer",
             "deepseek","gpt-oss","perplexity","snowflake","titan","command","j2","llama","minimax"]
model = llm_config["model"]
if not any(re.search(rf"\b{p}\b", model) for p in PROVIDERS):
    llm_config.setdefault("provider_override", "anthropic")  # disambiguate explicitly
    print("model ID ambiguous; set provider_override")

Type guard

import re

def model_has_known_provider(model: str, providers=PROVIDERS) -> bool:
    return any(re.search(rf"\b{re.escape(p)}\b", model) for p in providers)

Try / catch

try:
    llm = AWSBedrockLLM(config)
except ValueError as e:
    if "Unknown provider in model" in str(e):
        config["provider_override"] = "anthropic"  # or the true base model family
        llm = AWSBedrockLLM(config)
    else:
        raise

Prevention

When it happens

Trigger: Using a Bedrock custom/provisioned model ID, an inference-profile ARN, or a marketplace model whose ID contains none of the allowlisted tokens (e.g. 'us.anthropic...' works, but a custom name like 'my-company-model-v2' does not); typos in the model string

Common situations: Cross-region inference profile IDs; Bedrock Marketplace models; custom fine-tuned model names (with suffixes) that still contain a provider token (those work) vs fully custom names (these fail).

Related errors


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