Skip to main content

Vertex AI Nano Banana API: Model IDs, Setup, and Cost per Image

Use GA IDs like gemini-3.1-flash-image with enterprise=True and location global. List prices match the Gemini API; choose Vertex for IAM, VPC-SC, or residency.

LaoZhang AI TeamPublished15 min read
On this page
Vertex AI Nano Banana API cover showing the three changes that break 2025 code: preview model IDs to gemini-3.1-flash-image, vertexai=True to enterprise=True, and us-central1 to global

To call Nano Banana through Vertex AI today, use a GA model ID: gemini-3.1-flash-image (Nano Banana 2), gemini-3-pro-image (Nano Banana Pro), or gemini-3.1-flash-lite-image (Nano Banana 2 Lite). Create the Google Gen AI SDK client with enterprise=True, your project ID, and location="global", and authenticate with Application Default Credentials (ADC) or a service account. Code from 2025 usually breaks for one of three reasons: it asks for a -preview model that Google retired on July 17, 2026, it points at us-central1, where the newer image models aren't offered, or it mixes Gemini API sample code into a Google Cloud client.

Vertex AI hasn't disappeared. On April 22, 2026, Google made it part of Gemini Enterprise Agent Platform: Vertex AI Studio became Agent Studio and the Vertex AI API became the Agent Platform API. The endpoint is still aiplatform.googleapis.com, and old vertex-ai/generative-ai/docs links still resolve. "Vertex AI" and "Agent Platform" below mean the same service.

Price is not a reason to switch. As of September 24, 2026, Agent Platform list prices on the global endpoint match the paid Gemini API: about $0.067 for a 1K Nano Banana 2 image, $0.101 at 2K, and $0.134 for a 1K or 2K Nano Banana Pro image. Agent Platform earns its setup cost when you need what a Gemini API key doesn't give you: IAM and service accounts, VPC Service Controls, customer-managed encryption keys (CMEK), US or EU data residency, Provisioned Throughput, or billing on an existing Google Cloud account.

What changed since the 2025 tutorials

If a tutorial or an old script stopped working, compare it with this table first. Each row is a change Google shipped between late 2025 and September 2026.

In older code or guidesStatus as of September 24, 2026Use instead
gemini-3.1-flash-image-preview, gemini-3-pro-image-previewRetired on Agent Platform on July 17, 2026; "no longer accessible"gemini-3.1-flash-image, gemini-3-pro-image
gemini-2.5-flash-imageDeprecated; retires on Agent Platform on March 15, 2027Google recommends gemini-3.1-flash-lite-image
vertexai=True, GOOGLE_GENAI_USE_VERTEXAI=TrueLegacy flag, still acceptedenterprise=True, GOOGLE_GENAI_USE_ENTERPRISE=True
location="us-central1"Not listed for Nano Banana 2, Pro, or 2 Liteglobal; Nano Banana 2 also accepts us or eu
Vertex AI StudioRenamed Agent StudioAgent Studio > Create prompt
client.interactions.create(...) samples from ai.google.devGemini API style; Agent Platform docs use generate_contentgenerate_content with image_config

The Python SDK doesn't check model names. With google-genai 2.25.0 (released September 22, 2026), a client built offline assembles .../models/gemini-3.1-flash-image-preview:generateContent exactly as it does the GA ID. The call only fails once Google's server receives it. If code that worked in the spring started failing in July, check the model string before you touch credentials.

One trap in Google's own text: the July 17 release note suggests gemini-3-flash-image as a replacement. That ID is a typo. The model page and the deprecation table both name gemini-3-pro-image.

Which Nano Banana model and location to use

Agent Platform serves four Nano Banana models. They differ in where they run, what sizes they produce, and how long they stay available.

Nano Banana 2Nano Banana ProNano Banana 2 LiteNano Banana (original)
Model IDgemini-3.1-flash-imagegemini-3-pro-imagegemini-3.1-flash-lite-imagegemini-2.5-flash-image
StatusGA since May 28, 2026GA since May 28, 2026GA since June 23, 2026Deprecated
Retirement on Agent PlatformMay 28, 2027 or laterMay 28, 2027 or laterJune 28, 2027 or laterMarch 15, 2027
Locationsglobal, us, euglobal onlyglobal onlyglobal plus 13 US and EU regions
Output sizes512, 1K, 2K, 4K1K, 2K, 4K1K1024×1024 at 1:1
Aspect ratios15, including 1:8 and 8:1151410
Grounding with Google SearchSupportedSupportedNot supportedNot supported
Image output, Standard PayGo$60 per 1M tokens ($66 on us/eu)$120 per 1M tokens$30 per 1M tokens$30 per 1M tokens

