Skip to content

Revert "fix: gemini image correct generationConfig" - #2336

Merged
Calcium-Ion merged 1 commit into
mainfrom
revert-2309-pr/fix-gemini-ImageConfig
Nov 30, 2025
Merged

Calcium-Ion merged 1 commit into
mainfrom
revert-2309-pr/fix-gemini-ImageConfig

Conversation

@seefs001

@seefs001 seefs001 commented Nov 30, 2025 •

Copy link
Copy Markdown
Collaborator

Reverts #2309

Summary by CodeRabbit

Release Notes

  • Bug Fixes

    • Updated Gemini API request formatting to align with current API specifications for improved compatibility and reliability.
  • Chores

    • Streamlined Gemini integration configuration for enhanced request handling.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai

coderabbitai Bot commented Nov 30, 2025 •

Copy link
Copy Markdown
Contributor

Walkthrough

The pull request updates Gemini API integration by converting parameter names from camelCase to snake_case, removing Gemini 2.5 and preview model size mappings, and consolidating generation config handling by removing separate extra_body marshaling logic.

Changes

Cohort / File(s) Summary
API parameter naming and request structure
relay/channel/gemini/adaptor.go
Converted Google API request parameters to snake_case (responseModalities, imageConfig, generationConfig), nested google.generation_config under google in request payload, and adjusted Gemini 3 Pro size mappings by clearing AspectRatio values.
Generation config handling
relay/channel/gemini/relay-gemini.go
Removed marshaling and unmarshaling logic for extra_body.google.generationConfig in CovertOpenAI2Gemini function, eliminating the separate code path for applying GenerationConfig from request extra_body.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~15–20 minutes

  • API parameter naming consistency across both files requires verification that snake_case naming matches Gemini API specifications
  • Removal of GenerationConfig extra_body handling should be validated to ensure no functionality regression
  • Size mapping changes and AspectRatio modifications may impact image generation capabilities for Gemini 3 Pro and earlier model versions

Possibly related PRs

Suggested reviewers

  • creamlike1024

Poem

🐰 Snake_case hops where camelCase once trod,
Size mappings trimmed, configurations nod,
Gemini paths converge and clarify,
API requests streamlined—no need to sigh! ✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: reverting a previous fix related to Gemini image generationConfig handling, which aligns with the file modifications removing generationConfig handling logic.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch revert-2309-pr/fix-gemini-ImageConfig

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8d0827c and e337936.

📒 Files selected for processing (2)
  • relay/channel/gemini/adaptor.go (2 hunks)
  • relay/channel/gemini/relay-gemini.go (0 hunks)
💤 Files with no reviewable changes (1)
  • relay/channel/gemini/relay-gemini.go
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: RedwindA
Repo: QuantumNous/new-api PR: 1537
File: relay/gemini_handler.go:330-342
Timestamp: 2025-08-08T17:12:43.157Z
Learning: In the new-api repository, the `GeminiEmbeddingHandler` function in `relay/gemini_handler.go` is designed specifically for native Gemini embedding requests and therefore does not require the `ConvertGeminiRequest` step that is used in the chat handler. The embedding requests are already in the native Gemini format and don't need conversion.
📚 Learning: 2025-08-08T17:12:43.157Z
Learnt from: RedwindA
Repo: QuantumNous/new-api PR: 1537
File: relay/gemini_handler.go:330-342
Timestamp: 2025-08-08T17:12:43.157Z
Learning: In the new-api repository, the `GeminiEmbeddingHandler` function in `relay/gemini_handler.go` is designed specifically for native Gemini embedding requests and therefore does not require the `ConvertGeminiRequest` step that is used in the chat handler. The embedding requests are already in the native Gemini format and don't need conversion.

Applied to files:

  • relay/channel/gemini/adaptor.go
🔇 Additional comments (2)
relay/channel/gemini/adaptor.go (2)

94-95: Verify the removal of AspectRatio for square resolutions.

The size mappings for "2048x2048" and "4096x4096" now have an empty AspectRatio (previously would have been "1:1" for square images) while retaining ImageSize values of "2K" and "4K". This appears to prioritize resolution-based sizing over aspect ratio for these specific sizes.

Ensure this behavior aligns with the Gemini API's handling of square high-resolution images and that the API doesn't require an explicit aspect ratio even when only imageSize is specified.


168-174: Parameter format is correct per Gemini API specification.

The snake_case parameters (response_modalities, image_config, generation_config) match the official Google Gemini API JSON/REST request format. This change aligns with API requirements and will function correctly.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Calcium-Ion
Calcium-Ion merged commit a66b314 into main Nov 30, 2025
@Calcium-Ion
Calcium-Ion deleted the revert-2309-pr/fix-gemini-ImageConfig branch January 29, 2026 17:10
ennnnny pushed a commit to ennnnny/new-api that referenced this pull request Mar 17, 2026
…ix-gemini-ImageConfig

Revert "fix: gemini image correct generationConfig"
salem-2007 added a commit to salem-2007/new-api that referenced this pull request Sep 10, 2026
…ix-gemini-ImageConfig

Revert "fix: gemini image correct generationConfig"
junjundesk pushed a commit to junjundesk/new-api that referenced this pull request Oct 3, 2026
…ix-gemini-ImageConfig

Revert "fix: gemini image correct generationConfig"
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.

2 participants