{"record":{"id":"42ae8d88aec080e6","repo":"mem0ai/mem0","slug":"unknown-provider-in-model-model-42ae8d","errorCode":null,"errorMessage":"Unknown provider in model: {model}","messagePattern":"Unknown provider in model: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"mem0/llms/aws_bedrock.py","lineNumber":37,"sourceCode":"PROVIDERS = [\n    \"ai21\", \"amazon\", \"anthropic\", \"cohere\", \"meta\", \"mistral\", \"stability\", \"writer\",\n    \"deepseek\", \"gpt-oss\", \"perplexity\", \"snowflake\", \"titan\", \"command\", \"j2\", \"llama\",\n    \"minimax\",\n]\n\n\ndef extract_provider(model: str, explicit_provider: Optional[str] = None) -> str:\n    \"\"\"Extract provider from model identifier, or return explicit_provider when set.\"\"\"\n    if explicit_provider:\n        if explicit_provider not in PROVIDERS:\n            raise ValueError(\n                f\"Unknown provider_override '{explicit_provider}'. Valid providers: {', '.join(PROVIDERS)}\"\n            )\n        return explicit_provider\n    for provider in PROVIDERS:\n        if re.search(rf\"\\b{re.escape(provider)}\\b\", model):\n            return provider\n    raise ValueError(f\"Unknown provider in model: {model}\")\n\n\nclass AWSBedrockLLM(LLMBase):\n    \"\"\"\n    AWS Bedrock LLM integration for Mem0.\n\n    Supports all available Bedrock models with automatic provider detection.\n    \"\"\"\n\n    def __init__(self, config: Optional[Union[AWSBedrockConfig, BaseLlmConfig, Dict]] = None):\n        \"\"\"\n        Initialize AWS Bedrock LLM.\n\n        Args:\n            config: AWS Bedrock configuration object\n        \"\"\"\n        # Convert to AWSBedrockConfig if needed\n        if config is None:","sourceCodeStart":19,"sourceCodeEnd":55,"githubUrl":"https://github.com/mem0ai/mem0/blob/001c235229be8795e3834520467bd0d661ed8f34/mem0/llms/aws_bedrock.py#L19-L55","documentation":"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.","triggerScenarios":"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","commonSituations":"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).","solutions":["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)","Fix the model ID — for fine-tunes keep the base provider prefix: anthropic.my-model-xyz","Use the full model ARN if the plain ID is ambiguous","Upgrade mem0ai if you need a provider token added to the allowlist"],"exampleFix":"// before\n{\"model\": \"my-finetune-123\"}  # ValueError: Unknown provider in model\n\n# after\n{\"model\": \"my-finetune-123\", \"provider_override\": \"anthropic\"}","handlingStrategy":"type-guard","validationCode":"import re\nPROVIDERS = [\"ai21\",\"amazon\",\"anthropic\",\"cohere\",\"meta\",\"mistral\",\"stability\",\"writer\",\n             \"deepseek\",\"gpt-oss\",\"perplexity\",\"snowflake\",\"titan\",\"command\",\"j2\",\"llama\",\"minimax\"]\nmodel = llm_config[\"model\"]\nif not any(re.search(rf\"\\b{p}\\b\", model) for p in PROVIDERS):\n    llm_config.setdefault(\"provider_override\", \"anthropic\")  # disambiguate explicitly\n    print(\"model ID ambiguous; set provider_override\")","typeGuard":"import re\n\ndef model_has_known_provider(model: str, providers=PROVIDERS) -> bool:\n    return any(re.search(rf\"\\b{re.escape(p)}\\b\", model) for p in providers)","tryCatchPattern":"try:\n    llm = AWSBedrockLLM(config)\nexcept ValueError as e:\n    if \"Unknown provider in model\" in str(e):\n        config[\"provider_override\"] = \"anthropic\"  # or the true base model family\n        llm = AWSBedrockLLM(config)\n    else:\n        raise","preventionTips":["Prefer standard Bedrock model IDs with provider prefixes","For custom/fine-tuned models, always set provider_override","Validate model IDs against the Bedrock console list at deploy time"],"tags":["python","aws","bedrock","model-id","validation","mem0"],"backgroundTag":null,"analyzedSha":"001c235229be8795e3834520467bd0d661ed8f34","analyzedAt":"2026-08-15T01:55:42.685Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}