{"id":889,"library":"langchain-google-vertexai","title":"LangChain Google Vertex AI Integration","description":"This package provides LangChain integrations for Google Cloud generative models via the Vertex AI Platform. It enables access to foundational models (like Gemini) and third-party models available on Vertex AI Model Garden, along with services like Vector Search. The current version is 3.2.2, with active development and frequent releases to support new features and address issues.","status":"active","version":"3.2.2","language":"python","source_language":"en","source_url":"https://github.com/langchain-ai/langchain-google/tree/main/libs/vertexai","tags":["LangChain","Google Cloud","Vertex AI","LLM","Chat Model","Embeddings","Generative AI","Google Gemini"],"install":[{"cmd":"pip install langchain-google-vertexai","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Required for interacting with Google Vertex AI services.","package":"google-cloud-aiplatform","optional":false},{"reason":"Core LangChain functionalities.","package":"langchain-core","optional":false},{"reason":"Used for making HTTP requests.","package":"httpx","optional":false},{"reason":"Used for data validation and settings management.","package":"pydantic","optional":false}],"imports":[{"note":"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]","wrong":"from langchain.llms import VertexAI or from langchain.chat_models import ChatVertexAI (for older LangChain versions)","symbol":"ChatVertexAI","correct":"from langchain_google_vertexai import ChatVertexAI"},{"note":"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]","wrong":"from langchain.llms import VertexAI (for older LangChain versions)","symbol":"VertexAI","correct":"from langchain_google_vertexai import VertexAI"},{"note":"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]","wrong":"from langchain.embeddings import VertexAIEmbeddings (for older LangChain versions)","symbol":"VertexAIEmbeddings","correct":"from langchain_google_vertexai import VertexAIEmbeddings"},{"note":"For integrating with Anthropic's Claude models hosted on Vertex AI. [9]","symbol":"ChatAnthropicVertex","correct":"from langchain_google_vertexai import ChatAnthropicVertex"}],"quickstart":{"code":"import os\nfrom langchain_core.messages import HumanMessage\nfrom langchain_google_vertexai import ChatVertexAI\n\n# Ensure your Google Cloud Project ID and location are set\n# or use GOOGLE_APPLICATION_CREDENTIALS for authentication.\n# For example, by running 'gcloud auth application-default login'\n# os.environ[\"GOOGLE_CLOUD_PROJECT\"] = os.environ.get(\"GOOGLE_CLOUD_PROJECT\", \"your-gcp-project-id\")\n# os.environ[\"GOOGLE_CLOUD_LOCATION\"] = os.environ.get(\"GOOGLE_CLOUD_LOCATION\", \"us-central1\")\n\n# Initialize the chat model\n# Note: ChatVertexAI is deprecated in favor of ChatGoogleGenerativeAI from langchain_google_genai\n# for most Gemini models, but can still be used for Vertex AI specific deployments.\nllm = ChatVertexAI(model=\"gemini-pro\") # or \"gemini-2.5-flash\", \"chat-bison\", etc.\n\n# Invoke the model with a message\nresponse = llm.invoke(\"What is the capital of France?\")\nprint(response.content)\n\n# Example with multimodal input (requires a vision model like \"gemini-pro-vision\")\n# from langchain_core.messages import HumanMessage\n# llm_vision = ChatVertexAI(model=\"gemini-pro-vision\")\n# message_with_image = HumanMessage(\n#     content=[\n#         {\"type\": \"text\", \"text\": \"What's in this image?\"},\n#         {\"type\": \"image_url\", \"image_url\": {\"url\": \"https://picsum.photos/seed/picsum/200/300\"}},\n#     ]\n# )\n# response_vision = llm_vision.invoke([message_with_image])\n# print(response_vision.content)","lang":"python","description":"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`."},"warnings":[{"fix":"Migrate to `ChatGoogleGenerativeAI`, `GoogleGenerativeAI`, and `GoogleGenerativeAIEmbeddings` respectively, from the `langchain-google-genai` package for most Gemini API interactions. `langchain-google-vertexai` remains supported for Vertex AI platform-specific features (Model Garden, Vector Search, etc.). [8, 9, 22]","message":"Classes `ChatVertexAI`, `VertexAI`, and `VertexAIEmbeddings` are officially deprecated in `langchain-google-vertexai` version 3.2.0 and will be removed in 4.0.0. [8, 9, 20]","severity":"deprecated","affected_versions":">=3.2.0"},{"fix":"Ensure you are authenticated via `gcloud auth application-default login` or by setting the `GOOGLE_APPLICATION_CREDENTIALS` environment variable to the path of a service account JSON key file. Project ID and location might also need to be specified in the model constructor or environment variables. [2, 3, 6, 20]","message":"Authentication to Google Cloud Vertex AI typically requires Application Default Credentials (ADC). Incorrect or missing authentication setup is a common source of errors. [2, 3, 6, 7]","severity":"gotcha","affected_versions":"All"},{"fix":"For general Gemini model access (Gemini API), use `langchain-google-genai`. For integrations requiring Vertex AI platform features or third-party models deployed on Vertex AI, use `langchain-google-vertexai`. Refer to the official LangChain Google documentation for guidance on which package to use. [22]","message":"There can be confusion between `langchain-google-vertexai` and `langchain-google-genai`. While both offer Google LLM integrations, `langchain-google-vertexai` focuses on Vertex AI platform-specific features (e.g., Model Garden, Vector Search, Anthropic models on Vertex AI), whereas `langchain-google-genai` is for direct Google Generative AI (Gemini API) access. [2, 7, 22, 33, 34]","severity":"gotcha","affected_versions":"All"},{"fix":"Use simple, flat object structures for tool schemas, replace discriminated unions with enums and optional fields, and prefer `min()` over `positive()` for number constraints. Test your tool schemas thoroughly. [3, 19]","message":"When using tools with Gemini models through Vertex AI, certain Zod schema features (e.g., discriminated unions, union types, positive refinements) are not supported or are automatically converted, potentially leading to unexpected behavior or errors. [3, 19]","severity":"gotcha","affected_versions":"All"}],"env_vars":null,"last_verified":"2026-05-12T20:57:43.790Z","next_check":"2026-06-27T00:00:00.000Z","problems":[{"fix":"Install the package using pip: `pip install langchain-google-vertexai`. Ensure this is run in the same Python environment used by your application.","cause":"The 'langchain-google-vertexai' package is not installed, or the Python environment where the code is being run does not have it installed.","error":"ModuleNotFoundError: No module named 'langchain_google_vertexai'"},{"fix":"Update '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`.","cause":"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.","error":"AttributeError: 'TextGenerationResponse' object has no attribute 'candidates'"},{"fix":"Ensure 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.","cause":"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.","error":"ValueError: Could not resolve project_id"},{"fix":"Upgrade `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`.","cause":"This error arises from an incompatibility between the installed version of `langchain-google-vertexai` and `google-cloud-aiplatform`, especially when using tool-calling features.","error":"ValueError: Cannot get the Candidate text. Response candidate content part has no text."}],"ecosystem":"pypi","meta_description":null,"install_score":80,"install_tag":"verified","quickstart_score":null,"quickstart_tag":null,"pypi_latest":"3.2.3","cli_name":"","cli_version":null,"install_checks":{"last_tested":"2026-05-12","tag":"verified","tag_description":"installs cleanly on critical runtimes, fast import, recently tested","installed_version":"2.1.2","pypi_latest":"3.2.3","is_stale":true,"results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"langchain-google-vertexai","exit_code":0,"wheel_type":"sdist","failure_reason":null,"import_side_effects":"noisy","install_time_s":null,"import_time_s":19.86,"mem_mb":273.4,"disk_size":"549.8M"},{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"langchain-google-vertexai","exit_code":0,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":21.61,"mem_mb":267.2,"disk_size":"541.5M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"langchain-google-vertexai","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"noisy","install_time_s":27,"import_time_s":7.78,"mem_mb":181.9,"disk_size":"527M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"langchain-google-vertexai","exit_code":0,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":9.23,"mem_mb":178.1,"disk_size":"523M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"langchain-google-vertexai","exit_code":0,"wheel_type":"sdist","failure_reason":null,"import_side_effects":"noisy","install_time_s":null,"import_time_s":22.65,"mem_mb":285.4,"disk_size":"593.8M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"langchain-google-vertexai","exit_code":0,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":29.68,"mem_mb":281.4,"disk_size":"584.7M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"langchain-google-vertexai","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":25.3,"import_time_s":13.39,"mem_mb":203.2,"disk_size":"571M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"langchain-google-vertexai","exit_code":0,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":16.85,"mem_mb":202.1,"disk_size":"565M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"langchain-google-vertexai","exit_code":0,"wheel_type":"sdist","failure_reason":null,"import_side_effects":"noisy","install_time_s":null,"import_time_s":20.32,"mem_mb":280.6,"disk_size":"576.7M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"langchain-google-vertexai","exit_code":0,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":31.4,"mem_mb":278.4,"disk_size":"567.7M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"langchain-google-vertexai","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":22.5,"import_time_s":12.26,"mem_mb":199.3,"disk_size":"554M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"langchain-google-vertexai","exit_code":0,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":24.25,"mem_mb":195.4,"disk_size":"548M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"langchain-google-vertexai","exit_code":0,"wheel_type":"sdist","failure_reason":null,"import_side_effects":"noisy","install_time_s":null,"import_time_s":17.45,"mem_mb":281.2,"disk_size":"573.7M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"langchain-google-vertexai","exit_code":0,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":30.19,"mem_mb":281.9,"disk_size":"564.8M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"langchain-google-vertexai","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":22.8,"import_time_s":11.76,"mem_mb":198.3,"disk_size":"551M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"langchain-google-vertexai","exit_code":0,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":24.49,"mem_mb":194.9,"disk_size":"545M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"langchain-google-vertexai","exit_code":0,"wheel_type":"sdist","failure_reason":null,"import_side_effects":"noisy","install_time_s":null,"import_time_s":16.97,"mem_mb":250.4,"disk_size":"505.7M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"langchain-google-vertexai","exit_code":0,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":16.89,"mem_mb":250.2,"disk_size":"504.5M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"langchain-google-vertexai","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"noisy","install_time_s":26.6,"import_time_s":7.02,"mem_mb":163.3,"disk_size":"488M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"langchain-google-vertexai","exit_code":0,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":6.81,"mem_mb":163.2,"disk_size":"487M"}]},"quickstart_checks":{"last_tested":"2026-04-24","tag":null,"tag_description":null,"results":[{"runtime":"python:3.10-alpine","exit_code":1},{"runtime":"python:3.10-slim","exit_code":1},{"runtime":"python:3.11-alpine","exit_code":-1},{"runtime":"python:3.11-slim","exit_code":1},{"runtime":"python:3.12-alpine","exit_code":-1},{"runtime":"python:3.12-slim","exit_code":1},{"runtime":"python:3.13-alpine","exit_code":-1},{"runtime":"python:3.13-slim","exit_code":1},{"runtime":"python:3.9-alpine","exit_code":1},{"runtime":"python:3.9-slim","exit_code":1}]}}