Model and location details come from each model's Agent Platform page (last updated September 22, 2026) and the Agent Platform pricing page.

Google describes Nano Banana 2 as the balance of price and performance, Pro as the model for complex and multi-turn generation and editing, and 2 Lite as the fastest. In practice, the choice usually comes down to output size and location. If 1K is enough, 2 Lite costs half as much per image as Nano Banana 2. If you need 512, 2K, 4K, or the us/eu endpoints, use Nano Banana 2. Pro is worth its price when quality on complex compositions or multi-turn edits matters more than cost. For Nano Banana Pro request structure itself, see Nano Banana Pro API: Official Docs, Working JSON, YAML Config, and PDF Rules.

Location changes both the endpoint and the bill:

  • global is the default and the only choice for Pro and 2 Lite. Google recommends it because requests go to whichever region has capacity.
  • us or eu (multi-region, Nano Banana 2 only since August 31, 2026) keeps ML processing inside that geography and supports Provisioned Throughput and Standard PayGo. Image output costs 10% more: $66 instead of $60 per million tokens.
  • Single regions such as us-central1 or europe-west4 exist only for the original gemini-2.5-flash-image.

No Nano Banana model lists an Asia-Pacific endpoint. A team in Tokyo or Singapore that must keep processing in-country can't do that with these models on Agent Platform.

Matrix of the four Nano Banana models against the global, us/eu, and single-region locations on Vertex AI, with image output prices per million tokens and retirement dates

Some image options also work only on Agent Platform. The SDK's ImageConfig marks output_mime_type, output_compression_quality, prominent_people, and image_output_options as "not supported in Gemini API," so they only take effect with an enterprise=True client.

First image call with Python

You need a Google Cloud project with billing enabled and the Agent Platform API turned on. The code below matches google-genai 2.25.0. If an older install rejects enterprise=True, upgrade it; the legacy vertexai=True flag behaves the same in the meantime.

bash
pip install --upgrade google-genai

ADC or a service account

On your own machine, log in once so the SDK can find credentials. On Cloud Run, GKE, or a VM, the attached service account does the same job and you skip this step.

bash
gcloud auth application-default login
export GOOGLE_CLOUD_PROJECT=your-project-id

Then generate one 16:9 image at 2K with Nano Banana 2:

python
import os
from google import genai
from google.genai import types

client = genai.Client(
    enterprise=True,
    project=os.environ["GOOGLE_CLOUD_PROJECT"],
    location="global",
)

response = client.models.generate_content(
    model="gemini-3.1-flash-image",
    contents="A red bicycle leaning against a bakery window at sunrise",
    config=types.GenerateContentConfig(
        response_modalities=["TEXT", "IMAGE"],
        image_config=types.ImageConfig(aspect_ratio="16:9", image_size="2K"),
    ),
)

for i, part in enumerate(response.candidates[0].content.parts):
    if part.text:
        print(part.text)
    elif part.inline_data:
        ext = part.inline_data.mime_type.split("/")[-1]
        with open(f"bicycle-{i}.{ext}", "wb") as f:
            f.write(part.inline_data.data)

With these settings, the SDK sends the request to https://aiplatform.googleapis.com/v1beta1/projects/<project>/locations/global/publishers/google/models/gemini-3.1-flash-image:generateContent with "imageConfig": {"aspectRatio": "16:9", "imageSize": "2K"} inside generationConfig. If you leave out image_size, you get 1K.

Google's quickstart does the same thing through environment variables. Set GOOGLE_CLOUD_PROJECT, GOOGLE_CLOUD_LOCATION=global, and GOOGLE_GENAI_USE_ENTERPRISE=True, then call genai.Client() with no arguments. For the us or eu endpoint, change only the location: the SDK switches the host to aiplatform.us.rep.googleapis.com or aiplatform.eu.rep.googleapis.com.

Express mode API key

Agent Platform express mode, still in Preview, gives a @gmail.com account an API key instead of a project and location. The client then takes the key and nothing else:

python
client = genai.Client(enterprise=True, api_key=os.environ["EXPRESS_API_KEY"])

The request goes to aiplatform.googleapis.com without a project in the path. Before you build on it, read the express mode caveats in the free options section below.

REST with curl

The official REST sample authenticates with a short-lived access token from gcloud. For the global endpoint:

bash
PROJECT_ID=your-project-id
MODEL_ID=gemini-3.1-flash-image

