fix: move image generation off the shut-down Gemini model - #86
Closed
jsnapoli1 wants to merge 1 commit into
Closed
Conversation
/api/admin/ai/generate-image calls gemini-2.5-flash-image-preview, which
Google shut down on 2026-01-15. Every request to it now fails, so AI
image generation is broken for any store using this feature.
Switches to gemini-3.1-flash-image ("Nano Banana 2"), the replacement
Google names for that model. It is GA with no announced shutdown date,
and supports the reference images this endpoint already sends (10 object
/ 4 character / 3 style, against the 4 the UI allows).
The model is now overridable via GEMINI_IMAGE_MODEL so a store can move
to a cheaper option such as gemini-3.1-flash-lite-image, or to a newer
model, without waiting on a release.
generateContent remains fully supported, so this is a model-id change
rather than an API migration.
Claude-Session: https://claude.ai/code/session_015XLFFfHWNeazSuz6UcsQ4C
This was referenced Sep 2, 2026
Author
|
Superseded by #89, which moves image generation onto a provider abstraction (Gemini direct or OpenRouter) rather than only swapping the model id. #89 covers everything here — the shut-down Since opening this, the Gemini path in #89 has been verified end-to-end against a live deployment: real images generated, stored, and attached to products. |
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.
Problem
POST /api/admin/ai/generate-imagecallsgemini-2.5-flash-image-preview. Google shut that model down on 2026-01-15, so every request to it now fails — AI image generation is broken for any store using the feature.Source: Gemini API deprecations lists
gemini-2.5-flash-image-previewwith shutdown date "January 15, 2026".Fix
Switches to
gemini-3.1-flash-image("Nano Banana 2"):Also adds
GEMINI_IMAGE_MODELas an override, so a store can switch to a cheaper model (e.g.gemini-3.1-flash-lite-image) or a newer one without waiting on a release.generateContentremains fully supported, so this is a model-id change, not an API migration.Cost
Per 1K image, from Gemini API pricing:
gemini-2.5-flash-image-previewgemini-3.1-flash-imagegemini-3.1-flash-lite-imagegemini-3-pro-imageThe old
gemini-2.5-flash-image(still alive, but a dead end) was $0.039, so the default is ~1.7× more expensive.gemini-3.1-flash-lite-imageat $0.034 is cheaper than the old model for stores that don't need style references — hence the override.Verification
npm run lintclean; full suite passes (278 tests).I could not exercise the live endpoint — that needs a
GEMINI_API_KEY, which I don't have. The change is a model-id swap on an otherwise unmodified request shape, and the model id is taken from Google's own deprecation page. Worth a smoke test by someone with a key before merging.https://claude.ai/code/session_015XLFFfHWNeazSuz6UcsQ4C