infiniflow/ragflow · error · LookupError
Model {model_name} not found for type {model_type_val}.
Error message
Model {model_name} not found for type {model_type_val}. What it means
LookupError raised in name-based id resolution when the provider and instance resolved fine but TenantModelService.get_by_provider_id_and_instance_id_and_model_type_and_model_name found no tenant_model row for the pure model name under that provider+instance with that model_type. All three keys (provider, instance, model_type, model name) must match a registered row.
Source
Thrown at api/db/joint_services/tenant_model_service.py:399
# Builtin TEI embedding — no tenant_model row exists
compose_profiles = os.getenv("COMPOSE_PROFILES", "")
is_tei_builtin_embedding = (
model_type_val == LLMType.EMBEDDING.value and "tei-" in compose_profiles and pure_model_name == os.getenv("TEI_MODEL", "") and (provider_name == "Builtin" or not provider_name)
)
if is_tei_builtin_embedding:
return None
if not provider_name:
raise LookupError(f"Provider name is required to resolve model id for {model_name}.")
provider_obj = TenantModelProviderService.get_by_tenant_id_and_provider_name(tenant_id, provider_name)
if not provider_obj:
raise LookupError(f"Provider {provider_name} not found for model {model_name}.")
instance_obj = _resolve_instance_for_model(provider_obj, instance_name, model_name)
model_obj = TenantModelService.get_by_provider_id_and_instance_id_and_model_type_and_model_name(provider_obj.id, instance_obj.id, model_type_val, pure_model_name)
if not model_obj:
raise LookupError(f"Model {model_name} not found for type {model_type_val}.")
return model_obj.id
# Mapping from model-name field → (LLMType, tenant_model id field)
_MODEL_NAME_TO_ID_FIELD_MAP: dict[str, tuple[str, str]] = {
"llm_id": (LLMType.CHAT, "tenant_llm_id"),
"embd_id": (LLMType.EMBEDDING, "tenant_embd_id"),
"rerank_id": (LLMType.RERANK, "tenant_rerank_id"),
"asr_id": (LLMType.ASR, "tenant_asr_id"),
"img2txt_id": (LLMType.VISION, "tenant_img2txt_id"),
"tts_id": (LLMType.TTS, "tenant_tts_id"),
}
def ensure_tenant_model_ids_for_params(tenant_id: str, params: dict) -> dict:
"""For each model-name field present in *params*, resolve the corresponding
tenant_model id if the id field is not already present.
View on GitHub (pinned to 554fb1133a)
Solutions
- Open Model Providers, expand the provider, and confirm the model is listed with the exact name; re-add it if missing.
- Check the requested model_type matches how the model was added (e.g. an embedding-only entry will not resolve for CHAT).
- Re-copy the full 'model@provider' string from the UI selector into your config.
- Query tenant_model by provider_id and instance_id to see the exact stored names.
Defensive patterns
Strategy: try-catch
Validate before calling
provider = TenantModelProviderService.get_by_tenant_id_and_provider_name(tenant_id, provider_name)
instance = _resolve_instance_for_model(provider, instance_name, model_name)
if not TenantModelService.get_by_provider_id_and_instance_id_and_model_type_and_model_name(
provider.id, instance.id, model_type.value, pure_name):
raise ValueError(f"Model '{pure_name}' not registered under {provider_name}") Try / catch
try:
model_id = get_model_id_from_name(tenant_id, model_type, model_name)
except LookupError as e:
if "not found for type" in str(e):
# permanent: name/registration mismatch, no retry
raise Prevention
- Register custom models with stable, exact names before referencing them in config.
- When re-adding a model, keep the name identical to avoid breaking stored references.
- Validate the full provider->instance->model chain when onboarding a new model.
When it happens
Trigger: Resolving 'some-model@Provider' where 'some-model' was never added under that provider for this tenant; the model was added under a different model_type than requested (embedding vs chat); the model name has a typo or the provider's model list changed and the row was removed.
Common situations: Custom/self-hosted models added with a slightly different name ('qwen2.5-7b' vs 'Qwen2.5-7B'); requesting a type the row does not carry so the type-filtered query returns empty; stale names in old DSL after model re-registration.
Related errors
- Provider id={model_obj.provider_id} not found for model {mod
- Model {model_name} not found.
- TenantModel id={model_id} not found.
- TenantModel id={model_id} is disabled.
- TenantModel id={model_id} cannot be used as {model_type_val}
AI-assisted analysis of infiniflow/ragflow@554fb1133a (2026-08-15).
Data as JSON: /api/errors/ffdfaef70f68788e.
Report an issue: GitHub.