{"record":{"id":"4c6e72fe76240ae5","repo":"BerriAI/litellm","slug":"image-response-must-be-of-type-imageresponse-got-t-4c6e72","errorCode":null,"errorMessage":"image_response must be of type ImageResponse got type={type(image_response)}","messagePattern":"image_response must be of type ImageResponse got type=(.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/llms/cometapi/image_generation/cost_calculator.py","lineNumber":25,"sourceCode":"def cost_calculator(\n    model: str,\n    image_response: Any,\n) -> float:\n    \"\"\"\n    CometAPI image generation cost calculator\n    \"\"\"\n    _model_info: Final = litellm.get_model_info(\n        model=model,\n        custom_llm_provider=litellm.LlmProviders.COMETAPI.value,\n    )\n    output_cost_per_image: Final[float] = _model_info.get(\"output_cost_per_image\") or 0.0\n    num_images: int = 0\n    if isinstance(image_response, ImageResponse):\n        if image_response.data:\n            num_images = len(image_response.data)\n        return output_cost_per_image * num_images\n    else:\n        raise ValueError(f\"image_response must be of type ImageResponse got type={type(image_response)}\")\n","sourceCodeStart":7,"sourceCodeEnd":26,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/cometapi/image_generation/cost_calculator.py#L7-L26","documentation":"Error \"image_response must be of type ImageResponse got type={type(image_response)}\" thrown in BerriAI/litellm.","triggerScenarios":"Thrown at litellm/llms/cometapi/image_generation/cost_calculator.py:25 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass an ImageResponse object to the CometAPI image cost calculator."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}