Image-to-Image
Edit images with Nano Banana 2 Lite using a text instruction.
The model ID is gemini-3.1-flash-lite-image, without a -preview suffix.
This model supports 1K output only and has an independent price and API-key
permission. Enabling Nano Banana 2 does not automatically enable Nano Banana 2 Lite.
Do not request 2K or 4K; those sizes are not configured for this model.
POST /api/v1/generationsThis is the asynchronous native API: a successful request returns 202 Accepted.
Poll GET /api/v1/jobs/{job_id} to retrieve the result.
For a Gemini-compatible call with an image in contents, see the SDK quickstart.
Headers
Section titled “Headers”| Header | Required | Description |
|---|---|---|
Authorization | Yes | Bearer <MOONEZ_API_KEY>. The key must have permission for Nano Banana 2 Lite. |
Content-Type | Yes | application/json |
Idempotency-Key | No | Repeating the same key returns the original job_id; see Authentication. |
| Field | Required | Description |
|---|---|---|
model | Yes | gemini-3.1-flash-lite-image |
prompt | Yes | The editing instruction, at least one character long. |
input_images_urls | Yes, for the examples below | A list of image URLs starting with http:// or https://, accessible to the server. |
input_images_base64 | No | An alternative to URLs: a list of images encoded as base64 or data URIs. |
aspect_ratio | Yes | Aspect ratio, such as 1:1 or auto. |
resolution | Yes | Resolution: 1K only. |
callback_url | No | Webhook URL for this job. |
metadata | No | An arbitrary JSON object. |
timeout | No | Total execution budget in seconds, from 30 to 1200. |
Provide at least one image for editing. With aspect_ratio: "auto", Moonez.ai
does not specify an aspect ratio to the provider; this does not guarantee that
the first input image’s proportions will be preserved. For the same behavior in
the Gemini-compatible API, omit generationConfig.imageConfig.aspectRatio.
Input image limits depend on the active route: up to 100 for AI Studio or up to 30 for Vertex, with a combined size limit of 200 MiB. The provider may impose additional validation limits.
Request examples
Section titled “Request examples”Set your key in MOONEZ_API_KEY and replace
https://example.com/photo.jpg with an accessible URL for your image.
curl -sS https://api.moonez.ai/api/v1/generations \ -H "Authorization: Bearer $MOONEZ_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "gemini-3.1-flash-lite-image", "prompt": "Turn the photo into a watercolor painting.", "aspect_ratio": "auto", "resolution": "1K", "input_images_urls": ["https://example.com/photo.jpg"] }'import os
import requests
response = requests.post( "https://api.moonez.ai/api/v1/generations", headers={"Authorization": f"Bearer {os.environ['MOONEZ_API_KEY']}"}, json={ "model": "gemini-3.1-flash-lite-image", "prompt": "Turn the photo into a watercolor painting.", "aspect_ratio": "auto", "resolution": "1K", "input_images_urls": ["https://example.com/photo.jpg"], }, timeout=30,)response.raise_for_status()print(response.json())const response = await fetch("https://api.moonez.ai/api/v1/generations", { method: "POST", headers: { Authorization: `Bearer ${process.env.MOONEZ_API_KEY}`, "Content-Type": "application/json", }, body: JSON.stringify({ model: "gemini-3.1-flash-lite-image", prompt: "Turn the photo into a watercolor painting.", aspect_ratio: "auto", resolution: "1K", input_images_urls: ["https://example.com/photo.jpg"], }), signal: AbortSignal.timeout(30_000),});if (!response.ok) throw new Error(`Generation request failed: ${response.status}`);console.log(await response.json());Response
Section titled “Response”202 Accepted means the job has been accepted, not that generation is complete.
{ "job_id": "0193a7f2-1c4a-7e0b-9b3a-2f1d8c6e4a55", "status": "queued", "status_url": "/api/v1/jobs/0193a7f2-1c4a-7e0b-9b3a-2f1d8c6e4a55"}Poll status_url with the same Authorization header until the status is done
or failed. If the model returns an image, its link is available in result.image_url.
An invalid URL format is rejected during request validation. If a URL is valid but the image cannot be downloaded, the error may appear after the job has been accepted. See API errors for details.