Skip to content

fix(vertex_ai): pass through native Gemini imageConfig params for image generation - #21585

Merged
Chesars merged 1 commit into
BerriAI:litellm_oss_staging_02_27_2026from
Chesars:fix/vertex-gemini-image-config-params
Feb 27, 2026
Merged

fix(vertex_ai): pass through native Gemini imageConfig params for image generation#21585
Chesars merged 1 commit into
BerriAI:litellm_oss_staging_02_27_2026from
Chesars:fix/vertex-gemini-image-config-params

Conversation

@Chesars

@Chesars Chesars commented Feb 19, 2026

Copy link
Copy Markdown
Contributor

Relevant issues

Fixes #21070

Pre-Submission checklist

  • I have Added testing in the tests/litellm/ directory, Adding at least 1 test is a hard requirement - see details
  • My PR passes all unit tests on make test-unit
  • My PR's scope is as isolated as possible, it only solves 1 specific problem
  • I have requested a Greptile review by commenting @greptileai and received a Confidence Score of at least 4/5 before requesting a maintainer review

Type

🐛 Bug Fix

Changes

aspectRatio and imageSize parameters were dropped when calling Vertex AI Gemini image generation models (gemini-3-pro-image-preview, gemini-2.5-flash-image).

Fix:

  • Added aspectRatio, aspect_ratio, imageSize, image_size to get_supported_openai_params() so they pass validation
  • Added explicit mapping in map_openai_params() to normalize snake_case variants to camelCase
  • 5 new unit tests covering both camelCase and snake_case variants

*Example

response = litellm.image_generation(
    model="vertex_ai/gemini-3-pro-image-preview",
    prompt="A landscape photo of mountains",
    aspectRatio="9:16",
    imageSize="4K",
)

After this fix, both params are correctly forwarded to the Gemini API

…ge generation

aspectRatio and imageSize were silently dropped because they weren't
listed in get_supported_openai_params(), so the validation layer filtered
them out before they could reach transform_image_generation_request().

Fixes BerriAI#21070
@vercel

vercel Bot commented Feb 19, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
litellm Ready Ready Preview, Comment Feb 19, 2026 6:42pm

Request Review

@greptile-apps

greptile-apps Bot commented Feb 19, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Fixed silently dropped aspectRatio and imageSize parameters when calling Vertex AI Gemini image generation models (gemini-3-pro-image-preview, gemini-2.5-flash-image).

Key changes:

  • Added aspectRatio, aspect_ratio, imageSize, image_size to supported parameters in get_supported_openai_params()
  • Added explicit mapping in map_openai_params() to normalize snake_case variants to camelCase
  • 5 new unit tests covering both camelCase and snake_case variants (all mock-only, no network calls)

The fix ensures these native Gemini parameters flow correctly through the validation and transformation pipeline to reach the Gemini API inside generationConfig.imageConfig.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The changes are isolated to Vertex AI Gemini image generation, add well-tested parameter mapping for native Gemini params, follow existing code patterns perfectly, include comprehensive unit tests with no network calls, and fix a genuine bug where parameters were silently dropped
  • No files require special attention

Important Files Changed

Filename Overview
litellm/llms/vertex_ai/image_generation/vertex_gemini_transformation.py Added support for aspectRatio and imageSize parameters in both camelCase and snake_case variants, properly mapping them through validation and transformation
tests/test_litellm/llms/vertex_ai/image_generation/test_vertex_ai_image_generation_transformation.py Added 5 comprehensive unit tests covering both camelCase and snake_case variants of new parameters, all tests are mock-only with no network calls

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[User calls litellm.image_generation with aspectRatio/imageSize] --> B[get_optional_params_image_gen]
    B --> C[Provider config detected: VertexAIGeminiImageGenerationConfig]
    C --> D[get_supported_openai_params validates parameters]
    D --> E{Parameter variant?}
    E -->|snake_case| F[map_openai_params normalizes to camelCase]
    E -->|camelCase| F
    F --> G[transform_image_generation_request]
    G --> H[Builds imageConfig in generationConfig]
    H --> I[Parameters sent to Vertex AI Gemini API]
Loading

Last reviewed commit: 155bed5

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@Chesars
Chesars changed the base branch from main to litellm_oss_staging_02_27_2026 February 27, 2026 20:39
@Chesars
Chesars merged commit 955bf90 into BerriAI:litellm_oss_staging_02_27_2026 Feb 27, 2026
6 of 21 checks passed
@Chesars
Chesars deleted the fix/vertex-gemini-image-config-params branch February 27, 2026 20:39
fzowl pushed a commit to fzowl/litellm that referenced this pull request Jun 24, 2026
…-config-params

fix(vertex_ai): pass through native Gemini imageConfig params for image generation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: vertex_ai Gemini Image Generation: imageConfig parameters (imageSize, aspectRatio) are completely ignored

1 participant