home / skills / cnemri / google-genai-skills / nano-banana-use

nano-banana-use skill

/skills/nano-banana-use

This skill helps you generate, edit, and compose images using Gemini Nano Banana models with configurable prompts, models, aspect ratios, and safety levels.

npx playbooks add skill cnemri/google-genai-skills --skill nano-banana-use

Review the files below or copy the command above to add this skill to your agents.

Files (4)
SKILL.md
2.3 KB
---
name: nano-banana-use
description: "Generate, edit, and compose images using Gemini Nano Banana models via portable Python scripts. Handles authentication via API Key or Vertex AI environment variables. Available parameters: prompt, model, aspect-ratio, safety-filter-level. Always confirm parameters with the user or explicitly state defaults before running."
---

# Nano Banana Use

Use this skill to generate, edit, and compose images using Gemini's Nano Banana models (`gemini-2.5-flash-image` and `gemini-3-pro-image-preview`).

This skill uses portable Python scripts managed by `uv`.

## Prerequisites

Ensure you have one of the following authentication methods configured in your environment:

1.  **API Key**:
    -   `GOOGLE_API_KEY` or `GEMINI_API_KEY`

2.  **Vertex AI**:
    -   `GOOGLE_CLOUD_PROJECT`
    -   `GOOGLE_CLOUD_LOCATION`
    -   `GOOGLE_GENAI_USE_VERTEXAI=1`

## Usage

### Generate an Image

**Step 1: Confirm Parameters**
Before running the script, confirm the following parameters with the user or state the defaults you will use:
-   **Prompt**: The image description.
-   **Model**: Default is `gemini-3-pro-image-preview`.
-   **Aspect Ratio**: Default is `1:1`.
-   **Safety Filter**: Default is `BLOCK_MEDIUM_AND_ABOVE`.

**Step 2: Run the Script**
Run the python script using `uv`:

```bash
uv run skills/nano-banana-use/scripts/generate_image.py "A futuristic banana city" --output city.png
```

### Edit an Image

Modify an existing image based on a text prompt.

```bash
uv run skills/nano-banana-use/scripts/edit_image.py original.png "Make the sky purple" --output edited.png
```

### Compose Images

Generate a new image based on multiple input images and a prompt.

```bash
uv run skills/nano-banana-use/scripts/compose_image.py --image style.png --image subject.jpg "A painting of the subject in the style of the first image" --output composition.png
```

### Options

-   `prompt`: The text description of the image.
-   `--model`: The model to use. Defaults to `gemini-3-pro-image-preview`.
-   `--output`: The filename for the saved image. Defaults to `generated_image.png`.
-   `--aspect-ratio`: The aspect ratio of the generated image. Defaults to `1:1`. Supported: `1:1`, `16:9`, `4:3`, `3:4`, `9:16`.
-   `--safety-filter-level`: Safety filter threshold. Defaults to `BLOCK_MEDIUM_AND_ABOVE`.

Overview

This skill lets you generate, edit, and compose images using Gemini Nano Banana image models via small, portable Python scripts. It supports both API key and Vertex AI authentication and exposes parameters for prompt, model, aspect ratio, and safety filter. Always confirm parameters with the user or explicitly state the defaults before running.

How this skill works

The skill runs lightweight Python scripts (invoked with uv) that call Gemini Nano Banana image endpoints (gemini-2.5-flash-image and gemini-3-pro-image-preview). Scripts accept a prompt plus options for model, aspect ratio, and safety filter, and can generate, edit, or compose images from one or more inputs. Authentication is handled either by setting an API key environment variable or by using Vertex AI environment variables if running within Google Cloud.

When to use it

  • Quickly prototype image concepts from text prompts.
  • Edit or retouch existing images using descriptive instructions.
  • Compose a new image from multiple source images and a guiding prompt.
  • Run image generation from local machines or CI systems with lightweight scripts.
  • Integrate simple image creation into experiments without heavy SDK setup.

Best practices

  • Always confirm or explicitly state the prompt, model, aspect-ratio, and safety-filter-level before executing a run.
  • Prefer gemini-3-pro-image-preview as the default model unless you need a specific capability from gemini-2.5-flash-image.
  • Set authentication via GOOGLE_API_KEY or GEMINI_API_KEY for local use; set GOOGLE_CLOUD_PROJECT, GOOGLE_CLOUD_LOCATION and GOOGLE_GENAI_USE_VERTEXAI=1 for Vertex AI.
  • Use descriptive prompts and include style or composition details for predictable results.
  • Choose an appropriate safety filter; default is BLOCK_MEDIUM_AND_ABOVE, but verify policy needs before lowering it.

Example use cases

  • Generate concept art: "A futuristic banana city" -> save as city.png.
  • Edit photos: provide original.png and prompt "Make the sky purple" -> edited.png.
  • Compose stylized images: combine style.png and subject.jpg with a prompt to produce a painted composition.
  • Batch-run experiments: script-driven generation across multiple prompts and aspect ratios for A/B testing.
  • Local prototyping: run the scripts from a laptop using an API key environment variable.

FAQ

What authentication methods are supported?

You can authenticate with an API key via GOOGLE_API_KEY or GEMINI_API_KEY, or use Vertex AI by setting GOOGLE_CLOUD_PROJECT, GOOGLE_CLOUD_LOCATION, and GOOGLE_GENAI_USE_VERTEXAI=1.

Do I need to confirm parameters before running?

Yes — always confirm the prompt, model, aspect ratio, and safety filter with the user or state the defaults (model: gemini-3-pro-image-preview, aspect-ratio: 1:1, safety-filter: BLOCK_MEDIUM_AND_ABOVE) before executing.