{"record":{"id":"4dcf6ebadcb651ac","repo":"BerriAI/litellm","slug":"image-response-must-be-of-type-imageresponse-got","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/runwayml/cost_calculator.py","lineNumber":28,"sourceCode":") -> float:\n    \"\"\"\n    RunwayML image generation cost calculator.\n\n    RunwayML charges per image generated, not per pixel.\n    Pricing is stored in model_prices_and_context_window.json with output_cost_per_image.\n    \"\"\"\n    _model_info: Final = litellm.get_model_info(\n        model=model,\n        custom_llm_provider=litellm.LlmProviders.RUNWAYML.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":10,"sourceCodeEnd":29,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/runwayml/cost_calculator.py#L10-L29","documentation":"Type guard in the RunwayML cost calculator: pricing is per generated image, but the object passed as image_response is not an ImageResponse instance (wrong shape from a nonstandard handler), so num_images cannot be determined.","triggerScenarios":"Triggered when the RunwayML cost calculator receives an image_response that is not an ImageResponse instance.","commonSituations":"See trigger scenarios.","solutions":["Internal type check failed; pass the ImageResponse returned by litellm rather than a custom object.","If reached from a public call, report it to the litellm issue tracker."],"exampleFix":"# use litellm.image_generation output directly for cost tracking.","handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}