langgenius/dify · error · ProviderNotInitializeError
provider_not_initialize
provider_not_initialize
Error message
No valid model provider credentials found. Please go to Settings -> Model Provider to complete your provider credentials.
What it means
Raised by CompletionApi.post (HTTP 400, error_code 'provider_not_initialize') when core.errors.error.ProviderTokenNotInitError is thrown during generation. The app references a model provider whose API credentials have not been configured (or were cleared) in Settings -> Model Provider. The exception's description is forwarded to the client.
Source
Thrown at api/controllers/console/explore/completion.py:134
session=session,
app_model=app_model,
user=current_user,
args=args,
invoke_from=InvokeFrom.EXPLORE,
streaming=streaming,
)
# response-contract:ignore compact_generate_response
return helper.compact_generate_response(response)
except services.errors.conversation.ConversationNotExistsError:
raise NotFound("Conversation Not Exists.")
except services.errors.conversation.ConversationCompletedError:
raise ConversationCompletedError()
except services.errors.app_model_config.AppModelConfigBrokenError:
logger.exception("App model config broken.")
raise AppUnavailableError()
except ProviderTokenNotInitError as ex:
raise ProviderNotInitializeError(ex.description)
except QuotaExceededError:
raise ProviderQuotaExceededError()
except ModelCurrentlyNotSupportError:
raise ProviderModelCurrentlyNotSupportError()
except InvokeError as e:
raise CompletionRequestError(e.description)
except ValueError as e:
raise e
except Exception:
logger.exception("internal server error.")
raise InternalServerError()
@console_ns.route(
"/installed-apps/<uuid:installed_app_id>/completion-messages/<string:task_id>/stop",
endpoint="installed_app_stop_completion",
)
class CompletionStopApi(InstalledAppResource):View on GitHub (pinned to ef8544b173)
Solutions
- Go to Settings -> Model Provider and add valid API credentials for the provider the app uses.
- Identify which provider/model the app needs by opening it in Studio and checking the model node.
- If using OpenAI, ensure the key is active and has credit.
- After saving credentials, retry the completion request.
Example fix
# before: app uses gpt-4o but no OpenAI key is configured # (request fails with provider_not_initialize) # after: configure the provider, then retry # Settings -> Model Provider -> OpenAI -> Add API Key -> Save # then re-send the same completion request
Defensive patterns
Strategy: validation
Validate before calling
// Before posting, confirm the tenant has credentials for the provider the app uses.
const providers = await fetch('/console/workspaces/current/model-providers').then(r => r.json());
const hasCreds = (providerName) =>
providers.data.some(p => p.provider === providerName && p.is_valid);
if (!hasCreds(appProvider)) { promptConfigureProvider(appProvider); } Type guard
function providerIsConfigured(providerEntry) {
return Boolean(providerEntry && providerEntry.is_valid);
} Try / catch
try {
await postCompletion(id, payload);
} catch (err) {
if (err.code === 'provider_not_initialize') {
// direct user to Settings -> Model Provider; do not blind-retry
showProviderSetupUI();
} else { throw err; }
} Prevention
- Configure required provider credentials before installing apps that depend on them.
- Validate provider credentials after key rotation or expiry.
- Surface a pre-flight provider check in onboarding flows for Explore apps.
When it happens
Trigger: POST /console/installed-apps/<id>/completion-messages where the app's configured model provider has no valid credentials on the tenant. AppGenerateService tries to load the provider credentials and ProviderTokenNotInitError fires before any model call.
Common situations: New deployment where no provider keys were added; provider credentials were rotated/expired and removed; the app was installed from a template that uses a provider the tenant never configured; switching from Dify-hosted trial to BYO-key without entering keys.
Related errors
- provider_quota_exceeded
- model_currently_not_support
- provider_not_initialize
- server_4xx_other
- provider_not_support_speech_to_text
AI-assisted analysis of langgenius/dify@ef8544b173 (2026-08-12).
Data as JSON: /api/errors/6845aaf25cacd42f.
Report an issue: GitHub.