Skip to main content
Glama

gemini_interact

Generate and refine images with Gemini's Interactions API. Chain multi-turn edits by passing the previous interaction ID to maintain context for step-by-step modifications.

Instructions

Preferred tool for iterative or multi-step refinement of a single image — multi-turn generation/editing via Gemini's Interactions API. To refine, capture the returned interaction id and pass it as previous_interaction_id on the next call — do NOT start a new interaction or re-upload the image for each tweak. continue_last: true chains from this session's most recent interaction without threading the id. If a call times out on the client side, the generation usually still completes: the image plus a <image>.json sidecar recording its interaction id land in the output dir, and continue_last: true still resumes that interaction — check the output dir before re-issuing (a re-issue is a second billable generation). If a chained call 404s, this tool re-anchors itself on the prior output image and re-issues un-chained: success is reported as chain_recovered (the chain was the problem, and you get your image anyway); a second 404 is reported as the interaction id NOT being the cause (check the model id / files uri instead). Output is JPEG.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
asyncNoRun in the background and return a job_id immediately instead of the image, so a long (Pro/4K) generation cannot hit the host tools/call timeout (-32001). Poll gemini_get_result with the job_id to fetch the result. PREFER `max_wait_ms` on the hosted connector: it runs where the executor is only guaranteed to stay alive while the request is open, so this option is served there as a bounded wait rather than an immediate hand-off.
inputYesText prompt or editing instruction
modelNoModel id override (default: server default; see gemini_list_models). gemini-3.1-flash-image (Nano Banana 2) is the versatile generalist workhorse — balances speed with state-of-the-art 4K generation, world knowledge, and reliable text rendering; excels at multi-reference-image processing and consistency. gemini-3-pro-image (Nano Banana Pro) is the premium choice for the most complex visual tasks — highest world knowledge, advanced localization, accurate brand consistency, precision creative control. gemini-3.1-flash-lite-image (Nano Banana 2 Lite) is the fastest/cheapest for simple tasks (1K only, no search grounding).
imagesNoPaths to reference input images. NEW reference images only (e.g. a style or target photo). When chaining with previous_interaction_id, do NOT re-attach the prior turn's output — the interaction already contains it, and re-sending it anchors the model against your edit.
inlineNoReturn base64 images inline instead of writing to disk
confirmNoMust be true to proceed. Without this, the tool returns a preview.
filenameNoBase filename for the output image (extension stripped; default: slugified input)
video_urlNoPublic YouTube URL (or a previously uploaded Files API uri) as a video reference (video→image; use a Flash model e.g. gemini-3.1-flash-image)
image_sizeNoOutput resolution (512 = 0.5K, Flash-only)
images_urlNoReference images. NEW reference images only (e.g. a style or target photo). When chaining with previous_interaction_id, do NOT re-attach the prior turn's output — the interaction already contains it, and re-sending it anchors the model against your edit. Given as public https URLs — the SERVER downloads them, so no image bytes travel through the conversation. Preferred over images_base64, which costs ~14k tokens per photo and breaks if a file read was truncated. Max 15MB each; must be a directly-linked image (Content-Type image/*).
output_dirNoDirectory to write images to (default: $GEMINI_OUTPUT_DIR or cwd)
timeout_msNoUpstream request timeout in ms for this call (default: $GEMINI_TIMEOUT_MS, else 60000 — or 120000 when image_size is 4K, which routinely runs past 60s)
video_pathNoPath to a local video file — uploaded to the Gemini Files API (~48h retention, 2 GB max) and used as the video reference. Alternative to video_url.
max_wait_msNoWait up to this many ms for the result; if generation is still running when the budget expires, return { job_id, status: "running" } immediately instead (poll gemini_get_result). Keeps fast results in-band while a slow batch can never trip the host tools/call timeout (-32001) — e.g. 20000 for multi-image sets. Ignored when async is set.
orientationNoShape of the output, in plain terms: "landscape" (wide, 16:9), "portrait" (tall, 9:16) or "square" (1:1). Use this for a request phrased as landscape/portrait/vertical/horizontal. For any other proportion — 35mm photo (3:2), print (4:3), social (4:5), cinematic (21:9) — name it with aspect_ratio instead, which overrides this when both are given.
aspect_ratioNoExact output aspect ratio. For a plain landscape/portrait/square request, `orientation` is the shorthand; this wins if both are given.
search_typesNoGrounding search types (implies google_search). image_search (gemini-3.1-flash-image only) uses Google Image Search results as visual references; per Google ToS the returned grounding.search_suggestions HTML must then be displayed to the user. Cannot depict real people from web images.
continue_lastNoContinue from the most recent interaction this server created (convenience for previous_interaction_id; an explicit id wins). Survives a server restart by falling back to the newest <image>.json sidecar in the output dir.
google_searchNoGround the image in live Google Search results (current events, weather, data)
images_base64NoReference images as base64 strings or data URIs. Last resort: prefer images_url or images_file_uris, which keep image bytes out of the conversation. NEW reference images only (e.g. a style or target photo). When chaining with previous_interaction_id, do NOT re-attach the prior turn's output — the interaction already contains it, and re-sending it anchors the model against your edit.
from_clipboardNoUse the image currently on the macOS system clipboard as an input (downscaled to JPEG)
thinking_levelNoReasoning depth; higher can help complex/structural edits
idempotency_keyNoOpaque idempotency key: a repeat call with the same key returns the recorded result (reused: true) instead of billing a new generation. Set it when retrying after a host timeout (-32001) to avoid a duplicate charge.
images_file_urisNoReference images. NEW reference images only (e.g. a style or target photo). When chaining with previous_interaction_id, do NOT re-attach the prior turn's output — the interaction already contains it, and re-sending it anchors the model against your edit. Given by Gemini Files API reference ("files/<id>", or the full uri) from gemini_upload_file or POST /upload. Upload once, then reference it across as many calls as you like — no bytes are re-sent and none enter the conversation. Files are retained ~48h, after which the reference stops resolving.
previous_interaction_idNoID from a prior gemini_interact call — continues that multi-turn conversation

