{"record":{"id":"f49555bb974ed1f0","repo":"BerriAI/litellm","slug":"nova-canvas-image-edit-requires-an-image-input","errorCode":null,"errorMessage":"Nova Canvas image edit requires an image input","messagePattern":"Nova Canvas image edit requires an image input","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/llms/bedrock/image_edit/amazon_nova_canvas_image_edit_transformation.py","lineNumber":134,"sourceCode":"        return {\"taskType\": \"INPAINTING\", \"inPaintingParams\": in_params}\n    var_params: Final[dict[str, Any]] = {\n        \"images\": [image_b64],\n        \"text\": text,\n    }\n    if negative_text is not None:\n        var_params[\"negativeText\"] = negative_text\n    if similarity_strength is not None:\n        var_params[\"similarityStrength\"] = similarity_strength\n    return {\n        \"taskType\": \"IMAGE_VARIATION\",\n        \"imageVariationParams\": var_params,\n    }\n\n\ndef _file_types_to_b64(image: FileTypes | None) -> str:\n    \"\"\"Encode OpenAI image input to base64 string for Nova Canvas.\"\"\"\n    if image is None:\n        raise ValueError(\"Nova Canvas image edit requires an image input\")\n    if hasattr(image, \"read\") and callable(getattr(image, \"read\", None)):\n        if hasattr(image, \"seek\"):\n            image.seek(0)\n        image_bytes: Final = image.read()\n        return base64.b64encode(image_bytes).decode(\"utf-8\")\n    if isinstance(image, bytes):\n        return base64.b64encode(image).decode(\"utf-8\")\n    if isinstance(image, str):\n        return image\n    if isinstance(image, os.PathLike):\n        with open(image, \"rb\") as f:\n            return base64.b64encode(f.read()).decode(\"utf-8\")\n    if isinstance(image, tuple):\n        raise ValueError(\n            \"Nova Canvas image edit does not support tuple FileTypes. \"\n            \"Pass a file-like object, bytes, or a base64-encoded string.\"\n        )\n    return base64.b64encode(bytes(image)).decode(\"utf-8\")","sourceCodeStart":116,"sourceCodeEnd":152,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/bedrock/image_edit/amazon_nova_canvas_image_edit_transformation.py#L116-L152","documentation":"Every Nova Canvas image edit fundamentally needs a source image. The helper _file_types_to_b64 encodes the OpenAI image input to base64 and raises ValueError when image is None, i.e. the request reached transformation without any image payload.","triggerScenarios":"POST /v1/images/edits on a nova-canvas model with no 'image' file part (only prompt), or litellm.image_edit(image=None) / empty list; also when a gateway drops the multipart image field.","commonSituations":"Client code written for DALL-E-style prompt-only edits; sending image as a JSON field instead of multipart file; test harness that omits fixtures.","solutions":["Include the source image as the 'image' file part of the multipart images/edits request.","Acceptable forms: file-like object, raw bytes, base64 string, or os.PathLike path (tuples are rejected separately).","If you meant generation from text only, call /v1/images/generations instead."],"exampleFix":"# before\nlitellm.image_edit(model=\"bedrock/nova-canvas\", prompt=\"a cat\")  # no image\n# after\nwith open(\"cat.png\", \"rb\") as f:\n    litellm.image_edit(model=\"bedrock/nova-canvas\", prompt=\"a cat\", image=f)","handlingStrategy":"type-guard","validationCode":"def has_image(image) -> bool:\n    return image is not None and image != []","typeGuard":"def is_usable_nova_image(v: object) -> bool:\n    import os\n    return (\n        v is not None\n        and (hasattr(v, \"read\") or isinstance(v, (bytes, str, os.PathLike)))\n    )","tryCatchPattern":null,"preventionTips":["Make the image argument required in internal wrappers around images/edits.","Assert the multipart request contains an 'image' file part before sending.","Use /images/generations for prompt-only workflows."],"tags":["bedrock","nova-canvas","image-edit","validation","input-missing"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}