{"record":{"id":"46405aa103a21c25","repo":"zylon-ai/private-gpt","slug":"default-llm-model-model-id-could-not-be-initia","errorCode":null,"errorMessage":"Default LLM model '{model_id}' could not be initialized: {e}","messagePattern":"Default LLM model '(.+?)' could not be initialized: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"critical","filePath":"private_gpt/components/llm/llm_component.py","lineNumber":98,"sourceCode":"                instance = factory.create_llm(model_config)\n\n                alias = instance.alias\n                aliases = [alias] if alias and alias != model_id else []\n                if model_id == self._default_model_id:\n                    aliases.append(LLMRegistry.default())\n\n                registry_instance = LLMInstance(\n                    llm=instance.llm, tokenizer=instance.tokenizer\n                )\n                self.registry.register(model_id, registry_instance, aliases=aliases)\n                registered_model_ids.append(model_id)\n\n                logger.info(\"Successfully registered LLM model '%s'\", model_id)\n\n            except Exception as e:\n                self.llm_models.pop(model_id, None)\n                if model_id == self._default_model_id:\n                    raise ValueError(\n                        f\"Default LLM model '{model_id}' could not be initialized: {e}\"\n                    ) from e\n                logger.warning(\n                    \"Skipping unavailable LLM model '%s': %s\",\n                    model_id,\n                    e,\n                )\n\n        if not self._default_model_id and registered_model_ids:\n            self._default_model_id = next(iter(self.llm_models))\n            logger.warning(\n                \"No default LLM model configured. Auto-selecting: '%s'\",\n                self._default_model_id,\n            )\n\n        if self._default_model_id:\n            default_instance = self.registry.get(self._default_model_id)\n            if not default_instance:","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/zylon-ai/private-gpt/blob/4a030776a31a901ad80b1bf4d7faa2c1a367efbb/private_gpt/components/llm/llm_component.py#L80-L116","documentation":"ValueError from LLMComponent startup: initializing the model configured as the default raised an exception, so the component removes it from the registry and re-raises (rather than the skip-and-warn path used for non-default models). The original exception is chained as __cause__, so the real failure (bad API key, unreachable endpoint, missing dependency) is in the caused-by chain.","triggerScenarios":"Any factory/init failure for the model whose id equals the configured default: invalid or missing OPENAI_API_KEY, wrong endpoint URL, missing optional extra for that mode, bad model path, or misconfigured tokenizer.","commonSituations":"First boot with incomplete credentials; rotating/revoked API keys; endpoint URL typos; adding a new default model that requires an extra not installed in the image.","solutions":["Read the chained exception (`raise ... from e` — inspect __cause__) to identify the real init failure and fix it (key, URL, dependency).","Verify credentials/env for that provider are set in the environment the service actually runs in.","As a stopgap, set default_model to a model that initializes cleanly so the app can boot while you fix the broken one."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"def default_model_config_valid(settings) -> bool:\n    models = settings.llm.models or {}\n    default = settings.llm.default_model\n    return default is None or default in models","typeGuard":null,"tryCatchPattern":"try:\n    component = LLMComponent()\nexcept ValueError as e:\n    if 'could not be initialized' in str(e):\n        cause = e.__cause__  # real failure: auth, endpoint, dependency\n        log.error('Default model init failed: %s', cause)\n        raise\n    raise","preventionTips":["Validate provider credentials and endpoint reachability in a preflight check before app startup.","Surface e.__cause__ in logs — the wrapper message hides the actual error.","Keep a known-good fallback default model so a single broken provider doesn't block boot."],"tags":["configuration","startup","llm","credentials"],"backgroundTag":null,"analyzedSha":"4a030776a31a901ad80b1bf4d7faa2c1a367efbb","analyzedAt":"2026-08-15T03:51:26.951Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}