{"record":{"id":"aaa1317cab0d9ef4","repo":"langgenius/dify","slug":"provider-not-initialize-aaa131","errorCode":"provider_not_initialize","errorMessage":"No Embedding Model available. Please configure a valid provider in the Settings -> Model Provider.","messagePattern":"No Embedding Model available\\. Please configure a valid provider in the Settings -> Model Provider\\.","errorType":"error_code","errorClass":"ProviderNotInitializeError","httpStatus":400,"severity":"error","filePath":"api/controllers/console/datasets/datasets.py","lineNumber":972,"sourceCode":"                        document_model=args[\"doc_form\"],\n                    )\n                    extract_settings.append(extract_setting)\n            case _:\n                raise ValueError(\"Data source type not support\")\n        indexing_runner = IndexingRunner()\n        try:\n            response = indexing_runner.indexing_estimate(\n                tenant_id=current_tenant_id,\n                extract_settings=extract_settings,\n                tmp_processing_rule=args[\"process_rule\"],\n                doc_form=args[\"doc_form\"],\n                doc_language=args[\"doc_language\"],\n                dataset_id=args[\"dataset_id\"],\n                indexing_technique=args[\"indexing_technique\"],\n                session=session,\n            )\n        except LLMBadRequestError:\n            raise ProviderNotInitializeError(\n                \"No Embedding Model available. Please configure a valid provider in the Settings -> Model Provider.\"\n            )\n        except ProviderTokenNotInitError as ex:\n            raise ProviderNotInitializeError(ex.description)\n        except Exception as e:\n            raise IndexingEstimateError(str(e))\n\n        return (\n            IndexingEstimateResponse(\n                tokens=0,\n                total_price=0,\n                currency=\"USD\",\n                total_segments=response.total_segments,\n                preview=response.preview,\n                qa_preview=response.qa_preview,\n            ).model_dump(mode=\"json\", exclude_none=True),\n            200,\n        )","sourceCodeStart":954,"sourceCodeEnd":990,"githubUrl":"https://github.com/langgenius/dify/blob/ef8544b173fd6cd7a8e71df2cab576e52bebbfbc/api/controllers/console/datasets/datasets.py#L954-L990","documentation":"Thrown as ProviderNotInitializeError (HTTP 400, code provider_not_initialize) when the indexing-cost estimate step cannot run because the tenant has no usable embedding model. The controller catches LLMBadRequestError from IndexingRunner.indexing_estimate and re-wraps it, masking the original detail with a generic message pointing to Settings -> Model Provider. This means the estimate never even reached the embedding call — the model resolution itself failed.","triggerScenarios":"Calling the dataset indexing-estimate endpoint (POST /console/api/datasets/<id>/indexing-estimate or the estimate sub-route used during document creation preview) on a tenant that has either (a) no embedding model configured at all, or (b) a configured provider whose model is unavailable/invalid so model resolution raises LLMBadRequestError. Reproduced whenever the Knowledge page opens the cost-estimate panel before any embedding provider is set up.","commonSituations":"Fresh tenant that has never visited Settings -> Model Provider; an embedding provider was configured but its API key was later revoked or deleted; a self-hosted model server (e.g. Xinference/Ollama) went offline after the dataset was created; the dataset references a model from a provider plugin that was uninstalled.","solutions":["In Settings -> Model Provider, add a valid embedding model (e.g. OpenAI text-embedding-3-small) and confirm it shows as 'Available'.","If a provider already exists, click it and re-enter / refresh its API key, then retry the estimate.","Verify the embedding provider backend is reachable (curl the provider's endpoint) when using self-hosted/volc/local providers.","Check docker/.env / docker/envs/*.env for the correct EMBEDDING_* / provider credentials when running self-hosted Dify."],"exampleFix":"// before: estimate called with no embedding model configured\nPOST /console/api/datasets/<id>/indexing-estimate  →  400 provider_not_initialize\n\n// after: configure provider first, then estimate returns 200\n// 1. UI: Settings → Model Provider → add embedding model\n// 2. Retry the same estimate request","handlingStrategy":"validation","validationCode":"from core.model_manager import ModelManager\nfrom models.dataset import Dataset\n\ndef has_embedding_model(tenant_id: str, dataset: Dataset) -> bool:\n    \"\"\"Return True only if the dataset's embedding provider is resolvable.\"\"\"\n    if not dataset.embedding_model_provider:\n        return False\n    try:\n        mm = ModelManager.for_tenant(tenant_id=tenant_id)\n        mm.get_model_instance(\n            tenant_id=tenant_id,\n            provider=dataset.embedding_model_provider,\n            model_type=ModelType.TEXT_EMBEDDING,\n            model=dataset.embedding_model or \"\",\n        )\n        return True\n    except Exception:\n        return False\n\n# before calling indexing_estimate\nif not has_embedding_model(current_tenant_id, dataset):\n    return error(\"Configure an embedding model first.\")","typeGuard":null,"tryCatchPattern":"# controller-level: narrow the catch instead of relying on LLMBadRequestError\ntry:\n    response = indexing_runner.indexing_estimate(...)\nexcept (LLMBadRequestError, ProviderTokenNotInitError) as ex:\n    # surface a single, actionable error to the client\n    raise ProviderNotInitializeError(\n        \"Embedding model unavailable for this tenant. Configure one in Settings -> Model Provider.\"\n    )","preventionTips":["Run a pre-flight check that the dataset's embedding_model_provider resolves to a valid ModelInstance before opening the estimate panel.","Add a startup health-check that warns admins when a tenant has high_quality datasets but no embedding provider.","Treat LLMBadRequestError and ProviderTokenNotInitError as the same user-facing condition to avoid divergent messages."],"tags":["embedding","model-provider","datasets","rag","configuration"],"backgroundTag":null,"analyzedSha":"ef8544b173fd6cd7a8e71df2cab576e52bebbfbc","analyzedAt":"2026-08-12T05:15:17.394Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}