diff --git a/litellm/llms/minimax/image_generation/transformation.py b/litellm/llms/minimax/image_generation/transformation.py index 2bcdd7ba1ce..b151abe079c 100644 --- a/litellm/llms/minimax/image_generation/transformation.py +++ b/litellm/llms/minimax/image_generation/transformation.py @@ -24,7 +24,7 @@ Response format: Reference: https://platform.minimax.io/docs/api-reference/image-generation-t2i """ -from typing import TYPE_CHECKING, Any +from typing import TYPE_CHECKING import httpx @@ -45,7 +45,7 @@ if TYPE_CHECKING: LiteLLMLoggingObj = _LiteLLMLoggingObj else: - LiteLLMLoggingObj = Any + LiteLLMLoggingObj = object DEFAULT_API_BASE = "https://api.minimax.io" IMAGE_GENERATION_ENDPOINT = "/v1/image_generation" @@ -122,7 +122,7 @@ class MinimaxImageGenerationConfig(BaseImageGenerationConfig): base_url: str = api_base or get_secret_str("MINIMAX_API_BASE") or DEFAULT_API_BASE base_url = base_url.rstrip("/") if base_url.endswith(IMAGE_GENERATION_ENDPOINT): - base_url = base_url[: -len(IMAGE_GENERATION_ENDPOINT)] + base_url = base_url.removesuffix(IMAGE_GENERATION_ENDPOINT) if not base_url.endswith("/v1"): base_url = f"{base_url}/v1" return f"{base_url}/image_generation" @@ -187,7 +187,7 @@ class MinimaxImageGenerationConfig(BaseImageGenerationConfig): request_data: dict, optional_params: dict, litellm_params: dict, - encoding: Any, + encoding: object, api_key: str | None = None, json_mode: bool | None = None, ) -> ImageResponse: @@ -199,7 +199,7 @@ class MinimaxImageGenerationConfig(BaseImageGenerationConfig): """ try: response_data = raw_response.json() - except Exception as e: + except ValueError as e: raise self.get_error_class( error_message=f"Failed to parse MiniMax image generation response: {e}", status_code=raw_response.status_code, @@ -239,7 +239,7 @@ class MinimaxImageGenerationConfig(BaseImageGenerationConfig): ) @staticmethod - def _parse_size(size: Any) -> tuple[int | None, int | None]: + def _parse_size(size: object) -> tuple[int | None, int | None]: """ Parse an OpenAI `WxH` size string into width/height integers. diff --git a/tests/test_litellm/test_utils.py b/tests/test_litellm/test_utils.py index b23d3333ea7..f24b1325851 100644 --- a/tests/test_litellm/test_utils.py +++ b/tests/test_litellm/test_utils.py @@ -949,6 +949,7 @@ def test_aaamodel_prices_and_context_window_json_is_valid(): "/v1/realtime/transcription_sessions", "/v1/images/variations", "/v1/images/edits", + "/v1/image_generation", "/v1/batch", "/v1/audio/transcriptions", "/v1/audio/speech",