{"record":{"id":"750b92852df0ad0b","repo":"zylon-ai/private-gpt","slug":"openai-llm-dependencies-are-not-installed-install","errorCode":null,"errorMessage":"OpenAI LLM dependencies are not installed. Install with `uv sync --inexact --extra llm-openai`.","messagePattern":"OpenAI LLM dependencies are not installed\\. Install with `uv sync --inexact --extra llm-openai`\\.","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"private_gpt/components/llm/factories/completions/openai.py","lineNumber":17,"sourceCode":"from typing import Any, cast\n\nfrom llama_index.core.llms import LLM\n\nfrom private_gpt.components.llm.factories.base import LLMFactory\nfrom private_gpt.components.llm.tokenizers.tokenizer_base import TokenizerBase\nfrom private_gpt.settings.settings import LLMModelConfig, Settings\nfrom private_gpt.utils.dependencies import format_missing_dependency_message\n\n\ndef _load_patched_openai() -> type[Any]:\n    try:\n        from private_gpt.components.llm.custom.openai import PatchedOpenAILLM\n\n        return PatchedOpenAILLM\n    except ImportError as e:\n        raise ImportError(\n            format_missing_dependency_message(\n                \"OpenAI LLM\",\n                extras=\"llm-openai\",\n            )\n        ) from e\n\n\nclass OpenAICompletionsFactory(LLMFactory):\n    \"\"\"Chat Completions factory for the real OpenAI endpoint (api.openai.com).\"\"\"\n\n    def __init__(self, settings: Settings):\n        super().__init__(settings)\n        self.openai_settings = settings.openai\n\n    def _create_llm(\n        self, model_config: LLMModelConfig, tokenizer: TokenizerBase | None = None\n    ) -> tuple[LLM, str | None]:\n        PatchedOpenAILLM = _load_patched_openai()","sourceCodeStart":1,"sourceCodeEnd":35,"githubUrl":"https://github.com/zylon-ai/private-gpt/blob/4a030776a31a901ad80b1bf4d7faa2c1a367efbb/private_gpt/components/llm/factories/completions/openai.py#L1-L35","documentation":"ImportError raised by the lazy loader in the OpenAI completions factory: importing PatchedOpenAILLM (which pulls in the openai package and llama-index OpenAI integration) failed, so the optional 'llm-openai' extra is not installed. The message tells you the exact uv command to install the missing extra.","triggerScenarios":"Configuring llm mode to use the OpenAI (api.openai.com) completions backend without having installed the project's llm-openai optional dependency group.","commonSituations":"Fresh clone with a minimal sync (`uv sync` without extras); Docker images built with a slim dependency set; CI environments where only core deps are installed.","solutions":["Run `uv sync --inexact --extra llm-openai` as the message instructs.","If not using uv, install the openai/llama-index OpenAI packages named in the llm-openai extra (check pyproject.toml).","Rebuild your Docker/CI image with the extra included."],"exampleFix":"# before: default sync only\nuv sync\n\n# after\nuv sync --inexact --extra llm-openai","handlingStrategy":"validation","validationCode":"def openai_extra_available() -> bool:\n    try:\n        import openai  # noqa: F401\n        return True\n    except ImportError:\n        return False","typeGuard":null,"tryCatchPattern":"try:\n    factory = registry.get_factory(\"openai\")\nexcept ImportError as e:\n    if 'llm-openai' in str(e):\n        raise SystemExit('Install extras: uv sync --inexact --extra llm-openai') from e\n    raise","preventionTips":["Pin the full set of extras your modes need in deployment scripts/CI from day one.","Fail fast at startup: attempt to resolve every configured LLM mode before serving traffic.","Document required extras per mode in the project README so onboarding installs them."],"tags":["dependencies","openai","import-error","installation"],"backgroundTag":null,"analyzedSha":"4a030776a31a901ad80b1bf4d7faa2c1a367efbb","analyzedAt":"2026-08-15T03:51:26.951Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}