Cloud Explainers

Gemini API vs Vertex AI: Which One Should You Use?

Gemini API & Google AI Studio10 min videoPublished Nov 7, 2026

The Gemini API and Vertex AI (now called Gemini Enterprise Agent Platform) reach the same Gemini models through two doors. We sent the same request to both for real: the AI Studio key is blocked at Vertex AI, which wants a Google Cloud identity, a role and billing; the code change is one line; and Vertex AI lets you choose where the model runs. Then which one to pick.

Gemini API vs Vertex AI: Which One Should You Use?, the full picture: diagram of Ana's script, Gemini API, Vertex AI, Three checks, Gemini models, Ana's Google Cloud project
The whole picture, from the video's recap.

Same model, two doors

Your app talks to Gemini with an API key from AI Studio, and now someone says: move it to Vertex AI. Same Gemini models, so what actually changes? Here's Ana's tea shop script on the Gemini API: an answer. The same key, sent to Vertex AI: blocked.

laptop: Ana's terminal
python describe.pyWith soft notes of tender sweet grass and a luminous emerald glow, our Sencha green tea offers a quiet moment of refreshing clarity.
(through the Gemini API)
laptop: Ana's terminal
./ask vertex --keyerror 403 PERMISSION_DENIED (API_KEY_SERVICE_BLOCKED)

Both are doors to the same Gemini models. The Gemini API is the quick door: a key, and you're in. Vertex AI is the Google Cloud door: it checks who you are, what you're allowed to do, and who pays. By the end you'll know which door fits your app, and why asking for Gemini in Europe got us a not found.

Someone asked exactly this on Google's AI developer forum: the API works fine for me, so why would I want to go to Vertex? Fair question. Google's own answer: most developers should use the Gemini API, unless they need specific enterprise controls. So what are those controls?

A real question, from Google's AI developer forum: cards of "The API works fine", "Why go to Vertex?", Google's answer, Unless

One thing first: Google Cloud's docs now call Vertex AI Gemini Enterprise Agent Platform, an evolution of Vertex AI. The address your code calls didn't change, so we'll keep the name people search for.

Two addresses, one family of models: cards of Gemini API, Vertex AI, Its new name, Same address

And one word we'll use a lot: project. A Google Cloud project is a folder for everything an app uses: its services, its keys, its people, and its bill. Even an AI Studio key lives in one, made for you behind the scenes. The Gemini API hides that project; Vertex AI makes you work in it.

A Google Cloud project holds: diagram of Services, Keys and accounts, People and roles, A bill, AI Studio keys live in a project too

The key Vertex AI won't take

Start where most people start. Ana's script makes a client, picks a model, and asks one question. The client finds her key by itself, in an environment variable: a named setting the shell hands to every program. Her small ask script sends the same question with curl, a tool for web requests: another answer.

laptop: Ana's terminal
cat describe.pyfrom google import genai

client = genai.Client()  # Gemini API: a key, from GEMINI_API_KEY

reply = client.models.generate_content(
    model="gemini-3.8-flash",
    contents="Describe our Sencha green tea in one calm sentence.",
)
print(reply.text)
print("(through Vertex AI)" if client.vertexai else "(through the Gemini API)")
laptop: Ana's terminal
./ask geminiSoftly steamed to preserve the fresh vitality of tender spring leaves, our Sencha green tea unfolds with a delicate, grassy sweetness that brings a moment of quiet stillness to your day.

Back to that blocked request: the same key, at Vertex AI's address, same model, same question. Guess first: does it work? No. Four oh three, permission denied: API key service blocked. The message says requests to this API are blocked. Not a typo in the address, and not a broken key: it worked a moment ago.

laptop: Ana's terminal
jq -r .error.message reply.jsonRequests to this API aiplatform.googleapis.com method google.cloud.aiplatform.v1.PredictionService.GenerateContent are blocked.

Why? Ana's key was made in AI Studio, and it's restricted to one Google service: the Gemini API. Vertex AI is a different service, so Google turns the key away before any model sees the question. Vertex AI does have a preview express mode with keys of its own, for a few models, but that's a separate key.

