{"record":{"id":"7df35c5cac750046","repo":"run-llama/llama_index","slug":"must-provide-either-prompt-or-prompt-template-str-7df35c","errorCode":null,"errorMessage":"Must provide either prompt or prompt_template_str.","messagePattern":"Must provide either prompt or prompt_template_str\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"llama-index-core/llama_index/core/program/multi_modal_llm_program.py","lineNumber":71,"sourceCode":"        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),\n            multi_modal_llm=multi_modal_llm,\n            image_documents=image_documents or [],\n            verbose=verbose,\n        )\n","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/run-llama/llama_index/blob/afd0fef371831f9bda13e5af7167cf4e981278ab/llama-index-core/llama_index/core/program/multi_modal_llm_program.py#L53-L89","documentation":"The multimodal program factory mirrors LLMTextCompletionProgram: it needs exactly one prompt source. This instance fires when both prompt and prompt_template_str are None, so there is nothing to format for the LLM. It is a pre-flight configuration error, not an LLM failure.","triggerScenarios":"Calling MultiModalLLMCompletionProgram.from_defaults(output_cls=..., image_documents=[...]) with neither prompt nor prompt_template_str.","commonSituations":"Adapting single-modal example code that omitted the prompt argument; prompt variable conditionally set to None; typo in the kwarg name (e.g. prompt_str).","solutions":["Pass prompt_template_str or prompt (exactly one) to from_defaults.","Add a guard before construction: if not (prompt or prompt_template_str): raise early with your own message.","Check that **kwargs forwarding from your wrapper includes the prompt key."],"exampleFix":"# before\nprogram = MultiModalLLMCompletionProgram.from_defaults(\n    output_cls=Description,\n    image_documents=docs,\n)\n# after\nprogram = MultiModalLLMCompletionProgram.from_defaults(\n    output_cls=Description,\n    image_documents=docs,\n    prompt_template_str=\"Describe the image: {context}\",\n)","handlingStrategy":"validation","validationCode":"if prompt is None and prompt_template_str is None:\n    raise ValueError(\"multimodal program needs a prompt\")","typeGuard":"def has_prompt_source(prompt, template_str) -> bool:\n    return (prompt is None) != (template_str is None)","tryCatchPattern":null,"preventionTips":["Reuse the same validated program builder for single- and multi-modal programs.","Image documents alone are not a prompt — always include instructions."],"tags":["validation","prompt","configuration","multimodal"],"backgroundTag":null,"analyzedSha":"afd0fef371831f9bda13e5af7167cf4e981278ab","analyzedAt":"2026-08-15T05:42:58.429Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}