Skip to main content
google avatar

Nano Banana 2 Image Editing API

google/nano-banana-2/edit

Edit images with text prompts. Make targeted changes like adding or removing objects, changing styles, or modifying specific elements while preserving the rest of the image.

edit
Priced by megapixels

Model Input

Input

  • https://media.modelrunner.ai/02EUGEXqn5lSoHvJwjPrY.png

The input image(s) for editing. The model supports providing multiple images in a single request.

The text prompt for image editing.

Enables Google Search grounding to provide more accurate and up-to-date information in the generated image.

The size of the generated image. Use a preset string (e.g. '4_3_1k') or a custom {width, height} object.

The harm category to apply the setting to.

The threshold for blocking content in the specified category.

The harm category to apply the setting to.

The threshold for blocking content in the specified category.

The harm category to apply the setting to.

The threshold for blocking content in the specified category.

The harm category to apply the setting to.

The threshold for blocking content in the specified category.

A list of unique safety settings for blocking unsafe content. Supported categories: HARM_CATEGORY_HARASSMENT, HARM_CATEGORY_HATE_SPEECH, HARM_CATEGORY_SEXUALLY_EXPLICIT, HARM_CATEGORY_DANGEROUS_CONTENT. Supported thresholds: HARM_BLOCK_THRESHOLD_UNSPECIFIED, BLOCK_LOW_AND_ABOVE, BLOCK_MEDIUM_AND_ABOVE, BLOCK_ONLY_HIGH, BLOCK_NONE. This setting can only be configured via the API.

You need to be logged in to run this model and view results.
Log in

Model Output

Output

Generated image output
Generated in 109.919 seconds
Logs (1 lines)

Model Example Requests

Examples

Example output 1Example output 2Example output 3

Model Pricing

Pricing

Model pricing varies by the megapixel count of your output image.

Up to 0.5 MP
$0.0450
per megapixel of image
or around 22 megapixels for $1
Up to 1.5 MP
$0.0670
per megapixel of image
or around 15 megapixels for $1
Up to 5 MP
$0.1010
per megapixel of image
or around 10 megapixels for $1
Up to 18 MP
$0.1510
per megapixel of image
or around 7 megapixels for $1

Nano Banana 2 Image Editing API

Nano Banana 2 Image Editing is a image-to-image AI model by google. On ModelRunner it runs through a REST API or via MCP from any AI assistant with pay-per-use pricing.

POST https://queue.modelrunner.run/google/nano-banana-2/edit

cURL

# Submit a request to the queue. Input fields go at the top level of the
# body. The optional reserved "metadata" object holds your own flat string
# tags — stored on the request, never sent to the model; filter later with
# GET https://queue.modelrunner.run/requests?metadata=<url-encoded JSON>.
curl -X POST https://queue.modelrunner.run/google/nano-banana-2/edit \
  -H "Authorization: Key $MRUN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "images": [
      "https://media.modelrunner.ai/02EUGEXqn5lSoHvJwjPrY.png"
    ],
    "prompt": "Using the provided image of the map on the table, change the map to show a fantastical city with crystal spires and g…",
    "resolution": "512",
    "aspect_ratio": "1:1",
    "google_search": false,
    "safetySettings": [
      {
        "category": "HARM_CATEGORY_HARASSMENT",
        "threshold": "BLOCK_LOW_AND_ABOVE"
      },
      {
        "category": "HARM_CATEGORY_HATE_SPEECH",
        "threshold": "BLOCK_LOW_AND_ABOVE"
      },
      {
        "category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
        "threshold": "BLOCK_LOW_AND_ABOVE"
      },
      {
        "category": "HARM_CATEGORY_DANGEROUS_CONTENT",
        "threshold": "BLOCK_LOW_AND_ABOVE"
      }
    ],
    "safety_settings": [
      {
        "category": "HARM_CATEGORY_HARASSMENT",
        "threshold": "BLOCK_LOW_AND_ABOVE"
      },
      {
        "category": "HARM_CATEGORY_HATE_SPEECH",
        "threshold": "BLOCK_LOW_AND_ABOVE"
      },
      {
        "category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
        "threshold": "BLOCK_LOW_AND_ABOVE"
      },
      {
        "category": "HARM_CATEGORY_DANGEROUS_CONTENT",
        "threshold": "BLOCK_LOW_AND_ABOVE"
      }
    ],
    "google_search_grounding": false,
    "metadata": {
      "project": "my-project"
    }
  }'
# → { "request_id": "...", "status_url": "...", "response_url": "..." }

