diff --git a/litellm/llms/bedrock/image/cost_calculator.py b/litellm/llms/bedrock/image/cost_calculator.py index 0a20b44cb38..a0dc91d7119 100644 --- a/litellm/llms/bedrock/image/cost_calculator.py +++ b/litellm/llms/bedrock/image/cost_calculator.py @@ -37,5 +37,7 @@ def cost_calculator( ) output_cost_per_image: float = _model_info.get("output_cost_per_image") or 0.0 - num_images: int = len(image_response.data) + num_images: int = 0 + if image_response.data: + num_images = len(image_response.data) return output_cost_per_image * num_images diff --git a/litellm/llms/vertex_ai/image_generation/cost_calculator.py b/litellm/llms/vertex_ai/image_generation/cost_calculator.py index 2ba18c095bd..646c6080a2e 100644 --- a/litellm/llms/vertex_ai/image_generation/cost_calculator.py +++ b/litellm/llms/vertex_ai/image_generation/cost_calculator.py @@ -19,5 +19,7 @@ def cost_calculator( ) output_cost_per_image: float = _model_info.get("output_cost_per_image") or 0.0 - num_images: int = len(image_response.data) + num_images: int = 0 + if image_response.data: + num_images = len(image_response.data) return output_cost_per_image * num_images diff --git a/litellm/responses/litellm_completion_transformation/transformation.py b/litellm/responses/litellm_completion_transformation/transformation.py index 5812daad462..baffca3ac68 100644 --- a/litellm/responses/litellm_completion_transformation/transformation.py +++ b/litellm/responses/litellm_completion_transformation/transformation.py @@ -457,8 +457,8 @@ class LiteLLMCompletionResponsesConfig: function=ChatCompletionToolParamFunctionChunk( name=tool["name"], description=tool.get("description") or "", - parameters=tool.get("parameters", {}), - strict=tool.get("strict", False), + parameters=dict(tool.get("parameters", {}) or {}), + strict=tool.get("strict", False) or False, ), ) ) diff --git a/litellm/types/utils.py b/litellm/types/utils.py index 5d4b20bdb0d..89a766de05c 100644 --- a/litellm/types/utils.py +++ b/litellm/types/utils.py @@ -1567,7 +1567,7 @@ class ImageUsage(BaseLiteLLMOpenAIResponseObject): from openai.types.images_response import ImagesResponse as OpenAIImageResponse -class ImageResponse(OpenAIImageResponse, BaseLiteLLMOpenAIResponseObject): +class ImageResponse(BaseLiteLLMOpenAIResponseObject): _hidden_params: dict = {} usage: ImageUsage @@ -1609,7 +1609,12 @@ class ImageResponse(OpenAIImageResponse, BaseLiteLLMOpenAIResponseObject): output_tokens=0, total_tokens=0, ) - super().__init__(created=created, data=_data, usage=_usage) # type: ignore + + ####################### + self.created = created + self.data = _data + self.usage = _usage + ####################### self._hidden_params = hidden_params or {} def __contains__(self, key):