← Back to Blog
Integration • Jan 20, 2026 • Updated Oct 9, 2026

Can Nano Banana 2 Run Locally? The Client Explained

No: Nano Banana 2 does not perform inference on your PC. You can install its Python API client locally without a local GPU, but generation runs in Google's cloud and requires a connection. A different open-weight model is needed for offline inference.

Model selection checked : Google recommends Nano Banana 2.1 for new projects. The linked Nano Banana 2 tutorial remains pinned to gemini-3.1-flash-image. This page explains client setup, not a conversion of Google's model into local weights.

The "Closed Source" Reality

Before we begin, a crucial clarification: Nano Banana 2 cannot truly run offline.

Why? Because the core model is closed source. It runs on Google's current Gemini image infrastructure, while your machine only acts as the local controller. When you "run it locally," you are actually running a local client that sends instructions to the cloud model.

Step 1: Get Your API Key

Because inference happens in Google's cloud, the Python client needs a Gemini API key.

  1. Visit Google AI Studio.
  2. Click "Get API Key".
  3. Copy it to a safe place.

Before sending images, check current pricing for the exact model and account. This setup guide does not promise a free tier or a fixed generation cost.

Step 2: Prepare Your Environment

You don't need a GPU, but you do need Python.

# Check if you have Python installed
python --version

# Create a clean workspace
mkdir nano-client
cd nano-client
python -m venv venv
# On Windows:
.\venv\Scripts\activate
# On Mac/Linux:
source venv/bin/activate

Step 3: Install the Client SDK

We use the official Google GenAI SDK to communicate with the Nano Banana 2 model.

python -m pip install --upgrade google-genai
python -c "from google import genai; print('SDK import OK')"

The import check does not call Google or test model access. If it fails, confirm that the activated environment and python -m pip refer to the same Python installation.

Step 4: Configure the API Key

Google's API-key documentation supports GEMINI_API_KEY or GOOGLE_API_KEY; when both exist, GOOGLE_API_KEY takes precedence. Keep keys out of public repositories and browser-side code.

For the current PowerShell session:

$env:GEMINI_API_KEY = "YOUR_API_KEY"

For the current Bash or Zsh session:

export GEMINI_API_KEY="YOUR_API_KEY"

Check that a key is present without printing its value:

python -c "import os; print(bool(os.getenv('GOOGLE_API_KEY') or os.getenv('GEMINI_API_KEY')))"

For persistent Windows configuration and terminal refresh behavior, see the Windows environment-variable guide.

Step 5: Send One Image with a Versioned Example

The API surface changes over time, so use the maintained Nano Banana 2 Python tutorial. It follows Google's current gemini-3.1-flash-image Interactions API, keeps the key in an environment variable, uploads the input with its MIME type, and decodes the returned image.

For the underlying source of truth, compare the example against Google's image-generation documentation.

Start with one input and save the model ID, SDK version, prompt, output and any error. Then continue with the image input workflow or aspect-ratio and resolution settings.

If Setup Fails

What About ChatGPT Image 2?

Same boundary: OpenAI documents GPT Image 2 as an API image generation and editing model. No public GPT Image 2 weights are listed for self-hosted inference.

A tutorial can run an API client on your computer, but that does not make the underlying model local.

Want True Offline?

Choose a separate model from the offline-model route chooser. Begin with Qwen image editing, HunyuanImage hardware requirements, or Z-Image generation, depending on the task.

Prepare the checkpoint and dependencies before disconnecting, check the exact license, and validate the pipeline without network access. Different precision, resolution and inputs can change memory use; consult the VRAM planning guide rather than assuming one GPU minimum fits every model.