Skip to content

fix: move image generation off the shut-down Gemini model - #86

Closed
jsnapoli1 wants to merge 1 commit into
AJFrio:mainfrom
jsnapoli1:fix/gemini-image-model-shutdown
Closed

fix: move image generation off the shut-down Gemini model#86
jsnapoli1 wants to merge 1 commit into
AJFrio:mainfrom
jsnapoli1:fix/gemini-image-model-shutdown

Conversation

@jsnapoli1

Copy link
Copy Markdown

Problem

POST /api/admin/ai/generate-image calls gemini-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-preview with shutdown date "January 15, 2026".

Fix

Switches to gemini-3.1-flash-image ("Nano Banana 2"):

  • GA, no announced shutdown date
  • Google's named replacement for the retired preview model
  • Supports reference-image conditioning (10 object / 4 character / 3 style), which covers the up-to-4 reference images this endpoint already sends

Also adds GEMINI_IMAGE_MODEL as 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.

generateContent remains fully supported, so this is a model-id change, not an API migration.

Cost

Per 1K image, from Gemini API pricing:

Model Price Notes
gemini-2.5-flash-image-preview shut down
gemini-3.1-flash-image $0.067 new default
gemini-3.1-flash-lite-image $0.034 cheaper, no style/character refs
gemini-3-pro-image $0.134

The 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-image at $0.034 is cheaper than the old model for stores that don't need style references — hence the override.

Verification

npm run lint clean; 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

/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
@jsnapoli1

Copy link
Copy Markdown
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 gemini-2.5-flash-image-preview is replaced by gemini-3.1-flash-image, and GEMINI_IMAGE_MODEL remains available as an override — plus OpenRouter as a second provider.

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.

@jsnapoli1 jsnapoli1 closed this Sep 2, 2026
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.

1 participant