Skip to content

feat(ai-gemini): multi-turn image editing via the Interactions API #1653

Closed

Description

@tombeckenham

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 (feat(ai-gemini): Gemini Omni Flash video generation via the Interactions API #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.

Activity

  1. added
    has-pr
    waiting-on: maintainer
    on Oct 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

has-prwaiting-on: maintainer

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions