Skip to main content
POST
Image Editing: Edit an existing image with text instructions
The interactive Playground on the right supports dropdown selection for parameters. Enter your API Key in the Authorization field (format: Bearer sk-xxx) to send test requests with one click.
Scope: This page is for image editing. You must provide an input image (base64-encoded) along with edit instructions. To generate a new image from text only, use the Text-to-Image endpoint.
🖥️ Browser Playground limitation (important)This endpoint returns a base64-encoded image (inlineData.data, typically several MB) in the response. Due to browser rendering limits, the Playground on the right may show 请求时发生错误: unable to complete request after the response arrives — the request actually succeeded; the browser just can’t render such a long base64 string.Recommended workflow (beginner-friendly):
  • Copy the Python / Node.js / cURL sample below and run it locally. The code automatically base64.b64decodes the response and writes the image to a file.
  • If you must use the in-browser Playground, use a tiny reference image (< 50KB) and set imageSize to the smallest tier (e.g. 1K).
⚠️ parts array structure (important — read this for multi-image edits)Each part must be either a text or an inlineData, never both. This matches Google’s official gemini-3-pro-image-preview contract.Correct: one text part (the instruction) + N inlineData parts (one per image):
Incorrect (each part contains both text and inlineData — produces undefined behavior):
About the inlineData.data fieldThis endpoint uses JSON format (not multipart file upload), so the Playground cannot directly select local files. You need to convert your image to a Base64 string first, then paste it into the data input.One-line command: convert + copy to clipboard:
After running, just Cmd+V / Ctrl+V paste into the data field in the Playground. Also remember to set mimeType to the matching image/jpeg or image/png.Recommendation: Use small images (less than 200KB) for testing to avoid browser lag from long base64 strings. For frequent image editing tests, use the code examples below to run locally instead.

Code Examples

Python

Node.js

cURL

Multi-Image Editing

When merging or comparing several input images, use a single text part (the instruction) followed by multiple inlineData parts (one per image).

Python (multi-image)

cURL (multi-image, mirrors Google’s official format)

Parameter Quick Reference

Nano Banana Pro supports multi-image editing: you can input multiple images along with edit instructions for advanced features like multi-image composition and style transfer.

Authorizations

Authorization
string
header
required

API Key from APIYI Console

Body

application/json
contents
object[]
required

Content array with edit instructions and image to edit

generationConfig
object
required

Response

Image edited successfully

candidates
object[]

Generated results array

usageMetadata
object