# Poll status_url until "COMPLETED", then fetch the result
curl "https://queue.modelrunner.run/google/nano-banana-2/edit/requests/$REQUEST_ID/status" \
  -H "Authorization: Key $MRUN_API_KEY"
curl "https://queue.modelrunner.run/google/nano-banana-2/edit/requests/$REQUEST_ID" \
  -H "Authorization: Key $MRUN_API_KEY"

JavaScript

import { modelrunner } from "@modelrunner/client";

const result = await modelrunner.subscribe("google/nano-banana-2/edit", {
  input: {
    "images": [
      "https://media.modelrunner.ai/02EUGEXqn5lSoHvJwjPrY.png"
    ],
    "prompt": "Using the provided image of the map on the table, change the map to show a fantastical city with crystal spires and g…",
    "resolution": "512",
    "aspect_ratio": "1:1",
    "google_search": false,
    "safetySettings": [
      {
        "category": "HARM_CATEGORY_HARASSMENT",
        "threshold": "BLOCK_LOW_AND_ABOVE"
      },
      {
        "category": "HARM_CATEGORY_HATE_SPEECH",
        "threshold": "BLOCK_LOW_AND_ABOVE"
      },
      {
        "category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
        "threshold": "BLOCK_LOW_AND_ABOVE"
      },
      {
        "category": "HARM_CATEGORY_DANGEROUS_CONTENT",
        "threshold": "BLOCK_LOW_AND_ABOVE"
      }
    ],
    "safety_settings": [
      {
        "category": "HARM_CATEGORY_HARASSMENT",
        "threshold": "BLOCK_LOW_AND_ABOVE"
      },
      {
        "category": "HARM_CATEGORY_HATE_SPEECH",
        "threshold": "BLOCK_LOW_AND_ABOVE"
      },
      {
        "category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
        "threshold": "BLOCK_LOW_AND_ABOVE"
      },
      {
        "category": "HARM_CATEGORY_DANGEROUS_CONTENT",
        "threshold": "BLOCK_LOW_AND_ABOVE"
      }
    ],
    "google_search_grounding": false
  },
});
console.log(result);

Python

import os
import requests

headers = {"Authorization": f"Key {os.environ['MRUN_API_KEY']}"}

submitted = requests.post(
    "https://queue.modelrunner.run/google/nano-banana-2/edit",
    headers=headers,
    json={
      "images": [
        "https://media.modelrunner.ai/02EUGEXqn5lSoHvJwjPrY.png"
      ],
      "prompt": "Using the provided image of the map on the table, change the map to show a fantastical city with crystal spires and g…",
      "resolution": "512",
      "aspect_ratio": "1:1",
      "google_search": false,
      "safetySettings": [
        {
          "category": "HARM_CATEGORY_HARASSMENT",
          "threshold": "BLOCK_LOW_AND_ABOVE"
        },
        {
          "category": "HARM_CATEGORY_HATE_SPEECH",
          "threshold": "BLOCK_LOW_AND_ABOVE"
        },
        {
          "category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
          "threshold": "BLOCK_LOW_AND_ABOVE"
        },
        {
          "category": "HARM_CATEGORY_DANGEROUS_CONTENT",
          "threshold": "BLOCK_LOW_AND_ABOVE"
        }
      ],
      "safety_settings": [
        {
          "category": "HARM_CATEGORY_HARASSMENT",
          "threshold": "BLOCK_LOW_AND_ABOVE"
        },
        {
          "category": "HARM_CATEGORY_HATE_SPEECH",
          "threshold": "BLOCK_LOW_AND_ABOVE"
        },
        {
          "category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
          "threshold": "BLOCK_LOW_AND_ABOVE"
        },
        {
          "category": "HARM_CATEGORY_DANGEROUS_CONTENT",
          "threshold": "BLOCK_LOW_AND_ABOVE"
        }
      ],
      "google_search_grounding": false
    },
).json()

# Poll submitted["status_url"] until "COMPLETED", then:
result = requests.get(submitted["response_url"], headers=headers).json()

Input parameters

