langgenius/dify · error · ProviderNotInitializeError
provider_not_initialize
provider_not_initialize
Error message
No Embedding Model available. Please configure a valid provider in the Settings -> Model Provider.
What it means
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.
Source
Thrown at api/controllers/console/datasets/datasets.py:972
document_model=args["doc_form"],
)
extract_settings.append(extract_setting)
case _:
raise ValueError("Data source type not support")
indexing_runner = IndexingRunner()
try:
response = indexing_runner.indexing_estimate(
tenant_id=current_tenant_id,
extract_settings=extract_settings,
tmp_processing_rule=args["process_rule"],
doc_form=args["doc_form"],
doc_language=args["doc_language"],
dataset_id=args["dataset_id"],
indexing_technique=args["indexing_technique"],
session=session,
)
except LLMBadRequestError:
raise ProviderNotInitializeError(
"No Embedding Model available. Please configure a valid provider in the Settings -> Model Provider."
)
except ProviderTokenNotInitError as ex:
raise ProviderNotInitializeError(ex.description)
except Exception as e:
raise IndexingEstimateError(str(e))
return (
IndexingEstimateResponse(
tokens=0,
total_price=0,
currency="USD",
total_segments=response.total_segments,
preview=response.preview,
qa_preview=response.qa_preview,
).model_dump(mode="json", exclude_none=True),
200,
)View on GitHub (pinned to ef8544b173)
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.
Example fix
// before: estimate called with no embedding model configured POST /console/api/datasets/<id>/indexing-estimate → 400 provider_not_initialize // after: configure provider first, then estimate returns 200 // 1. UI: Settings → Model Provider → add embedding model // 2. Retry the same estimate request
Defensive patterns
Strategy: validation
Validate before calling
from core.model_manager import ModelManager
from models.dataset import Dataset
def has_embedding_model(tenant_id: str, dataset: Dataset) -> bool:
"""Return True only if the dataset's embedding provider is resolvable."""
if not dataset.embedding_model_provider:
return False
try:
mm = ModelManager.for_tenant(tenant_id=tenant_id)
mm.get_model_instance(
tenant_id=tenant_id,
provider=dataset.embedding_model_provider,
model_type=ModelType.TEXT_EMBEDDING,
model=dataset.embedding_model or "",
)
return True
except Exception:
return False
# before calling indexing_estimate
if not has_embedding_model(current_tenant_id, dataset):
return error("Configure an embedding model first.") Try / catch
# controller-level: narrow the catch instead of relying on LLMBadRequestError
try:
response = indexing_runner.indexing_estimate(...)
except (LLMBadRequestError, ProviderTokenNotInitError) as ex:
# surface a single, actionable error to the client
raise ProviderNotInitializeError(
"Embedding model unavailable for this tenant. Configure one in Settings -> Model Provider."
) Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- provider_not_initialize
- model_currently_not_support
- server_4xx_other
- provider_quota_exceeded
- provider_not_support_speech_to_text
AI-assisted analysis of langgenius/dify@ef8544b173 (2026-08-12).
Data as JSON: /api/errors/aaa1317cab0d9ef4.
Report an issue: GitHub.