The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
Add test for gemini-2.5-flash-image-preview fix
Tim Elfrinkf5e6246143e0
diff --git a/tests/llm_translation/test_gemini.py b/tests/llm_translation/test_gemini.pyindex 8fcc85aba87..44f921536cf 100644--- a/tests/llm_translation/test_gemini.py+++ b/tests/llm_translation/test_gemini.py@@ -272,6 +272,67 @@ def test_gemini_image_generation():assert response.choices[0].message.images[0]["image_url"]["url"].startswith("data:image/png;base64,")+def test_gemini_2_5_flash_image_preview():+ """+ Test for GitHub issue #14120 - gemini-2.5-flash-image-preview model routing fix+ Validates that the model correctly routes to image generation instead of chat completion+ """+ from unittest.mock import patch, MagicMock+ from litellm.types.utils import ImageResponse, ImageObject++ # Mock successful response to avoid API limits+ mock_response = ImageResponse()+ mock_response.data = [ImageObject(b64_json="test_base64_data", url=None)]++ with patch("litellm.llms.custom_httpx.llm_http_handler.HTTPHandler.post") as mock_post:+ # Mock successful HTTP response+ mock_http_response = MagicMock()+ mock_http_response.json.return_value = {+ "candidates": [+ {+ "content": {+ "parts": [+ {+ "inline_data": {+ "data": "test_base64_image_data"+ }+ }+ ]+ }+ }+ ]+ }+ mock_http_response.status_code = 200+ mock_post.return_value = mock_http_response++ # Test that the function works without throwing the original 400 error+ response = litellm.image_generation(+ model="gemini/gemini-2.5-flash-image-preview",+ prompt="Generate a simple test image",+ api_key="test_api_key"+ )++ # Validate response structure+ assert response is not None+ assert hasattr(response, 'data')+ assert response.data is not None+ assert len(response.data) > 0++ # Validate the correct endpoint was called+ mock_post.assert_called_once()+ call_args = mock_post.call_args+ called_url = call_args[0][0] if call_args[0] else call_args.kwargs.get('url', '')++ # Verify it uses generateContent endpoint (not predict)+ assert ":generateContent" in called_url+ assert "gemini-2.5-flash-image-preview" in called_url++ # Verify request format is Gemini format (not Imagen)+ request_data = call_args.kwargs.get('json', {})+ assert "contents" in request_data+ assert "parts" in request_data["contents"][0]++def test_gemini_thinking():litellm._turn_on_debug()from litellm.types.utils import Message, CallTypes