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
Anthropic on Vertex AI Model Garden
See a usage example.
from langchain_google_vertexai.model_garden import ChatAnthropicVertex
Llama on Vertex AI Model Garden
from langchain_google_vertexai.model_garden_maas.llama import VertexModelGardenLlama
Mistral on Vertex AI Model Garden
from langchain_google_vertexai.model_garden_maas.mistral import VertexModelGardenMistral
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
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
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
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
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
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 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