diff --git a/litellm/llms/modelslab/videos/transformation.py b/litellm/llms/modelslab/videos/transformation.py index da257c4f0d5..0f6c10a4448 100644 --- a/litellm/llms/modelslab/videos/transformation.py +++ b/litellm/llms/modelslab/videos/transformation.py @@ -179,6 +179,13 @@ class ModelsLabVideoConfig(BaseVideoConfig): response_data = self._poll_sync(request_id) status = response_data.get("status", "") + if status == "error": + raise BaseLLMException( + status_code=500, + message=response_data.get("message", "ModelsLab video generation failed"), + headers={}, + ) + if status == "success": output = response_data.get("output", []) output_url = output[0] if output else None diff --git a/tests/test_litellm/llms/modelslab/videos/test_modelslab_video_transformation.py b/tests/test_litellm/llms/modelslab/videos/test_modelslab_video_transformation.py index f392c79843d..9932ea83298 100644 --- a/tests/test_litellm/llms/modelslab/videos/test_modelslab_video_transformation.py +++ b/tests/test_litellm/llms/modelslab/videos/test_modelslab_video_transformation.py @@ -186,3 +186,30 @@ class TestModelsLabVideoTransformation: assert "req_789" in url assert "fetch" in url assert body["key"] == "test-api-key" + + def test_transform_video_create_response_poll_error_surfaces_message(self): + """When _poll_sync returns status=error, the actual error message is raised.""" + from litellm.llms.base_llm.chat.transformation import BaseLLMException + + mock_response = Mock(spec=httpx.Response) + mock_response.status_code = 200 + mock_response.headers = {} + mock_response.json.return_value = { + "status": "processing", + "request_id": "req_err", + } + + poll_result = { + "status": "error", + "message": "Insufficient credits", + } + + with patch.object(self.config, "_poll_sync", return_value=poll_result): + with pytest.raises(BaseLLMException) as exc_info: + self.config.transform_video_create_response( + model="i2vgen-xl", + raw_response=mock_response, + logging_obj=self.mock_logging_obj, + ) + + assert "Insufficient credits" in str(exc_info.value)