One key, allowed at one door: diagram of AI Studio key, Gemini API, Vertex AI, Gemini models

How Vertex AI knows who you are

Vertex AI wants a Google Cloud identity instead. Ana's Vertex script changes only the client line. With no identity on the laptop, the library stops before sending anything: default credentials not found. And curl, with nothing to sign in with, gets four oh one: unauthenticated, credentials missing.

laptop: Ana's terminal
cat describe_vertex.pyfrom google import genai

client = genai.Client(vertexai=True, project="ce-vertex-p048", location="global")

reply = client.models.generate_content(
    model="gemini-3.8-flash",
    contents="Describe our Sencha green tea in one calm sentence.",
)
print(reply.text)
print("(through Vertex AI)" if client.vertexai else "(through the Gemini API)")
laptop: Ana's terminal
python describe_vertex.py 2>&1 | tail -1google.auth.exceptions.DefaultCredentialsError: Your default credentials were not found. To set up Application Default Credentials, see https://cloud.google.com/docs/authentication/external/set-up-adc for more information.
laptop: Ana's terminal
./ask vertexerror 401 UNAUTHENTICATED (CREDENTIALS_MISSING)

Default credentials are the places Google's libraries look for an identity. On a laptop, that's often a service account: a Google Cloud account for a program, not a person, with a key file. The library trades that file for a sign-in token that lasts an hour, and sends the token with every request. On Google Cloud's own servers, the server already has an identity, so there's no file at all.

How a Vertex AI request signs in: diagram of Script, Sign-in, Vertex AI, the key file, a token, question + token, the answer

Google's libraries look in a fixed order. First a key file, named in an environment variable. Then your own Google login, if you signed in on this laptop with gcloud, Google Cloud's command-line tool. Then the identity of the Google Cloud server the code runs on. Ana's laptop had none of the three, so the library gave up.

Where default credentials come from, in order: cards of 1. A key file, 2. Your own login, 3. The server's identity, None of them

Ana points the library at the key file she downloaded when she made her service account, called shop-bot. Now Google knows who's asking, and still says no: four oh three, I A M permission denied. The message names the missing permission: A I platform dot endpoints dot predict.

laptop: Ana's terminal
export GOOGLE_APPLICATION_CREDENTIALS=~/keys/shop-bot.json
laptop: Ana's terminal
./ask vertexerror 403 PERMISSION_DENIED (IAM_PERMISSION_DENIED)
laptop: Ana's terminal
jq -r .error.message reply.json | cut -d' ' -f1-4Permission 'aiplatform.endpoints.predict' denied on

I A M is Google Cloud's rulebook: who can do what, in which project. Being someone isn't enough; you need a role that holds that permission. So the project's owner grants shop bot the Agent Platform User role, on the console's I A M page or from the command line, which includes predict. A key can't say any of this: anyone who holds it can use it.

Identity, then a role: diagram of shop-bot, Agent Platform User, Ask a model, Ana's Google Cloud project

A couple of minutes later, once the change has spread, the same command: an answer from Vertex AI.

laptop: Ana's terminal
./ask vertexDelicately steamed to capture the essence of early spring, our Sencha green tea unfolds with a soft, grassy sweetness that brings quiet clarity to your day.

One more check. With billing turned off for the project, the same request fails again: four oh three, billing disabled. This API method requires billing to be enabled. Someone has to pay for every request, and Vertex AI checks who that is first.

laptop: Ana's terminal
./ask vertexerror 403 PERMISSION_DENIED (BILLING_DISABLED)
laptop: Ana's terminal
jq -r .error.message reply.json | cut -d. -f1This API method requires billing to be enabled

So every Vertex AI request passes three checks the key never asked about. Who are you: a Google Cloud identity. Are you allowed: a role. Who pays: the project's billing. The Gemini API has a free tier with no billing at all; Vertex AI doesn't, though new Google Cloud accounts get three hundred dollars of credit. That's more setup, and for a company, it's the whole point.