NameTypeRequiredDescription
imagesarrayyesThe input image(s) for editing. The model supports providing multiple images in a single request.
promptstringyesThe text prompt for image editing.
google_search_groundingbooleannoEnables Google Search grounding to provide more accurate and up-to-date information in the generated image. Default: false.
image_sizeenumnoThe size of the generated image. Use a preset string (e.g. '4_3_1k') or a custom {width, height} object. Default: "1_1_2k".
safety_settingsarraynoA list of unique safety settings for blocking unsafe content. Supported categories: HARM_CATEGORY_HARASSMENT, HARM_CATEGORY_HATE_SPEECH, HARM_CATEGORY_SEXUALLY_EXPLICIT, HARM_CATEGORY_DANGEROUS_CONTENT. Supported thresholds: HARM_BLOCK_THRESHOLD_UNSPECIFIED, BLOCK_LOW_AND_ABOVE, BLOCK_MEDIUM_AND_ABOVE, BLOCK_ONLY_HIGH, BLOCK_NONE. This setting can only be configured via the API. Default: [{"category":"HARM_CATEGORY_HARASSMENT","threshold":"BLOCK_LOW_AND_ABOVE"},{"category":"HARM_CATEGORY_HATE_SPEECH","threshold":"BLOCK_LOW_AND_ABOVE"},{"category":"HARM_CATEGORY_SEXUALLY_EXPLICIT","threshold":"BLOCK_LOW_AND_ABOVE"},{"category":"HARM_CATEGORY_DANGEROUS_CONTENT","threshold":"BLOCK_LOW_AND_ABOVE"}].

Machine-readable: OpenAPI schema · llms.txt

Use Nano Banana 2 Image Editing from Claude & Cursor (MCP)

Point Claude Code, Claude Desktop, Cursor, or any MCP client at the ModelRunner MCP server and Nano Banana 2 Image Editing becomes a tool your assistant can call directly — it authorizes via OAuth (no API key in config) and runs this model with the run_model tool using the endpoint google/nano-banana-2/edit.

MCP client config (Claude Desktop, Cursor)

{
  "mcpServers": {
    "modelrunner": {
      "command": "npx",
      "args": ["-y", "mcp-remote", "https://mcp.modelrunner.run/mcp"]
    }
  }
}

Claude Code

claude mcp add --transport http modelrunner https://mcp.modelrunner.run/mcp

Then ask your assistant, for example: “Run google/nano-banana-2/edit on ModelRunner to generate image”. MCP setup guide.

Model Details

Model Details

Nano Banana 2/Edit is a high-efficiency model for editing images with text prompts. It excels at making specific, context-aware changes to your images, from simple additions to complete stylistic transformations. Provide one or more images and a descriptive prompt to modify elements, apply new styles, or create composite scenes while maintaining the original image's lighting, perspective, and overall coherence.

This model is ideal for a variety of creative and commercial tasks, including: - **Inpainting and Masking:** Conversationally define a "mask" to edit a specific part of an image while leaving the rest untouched. For example, instruct the model to "change only the blue sofa to be a vintage, brown leather chesterfield," and it will preserve the rest of the room. - **Adding & Removing Elements:** Seamlessly add new objects to your images or remove unwanted ones. The model intelligently matches the style, lighting, and perspective of the original photo, making edits appear natural. - **Style Transfer:** Transform a photograph into a different artistic style. Provide a reference image and instruct the model to recreate it in the style of a famous artist or a specific art movement.

### Example Usage ```javascript import { modelrunner } from "@modelrunner/client";

const result = await modelrunner.subscribe("google/nano-banana-2/edit", { input: { images: ["https://ai.google.dev/static/gemini-api/docs/images/cat_photo.png"], prompt: "Using the provided image of my cat, please add a small, knitted wizard hat on its head. Make it look like it's sitting comfortably and matches the soft lighting of the photo.", aspect_ratio: "1:1", resolution: "2K" }, }); ```

## Safety & Content Moderation

The `safety_settings` parameter allows you to adjust content moderation filters for your specific use case. This setting can only be configured via the API. You can set a blocking threshold for four harm categories: Harassment, Hate Speech, Sexually Explicit, and Dangerous Content.

Each safety setting consists of a `category` and a `threshold`.

- **`threshold`**: The confidence level at which to block content for the given category. - `BLOCK_NONE`: Always show content, regardless of the probability of it being unsafe. - `BLOCK_ONLY_HIGH`: Block content when there is a high probability of it being unsafe. - `BLOCK_MEDIUM_AND_ABOVE`: Block content when there is a medium or high probability of it being unsafe. - `BLOCK_LOW_AND_ABOVE`: Block content when there is a low, medium, or high probability of it being unsafe.

```javascript import { modelrunner } from "@modelrunner/client";

const result = await modelrunner.subscribe("google/nano-banana-2/edit", { input: { images: ["https://ai.google.dev/static/gemini-api/docs/images/cat_photo.png"], prompt: "A cat wearing a wizard hat.", safety_settings: [ { "category": "HARM_CATEGORY_HATE_SPEECH", "threshold": "BLOCK_ONLY_HIGH" }, { "category": "HARM_CATEGORY_DANGEROUS_CONTENT", "threshold": "BLOCK_MEDIUM_AND_ABOVE" } ] }, }); ```