curl -X POST \
  -H "Authorization: Bearer $(gcloud auth print-access-token)" \
  -H "Content-Type: application/json" \
  "https://aiplatform.googleapis.com/v1/projects/${PROJECT_ID}/locations/global/publishers/google/models/${MODEL_ID}:generateContent" \
  -d '{
    "contents": [{"role": "user", "parts": [{"text": "A red bicycle leaning against a bakery window at sunrise"}]}],
    "generationConfig": {
      "responseModalities": ["TEXT", "IMAGE"],
      "imageConfig": {"aspectRatio": "16:9", "imageSize": "2K"}
    }
  }' > response.json

jq -r '.candidates[0].content.parts[] | select(.inlineData) | .inlineData.data' response.json \
  | head -n 1 | base64 --decode > bicycle.png

The image comes back as base64 inside inlineData, which makes 2K and 4K responses large. If you call through a self-hosted gateway, check that it supports the new model names and passes large inline payloads. In a 2025 linux.do thread, users of new-api and done-hub reported that calls working in Vertex AI Studio failed through the gateway until it was updated.

Setup errors and what they mean

The client-side messages below come from google-genai 2.25.0 run locally without credentials. The client was built and the request URL captured, but nothing was sent to Google, so the table quotes no server responses. Wording can change between SDK versions.

What you seeCauseFix
ValueError: Gemini API does not support project/location.You passed project and location, but the client defaulted to the Gemini Developer APIAdd enterprise=True, or export GOOGLE_GENAI_USE_ENTERPRISE=True in the same shell
ValueError: No API key was provided...No API key and no enterprise flag, so the SDK assumes an AI Studio keySet the enterprise flag or variable; this message doesn't mean Agent Platform needs a key
DefaultCredentialsError: Your default credentials were not found...enterprise=True but no ADC on this machineRun gcloud auth application-default login, or run under a service account
ValueError: enterprise and vertexai flags have conflicting values, please set enterprise value only.enterprise=True together with vertexai=FalseRemove vertexai from the call
Warning that both GOOGLE_GENAI_USE_ENTERPRISE and GOOGLE_GENAI_USE_VERTEXAI are setAn old .env still sets the Vertex variableGOOGLE_GENAI_USE_ENTERPRISE wins; delete the other one to silence it
Missing key inputs argument! ... provide (vertexai, project & location) arguments.An older google-genai releasepip install --upgrade google-genai
Client builds fine, the server rejects the modelA retired -preview ID or a typoUse an ID from the model table above
location="us-central1" with Nano Banana 2, Pro, or 2 LiteThe model pages list these models only on global, plus us and eu for Nano Banana 2Use global; for Nano Banana 2 you can also use us or eu
Sample code calls client.interactions.create or sets response_formatIt was copied from ai.google.dev, which now leads with the Interactions API; Agent Platform docs use generateContentRewrite with client.models.generate_content and image_config
429 with Resource exhausted, please try again later.Shared capacity is busy (next section)Back off, smooth traffic, stay on global

The Node.js sample on Google's image-generation page is its own trap. As of September 24, 2026, it still uses vertexai: true and falls back to us-central1 when no location is set, a region the model pages don't list for Nano Banana 2 or Pro. Set GOOGLE_CLOUD_LOCATION=global explicitly when you start from that sample.

What one image costs on Vertex AI

Google bills Nano Banana by tokens, and each output image has a fixed token count by resolution. The cost of the image itself is:

image tokens × price per 1M output image tokens ÷ 1,000,000

Token counts per output image: Nano Banana 2 uses 747 at 512, 1,120 at 1K, 1,680 at 2K, and 2,520 at 4K. Pro uses 1,120 at both 1K and 2K and 2,000 at 4K. 2 Lite uses 1,120 at 1K. Applying the September 24, 2026 Agent Platform prices:

Model and option5121K2K4K
Nano Banana 2, Standard, global ($60/1M)$0.0448$0.0672$0.1008$0.1512
Nano Banana 2, Standard, us/eu ($66/1M)$0.0493$0.0739$0.1109$0.1663
Nano Banana 2, Flex or Batch, global ($30/1M)$0.0224$0.0336$0.0504$0.0756
Nano Banana Pro, Standard ($120/1M)$0.1344$0.1344$0.24
Nano Banana Pro, Flex or Batch ($60/1M)$0.0672$0.0672$0.12
Nano Banana 2 Lite, Standard ($30/1M)$0.0336
Nano Banana 2 Lite, Flex or Batch ($15/1M)$0.0168

