BerriAI/litellm · error · ValueError
Error in response object format, got None
Error message
Error in response object format, got None
What it means
After a successful HTTP response, litellm calls response.json() and checks the result: if parsing yields None (e.g. body was the literal string 'null' or an empty/invalid JSON body), it raises ValueError('Error in response object format, got None') before transforming to the OpenAI image response shape.
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 6c2dcb801b)
Solutions
- Enable verbose logging (litellm.verbose = True or set litellm.set_verbose) and inspect 'raw model_response' to see what body actually arrived.
- Bypass the proxy/intermediary and call Bedrock directly to confirm where the empty body originates.
- Retry the request — empty 200 bodies are usually transient infrastructure faults.
- If reproducible with a direct AWS call, report to litellm with the raw response; otherwise fix the intermediary (proxy timeouts, buffering).
Defensive patterns
Strategy: fallback
Try / catch
try:
resp = litellm.image_generation(model=model, prompt=p)
except ValueError as e:
if "got None" in str(e):
log.error("Empty/null body from Bedrock — retrying once")
return litellm.image_generation(model=model, prompt=p) # usually transient
raise Prevention
- Enable litellm verbose logging to capture the raw response text when this fires.
- If behind a proxy, verify it does not truncate/empty 200 bodies.
- Alert on frequency — recurring empty bodies indicate infra faults, not bad requests.
When it happens
Trigger: Bedrock returning a 200 with an empty body or 'null' body — seen with some proxy setups, API gateways, or truncated responses — while model/response parsing expects a JSON object.
Common situations: Self-hosted proxies (LiteLLM proxy chains, nginx) stripping bodies, gateway timeouts returning empty 200s, or a provider bug returning null JSON for failed generations.
Related errors
- Error parsing initial response: {e}
- Error parsing BFL response: {e}
- Error parsing BFL response: {e}
- Invalid JSON response: {raw_response.text}
- Failed to parse OCI embed response as JSON: {e}
AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15).
Data as JSON: /api/errors/6e89e82e5a7a81f9.
Report an issue: GitHub.