{"record":{"id":"74cdb9bdd8e0efe0","repo":"run-llama/llama_index","slug":"llama-index-llms-openai-package-cannot-be-found","errorCode":null,"errorMessage":"`llama-index-llms-openai` package cannot be found. Please install it by using `pip install `llama-index-llms-openai`","messagePattern":"`llama-index-llms-openai` package cannot be found\\. Please install it by using `pip install `llama-index-llms-openai`","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"llama-index-core/llama_index/core/program/multi_modal_llm_program.py","lineNumber":66,"sourceCode":"        cls,\n        output_parser: Optional[PydanticOutputParser] = None,\n        output_cls: Optional[Type[BaseModel]] = None,\n        prompt_template_str: Optional[str] = None,\n        prompt: Optional[PromptTemplate] = None,\n        multi_modal_llm: Optional[LLM] = None,\n        image_documents: Optional[List[Union[ImageBlock, ImageNode]]] = None,\n        verbose: bool = False,\n        **kwargs: Any,\n    ) -> \"MultiModalLLMCompletionProgram\":\n        if multi_modal_llm is None:\n            try:\n                from llama_index.llms.openai import (\n                    OpenAIResponses,\n                )  # pants: no-infer-dep\n\n                multi_modal_llm = OpenAIResponses(model=\"gpt-4.1\", temperature=0)\n            except ImportError as e:\n                raise ImportError(\n                    \"`llama-index-llms-openai` package cannot be found. \"\n                    \"Please install it by using `pip install `llama-index-llms-openai`\"\n                )\n        if prompt is None and prompt_template_str is None:\n            raise ValueError(\"Must provide either prompt or prompt_template_str.\")\n        if prompt is not None and prompt_template_str is not None:\n            raise ValueError(\"Must provide either prompt or prompt_template_str.\")\n        if prompt_template_str is not None:\n            prompt = PromptTemplate(prompt_template_str)\n\n        if output_parser is None:\n            if output_cls is None:\n                raise ValueError(\"Must provide either output_cls or output_parser.\")\n            output_parser = PydanticOutputParser(output_cls=output_cls)\n\n        return cls(\n            output_parser,\n            prompt=cast(PromptTemplate, prompt),","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/run-llama/llama_index/blob/afd0fef371831f9bda13e5af7167cf4e981278ab/llama-index-core/llama_index/core/program/multi_modal_llm_program.py#L48-L84","documentation":"MultiModalLLMCompletionProgram.from_defaults defaults to OpenAIResponses (a multimodal model) when multi_modal_llm is None. That import lives in the optional llama-index-llms-openai package; if it is not installed, this ImportError is raised with install instructions. Supplying your own multi_modal_llm avoids the import entirely.","triggerScenarios":"Calling MultiModalLLMCompletionProgram.from_defaults(...) without multi_modal_llm in an environment where llama-index-llms-openai is not installed (e.g. only llama-index-core is present).","commonSituations":"Minimal installs of llama-index-core; using a non-OpenAI multimodal provider but forgetting to pass it explicitly; CI environments trimmed of optional dependencies.","solutions":["pip install llama-index-llms-openai to enable the default OpenAIResponses model.","Or pass multi_modal_llm=<your multimodal LLM> explicitly so no OpenAI import is attempted.","Pin optional integrations in requirements to keep environments reproducible."],"exampleFix":"# before\nprogram = MultiModalLLMCompletionProgram.from_defaults(\n    output_cls=Description,\n    prompt_template_str=\"...\",\n)\n# after\npip install llama-index-llms-openai\n# or\nprogram = MultiModalLLMCompletionProgram.from_defaults(\n    output_keys_parser=None,\n    output_cls=Description,\n    image_documents=docs,\n    multi_modal_llm=my_multimodal_llm,\n    prompt_template_str=\"...\",\n)","handlingStrategy":"try-catch","validationCode":"import importlib.util\nif multi_modal_llm is None and importlib.util.find_spec(\"llama_index.llms.openai\") is None:\n    raise RuntimeError(\"pass multi_modal_llm or pip install llama-index-llms-openai\")","typeGuard":"def has_openai_llm_package() -> bool:\n    import importlib.util\n    return importlib.util.find_spec(\"llama_index.llms.openai\") is not None","tryCatchPattern":"try:\n    program = MultiModalLLMCompletionProgram.from_defaults(...)\nexcept ImportError as e:\n    if \"llama-index-llms-openai\" in str(e):\n        program = MultiModalLLMCompletionProgram.from_defaults(\n            multi_modal_llm=my_fallback_multimodal_llm, ...\n        )\n    else:\n        raise","preventionTips":["Always pass an explicit multi_modal_llm in library/wrapper code.","Declare llama-index-llms-openai in your dependency list if you rely on the default."],"tags":["dependency","import","optional-package","multimodal"],"backgroundTag":null,"analyzedSha":"afd0fef371831f9bda13e5af7167cf4e981278ab","analyzedAt":"2026-08-15T05:42:58.429Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}