-
Notifications
You must be signed in to change notification settings - Fork 2.4k
feat: add Gemini provider support for image generation #7945
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your contribution! I've reviewed the changes and found some issues that need attention. The implementation looks solid overall, but there are critical issues with test coverage and model configuration that should be addressed.
Critical Issues:
- Missing test coverage - The existing test file only tests OpenRouter but doesn't include any tests for the new Gemini provider functionality.
- Model ID mismatch - The PR description mentions using gemini-2.0-flash-exp but the code uses gemini-2.5-flash-image-preview.
| // For Gemini, we can use the existing Gemini API key from the provider settings | ||
| // Check for a dedicated image generation API key first, then fall back to the provider's API key | ||
| apiKey = | ||
| state?.geminiImageApiKey || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fallback to the main Gemini API key is a nice touch for user convenience. However, could we add a comment here explaining this fallback behavior so future maintainers understand the logic?
- Create centralized image generation models configuration in types package - Implement generateImage() method in Gemini provider for text-to-image and image-to-image - Add provider dropdown in UI settings to switch between OpenRouter and Gemini - Update generateImageTool to route requests to appropriate provider - Add settings persistence for Gemini API key and model selection - Translate all new UI strings across 18 supported languages - Fix settings state management to properly handle new image generation settings
Address PR review feedback by using the correct Content type from the Gemini SDK for the contents array in generateImage method
The provider state was being updated inside the effect while also being included in the dependency array, which could cause unnecessary re-renders or potential infinite loops. Fixed by using a local newProvider variable to calculate the correct selected model before updating state.
d7a20fd to
71c2bcf
Compare
Review SummaryAll previously identified issues have been addressed or acknowledged:
Code Review Complete - No additional issues found. The implementation follows existing patterns, maintains type safety, and integrates cleanly with the codebase architecture. |
Summary
This PR adds support for the Gemini provider for image generation, allowing users to choose between OpenRouter and Gemini for generating images.
Changes
Features
Architecture
UI/UX
Internationalization
Settings Management
Testing
Breaking Changes
None - maintains full backward compatibility with existing OpenRouter integration