The three checks on a Vertex AI request: cards of 1. Who are you?, 2. Are you allowed?, 3. Who pays?, The Gemini API

That's how companies run it in production. Mito, an AI video company, wrote on Google Cloud's blog this month how it made more than five thousand AI assets for a World Cup TV spot, with models it calls through Vertex AI, storage kept next to them, and client files kept private.

Mito, from Google Cloud's blog: cards of 5,000+ AI assets, Models, Storage, Client files

What changes in your code

And your code? Diff compares the two scripts: the line marked with a less-than sign is from the first file, the greater-than line from the second. They differ in one line, the client. Vertex AI true, the project's I D, and a location. Everything after it is the same: the model name, the call, the reply.

laptop: Ana's terminal
diff describe.py describe_vertex.py3c3
< client = genai.Client()  # Gemini API: a key, from GEMINI_API_KEY
---
> client = genai.Client(vertexai=True, project="ce-vertex-p048", location="global")

Run it, and there's the answer, through Vertex AI. You can even leave the first script alone. Set three environment variables: use Vertex AI, the project, and the location, and the first script, unchanged, now goes through Vertex as well.

laptop: Ana's terminal
python describe_vertex.pySteamed from tender spring leaves, our Sencha unfolds with a soft, grassy sweetness and a quiet clarity that gently invites you to pause.
(through Vertex AI)
laptop: Ana's terminal
GOOGLE_GENAI_USE_VERTEXAI=true GOOGLE_CLOUD_PROJECT=ce-vertex-p048 GOOGLE_CLOUD_LOCATION=global python describe.pyGently steamed to capture the quiet freshness of tender spring leaves, our Sencha green tea unfolds with a soothing, verdant warmth and a soft, lingering sweetness.
(through Vertex AI)

Under the hood, the address shows what moved. Every Vertex AI request names a project, the one whose rules and bill apply, and a location: where Google runs the model. The Gemini API's address has neither.

Part of Ana's Vertex AI address: diagram of projects/ce-vertex-p048/locations/global, ce-vertex-p048 = a project, global = a location

Where your request runs

So does the location matter? Ana's where script asks Gemini 3.8 Flash for three words at five locations: global, the US and EU multi-regions, and two single regions, Iowa and the Netherlands. Guess first: which ones answer? Global, US and EU. Both single regions: four oh four, not found.

laptop: Ana's terminal
cat where.pyimport os

from google import genai

model = os.environ.get("MODEL", "gemini-3.8-flash")
for location in ["global", "us", "eu", "us-central1", "europe-west4"]:
    client = genai.Client(vertexai=True, project="ce-vertex-p048", location=location)
    try:
        client.models.generate_content(model=model, contents="Say hi in three words.")
        print(f"{location:16} answered")
    except genai.errors.ClientError as e:
        print(f"{location:16} {e.code} {e.status}")
laptop: Ana's terminal
python where.pyglobal           answered
us               answered
eu               answered
us-central1      404 NOT_FOUND
europe-west4     404 NOT_FOUND

That's the not found from the start. This model isn't offered in those single regions. Global means Google may run your request in any of its locations around the world: good availability, but no promise where your data is processed. The EU multi-region keeps that processing inside the European Union, which some companies must do. The Gemini API has one global address, and no choice.

Where a request to Gemini 3.8 Flash can run: diagram of Ana's script, global, eu, europe-west4, Gemini 3.8 Flash

Which one to pick

What else does Vertex AI add? Google's own comparison lists it: compliance certifications like HIPAA, for health data in the US, and SOC 2, a security audit, reserved capacity called provisioned throughput, enterprise support with service level agreements, and model tuning.

Only on Vertex AI, from Google's comparison: cards of Compliance, Reserved capacity, Support + SLAs, Model tuning

And your data. On the Gemini API's free tier, Google uses your prompts and answers to improve its products. With billing on, the paid tier, it doesn't, and on Vertex AI it never does. So the line is free versus paid, not key versus Vertex. One more rule from the Gemini API terms: apps for users in Europe or the UK must use the paid tier.