A worked example: 1,000 Nano Banana 2 images at 2K on the global endpoint cost 1,000 × 1,680 × $60 ÷ 1,000,000 = $100.80 at Standard PayGo, or $50.40 through Batch inference. The original gemini-2.5-flash-image uses 1,290 tokens per 1024×1024 image at $30 per million, about $0.039.

Bar chart of Standard per-image prices for Nano Banana 2, Pro, and 2 Lite by resolution on the global endpoint, next to the 1,000-image 2K example at $100.80 Standard and $50.40 Batch

These figures cover the image output only. The real bill adds:

  • Input. Each reference image counts as 1,120 input tokens on Nano Banana 2 and 2 Lite and 560 on Pro. That's about $0.00056 per reference image on Nano Banana 2 and $0.00112 on Pro. Text prompts are billed at the model's input rate.
  • Text and reasoning output. Nano Banana 2 bills any text it returns, including reasoning, at $3 per million tokens on global; Pro bills it at $12.
  • Grounding with Google Search. 5,000 grounding queries per month are free across all Gemini 3 models. After that, each 1,000 queries cost $14.
  • Repeat attempts. Regenerations, and attempts that end in a blocked or unusable image, can still add cost. Treat the table as a floor, not an invoice.

Flex PayGo and Batch inference both halve the price. Batch fits work that can wait, such as catalog images or overnight jobs. Pro also has a Priority PayGo option that costs more than Standard, at $216 per million image output tokens.

Is Vertex AI more expensive than the Gemini API?

Not at list price. The Gemini API's paid tier charges the same $60 and $120 per million image output tokens for Nano Banana 2 and Pro, and it has the same 50% Batch discount. The only list-price gap is the 10% surcharge on Nano Banana 2 when you pin it to us or eu. When a Vertex bill looks high, the cause is usually 4K output, Pro instead of Nano Banana 2, reasoning tokens, grounding charges, or Priority PayGo, not the platform itself.

Why 429 errors happen and what helps

On Standard PayGo, Agent Platform answers overload with HTTP 429 and Resource exhausted, please try again later. Google's Standard PayGo page says a 429 "doesn't indicate that you've hit a fixed quota." It means shared capacity is temporarily contested.

Two facts rule out the obvious fixes. Each Nano Banana model page lists "Fixed quota: Not supported," so a quota increase request doesn't apply. The spend-based usage tiers, which give an organization a baseline of tokens per minute, don't cover these models either: the same page lists Gemini 3.1 Flash Image, 3.1 Flash-Lite Image, 3 Pro Image, and 2.5 Flash Image as supporting Standard PayGo "but the usage tiers don't apply to these models." Spending more on other Agent Platform services won't raise an image model's baseline.

What Google does recommend for 429s on PayGo:

  1. Stay on the global endpoint. It routes each request to the region with capacity. A regional endpoint draws from a smaller pool.
  2. Retry with truncated exponential backoff. google-genai doesn't retry unless you turn it on. With HttpRetryOptions, it retries 408, 429, 500, 502, 503, and 504 responses with jittered exponential waits.
  3. Smooth traffic within each minute. Short bursts can be throttled even when your per-minute average is low, so cap concurrency instead of firing a whole batch at once.
  4. Ramp up gradually. A sudden jump in usage can hit acceleration limits.
  5. Buy Provisioned Throughput if you need an SLA. All three current models support it. When you exceed reserved capacity, the message changes to Too many requests. Exceeded the Provisioned Throughput.

Turning on the SDK's built-in retry takes a few lines:

python
client = genai.Client(
    enterprise=True,
    project=os.environ["GOOGLE_CLOUD_PROJECT"],
    location="global",
    http_options=types.HttpOptions(
        retry_options=types.HttpRetryOptions(attempts=5, initial_delay=2.0, max_delay=60.0),
    ),
)

Some Vertex users hit 429s constantly early in 2026. In a Google AI Developers Forum thread opened January 2, 2026, while Nano Banana Pro was still in preview, developers reported 429s on sparse traffic. One said moving the same code to the Gemini API stopped the errors, and a Google staff member said a fix was pushed on January 8. Later posts in February and March described 429s at five or six concurrent requests. Those reports predate GA and say nothing either way about capacity today.

If errors suddenly appear with no change on your side, check Google's status pages before you rework your client; Is Nano Banana 2 Down? Check the Right Status Page First walks through that. Rate limits on the Gemini API key side work differently and are covered in Nano Banana 2 Limits: How Gemini Usage and API Rate Limits Work.

Free credit, express mode, and free API keys

