{"record":{"id":"fd44b067409c2e80","repo":"langchain-ai/langchain","slug":"input-variables-for-the-image-template-cannot-cont","errorCode":null,"errorMessage":"input_variables for the image template cannot contain any of 'url', 'path', or 'detail'. Found: {overlap}","messagePattern":"input_variables for the image template cannot contain any of 'url', 'path', or 'detail'\\. Found: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"libs/core/langchain_core/prompts/image.py","lineNumber":58,"sourceCode":"\n    def __init__(self, **kwargs: Any) -> None:\n        \"\"\"Create an image prompt template.\n\n        Raises:\n            ValueError: If the input variables contain `'url'`, `'path'`, or\n                `'detail'`.\n        \"\"\"\n        if \"input_variables\" not in kwargs:\n            kwargs[\"input_variables\"] = []\n\n        overlap = set(kwargs[\"input_variables\"]) & {\"url\", \"path\", \"detail\"}\n        if overlap:\n            msg = (\n                \"input_variables for the image template cannot contain\"\n                \" any of 'url', 'path', or 'detail'.\"\n                f\" Found: {overlap}\"\n            )\n            raise ValueError(msg)\n\n        template = kwargs.get(\"template\", {})\n        template_format = kwargs.get(\"template_format\", \"f-string\")\n        for value in template.values():\n            if isinstance(value, str):\n                get_template_variables(value, template_format)\n\n        super().__init__(**kwargs)\n\n    @property\n    def _prompt_type(self) -> str:\n        \"\"\"Return the prompt type key.\"\"\"\n        return \"image-prompt\"\n\n    @classmethod\n    def get_lc_namespace(cls) -> list[str]:\n        \"\"\"Get the namespace of the LangChain object.\n","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/langchain-ai/langchain/blob/e32fa9a52eab3b61ad7a45399bfde59b3e580fc4/libs/core/langchain_core/prompts/image.py#L40-L76","documentation":"`ImagePromptTemplate.__init__` validates that `input_variables` does not contain `url`, `path`, or `detail`. Those three names are reserved keys of the `ImageURL` output dict that `format()` produces, so declaring them as template variables would make the prompt unrenderable.","triggerScenarios":"Constructing `ImagePromptTemplate(template={'url': '{url}'})` or passing `input_variables=['url']` (or `path`/`detail`) — any overlap between the declared input variables and the reserved set `{url, path, detail}`.","commonSituations":"Reusing an old prompt config where `url` was previously an allowed input variable; copy-pasting a text `PromptTemplate` pattern into an image template; migrating code from before the `ImagePromptTemplate` input-variable restrictions.","solutions":["Rename the colliding variable in the template (e.g. `{url}` -> `{image_url}`) and pass `image_url=...` when calling `format`.","Pass the url directly via `template={'url': 'https://...'}` (a literal) instead of as a format variable.","If you only wanted a detail level, set it as a literal in `template={'detail': 'low'}` rather than a variable."],"exampleFix":"# before\nprompt = ImagePromptTemplate(\n    input_variables=['url'],\n    template={'url': '{url}'},\n)\n\n# after\nprompt = ImagePromptTemplate(\n    input_variables=['image_url'],\n    template={'url': '{image_url}'},\n)\nprompt.format(image_url='https://example.com/cat.png')","handlingStrategy":"validation","validationCode":"RESERVED = {'url', 'path', 'detail'}\nvars_ = set(input_variables or [])\nif vars_ & RESERVED:\n    raise ValueError(f'Rename reserved input variables: {vars_ & RESERVED}')\nImagePromptTemplate(input_variables=input_variables, template=template)","typeGuard":"def is_valid_image_input_variables(input_variables: list[str]) -> bool:\n    return not (set(input_variables) & {'url', 'path', 'detail'})","tryCatchPattern":null,"preventionTips":["Treat url/path/detail as reserved keys in any image prompt config.","Add a config lint step for image templates that rejects reserved variable names."],"tags":["prompts","image","multimodal","validation"],"backgroundTag":null,"analyzedSha":"e32fa9a52eab3b61ad7a45399bfde59b3e580fc4","analyzedAt":"2026-08-14T18:42:09.092Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}