Are your prompts used to improve Google's products?: comparison table of Used to improve? vs Needs, Gemini API, free, Gemini API, paid, Vertex AI, Europe and UK

So which one should you use? The Gemini API signs in with a key, has a free tier, and runs globally. Vertex AI signs in with a Google Cloud identity and a role, needs billing, and lets you pick where it runs. In one line: the Gemini API checks your key; Vertex AI checks your whole project.

Gemini API or Vertex AI?: comparison table of Gemini API vs Vertex AI, Sign in, Free tier, Where it runs, Extras, In one line

Start on the Gemini API. Move to Vertex AI when a rule says you must: a security team that wants roles instead of keys, data that has to stay in one place, a contract that needs an SLA, or a company already on Google Cloud. The move is one line of code, plus the three checks.

When to move to Vertex AI: cards of Roles, not keys, Data location, An SLA, Already on Google Cloud

Every command and the lab files are linked in the description, ready for your own key and your own project.

Run it yourself: cards of describe.py, describe_vertex.py, The ask script, where.py

Recap

So: same models, two doors. A key for building. A Google Cloud project when a company needs roles, a bill, and a place to run it.

If this saved you a day of reading Google's docs, subscribing helps us reach more beginners.

Every request here went to the real Gemini API and Vertex AI. Thanks for watching Cloud Explainers.

Sources

Demos: one container on our own Mac standing in for Ana's laptop, sending real requests with our own key and a lab Google Cloud project made for this video (credentials never shown); the tea shop is made up. Watch the full video on YouTube.

More videos

Linux9 min

Linux Makefiles Will Finally Make Sense After This

Auth (OAuth, JWT)9 min

SAML vs OAuth vs OpenID Connect: What's the Difference?

Python7 min

How to Fix Python cron Jobs That Never Run

Linux22 min

Linux Bash Scripting: Full Tutorial for Beginners

Networking10 min

How PXE Network Boot Works

Active Directory9 min

How Active Directory Works

Linux10 min

How to Fix a Linux systemd Service That Won't Start

Linux9 min

Linux Logs: syslog vs journald

Auth (OAuth, JWT)9 min

JWT vs Session Cookies: Which One Should You Use?

Docker10 min

Docker vs Docker Compose: Which One Should You Use?

Docker9 min

How to Fix Docker Compose Containers That Can't Talk to Each Other

Django (Python web framework)22 min

Django Full Tutorial for Beginners

Linux9 min

How Linux systemd Works

Networking8 min

How to Fix 'Windows Cannot Access' Network Share Errors (SMB)

APIs10 min

REST vs gRPC: Which One Should You Use?

Certificates & PKI (ADCS)9 min

How to Fix SSL Certificate Chain Errors (Missing Intermediate)

Python9 min

Every Python Concept for Beginners in 10 Minutes

Databases & SQL9 min

Every SQL Join Type in 10 Minutes

OpenRouter (one API for many AI models)9 min

Why OpenRouter Free Models Hit Their Limit So Fast

Gemini API & Google AI Studio9 min

Why Your Gemini API Free Tier Runs Out So Fast

OpenRouter (one API for many AI models)10 min

OpenRouter Will Finally Make Sense After This

Caching & Redis10 min

How Redis Caching Works

Gemini API & Google AI Studio8 min

How to Fix a Leaked Gemini API Key

Go (Golang)9 min

Why Golang Uses Goroutines Instead of Threads

Gemini API & Google AI Studio9 min

How to Fix Gemini API Error 429: Resource Exhausted

Claude & the Claude Developer Platform10 min

Claude Token Pricing Will Finally Make Sense After This

Python11 min

Why Python Web Scraping Returns Nothing (and the Fix)

Python10 min

Python uv vs pip: Which One Should You Use?

Python22 min

Python Automation: Full Tutorial for Beginners

Auth (OAuth, JWT)9 min

How OAuth Login Works

Gemini API & Google AI Studio10 min

Google AI Studio Will Finally Make Sense After This

Docker10 min

What Happens When You Run a Docker Container

