feat(plugins): add Google image_gen backend (Imagen 4 + Gemini Flash Image)#19082
Open
ItachiDevv wants to merge 1 commit into
Open
feat(plugins): add Google image_gen backend (Imagen 4 + Gemini Flash Image)#19082ItachiDevv wants to merge 1 commit into
ItachiDevv wants to merge 1 commit into
Conversation
…Image) Adds plugins/image_gen/google/ as a third image-gen backend, mirroring the existing openai/ and xai/ plugins. Six models are exposed through one provider: - imagen-4.0-fast-generate-001 (default) - imagen-4.0-generate-001 - imagen-4.0-ultra-generate-001 - gemini-2.5-flash-image - gemini-3.1-flash-image-preview - gemini-3-pro-image-preview The plugin dispatches by endpoint shape: - Imagen models → :predict - Gemini-image models → :generateContent with responseModalities=["IMAGE"] Auth via GEMINI_API_KEY (preferred) or GOOGLE_API_KEY. Image-gen models require Tier 1 (paid) on the Gemini API project; the plugin surfaces the upstream "paid plan required" / quota errors verbatim. Selection precedence: 1. GOOGLE_IMAGE_MODEL env var 2. image_gen.google.model in config.yaml 3. DEFAULT_MODEL (imagen-4.0-fast-generate-001) 24 tests added covering availability, model resolution, both endpoint shapes (success/empty/api-error/timeout), aspect-ratio mapping, auth (query-param not URL/header), and registration. All sibling image_gen tests still pass (97 total). Refs: NousResearch#13798
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds a third image-gen backend at
plugins/image_gen/google/, mirroring the existingopenai/andxai/plugins. Six models exposed through one provider:imagen-4.0-fast-generate-001(default):predictimagen-4.0-generate-001:predictimagen-4.0-ultra-generate-001:predictgemini-2.5-flash-image:generateContentgemini-3.1-flash-image-preview:generateContentgemini-3-pro-image-preview:generateContentWhy
Resolves the "Google as image-gen provider" gap discussed in #13798. Closest existing options route through Composio's MCP middleware; this plugin uses a direct Gemini API key, matching the existing
openai/xaiplugin pattern.Auth
GEMINI_API_KEY(preferred) orGOOGLE_API_KEY. Image-gen requires Tier 1 (paid) on the project — the plugin surfaces the upstream "paid plan required" / quota errors verbatim.Selection precedence
GOOGLE_IMAGE_MODELenv varimage_gen.google.modelinconfig.yamlDEFAULT_MODEL(imagen-4.0-fast-generate-001)How to test
Output saves to
~/.hermes/cache/images/google_<model>_<ts>_<id>.png.Tests
24 tests in
tests/plugins/image_gen/test_google_provider.pycovering availability (withGEMINI_API_KEY,GOOGLE_API_KEYfallback, neither), model resolution (default, env override, unknown-fallback), both endpoint shapes (success / empty response / API error / timeout), aspect ratio mapping (landscape→16:9, portrait→9:16, square→1:1), auth correctness (key passed asparams={"key": ...}, never in URL or header), and registration viaregister(ctx).All 97 sibling image_gen tests still pass.
Platforms tested
Linux (Ubuntu 24.04 / WSL2). Plugin is pure-Python with
requests; no OS-specific paths or process logic.Refs: #13798