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

HTTP 400 with error_code provider_not_initialize, raised when generate_more_like_this raises ProviderTokenNotInitError. The model provider backing the app has no valid credentials configured, so the LLM call cannot be made.

Source

Thrown at api/controllers/console/explore/message.py:185

        streaming = args.response_mode == "streaming"

        try:
            response = AppGenerateService.generate_more_like_this(
                session=session,
                app_model=app_model,
                user=current_user,
                message_id=message_id_str,
                invoke_from=InvokeFrom.EXPLORE,
                streaming=streaming,
            )
            # response-contract:ignore compact_generate_response
            return helper.compact_generate_response(response)
        except MessageNotExistsError:
            raise NotFound("Message Not Exists.")
        except MoreLikeThisDisabledError:
            raise AppMoreLikeThisDisabledError()
        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>/messages/<uuid:message_id>/suggested-questions",
    endpoint="installed_app_suggested_question",
)
class MessageSuggestedQuestionApi(InstalledAppResource):

View on GitHub (pinned to ef8544b173)

Solutions

  1. Configure the model provider credentials under Settings -> Model Provider (API key for OpenAI/Anthropic/etc.).
  2. Verify the app's configured provider matches one with valid credentials.
  3. After saving credentials, retry the request.
  4. If using a hosted provider, confirm the hosted credential grant is still active.

Example fix

# before: no API key for the app's provider
# Settings -> Model Provider -> add provider credentials

# after: verify credentials are present before calling generation
provider = get_configured_provider(app.provider_name)
if not provider.has_credentials:
    raise ProviderNotInitializeError('configure provider first')
resp = get(more_like_this_url(id, mid))
Defensive patterns

Strategy: validation

Validate before calling

// Ensure provider credentials are configured before generation
const providers = await get('/console/workspaces/current/model-providers');
const ok = providers.some(p => p.provider === app.provider_name && p.credentials_valid);
if (!ok) throw new ConfigError('Configure provider credentials first');

Type guard

function providerConfigured(app, providers) {
  return providers.some(p => p.provider === app.provider_name && p.credentials_valid);
}

Try / catch

try {
  return await get(moreLikeThisUrl(id, mid));
} catch (e) {
  if (e.code === 'provider_not_initialize') {
    routeTo('/settings/model-provider');
    return null;
  }
  throw e;
}

Prevention

When it happens

Trigger: GET more-like-this (or any generation path through this controller) on an app whose provider credentials are missing in Settings > Model Provider. The service raises ProviderTokenNotInitError and the controller maps it to ProviderNotInitializeError(400).

Common situations: Fresh install with no provider API key set; provider credentials revoked or expired; tenant admin removed the provider; the app references a provider the current tenant hasn't configured.

Related errors


AI-assisted analysis of langgenius/dify@ef8544b173 (2026-08-12). Data as JSON: /api/errors/4f6505274d8dacbf. Report an issue: GitHub.