{"record":{"id":"42717e927be0f77d","repo":"BerriAI/litellm","slug":"invalid-image-url-content-image-url","errorCode":null,"errorMessage":"Invalid image URL: {content_image_url}","messagePattern":"Invalid image URL: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/completion_extras/litellm_responses_transformation/transformation.py","lineNumber":832,"sourceCode":"        self, content: \"ChatCompletionImageObject\", role: str\n    ) -> \"ResponseInputImageParam\":\n        from openai.types.responses import ResponseInputImageParam\n\n        content_image_url: Final = content.get(\"image_url\")\n        actual_image_url: str | None = None\n        detail: Literal[\"low\", \"high\", \"auto\"] | None = None\n\n        if isinstance(content_image_url, str):\n            actual_image_url = content_image_url\n        elif isinstance(content_image_url, dict):\n            actual_image_url = content_image_url.get(\"url\")\n            detail = cast(\n                Literal[\"low\", \"high\", \"auto\"] | None,\n                content_image_url.get(\"detail\"),\n            )\n\n        if actual_image_url is None:\n            raise ValueError(f\"Invalid image URL: {content_image_url}\")\n\n        image_param: Final = ResponseInputImageParam(image_url=actual_image_url, detail=\"auto\", type=\"input_image\")\n\n        if detail:\n            image_param[\"detail\"] = detail\n\n        return image_param\n\n    def _convert_content_to_responses_format(\n        self,\n        content: str\n        | list[object]\n        | Iterable[\n            Union[\"OpenAIMessageContentListBlock\", \"ChatCompletionThinkingBlock\", \"ChatCompletionRedactedThinkingBlock\"]\n        ]\n        | None,\n        role: str,\n    ) -> list[dict[str, object]]:","sourceCodeStart":814,"sourceCodeEnd":850,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/completion_extras/litellm_responses_transformation/transformation.py#L814-L850","documentation":"_convert_image_url raises when an image content part yields no usable URL: the part is a dict whose 'url' key is missing or None (a bare string is accepted as-is). This happens while converting chat content blocks to Responses API input_image items.","triggerScenarios":"Sending content: [{'type': 'image_url', 'image_url': {}}] or {'image_url': {'detail': 'high'}} with no url; None url; base64 payloads built incorrectly so the url key is dropped.","commonSituations":"Dynamically assembling image parts where the URL fetch failed upstream; typos like 'imageUrl' or 'src' instead of 'url'; data-URL builders returning None on error.","solutions":["Ensure every image part has image_url.url set to an http(s) URL or a data: URL","Validate dynamic image parts before sending: skip or fail fast when the URL source returns None","Check for key typos ('src', 'imageUrl') when mapping from your own attachment model"],"exampleFix":"# before\ncontent = [\n  {\"type\": \"text\", \"text\": \"what is this?\"},\n  {\"type\": \"image_url\", \"image_url\": {\"detail\": \"high\"}},  # no url\n]\n\n# after\ncontent = [\n  {\"type\": \"text\", \"text\": \"what is this?\"},\n  {\"type\": \"image_url\", \"image_url\": {\"url\": image_src, \"detail\": \"high\"}},\n]","handlingStrategy":"validation","validationCode":"def image_parts_valid(content) -> bool:\n    if isinstance(content, str):\n        return True\n    for part in content or []:\n        if isinstance(part, dict) and part.get(\"type\") == \"image_url\":\n            url = (part.get(\"image_url\") or {}).get(\"url\")\n            if not url:\n                return False\n    return True","typeGuard":"def has_valid_image_url(part: dict) -> bool:\n    iu = part.get(\"image_url\")\n    return (isinstance(iu, str) and iu) or (isinstance(iu, dict) and isinstance(iu.get(\"url\"), str) and bool(iu[\"url\"]))","tryCatchPattern":null,"preventionTips":["Validate image parts at your input boundary before calling litellm","Fail fast when an upstream URL fetch returns None instead of building the part","Use data: URLs for local images; verify the key is exactly 'url'"],"tags":["vision","image-url","validation","transformation"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}