feat: add image generation support (gemini-3.1-flash-image)#521
feat: add image generation support (gemini-3.1-flash-image)#521bentcc wants to merge 1 commit intoNoeFabris:mainfrom
Conversation
…lags, and nanobanana output - Add antigravity-gemini-3-pro-image and antigravity-gemini-3.1-flash-image model definitions - Per-model aspect ratio validation (flash supports 1:4, 4:1, 1:8, 8:1; pro does not) - Per-model imageSize validation (flash supports 0.5K; pro does not) - Parse --resolution and --aspect-ratio flags from prompt text (stripped before sending to Gemini) - Prompt flag overrides take priority over env vars (OPENCODE_IMAGE_SIZE, OPENCODE_IMAGE_ASPECT_RATIO) - Change image output directory from ~/.opencode/generated-images/ to ./nanobanana/ - Flash-image thinking support (minimal/high) - Update README with image model config and usage docs
|
Caution Review failedThe pull request is closed. ℹ️ Recent review infoConfiguration used: Repository UI Review profile: CHILL Plan: Pro Cache: Disabled due to data retention organization setting Knowledge base: Disabled due to data retention organization setting ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (13)
WalkthroughThis PR adds support for a new image generation model ( Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes 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. Comment |
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Files Reviewed (14 files)
SummaryThis PR adds support for the new gemini-3.1-flash-image model with thinking capabilities (minimal/high tiers), along with a prompt flag system ( Key Changes:
The implementation follows existing codebase patterns and includes proper error handling for invalid parameters. |
Greptile SummaryThis PR adds comprehensive image generation support for Key changes:
Minor issue found:
Confidence Score: 4/5
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[User Prompt with Flags] --> B{Is Image Model?}
B -->|No| C[Standard Request Flow]
B -->|Yes| D[Extract Last User Prompt]
D --> E[Parse Flags with parsePromptFlags]
E --> F[Extract --resolution & --aspect-ratio]
F --> G[Strip Flags from Prompt]
G --> H{Flags Found?}
H -->|Yes| I[Create Overrides Object]
H -->|No| J[No Overrides]
I --> K[buildImageGenerationConfig with model + overrides]
J --> K
K --> L{Is Flash Image Model?}
L -->|Yes| M[Use Flash Config: 0.5K, 4:1, 8:1, thinking]
L -->|No| N[Use Base Config: 1K-4K, standard ratios]
M --> O[Validate & Build imageConfig]
N --> O
O --> P{Flash + Thinking Tier?}
P -->|Yes| Q[Add thinkingConfig: minimal/high]
P -->|No| R[Remove thinkingConfig]
Q --> S[Send Request to Gemini API]
R --> S
S --> T[Save Image to ./nanobanana/]
Last reviewed commit: 22ad11b |
| it("returns false for gemini-2.5-flash-image", () => { | ||
| // 2.5 flash image is not a gemini-3 flash image model | ||
| expect(isFlashImageModel("gemini-2.5-flash-image")).toBe(true); |
There was a problem hiding this comment.
Test name says "returns false" but expects true — contradicts the comment saying gemini-2.5-flash-image is "not a gemini-3 flash image model"
| it("returns false for gemini-2.5-flash-image", () => { | |
| // 2.5 flash image is not a gemini-3 flash image model | |
| expect(isFlashImageModel("gemini-2.5-flash-image")).toBe(true); | |
| it("returns true for gemini-2.5-flash-image", () => { | |
| // 2.5 flash image matches the flash.*image pattern | |
| expect(isFlashImageModel("gemini-2.5-flash-image")).toBe(true); |
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/plugin/transform/gemini.test.ts
Line: 648-650
Comment:
Test name says "returns false" but expects `true` — contradicts the comment saying `gemini-2.5-flash-image` is "not a gemini-3 flash image model"
```suggestion
it("returns true for gemini-2.5-flash-image", () => {
// 2.5 flash image matches the flash.*image pattern
expect(isFlashImageModel("gemini-2.5-flash-image")).toBe(true);
```
How can I resolve this? If you propose a fix, please make it concise.
Summary
antigravity-gemini-3.1-flash-imagemodel definition with per-model validation for aspect ratios and image sizes--resolutionand--aspect-ratioprompt flags that are parsed from user input and stripped before sending to Gemini~/.opencode/generated-images/to./nanobanana/(relative toprocess.cwd())gemini-3-pro-imagereferences (model was removed by Google from Antigravity — returns 404)Details
New model:
antigravity-gemini-3.1-flash-imageminimal(default) andhighvariants4:1,8:1) and image size0.5K(flash-only)Prompt flags
Users can inline
--resolution=4Kand--aspect-ratio=16:9in their prompt text. Flags are extracted, validated per-model, and stripped before the prompt reaches Gemini. Priority: prompt flags > env vars (OPENCODE_IMAGE_SIZE,OPENCODE_IMAGE_ASPECT_RATIO) > defaults.Per-model validation
4:1,8:1) and0.5Kimage sizeFiles changed (14 files, +805 / -53)
models.ts— flash-image model definition added, pro-image removedgemini.ts—buildImageGenerationConfig()now accepts model + overrides, per-model validation viagetValidAspectRatios()/getValidImageSizes()prompt-flags.ts(new) — parses--resolutionand--aspect-ratiofrom prompt textmodel-resolver.ts— flash-image thinking support (minimal/high), pro-image cleanuprequest.ts— integrates prompt flag parsing into image pipeline, flash-image thinking configimage-saver.ts— output dir changed to./nanobanana/index.ts— barrel exports for new modulesREADME.md— model table, JSON config, usage examples with flag documentationTest Plan
npm run buildcompiles cleanlynpm run typecheckpassesAttribution
All code in this PR was written by Claude Opus 4.6 (Anthropic), pair-programmed with a human operator via OpenCode.