BerriAI/litellm · error · ValueError
Error in response object format, got None
Error message
Error in response object format, got None
What it means
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.
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)
Defensive patterns
Strategy: try-catch
Try / catch
try:
resp = litellm.image(model=model, prompt=prompt)
except ValueError as e:
if "Error in response object format" in str(e):
log.error("bedrock returned 2xx with null body; check gateway/api_base")
raise Prevention
- 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
When it happens
Trigger: 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.
Common situations: Custom api_base pointing at a corporate gateway that returns null on success, model/router misconfiguration, behavior changes after upstream updates.
Related errors
- AgentCore: Failed to read/parse JSON response body
- completion_response must be of type ImageResponse for…
- err.response.text
- Error in response object format, got None
- Error parsing BFL response
AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18).
Data as JSON: /api/errors/6e89e82e5a7a81f9.
Report an issue: GitHub.
Appendix: source
Thrown at litellm/llms/bedrock/image_generation/image_handler.py:324
response: httpx.Response,
data: dict,
) -> ImageResponse:
"""
Transforms the Image Generation response from Bedrock to OpenAI format
"""
## LOGGING
if logging_obj is not None:
logging_obj.post_call(
input=prompt,
api_key="",
original_response=response.text,
additional_args={"complete_input_dict": data},
)
verbose_logger.debug("raw model_response: %s", response.text)
response_dict: Final = response.json()
if response_dict is None:
raise ValueError("Error in response object format, got None")
config_class: Final = self.get_config_class(model=model)
config_class.transform_response_dict_to_openai_response(
model_response=model_response,
response_dict=response_dict,
)
return model_response
View on GitHub (pinned to 77b7c6c40c)