{"record":{"id":"1d8f40c4d324f912","repo":"infiniflow/ragflow","slug":"model-model-name-not-found-for-model-model-type","errorCode":null,"errorMessage":"Model {model_name} not found for model {model_type_val}","messagePattern":"Model (.+?) not found for model (.+?)","errorType":"exception","errorClass":"LookupError","httpStatus":null,"severity":"error","filePath":"api/db/joint_services/tenant_model_service.py","lineNumber":321,"sourceCode":"            \"llm_factory\": provider_obj.provider_name,\n            \"api_key\": api_key,\n            \"llm_name\": model_obj.model_name,\n            \"api_base\": extra_fields.get(\"base_url\", \"\"),\n            \"model_type\": model_type_val,\n            \"is_tools\": model_extra.get(\"is_tools\", is_tool),\n            \"max_tokens\": max_tokens,\n        }\n        if provider_name.lower() == \"somark\":\n            # SoMark/OCR factories read parser config (somark_*, parse_method, ...)\n            # from model_config[\"extra\"]; see tenant_llm_service.LLMBundle OCR path.\n            model_config[\"extra\"] = model_extra\n\n        if api_key_payload is not None:\n            model_config[\"api_key_payload\"] = api_key_payload\n\n        return model_config\n    else:\n        raise LookupError(f\"Model {model_name} not found for model {model_type_val}\")\n\n\ndef get_model_config_by_id(tenant_id: str, model_type: str | enum.Enum, model_id: str):\n    \"\"\"Get model config from tenant_model by its id (CharField PK).\"\"\"\n    model_type_val = model_type if isinstance(model_type, str) else model_type.value\n    model_type_bin = calculate_model_type(model_type_val)\n    exist, model_obj = TenantModelService.get_by_id(model_id)\n    if not exist:\n        raise LookupError(f\"TenantModel id={model_id} not found.\")\n    if model_obj.status == ActiveStatusEnum.INACTIVE.value:\n        raise LookupError(f\"TenantModel id={model_id} is disabled.\")\n    if model_obj.status == ActiveStatusEnum.UNSUPPORTED.value:\n        raise LookupError(f\"TenantModel id={model_id} cannot be used as {model_type_val} model.\")\n    if not (model_obj.model_type & model_type_bin):\n        raise LookupError(f\"TenantModel id={model_id} cannot be used as {model_type_val} model.\")\n\n    ok, provider_obj = TenantModelProviderService.get_by_id(model_obj.provider_id)\n    if not ok:","sourceCodeStart":303,"sourceCodeEnd":339,"githubUrl":"https://github.com/infiniflow/ragflow/blob/554fb1133ac3861732235ad9c377eb5e0a770665/api/db/joint_services/tenant_model_service.py#L303-L339","documentation":"Error \"Model {model_name} not found for model {model_type_val}\" thrown in infiniflow/ragflow.","triggerScenarios":"Thrown at api/db/joint_services/tenant_model_service.py:321 when the library encounters an invalid state.","commonSituations":"The requested model is not configured for the tenant under the given type; adding or correcting the model configuration prevents this error.","solutions":["Verify the model name and type exist for the tenant.","Configure the model in the tenant model settings first."],"exampleFix":"# check available models for the tenant before referencing one","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"554fb1133ac3861732235ad9c377eb5e0a770665","analyzedAt":"2026-08-15T09:20:16.380Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}