BerriAI/litellm · error · ValueError

image_response must be of type ImageResponse got type={type(

Error message

image_response must be of type ImageResponse got type={type(image_response)}

What it means

Error "image_response must be of type ImageResponse got type={type(image_response)}" thrown in BerriAI/litellm.

Source

Thrown at litellm/llms/aiml/image_generation/cost_calculator.py:25

def cost_calculator(
    model: str,
    image_response: Any,
) -> float:
    """
    AI/ML flux image generation cost calculator
    """
    _model_info: Final = litellm.get_model_info(
        model=model,
        custom_llm_provider=litellm.LlmProviders.AIML.value,
    )
    output_cost_per_image: Final[float] = _model_info.get("output_cost_per_image") or 0.0
    num_images: int = 0
    if isinstance(image_response, ImageResponse):
        if image_response.data:
            num_images = len(image_response.data)
        return output_cost_per_image * num_images
    else:
        raise ValueError(f"image_response must be of type ImageResponse got type={type(image_response)}")

View on GitHub (pinned to 6c2dcb801b)

Solutions

  1. Pass an ImageResponse object to the AIML image cost calculator.

When it happens

Trigger: Thrown at litellm/llms/aiml/image_generation/cost_calculator.py:25 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15). Data as JSON: /api/errors/2df6a469e09cbb3c. Report an issue: GitHub.