{"record":{"id":"6e89e82e5a7a81f9","repo":"BerriAI/litellm","slug":"error-in-response-object-format-got-none-6e89e8","errorCode":null,"errorMessage":"Error in response object format, got None","messagePattern":"Error in response object format, got None","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/llms/bedrock/image_generation/image_handler.py","lineNumber":324,"sourceCode":"        response: httpx.Response,\n        data: dict,\n    ) -> ImageResponse:\n        \"\"\"\n        Transforms the Image Generation response from Bedrock to OpenAI format\n        \"\"\"\n\n        ## LOGGING\n        if logging_obj is not None:\n            logging_obj.post_call(\n                input=prompt,\n                api_key=\"\",\n                original_response=response.text,\n                additional_args={\"complete_input_dict\": data},\n            )\n        verbose_logger.debug(\"raw model_response: %s\", response.text)\n        response_dict: Final = response.json()\n        if response_dict is None:\n            raise ValueError(\"Error in response object format, got None\")\n\n        config_class: Final = self.get_config_class(model=model)\n\n        config_class.transform_response_dict_to_openai_response(\n            model_response=model_response,\n            response_dict=response_dict,\n        )\n\n        return model_response\n","sourceCodeStart":306,"sourceCodeEnd":334,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/bedrock/image_generation/image_handler.py#L306-L334","documentation":"In _transform_response_dict_to_openai_response the Bedrock image response body is parsed with response.json(); if the parsed value is None (body was 'null', empty, or not a JSON object), LiteLLM raises ValueError. It means Bedrock (or whatever answered at api_base) returned a 2xx response whose JSON body is null rather than an image payload. The raw body is debug-logged via verbose_logger before the check, which helps diagnosis.","triggerScenarios":"Bedrock image call returns HTTP 200 with a null or empty JSON body: seen with gateways/proxies at a custom api_base that mis-handle the response, truncated responses, or routing a non-image model to the image generation API.","commonSituations":"Custom api_base pointing at a corporate gateway that returns null on success, model/router misconfiguration, behavior changes after upstream updates.","solutions":["Enable litellm debug logging to capture the raw response.text just before the failure","If a gateway or proxy is in the path, reproduce the same request against real Bedrock to isolate it","Verify the model actually supports the image generation API you invoked (e.g. it is a Nova Canvas / Stability image model)"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    resp = litellm.image(model=model, prompt=prompt)\nexcept ValueError as e:\n    if \"Error in response object format\" in str(e):\n        log.error(\"bedrock returned 2xx with null body; check gateway/api_base\")\n    raise","preventionTips":["Enable litellm verbose/debug logging in image pipelines to capture the raw body on failure","Smoke-test custom api_base gateways with the image endpoint before relying on them","Route only genuine image models through the image generation API"],"tags":["bedrock","image-generation","response-parsing"],"backgroundTag":"empty-response-body","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}