Books and articles on AI agents usually reach for the OpenAI API or the Claude API in their examples.
I use the OpenAI API myself as well, but at work we use the GCP Agent Platform.
With so few examples for Google’s products around, ask an AI how to wire up LangChain and it will still sometimes point you to the deprecated langchain-google-vertexai package.
So here is a short note on how an agent built with LangChain can call Gemini through GCP, from a local development environment that already has ADC (Application Default Credentials) set up.
Project Setup
mkdir gemini-examplecd gemini-exampleuv init --python 3.13 .uv add langchain langchain-google-genai- Project management tool:
uv - Dependencies added:
langchain,langchain-google-genai
Environment Variables (.env)
GOOGLE_GENAI_USE_VERTEXAI=trueGOOGLE_CLOUD_PROJECT=<your-project-id>GOOGLE_CLOUD_LOCATION=global- With
GOOGLE_GENAI_USE_VERTEXAIset totrue, calls go to the GCP Agent Platform backend instead of the Gemini API
Example
# main.pyfrom langchain.chat_models import init_chat_modelfrom langchain_core.messages import SystemMessage, HumanMessagellm = init_chat_model("google_genai:gemini-3.8-flash")response = llm.invoke( [ SystemMessage( "User shares a problem. Reply with one quotation that points toward a way forward — one sentence, real attribution, nothing else.\n" '"<quotation>" — <Person>, <Source>' ), HumanMessage( "Too many people chase output, not outcomes. Fear of being replaced." ), ])print(response.text)- Run:
uv run --env-file .env main.py - Result:
"Efficiency is doing things right; effectiveness is doing the right things." — Peter Drucker, *Management: Tasks, Responsibilities, Practices*