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
feat: Add imageConfig parameter for gemini-2.5-flash-image (#15530)
wangjifeng8cbaec031011
diff --git a/litellm/types/llms/vertex_ai.py b/litellm/types/llms/vertex_ai.pyindex f1f7ac2c661..cb2075981a8 100644--- a/litellm/types/llms/vertex_ai.py+++ b/litellm/types/llms/vertex_ai.py@@ -178,6 +178,10 @@ class GeminiThinkingConfig(TypedDict, total=False):GeminiResponseModalities = Literal["TEXT", "IMAGE", "AUDIO", "VIDEO"]+GeminiImageAspectRatio = Literal["1:1", "2:3", "3:2", "3:4", "4:3", "9:16", "16:9", "21:9"]++class GeminiImageConfig(TypedDict, total=False):+ aspectRatio: GeminiImageAspectRatioclass PrebuiltVoiceConfig(TypedDict):voiceName: str@@ -206,6 +210,7 @@ class GenerationConfig(TypedDict, total=False):responseLogprobs: boollogprobs: intresponseModalities: List[GeminiResponseModalities]+ imageConfig: GeminiImageConfigthinkingConfig: GeminiThinkingConfigdiff --git a/tests/litellm/llms/vertex_ai/gemini/test_transformation.py b/tests/litellm/llms/vertex_ai/gemini/test_transformation.pyindex 7fd528f1693..139df0d6f09 100644--- a/tests/litellm/llms/vertex_ai/gemini/test_transformation.py+++ b/tests/litellm/llms/vertex_ai/gemini/test_transformation.py@@ -117,3 +117,39 @@ async def test__transform_request_body_labels_and_metadata():# Check URLassert rb["contents"] == [{'parts': [{'text': 'hi'}], 'role': 'user'}, {'parts': [{'text': 'Hello! How can I assist you today?'}], 'role': 'model'}, {'parts': [{'text': 'hi'}], 'role': 'user'}]assert "labels" in rb and rb["labels"] == {"lparam1": "lvalue1", "lparam2": "lvalue2"}++async def test__transform_request_body_image_config():+ """+ Test that Vertex AI Gemini supports the imageConfig parameter for gemini-2.5-flash-image model.+ """+ model = "gemini-2.5-flash-image"+ messages = [+ {+ "role": "user",+ "content": [+ {+ "type": "text",+ "text": "Create a picture of a nano banana dish in a fancy restaurant with a Gemini theme"+ }+ ]+ }+ ]+ optional_params = {+ "imageConfig": {"aspectRatio": "16:9"},+ "responseModalities": ["Image"]+ }+ litellm_params = {}+ transform_request_params = {+ "messages": messages,+ "model": model,+ "optional_params": optional_params,+ "custom_llm_provider": "gemini",+ "litellm_params": litellm_params,+ "cached_content": None,+ }++ rb: RequestBody = transformation._transform_request_body(**transform_request_params)++ assert "imageConfig" in rb+ assert rb["imageConfig"] == {"aspectRatio": "16:9"}\ No newline at end of file