Claude & the Claude Developer Platform8 min

How to Fix Claude Code Billing Your API Key Instead of Your Plan

Auth (OAuth, JWT)9 min

Why Passkeys Can't Be Phished Like Passwords

PowerShell10 min

PowerShell vs Bash: Which One Should You Learn?

Linux10 min

The Linux Roadmap for Beginners

Django (Python web framework)9 min

Django vs FastAPI: Which One Should You Use?

Databases & SQL10 min

Why SQLite Is the Most Used Database in the World

Databases & SQL11 min

How a NoSQL Database Like MongoDB Works

Python11 min

How to Fix Python pip error: externally-managed-environment

Databases & SQL9 min

How to Fix MySQL Too Many Connections Database Errors

Go (Golang)9 min

Golang Concurrency Will Finally Make Sense After This

AWS10 min

How Amazon S3 Works

Kubernetes10 min

How Kubernetes Works

Git10 min

How Git Works

Docker10 min

How to Fix Docker Port Already Allocated Errors

PostgreSQL10 min

How PostgreSQL Works

Git8 min

How to Fix Git Merge Conflicts

Linux9 min

How to Fix No Space Left on Device in Linux

Networking10 min

How the Internet Works

Databases & SQL9 min

SQL vs NoSQL: When Each One Wins

Auth (OAuth, JWT)8 min

How to Fix JWT Token Expired Errors (401 Unauthorized)

Claude & the Claude Developer Platform9 min

Claude API vs Claude Pro: Why Your Subscription Doesn't Include It

AI agent skills9 min

Why AI Agent Skills Beat Giant Prompts

Linux10 min

Linux Cron Jobs Will Finally Make Sense After This

Cybersecurity10 min

Security Logs Will Finally Make Sense After This

Cybersecurity8 min

How to Fix a Security Leak: An API Key Pushed to GitHub

DNS9 min

DNS Will Finally Make Sense After This

Cybersecurity9 min

Never Ignore a Security Update

Auth (OAuth, JWT)9 min

Two-Factor Authentication Will Finally Make Sense

Networking8 min

Never Expose a Database to the Internet

Cybersecurity10 min

SSH Keys vs Passwords: Which Is Safer for Security?

Linux10 min

The 5 Levels of Linux Boot: From Power On to Login

Networking12 min

The 5 Levels of Network Firewalls

Cybersecurity10 min

Password Security: Why Hackers Crack Weak Passwords

Linux9 min

Why Your Linux Server Runs Out of Memory

Networking10 min

HTTP vs HTTPS: What Actually Changes on Your Network

Linux12 min

Every Linux File Permission You Need to Know

Linux10 min

Linux Processes vs Threads: When Each One Wins

Networking11 min

The OSI Model Will Finally Make Sense After This

Git11 min

The 7 Levels of Git

Networking10 min

Every Network Troubleshooting Command You Need

Cybersecurity10 min

Hashing vs Encryption in Cybersecurity: When Each One Wins

Networking11 min

Why the Internet Ran Out of IP Addresses

Linux11 min

Linux Package Managers: apt vs Snap vs Flatpak

Python9 min

Why Python Is Slow (and When It Doesn't Matter)

Networking11 min

TCP vs UDP: When Each One Wins

Linux8 min

Stop Running Linux as Root (Do This Instead)

Linux11 min

Linux Users and Groups Will Finally Make Sense

Cybersecurity9 min

Why Phishing Beats Good Security (and How to Spot It)

Docker12 min

The 7 Levels of Docker

AI agents & MCP12 min

AI Agents Will Finally Make Sense After This

Git8 min

Stop Using git push --force (Use This Instead)

AI agent skills10 min

Agent Skills vs MCP: When Each One Wins

Networking12 min

Networking Will Finally Make Sense After This

Linux12 min

Every Linux Command You Actually Need

Cybersecurity12 min

The 7 Levels of Cybersecurity

System design12 min

Every System Design Concept You Need, in One Diagram

PostgreSQL10 min

Why PostgreSQL Ignores Your Index