There is no free API tier for current Nano Banana models on either Google platform, but a new Google Cloud account can cover them with trial credit.

  • Gemini API free tier. Google's pricing page lists the free tier as "Not available" for Nano Banana 2 and Nano Banana Pro. An AI Studio key reaches these models only on the paid tier.
  • The $300 Google Cloud Free Trial. The credit lasts 90 days. Its exclusions name "Gemini API in AI Studio costs" and partner models sold as managed APIs. First-party Gemini models on Agent Platform aren't on that list, so trial credit should cover Nano Banana calls made with enterprise=True. Watch the Billing reports after your first calls to confirm.
  • Express mode free tier. New Google Cloud users with a @gmail.com account get 90 days of express mode without billing details, within the express quotas. Existing Google Cloud users don't get the free tier, and enabling billing ends it. As of September 24, 2026, the express mode model table still lists gemini-3.1-flash-image-preview and gemini-3-pro-image-preview, both retired in July, plus gemini-2.5-flash-image at 10 requests per minute. It doesn't list the GA image IDs, so free Nano Banana 2 or Pro through express mode isn't documented. Test one call before you plan around it.

Vertex AI or a Gemini API key?

Google's own guidance is that most developers should use the Gemini Developer API unless they need specific enterprise controls. For Nano Banana, those controls are concrete:

QuestionAgent Platform (Vertex AI)Gemini API key (AI Studio)
AuthenticationADC, service accounts, IAM; API key in express modeAPI key
Endpointaiplatform.googleapis.com (or us/eu hosts)generativelanguage.googleapis.com
Data residency, CMEK, VPC-SCListed on each model page for online prediction and Batch inferenceGoogle points to Agent Platform when you need them
Provisioned ThroughputSupportedOffered through Agent Platform
gemini-2.5-flash-image shutdownMarch 15, 2027October 2, 2026
List priceSame as Gemini API on global; +10% for Nano Banana 2 on us/euSame as Agent Platform global

Data use isn't a deciding factor once you pay: the Gemini API's paid tier also states that your data is not used to improve Google's products.

Choose Agent Platform if your company already runs on Google Cloud, if security reviews require VPC-SC, CMEK, or EU/US residency, if you need reserved capacity, or if you have a Google Cloud trial credit to spend. It also buys time for code still on gemini-2.5-flash-image, which shuts down on the Gemini API on October 2, 2026 but keeps running on Agent Platform until March 15, 2027.

If none of that applies, an AI Studio key is less setup for the same models and the same list price. Nano Banana API Key Guide 2026: Official Gemini Models, Pricing, and Code covers that setup, and Gemini API vs Vertex AI API: Which Google Gemini Route Should You Use? compares the two platforms beyond image generation.

A third option fits readers who can't or don't want to open Google Cloud billing and need none of the controls above. laozhang.ai sells the same model IDs at a flat per-call price as of September 24, 2026: $0.025 for gemini-3.1-flash-lite-image, $0.055 for gemini-3.1-flash-image, and $0.09 for gemini-3-pro-image, whatever the output size. It accepts Gemini-native generateContent requests with imageConfig at https://api.laozhang.ai. Against Google's Standard prices, that is cheaper at every size except Nano Banana 2 at 512; Google's Flex and Batch prices are lower at 2K and below. It isn't Agent Platform: requests pass through a third party, with no VPC-SC, CMEK, data residency, Google SLA, or Provisioned Throughput.

FAQ

What happened to Vertex AI?

On April 22, 2026, Google made Vertex AI part of Gemini Enterprise Agent Platform. The product names changed: Vertex AI Studio is now Agent Studio, and the Vertex AI API is the Agent Platform API. Endpoints, projects, and billing did not change, and the SDK's legacy vertexai=True flag still works next to the new enterprise=True.

Is there a free API key for Nano Banana Pro?

Not from Google's free tiers. The Gemini API lists no free tier for Nano Banana Pro, and the express mode free tier doesn't list the GA gemini-3-pro-image ID. A new Google Cloud account's $300 trial credit is the closest thing: its exclusions cover AI Studio's Gemini API but not first-party Gemini on Agent Platform.

Do images from Vertex AI have a watermark?

They carry an invisible one. The Gemini API image generation docs state that all generated images include a SynthID watermark, Google Cloud's Nano Banana 2 enterprise announcement pairs SynthID with C2PA Content Credentials, and the Agent Platform model pages list C2PA as supported. Claims that Vertex output has "no watermark" can only refer to a visible mark.

Can I fine-tune Nano Banana on Vertex AI?

No. Every Nano Banana model page on Agent Platform lists tuning as "Not supported." To steer style or keep a subject consistent, pass reference images in the request instead: Nano Banana 2 and Pro accept up to 14 per prompt.

More in API Guides