{"record":{"id":"488b643399a8d613","repo":"BerriAI/litellm","slug":"error-transforming-inpainting-params-e-got-par","errorCode":null,"errorMessage":"Error transforming inpainting params: {e}. Got params: {inpainting_params}, Expected params: {AmazonNovaCanvasInpaintingParams.__annotations__}","messagePattern":"Error transforming inpainting params: (.+?)\\. Got params: (.+?), Expected params: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/llms/bedrock/image_generation/amazon_nova_canvas_transformation.py","lineNumber":132,"sourceCode":"            try:\n                image_generation_config_typed = AmazonNovaCanvasImageGenerationConfig(**image_generation_config)\n            except Exception as e:\n                raise ValueError(\n                    f\"Error transforming image generation config: {e}. Got params: {image_generation_config}, Expected params: {AmazonNovaCanvasImageGenerationConfig.__annotations__}\"\n                )\n\n            return AmazonNovaCanvasColorGuidedRequest(\n                taskType=task_type,\n                colorGuidedGenerationParams=color_guided_generation_params_typed,\n                imageGenerationConfig=image_generation_config_typed,\n            )\n        if task_type == \"INPAINTING\":\n            inpainting_params: dict[str, Any] = image_generation_config.pop(\"inpaintingParams\", {})\n            inpainting_params = {\"text\": text, **inpainting_params}\n            try:\n                inpainting_params_typed: Final = AmazonNovaCanvasInpaintingParams(**inpainting_params)\n            except Exception as e:\n                raise ValueError(\n                    f\"Error transforming inpainting params: {e}. Got params: {inpainting_params}, Expected params: {AmazonNovaCanvasInpaintingParams.__annotations__}\"\n                )\n\n            try:\n                image_generation_config_typed = AmazonNovaCanvasImageGenerationConfig(**image_generation_config)\n            except Exception as e:\n                raise ValueError(\n                    f\"Error transforming image generation config: {e}. Got params: {image_generation_config}, Expected params: {AmazonNovaCanvasImageGenerationConfig.__annotations__}\"\n                )\n\n            return AmazonNovaCanvasInpaintingRequest(\n                taskType=task_type,\n                inpaintingParams=inpainting_params_typed,\n                imageGenerationConfig=image_generation_config_typed,\n            )\n        raise NotImplementedError(f\"Task type {task_type} is not supported\")\n\n    @classmethod","sourceCodeStart":114,"sourceCodeEnd":150,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/bedrock/image_generation/amazon_nova_canvas_transformation.py#L114-L150","documentation":"For INPAINTING via image generation (litellm.image with taskType='INPAINTING'), inpaintingParams gets 'text' injected and is constructed as AmazonNovaCanvasInpaintingParams(**params); unknown keys raise TypeError, wrapped in this ValueError with the raw dict and annotations. Annotated keys: text, maskImage, inputImage, negativeText.","triggerScenarios":"Passing 'mask_prompt' instead of a valid key, including an unknown key like 'mask' inside inpaintingParams, or a misspelled 'input_image' in a generation-path INPAINTING call — note this generation branch has no maskPrompt key (unlike the image-edit path).","commonSituations":"Confusing the image-edit API (which accepts mask=/maskPrompt) with the raw generation API (which wants base64 maskImage inside inpaintingParams); translating AWS SDK examples with renamed keys.","solutions":["Use annotated keys only: text, maskImage (base64), inputImage (base64), negativeText","For mask-prompt driven inpainting use litellm.image_edit with maskPrompt=, which builds this structure for you","Base64-encode mask and input images; never pass file objects or raw bytes here","Check the 'Got params' dict in the message for the offending key"],"exampleFix":"# before\nresp = litellm.image(\n    model=\"bedrock/amazon.nova-canvas-v1:0\",\n    prompt=\"fill with foliage\",\n    taskType=\"INPAINTING\",\n    inpaintingParams={\"mask_prompt\": \"the bench\", \"inputImage\": img_b64},\n)\n\n# after\nresp = litellm.image(\n    model=\"bedrock/amazon.nova-canvas-v1:0\",\n    prompt=\"fill with foliage\",\n    taskType=\"INPAINTING\",\n    inpaintingParams={\"maskImage\": mask_b64, \"inputImage\": img_b64},\n)","handlingStrategy":"validation","validationCode":"from litellm.types.llms.bedrock import AmazonNovaCanvasInpaintingParams\n\ndef validate_inpainting_generation_params(p: dict) -> None:\n    allowed = set(AmazonNovaCanvasInpaintingParams.__annotations__)\n    stray = set(p) - allowed\n    assert not stray, f\"unknown inpaintingParams keys: {stray}; allowed: {sorted(allowed)}\"\n    assert \"maskImage\" in p, \"generation-path INPAINTING needs base64 maskImage\"\n\nvalidate_inpainting_generation_params(inpainting_params)","typeGuard":"def is_valid_inpainting_generation_params(p: dict) -> bool:\n    \"\"\"True when keys match the TypedDict and a base64 maskImage is present.\"\"\"\n    from litellm.types.llms.bedrock import AmazonNovaCanvasInpaintingParams\n    allowed = set(AmazonNovaCanvasInpaintingParams.__annotations__)\n    return set(p) <= allowed and isinstance(p.get(\"maskImage\"), str)","tryCatchPattern":"try:\n    resp = litellm.image(...)\nexcept ValueError as e:\n    if \"Error transforming inpainting params\" in str(e):\n        raise UserInputError(\"inpaintingParams: use text/maskImage/inputImage/negativeText (base64)\") from e\n    raise","preventionTips":["Prefer litellm.image_edit(mask=..., maskPrompt=...) so LiteLLM builds valid inpainting bodies","Encode masks to base64 strings once and reuse","Never forward raw file objects or multipart tuples into generation-path inpaintingParams"],"tags":["bedrock","nova-canvas","image-generation","inpainting","typeddict","schema-validation"],"backgroundTag":"schema-validation-failed","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}