{"record":{"id":"f4565f9d2ec9adf9","repo":"run-llama/llama_index","slug":"must-provide-either-prompt-or-prompt-template-str","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/function_program.py","lineNumber":116,"sourceCode":"        prompt: Optional[BasePromptTemplate] = None,\n        llm: Optional[LLM] = None,\n        verbose: bool = False,\n        allow_parallel_tool_calls: bool = False,\n        tool_choice: Optional[Union[str, Dict[str, Any]]] = None,\n        tool_required: bool = True,\n        **kwargs: Any,\n    ) -> \"FunctionCallingProgram\":\n        llm = llm or Settings.llm  # type: ignore\n        assert llm is not None\n\n        if not llm.metadata.is_function_calling_model:\n            raise ValueError(\n                f\"Model name {llm.metadata.model_name} does not support \"\n                \"function calling API. \"\n            )\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        return cls(\n            output_cls=output_cls,\n            llm=llm,  # type: ignore\n            prompt=cast(PromptTemplate, prompt),\n            tool_choice=tool_choice,\n            allow_parallel_tool_calls=allow_parallel_tool_calls,\n            tool_required=tool_required,\n            verbose=verbose,\n        )\n\n    @property\n    def output_cls(self) -> Type[Model]:\n        return self._output_cls","sourceCodeStart":98,"sourceCodeEnd":134,"githubUrl":"https://github.com/run-llama/llama_index/blob/afd0fef371831f9bda13e5af7167cf4e981278ab/llama-index-core/llama_index/core/program/function_program.py#L98-L134","documentation":"Error \"Must provide either prompt or prompt_template_str.\" thrown in run-llama/llama_index.","triggerScenarios":"Thrown at llama-index-core/llama_index/core/program/function_program.py:116 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Provide either a prompt object or prompt_template_str when constructing the program.","Create a PromptTemplate from your template string and pass it as prompt."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"afd0fef371831f9bda13e5af7167cf4e981278ab","analyzedAt":"2026-08-15T05:42:58.429Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}