Schema Changelog

Changes observed during successful MCP inspections. Dates show when Glama detected each change.

  1. Changed2 schema fields changedv1.10.0
    • changedInput schema / properties / aspect_ratio / description
      Previous value: -"Output aspect ratio"New value: +"Exact output aspect ratio. For a plain landscape/portrait/square request, `orientation` is the shorthand; this wins if both are given."
    • addedInput schema / properties / orientation
      Added value: +{
      +  "description": "Shape of the output, in plain terms: \"landscape\" (wide, 16:9), \"portrait\" (tall, 9:16) or \"square\" (1:1). Use this for a request phrased as landscape/portrait/vertical/horizontal. For any other proportion — 35mm photo (3:2), print (4:3), social (4:5), cinematic (21:9) — name it with aspect_ratio instead, which overrides this when both are given.",
      +  "enum": [
      +    "landscape",
      +    "portrait",
      +    "square"
      +  ],
      +  "type": "string"
      +}
  2. Changed2 schema fields changedv1.7.0
    • changedInput schema / properties / async / description
      Previous value: -"Run in the background and return a job_id immediately instead of the image, so a long (Pro/4K) generation cannot hit the host tools/call timeout (-32001). Poll gemini_get_result with the job_id to fetch the result (jobs are per-process and expire ~10 min after completion)."New value: +"Run in the background and return a job_id immediately instead of the image, so a long (Pro/4K) generation cannot hit the host tools/call timeout (-32001). Poll gemini_get_result with the job_id to fetch the result. PREFER `max_wait_ms` on the hosted connector: it runs where the executor is only guaranteed to stay alive while the request is open, so this option is served there as a bounded wait rather than an immediate hand-off."
    • addedInput schema / properties / max_wait_ms
      Added value: +{
      +  "description": "Wait up to this many ms for the result; if generation is still running when the budget expires, return { job_id, status: \"running\" } immediately instead (poll gemini_get_result). Keeps fast results in-band while a slow batch can never trip the host tools/call timeout (-32001) — e.g. 20000 for multi-image sets. Ignored when async is set.",
      +  "exclusiveMinimum": 0,
      +  "maximum": 600000,
      +  "type": "integer"
      +}
  3. First observedv1.2.0

TDQS

A4.6/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations are thin (readOnlyHint=false, openWorldHint=true), and the description carries the real burden with exceptional disclosure: client-side timeouts 'usually still complete' with a <image>.json sidecar, a re-issue is 'a second billable generation,' 404s recover via chain_recovered with a second 404 meaning the interaction id was not the cause, and output is JPEG. This goes far beyond the annotations and directly prevents double-billing and retry confusion.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Every sentence earns its place — purpose, chaining rule, timeout recovery, 404 recovery, output format — and the core purpose is front-loaded. It is a dense block with several long sentences, so it could be more scannable, but nothing is redundant with the schema.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a 25-parameter tool with serious failure modes (double billing, broken chains), no output schema, and thin annotations, the description covers all operational essentials: how chaining works, what happens on timeout and 404, where artifacts land (output dir, .json sidecar), and the output format. Remaining return-value behaviors (job_id, status: 'running', reused: true) are already documented in the schema's parameter descriptions.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100% with individually rich parameter docs, so the baseline is 3. The description adds genuine cross-parameter semantics not present in any single field: the chaining relationship among previous_interaction_id, continue_last, and images (do not re-attach the prior turn's output), and the timeout→sidecar→continue_last recovery flow. That earns one point above baseline, but the schema already does most of the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Opening sentence states a specific verb+resource: 'iterative or multi-step refinement of a single image — multi-turn generation/editing via Gemini's Interactions API.' The 'iterative/multi-step' framing distinguishes it from single-shot siblings like gemini_image_generate and gemini_image_edit, so an agent can tell them apart without opening schemas.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicitly positioned as the 'Preferred tool for iterative or multi-step refinement,' giving clear when-to-use context, plus a detailed chaining protocol: capture the returned interaction id, pass it as previous_interaction_id, and 'do NOT start a new interaction or re-upload the image for each tweak.' It stops short of a 5 because it never names the when-not-to-use alternative (a single one-shot generation would go to gemini_image_generate/gemini_image_edit).

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/chrischall/gemini-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server