All functionality related to Google Cloud Platform and other Google
products.
Chat modelsโ
We recommend individual developers to start with Gemini API (langchain-google-genai
) and move to Vertex AI (langchain-google-vertexai
) when they need access to commercial support and higher rate limits. If youโre already Cloud-friendly or Cloud-native, then you can get started in Vertex AI straight away.
Please see here for more information.
Google Generative AIโ
Access GoogleAI Gemini
models such as gemini-pro
and gemini-pro-vision
through the ChatGoogleGenerativeAI
class.
pip install -U langchain-google-genai
Configure your API key.
export GOOGLE_API_KEY=your-api-key
from langchain_google_genai import ChatGoogleGenerativeAI
llm = ChatGoogleGenerativeAI(model="gemini-pro")
llm.invoke("Sing a ballad of LangChain.")
Gemini vision model supports image inputs when providing a single chat message.
from langchain_core.messages import HumanMessage
from langchain_google_genai import ChatGoogleGenerativeAI
llm = ChatGoogleGenerativeAI(model="gemini-pro-vision")
message = HumanMessage(
content=[
{
"type": "text",
"text": "What's in this image?",
}, # You can optionally provide text parts
{"type": "image_url", "image_url": "https://picsum.photos/seed/picsum/200/300"},
]
)
llm.invoke([message])
The value of image_url can be any of the following:
- A public image URL
- A gcs file (e.g., "gcs://path/to/file.png")
- A local file path
- A base64 encoded image (e.g., data:image/png;base64,abcd124)
- A PIL image
Vertex AIโ
Access chat models like Gemini
via Google Cloud.
We need to install langchain-google-vertexai
python package.
pip install langchain-google-vertexai
See a usage example.
from langchain_google_vertexai import ChatVertexAI
Chat Anthropic on Vertex AI Model Gardenโ
See a usage example.
from langchain_google_vertexai.model_garden import ChatAnthropicVertex
Chat Llama on Vertex AI Model Gardenโ
from langchain_google_vertexai.model_garden_maas.llama import VertexModelGardenLlama
Chat Mistral on Vertex AI Model Gardenโ
from langchain_google_vertexai.model_garden_maas.mistral import VertexModelGardenMistral
Chat Gemma local from Hugging Faceโ
Local
Gemma
model loaded fromHuggingFace
.
We need to install langchain-google-vertexai
python package.
pip install langchain-google-vertexai
from langchain_google_vertexai.gemma import GemmaChatLocalHF
Chat Gemma local from Kaggleโ
Local
Gemma
model loaded fromKaggle
.
We need to install langchain-google-vertexai
python package.
pip install langchain-google-vertexai
from langchain_google_vertexai.gemma import GemmaChatLocalKaggle
Chat Gemma on Vertex AI Model Gardenโ
We need to install langchain-google-vertexai
python package.
pip install langchain-google-vertexai
from langchain_google_vertexai.gemma import GemmaChatVertexAIModelGarden
Vertex AI image captioning chatโ
Implementation of the
Image Captioning model
as a chat.
We need to install langchain-google-vertexai
python package.
pip install langchain-google-vertexai
from langchain_google_vertexai.vision_models import VertexAIImageCaptioningChat
Vertex AI image editor chatโ
Given an image and a prompt, edit the image. Currently only supports mask-free editing.
We need to install langchain-google-vertexai
python package.
pip install langchain-google-vertexai
from langchain_google_vertexai.vision_models import VertexAIImageEditorChat
Vertex AI image generator chatโ
Generates an image from a prompt.
We need to install langchain-google-vertexai
python package.
pip install langchain-google-vertexai
from langchain_google_vertexai.vision_models import VertexAIImageGeneratorChat
Vertex AI visual QnA chatโ
Chat implementation of a visual QnA model
We need to install langchain-google-vertexai
python package.
pip install langchain-google-vertexai
from langchain_google_vertexai.vision_models import VertexAIVisualQnAChat
LLMsโ
Google Generative AIโ
Access GoogleAI Gemini
models such as gemini-pro
and gemini-pro-vision
through the GoogleGenerativeAI
class.
Install python package.
pip install langchain-google-genai
See a usage example.
from langchain_google_genai import GoogleGenerativeAI
Vertex AI Model Gardenโ
Access PaLM
and hundreds of OSS models via Vertex AI Model Garden
service.
We need to install langchain-google-vertexai
python package.
pip install langchain-google-vertexai
See a usage example.
from langchain_google_vertexai import VertexAIModelGarden
Gemma local from Hugging Faceโ
Local
Gemma
model loaded fromHuggingFace
.
We need to install langchain-google-vertexai
python package.
pip install langchain-google-vertexai
from langchain_google_vertexai.gemma import GemmaLocalHF
Gemma local from Kaggleโ
Local
Gemma
model loaded fromKaggle
.
We need to install langchain-google-vertexai
python package.
pip install langchain-google-vertexai
from langchain_google_vertexai.gemma import GemmaLocalKaggle
Gemma on Vertex AI Model Gardenโ
We need to install langchain-google-vertexai
python package.
pip install langchain-google-vertexai
from langchain_google_vertexai.gemma import GemmaVertexAIModelGarden
Vertex AI image captioningโ
Implementation of the
Image Captioning model
as an LLM.
We need to install langchain-google-vertexai
python package.
pip install langchain-google-vertexai
from langchain_google_vertexai.vision_models import VertexAIImageCaptioning
Embedding modelsโ
Google Generative AI embeddingโ
See a usage example.
pip install -U langchain-google-genai
Configure your API key.
export GOOGLE_API_KEY=your-api-key
from langchain_google_genai import GoogleGenerativeAIEmbeddings
Google Generative AI server-side embeddingโ
Install the python package:
pip install langchain-google-genai
from langchain_google_genai.google_vector_store import ServerSideEmbedding
Vertex AIโ
We need to install langchain-google-vertexai
python package.
pip install langchain-google-vertexai
See a usage example.
from langchain_google_vertexai import VertexAIEmbeddings
Palm embeddingโ
We need to install langchain-community
python package.
pip install langchain-community
from langchain_community.embeddings.google_palm import GooglePalmEmbeddings
Document Loadersโ
AlloyDB for PostgreSQLโ
Google Cloud AlloyDB is a fully managed relational database service that offers high performance, seamless integration, and impressive scalability on Google Cloud. AlloyDB is 100% compatible with PostgreSQL.
Install the python package:
pip install langchain-google-alloydb-pg
See usage example.
from langchain_google_alloydb_pg import AlloyDBEngine, AlloyDBLoader
BigQueryโ
Google Cloud BigQuery is a serverless and cost-effective enterprise data warehouse that works across clouds and scales with your data in Google Cloud.
We need to install langchain-google-community
with Big Query dependencies:
pip install langchain-google-community[bigquery]
See a usage example.
from langchain_google_community import BigQueryLoader
Bigtableโ
Google Cloud Bigtable is Google's fully managed NoSQL Big Data database service in Google Cloud.
Install the python package:
pip install langchain-google-bigtable
See Googel Cloud usage example.
from langchain_google_bigtable import BigtableLoader
Cloud SQL for MySQLโ
Google Cloud SQL for MySQL is a fully-managed database service that helps you set up, maintain, manage, and administer your MySQL relational databases on Google Cloud.
Install the python package:
pip install langchain-google-cloud-sql-mysql
See usage example.
from langchain_google_cloud_sql_mysql import MySQLEngine, MySQLLoader
Cloud SQL for SQL Serverโ
Google Cloud SQL for SQL Server is a fully-managed database service that helps you set up, maintain, manage, and administer your SQL Server databases on Google Cloud.
Install the python package:
pip install langchain-google-cloud-sql-mssql
See usage example.
from langchain_google_cloud_sql_mssql import MSSQLEngine, MSSQLLoader
Cloud SQL for PostgreSQLโ
Google Cloud SQL for PostgreSQL is a fully-managed database service that helps you set up, maintain, manage, and administer your PostgreSQL relational databases on Google Cloud.
Install the python package:
pip install langchain-google-cloud-sql-pg
See usage example.
from langchain_google_cloud_sql_pg import PostgresEngine, PostgresLoader
Cloud Storageโ
Cloud Storage is a managed service for storing unstructured data in Google Cloud.
We need to install langchain-google-community
with Google Cloud Storage dependencies.
pip install langchain-google-community[gcs]
There are two loaders for the Google Cloud Storage
: the Directory
and the File
loaders.
See a usage example.
from langchain_google_community import GCSDirectoryLoader
See a usage example.
from langchain_google_community import GCSFileLoader
Cloud Vision loaderโ
Install the python package:
pip install langchain-google-community[vision]
from langchain_google_community.vision import CloudVisionLoader
El Carro for Oracle Workloadsโ
Google El Carro Oracle Operator offers a way to run Oracle databases in Kubernetes as a portable, open source, community driven, no vendor lock-in container orchestration system.
pip install langchain-google-el-carro
See usage example.
from langchain_google_el_carro import ElCarroLoader
Google Driveโ
Google Drive is a file storage and synchronization service developed by Google.
Currently, only Google Docs
are supported.
We need to install langchain-google-community
with Google Drive dependencies.
pip install langchain-google-community[drive]
See a usage example and authorization instructions.
from langchain_google_community import GoogleDriveLoader
Firestore (Native Mode)โ
Google Cloud Firestore is a NoSQL document database built for automatic scaling, high performance, and ease of application development.
Install the python package:
pip install langchain-google-firestore
See usage example.
from langchain_google_firestore import FirestoreLoader
Firestore (Datastore Mode)โ
Google Cloud Firestore in Datastore mode is a NoSQL document database built for automatic scaling, high performance, and ease of application development. Firestore is the newest version of Datastore and introduces several improvements over Datastore.
Install the python package:
pip install langchain-google-datastore
See usage example.
from langchain_google_datastore import DatastoreLoader
Memorystore for Redisโ
Google Cloud Memorystore for Redis is a fully managed Redis service for Google Cloud. Applications running on Google Cloud can achieve extreme performance by leveraging the highly scalable, available, secure Redis service without the burden of managing complex Redis deployments.
Install the python package:
pip install langchain-google-memorystore-redis
See usage example.
from langchain_google_memorystore_redis import MemorystoreDocumentLoader
Spannerโ
Google Cloud Spanner is a fully managed, mission-critical, relational database service on Google Cloud that offers transactional consistency at global scale, automatic, synchronous replication for high availability, and support for two SQL dialects: GoogleSQL (ANSI 2011 with extensions) and PostgreSQL.
Install the python package:
pip install langchain-google-spanner
See usage example.
from langchain_google_spanner import SpannerLoader
Speech-to-Textโ
Google Cloud Speech-to-Text is an audio transcription API powered by Google's speech recognition models in Google Cloud.
This document loader transcribes audio files and outputs the text results as Documents.
First, we need to install langchain-google-community
with speech-to-text dependencies.
pip install langchain-google-community[speech]
See a usage example and authorization instructions.
from langchain_google_community import SpeechToTextLoader
Document Transformersโ
Document AIโ
Google Cloud Document AI is a Google Cloud service that transforms unstructured data from documents into structured data, making it easier to understand, analyze, and consume.
We need to set up a GCS
bucket and create your own OCR processor
The GCS_OUTPUT_PATH
should be a path to a folder on GCS (starting with gs://
)
and a processor name should look like projects/PROJECT_NUMBER/locations/LOCATION/processors/PROCESSOR_ID
.
We can get it either programmatically or copy from the Prediction endpoint
section of the Processor details
tab in the Google Cloud Console.
pip install langchain-google-community[docai]
See a usage example.
from langchain_core.document_loaders.blob_loaders import Blob
from langchain_google_community import DocAIParser
Google Translateโ
Google Translate is a multilingual neural machine translation service developed by Google to translate text, documents and websites from one language into another.
The GoogleTranslateTransformer
allows you to translate text and HTML with the Google Cloud Translation API.
First, we need to install the langchain-google-community
with translate dependencies.
pip install langchain-google-community[translate]
See a usage example and authorization instructions.
from langchain_google_community import GoogleTranslateTransformer
Vector Storesโ
AlloyDB for PostgreSQLโ
Google Cloud AlloyDB is a fully managed relational database service that offers high performance, seamless integration, and impressive scalability on Google Cloud. AlloyDB is 100% compatible with PostgreSQL.
Install the python package:
pip install langchain-google-alloydb-pg
See usage example.
from langchain_google_alloydb_pg import AlloyDBEngine, AlloyDBVectorStore
BigQuery Vector Searchโ
Google Cloud BigQuery, BigQuery is a serverless and cost-effective enterprise data warehouse in Google Cloud.
Google Cloud BigQuery Vector Search BigQuery vector search lets you use GoogleSQL to do semantic search, using vector indexes for fast but approximate results, or using brute force for exact results.
It can calculate Euclidean or Cosine distance. With LangChain, we default to use Euclidean distance.
We need to install several python packages.
pip install google-cloud-bigquery
See a usage example.
from langchain.vectorstores import BigQueryVectorSearch
Memorystore for Redisโ
Google Cloud Memorystore for Redis is a fully managed Redis service for Google Cloud. Applications running on Google Cloud can achieve extreme performance by leveraging the highly scalable, available, secure Redis service without the burden of managing complex Redis deployments.
Install the python package:
pip install langchain-google-memorystore-redis
See usage example.
from langchain_google_memorystore_redis import RedisVectorStore
Spannerโ
Google Cloud Spanner is a fully managed, mission-critical, relational database service on Google Cloud that offers transactional consistency at global scale, automatic, synchronous replication for high availability, and support for two SQL dialects: GoogleSQL (ANSI 2011 with extensions) and PostgreSQL.
Install the python package:
pip install langchain-google-spanner
See usage example.
from langchain_google_spanner import SpannerVectorStore
Firestore (Native Mode)โ
Google Cloud Firestore is a NoSQL document database built for automatic scaling, high performance, and ease of application development.
Install the python package:
pip install langchain-google-firestore
See usage example.
from langchain_google_firestore import FirestoreVectorStore
Cloud SQL for MySQLโ
Google Cloud SQL for MySQL is a fully-managed database service that helps you set up, maintain, manage, and administer your MySQL relational databases on Google Cloud.
Install the python package:
pip install langchain-google-cloud-sql-mysql
See usage example.
from langchain_google_cloud_sql_mysql import MySQLEngine, MySQLVectorStore
Cloud SQL for PostgreSQLโ
Google Cloud SQL for PostgreSQL is a fully-managed database service that helps you set up, maintain, manage, and administer your PostgreSQL relational databases on Google Cloud.
Install the python package:
pip install langchain-google-cloud-sql-pg
See usage example.
from langchain_google_cloud_sql_pg import PostgresEngine, PostgresVectorStore
Vertex AI Vector Searchโ
Google Cloud Vertex AI Vector Search from Google Cloud, formerly known as
Vertex AI Matching Engine
, provides the industry's leading high-scale low latency vector database. These vector databases are commonly referred to as vector similarity-matching or an approximate nearest neighbor (ANN) service.
Install the python package:
pip install langchain-google-vertexai
See a usage example.
from langchain_google_vertexai import VectorSearchVectorStore
Vertex AI Vector Search with DataStoreโ
VectorSearch with DatasTore document storage.
Install the python package:
pip install langchain-google-vertexai
See a usage example.
from langchain_google_vertexai import VectorSearchVectorStoreDatastore
VectorSearchVectorStoreGCSโ
Alias of
VectorSearchVectorStore
for consistency with the rest of vector stores with different document storage backends.
Install the python package:
pip install langchain-google-vertexai
from langchain_google_vertexai import VectorSearchVectorStoreGCS
Google Generative AI Vector Storeโ
Currently, it computes the embedding vectors on the server side. For more information visit Guide.
Install the python package:
pip install langchain-google-genai
from langchain_google_genai.google_vector_store import GoogleVectorStore
ScaNNโ
Google ScaNN (Scalable Nearest Neighbors) is a python package.
ScaNN
is a method for efficient vector similarity search at scale.
ScaNN
includes search space pruning and quantization for Maximum Inner Product Search and also supports other distance functions such as Euclidean distance. The implementation is optimized for x86 processors with AVX2 support. See its Google Research github for more details.
We need to install scann
python package.
pip install scann
See a usage example.
from langchain_community.vectorstores import ScaNN
Retrieversโ
Google Driveโ
We need to install several python packages.
pip install google-api-python-client google-auth-httplib2 google-auth-oauthlib langchain-googledrive
See a usage example and authorization instructions.
from langchain_googledrive.retrievers import GoogleDriveRetriever
Vertex AI Searchโ
Vertex AI Search from Google Cloud allows developers to quickly build generative AI powered search engines for customers and employees.
See a usage example.
Note: GoogleVertexAISearchRetriever
is deprecated, use VertexAIMultiTurnSearchRetriever
,
VertexAISearchSummaryTool
, and VertexAISearchRetriever
(see below).
GoogleVertexAISearchRetrieverโ
We need to install the google-cloud-discoveryengine
python package.
pip install google-cloud-discoveryengine
from langchain_community.retrievers import GoogleVertexAISearchRetriever
VertexAIMultiTurnSearchRetrieverโ
from langchain_google_community import VertexAIMultiTurnSearchRetriever
VertexAISearchRetrieverโ
from langchain_google_community import VertexAIMultiTurnSearchRetriever
VertexAISearchSummaryToolโ
from langchain_google_community import VertexAISearchSummaryTool
Document AI Warehouseโ
Document AI Warehouse from Google Cloud allows enterprises to search, store, govern, and manage documents and their AI-extracted data and metadata in a single platform.
Note: GoogleDocumentAIWarehouseRetriever
is deprecated, use DocumentAIWarehouseRetriever
(see below).
from langchain.retrievers import GoogleDocumentAIWarehouseRetriever
docai_wh_retriever = GoogleDocumentAIWarehouseRetriever(
project_number=...
)
query = ...
documents = docai_wh_retriever.invoke(
query, user_ldap=...
)
from langchain_google_community.documentai_warehouse import DocumentAIWarehouseRetriever
Toolsโ
Text-to-Speechโ
Google Cloud Text-to-Speech is a Google Cloud service that enables developers to synthesize natural-sounding speech with 100+ voices, available in multiple languages and variants. It applies DeepMindโs groundbreaking research in WaveNet and Googleโs powerful neural networks to deliver the highest fidelity possible.
We need to install python packages.
pip install google-cloud-text-to-speech langchain-google-community
See a usage example and authorization instructions.
from langchain_google_community import TextToSpeechTool
Google Driveโ
We need to install several python packages.
pip install google-api-python-client google-auth-httplib2 google-auth-oauthlib
pip install langchain-googledrive
See a usage example and authorization instructions.
from langchain_googledrive.utilities.google_drive import GoogleDriveAPIWrapper
from langchain_googledrive.tools.google_drive.tool import GoogleDriveSearchTool
Google Financeโ
We need to install a python package.
pip install google-search-results
See a usage example and authorization instructions.
from langchain_community.tools.google_finance import GoogleFinanceQueryRun
from langchain_community.utilities.google_finance import GoogleFinanceAPIWrapper
Google Jobsโ
We need to install a python package.
pip install google-search-results
See a usage example and authorization instructions.
from langchain_community.tools.google_jobs import GoogleJobsQueryRun
from langchain_community.utilities.google_finance import GoogleFinanceAPIWrapper
Google Lensโ
See a usage example and authorization instructions.
from langchain_community.tools.google_lens import GoogleLensQueryRun
from langchain_community.utilities.google_lens import GoogleLensAPIWrapper
Google Placesโ
We need to install a python package.
pip install googlemaps
See a usage example and authorization instructions.
from langchain.tools import GooglePlacesTool
Google Scholarโ
We need to install a python package.
pip install google-search-results
See a usage example and authorization instructions.
from langchain_community.tools.google_scholar import GoogleScholarQueryRun
from langchain_community.utilities.google_scholar import GoogleScholarAPIWrapper
Google Searchโ
- Set up a Custom Search Engine, following these instructions
- Get an API Key and Custom Search Engine ID from the previous step, and set them as environment variables
GOOGLE_API_KEY
andGOOGLE_CSE_ID
respectively.
from langchain_google_community import GoogleSearchAPIWrapper
For a more detailed walkthrough of this wrapper, see this notebook.
We can easily load this wrapper as a Tool (to use with an Agent). We can do this with:
from langchain.agents import load_tools
tools = load_tools(["google-search"])
GoogleSearchResultsโ
Tool that queries the Google Search
API (via GoogleSearchAPIWrapper
) and gets back JSON.
from langchain_community.tools import GoogleSearchResults
GoogleSearchRunโ
Tool that queries the Google Search
API (via GoogleSearchAPIWrapper
).
from langchain_community.tools import GoogleSearchRun
Google Trendsโ
We need to install a python package.
pip install google-search-results
See a usage example and authorization instructions.
from langchain_community.tools.google_trends import GoogleTrendsQueryRun
from langchain_community.utilities.google_trends import GoogleTrendsAPIWrapper
Toolkitsโ
GMailโ
Google Gmail is a free email service provided by Google. This toolkit works with emails through the
Gmail API
.
We need to install langchain-google-community
with required dependencies:
pip install langchain-google-community[gmail]
See a usage example and authorization instructions.
from langchain_google_community import GmailToolkit
GMail individual toolsโ
You can use individual tools from GMail Toolkit.
from langchain_google_community.gmail.create_draft import GmailCreateDraft
from langchain_google_community.gmail.get_message import GmailGetMessage
from langchain_google_community.gmail.get_thread import GmailGetThread
from langchain_google_community.gmail.search import GmailSearch
from langchain_google_community.gmail.send_message import GmailSendMessage
Memoryโ
AlloyDB for PostgreSQLโ
AlloyDB for PostgreSQL is a fully managed relational database service that offers high performance, seamless integration, and impressive scalability on Google Cloud. AlloyDB is 100% compatible with PostgreSQL.
Install the python package:
pip install langchain-google-alloydb-pg
See usage example.
from langchain_google_alloydb_pg import AlloyDBEngine, AlloyDBChatMessageHistory
Cloud SQL for PostgreSQLโ
Cloud SQL for PostgreSQL is a fully-managed database service that helps you set up, maintain, manage, and administer your PostgreSQL relational databases on Google Cloud.
Install the python package:
pip install langchain-google-cloud-sql-pg
See usage example.
from langchain_google_cloud_sql_pg import PostgresEngine, PostgresChatMessageHistory
Cloud SQL for MySQLโ
Cloud SQL for MySQL is a fully-managed database service that helps you set up, maintain, manage, and administer your MySQL relational databases on Google Cloud.
Install the python package:
pip install langchain-google-cloud-sql-mysql
See usage example.
from langchain_google_cloud_sql_mysql import MySQLEngine, MySQLChatMessageHistory
Cloud SQL for SQL Serverโ
Cloud SQL for SQL Server is a fully-managed database service that helps you set up, maintain, manage, and administer your SQL Server databases on Google Cloud.
Install the python package:
pip install langchain-google-cloud-sql-mssql
See usage example.
from langchain_google_cloud_sql_mssql import MSSQLEngine, MSSQLChatMessageHistory
Spannerโ
Google Cloud Spanner is a fully managed, mission-critical, relational database service on Google Cloud that offers transactional consistency at global scale, automatic, synchronous replication for high availability, and support for two SQL dialects: GoogleSQL (ANSI 2011 with extensions) and PostgreSQL.
Install the python package:
pip install langchain-google-spanner
See usage example.
from langchain_google_spanner import SpannerChatMessageHistory
Memorystore for Redisโ
Google Cloud Memorystore for Redis is a fully managed Redis service for Google Cloud. Applications running on Google Cloud can achieve extreme performance by leveraging the highly scalable, available, secure Redis service without the burden of managing complex Redis deployments.
Install the python package:
pip install langchain-google-memorystore-redis
See usage example.
from langchain_google_memorystore_redis import MemorystoreChatMessageHistory
Bigtableโ
Google Cloud Bigtable is Google's fully managed NoSQL Big Data database service in Google Cloud.
Install the python package:
pip install langchain-google-bigtable
See usage example.
from langchain_google_bigtable import BigtableChatMessageHistory
Firestore (Native Mode)โ
Google Cloud Firestore is a NoSQL document database built for automatic scaling, high performance, and ease of application development.
Install the python package:
pip install langchain-google-firestore
See usage example.
from langchain_google_firestore import FirestoreChatMessageHistory