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.
- Visit Google AI Studio.
- Click "Get API Key".
- Copy it to a safe place.
As checked on August 18, 2026, Google's live pricing page lists no standard free tier for
gemini-3.1-flash-image. Check that page again before relying on any cost estimate.
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.
pip install -U google-genai
Step 4: Use the Current Image-Editing 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.
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?
If you strictly need to run without internet (e.g., for air-gapped security), you cannot use Nano Banana 2 or ChatGPT Image 2. Instead, check out HunyuanImage 3.0, Qwen-Image-Edit-2511, and Z-Image alternatives in our Quickstart Guide. These open models can run fully offline, but usually require a stronger GPU and more setup than the cloud client.