Problem#
geminiImage() sends one stateless generateContent request per call (packages/ai-gemini/src/adapters/image.ts). There is no way to continue an edit, so multi-turn editing means passing the previous output image back in as a prompt part on every turn.
Passing the image back degrades quality badly across turns. The model loses its own context for the earlier edits (model turns and thought signatures are not kept), and the image is re-encoded and re-interpreted each time.
This affects the Gemini-native image models: gemini-nano-banana-2.1, gemini-3.1-flash-image, gemini-3.1-flash-lite-image, gemini-3-pro-image, gemini-2.5-flash-image.
Proposal#
Route Gemini-native image generation through the Interactions API so edits chain server-side with previous_interaction_id, instead of re-sending the image.
- Generate images through an Interactions request with image output.
- Return the server-assigned interaction id on the image result.
- Accept
previous_interaction_id in modelOptions to continue an edit.
- Imagen models stay on
generateImages (text-to-image only, no change).
Current state#
- The only Interactions text adapter is experimental (
packages/ai-gemini/src/experimental/text-interactions/adapter.ts). It drops image and thought_signature output deltas, so it cannot return an edited image.
- The video adapter already uses the Interactions API with
previous_interaction_id (#886). Follow that precedent.
geminiText() is not a route: the image models are only in GEMINI_IMAGE_MODELS, and its stream handles only text and function-call parts.
First step#
Run a live probe to confirm which of these models the Interactions API accepts for image output, and what the chained-edit response looks like. This is not verified yet. The design depends on the result.
Open questions#
- Should Interactions replace
generateContent for these models, or be opt-in? Google marks the Interactions API as Beta.
- Interactions are stored server-side. What retention and
store behavior do we expose?
Done when#
- Chained multi-turn edit works without re-sending the image, verified live.
- Unit tests cover the new path. E2E coverage where aimock can emit it.
docs/media/image-generation.md and docs/adapters/gemini.md document multi-turn editing.
- The
ai-core/media-generation skill is updated.
- Changeset added.