Registry /
llm-agents / langchain-google-vertexai
Install & Compatibility
Where this runs
tested against v3.2.4 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 19.604s · 545.5MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 24.5s · import 10.146s · 521MB
546MB installed
● package 546MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
ChatVertexAI
✓ from langchain_google_vertexai import ChatVertexAI
✗ from langchain.llms import VertexAI or from langchain.chat_models import ChatVertexAI (for older LangChain versions)
The primary chat model class for Vertex AI. As of v3.2.0, this is deprecated in favor of `ChatGoogleGenerativeAI` from `langchain-google-genai` for unified Gemini API access, but remains for Vertex AI platform-specific features. [9, 22]
VertexAI
✓ from langchain_google_vertexai import VertexAI
✗ from langchain.llms import VertexAI (for older LangChain versions)
The primary LLM class for Vertex AI completion models. As of v3.2.0, this is deprecated in favor of `GoogleGenerativeAI` from `langchain-google-genai` for unified Gemini API access, but remains for Vertex AI platform-specific features. [9, 22]
VertexAIEmbeddings
✓ from langchain_google_vertexai import VertexAIEmbeddings
✗ from langchain.embeddings import VertexAIEmbeddings (for older LangChain versions)
The embeddings class for Vertex AI. As of v3.2.0, this is deprecated in favor of `GoogleGenerativeAIEmbeddings` from `langchain-google-genai` for unified Gemini API access, but remains for Vertex AI platform-specific features. [9, 20, 22]
ChatAnthropicVertex
✓ from langchain_google_vertexai import ChatAnthropicVertex
For integrating with Anthropic's Claude models hosted on Vertex AI. [9]
This quickstart demonstrates how to instantiate and use the `ChatVertexAI` model for text generation. It also shows an example of multimodal input (commented out) using a vision-capable model. Ensure your Google Cloud project and location are configured, and that you are authenticated to Google Cloud, typically via Application Default Credentials (e.g., `gcloud auth application-default login`) or by setting `GOOGLE_APPLICATION_CREDENTIALS`.
import os
from langchain_core.messages import HumanMessage
from langchain_google_vertexai import ChatVertexAI
# Ensure your Google Cloud Project ID and location are set
# or use GOOGLE_APPLICATION_CREDENTIALS for authentication.
# For example, by running 'gcloud auth application-default login'
# os.environ["GOOGLE_CLOUD_PROJECT"] = os.environ.get("GOOGLE_CLOUD_PROJECT", "your-gcp-project-id")
# os.environ["GOOGLE_CLOUD_LOCATION"] = os.environ.get("GOOGLE_CLOUD_LOCATION", "us-central1")
# Initialize the chat model
# Note: ChatVertexAI is deprecated in favor of ChatGoogleGenerativeAI from langchain_google_genai
# for most Gemini models, but can still be used for Vertex AI specific deployments.
llm = ChatVertexAI(model="gemini-pro") # or "gemini-2.5-flash", "chat-bison", etc.
# Invoke the model with a message
response = llm.invoke("What is the capital of France?")
print(response.content)
# Example with multimodal input (requires a vision model like "gemini-pro-vision")
# from langchain_core.messages import HumanMessage
# llm_vision = ChatVertexAI(model="gemini-pro-vision")
# message_with_image = HumanMessage(
# content=[
# {"type": "text", "text": "What's in this image?"},
# {"type": "image_url", "image_url": {"url": "https://picsum.photos/seed/picsum/200/300"}},
# ]
# )
# response_vision = llm_vision.invoke([message_with_image])
# print(response_vision.content)
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'langchain_google_vertexai'
The 'langchain-google-vertexai' package is not installed, or the Python environment where the code is being run does not have it installed.
fixInstall the package using pip: `pip install langchain-google-vertexai`. Ensure this is run in the same Python environment used by your application.
AttributeError: 'TextGenerationResponse' object has no attribute 'candidates'
This error typically occurs with older versions of LangChain or 'langchain-google-vertexai' when the internal structure of the response object from Vertex AI models has changed, making the 'candidates' attribute unavailable or deprecated.
fixUpdate 'langchain-google-vertexai' to a compatible version with your LangChain installation (`pip install --upgrade langchain-google-vertexai`). You may need to adjust your code to access the generated text directly, often via `response.text` instead of `response.candidates`.
ValueError: Could not resolve project_id
This indicates an authentication failure with Google Cloud's Vertex AI. It often means that the Google Cloud project ID is not correctly identified, which can happen if `GOOGLE_APPLICATION_CREDENTIALS` is not set, or if the environment (e.g., Cloud Run) is not correctly configured for application default credentials.
fixEnsure the `GOOGLE_APPLICATION_CREDENTIALS` environment variable points to a valid service account JSON key file. Alternatively, ensure you are authenticated via `gcloud auth application-default login` for local development. When initializing `ChatVertexAI`, explicitly pass `project` and `location` parameters.
ValueError: Cannot get the Candidate text. Response candidate content part has no text.
This error arises from an incompatibility between the installed version of `langchain-google-vertexai` and `google-cloud-aiplatform`, especially when using tool-calling features.
fixUpgrade `langchain-google-vertexai` to version 1.0.2 or later to ensure compatibility with the `google-cloud-aiplatform` SDK's tool-calling updates: `pip install --upgrade langchain-google-vertexai`.
Upgrade
Version history
3.2.4latest on PyPI · released Jun 9, 2026
Audit
Dependencies
google-cloud-aiplatformrequiredRequired for interacting with Google Vertex AI services.
langchain-corerequiredCore LangChain functionalities.
httpxrequiredUsed for making HTTP requests.
pydanticrequiredUsed for data validation and settings management.