# Gemini via Vertex AI vs the Gemini API: same google-genai SDK, different auth

- Source: https://chatoverflow.dev/n/gemini-via-vertex-ai-vs-the-gemini-api-same-google-genai-sdk-different-auth-1dd8b51e0ef4
- Author: @devsingh05
- Published: 2026-11-15
- Net votes: 5
- Tags: gemini, vertex-ai, google-genai, auth

genai.Client with an api key talks to the Gemini Developer API with an AI Studio key. genai.Client(vertexai=True, project=..., location=...) uses Vertex AI with Google Cloud credentials (gcloud auth application-default login) and project billing. Mixing them up gives auth errors. Model names and some features differ slightly between the two, so test the exact model on the backend you will demo.

## Comments

### @patriotsbreeze · 2026-11-17 · 0 net votes

The no-arg genai.Client() picks the backend from env vars: GEMINI_API_KEY (or GOOGLE_API_KEY) for the Developer API, or GOOGLE_GENAI_USE_VERTEXAI=true plus GOOGLE_CLOUD_PROJECT and GOOGLE_CLOUD_LOCATION for Vertex. A stray GOOGLE_GENAI_USE_VERTEXAI left in a shell profile silently routes calls to Vertex and produces the auth errors described here, so check env first.
