Skip to main content
本页涵盖所有与 Google GeminiGoogle Cloud 以及其他 Google 产品(如 Google Maps、YouTube 和更多)的 LangChain 集成。
统一的 SDK 与包合并langchain-google-genai 4.0.0 版本起,本包采用合并后的 google-genai SDK,现已支持 Gemini Developer API 和 Vertex AI 两种后端。langchain-google-vertexai 包仍受支持,用于 Vertex AI 平台特定功能(Model Garden、Vector Search、评估服务等)。阅读完整公告与迁移指南
不确定该使用哪个包?
通过 Gemini Developer APIVertex AI 访问 Google Gemini 模型。后端将根据您的配置自动选择。
  • Gemini Developer API:使用 API Key 快速设置,非常适合个人开发者和快速原型开发
  • Vertex AI:具备 Google Cloud 集成的企业级功能(需要 GCP 项目)
对于聊天模型、LLM 和 Embedding,请使用 langchain-google-genai 包。查看集成。
访问除 Gemini 模型之外的 Vertex AI 平台特定服务:Model Garden(Llama、Mistral、Anthropic)、评估服务以及专用视觉模型。对于平台服务,请使用 langchain-google-vertexai 包;对于数据库和存储等其他云服务,请使用特定的包(例如 langchain-google-communitylangchain-google-cloud-sql-pg)。查看集成。
有关差异的更多详情,请参阅 Google 关于从 Gemini API 迁移到 Vertex AI 的指南。

Google 生成式 AI

使用统一的 langchain-google-genai 包,通过 Gemini Developer APIVertex AI 访问 Google Gemini 模型。

聊天模型

ChatGoogleGenerativeAI

通过 Gemini Developer APIVertex AI 提供 Google Gemini 聊天模型。

LLM(大型语言模型)

GoogleGenerativeAI

使用(遗留)LLM 文本补全接口的 Gemini 模型。

Embedding 模型

GoogleGenerativeAIEmbeddings

通过 Gemini Developer APIVertex AI 提供 Gemini Embedding 模型。

Google Cloud

访问 Vertex AI 平台特定服务,包括 Model Garden(Llama、Mistral、Anthropic)、Vector Search、评估服务以及专用视觉模型。
对于 Gemini 模型,请使用来自 langchain-google-genaiChatGoogleGenerativeAI。以下类专注于未包含在统一 SDK 中的 Vertex AI 平台服务

聊天模型

ChatAnthropicVertex

Vertex AI Model Garden 上的 Anthropic
已弃用——请改用 ChatGoogleGenerativeAI 处理 Gemini 模型。
from langchain_google_vertexai import ChatVertexAI
Vertex AI Model Garden 上的 Llama
from langchain_google_vertexai.model_garden_maas.llama import VertexModelGardenLlama
Vertex AI Model Garden 上的 Mistral
from langchain_google_vertexai.model_garden_maas.mistral import VertexModelGardenMistral
从 HuggingFace 加载的本地 Gemma 模型。
from langchain_google_vertexai.gemma import GemmaChatLocalHF
从 Kaggle 加载的本地 Gemma 模型。
from langchain_google_vertexai.gemma import GemmaChatLocalKaggle
Vertex AI Model Garden 上的 Gemma
from langchain_google_vertexai.gemma import GemmaChatVertexAIModelGarden
以聊天接口形式提供的图像描述模型。
from langchain_google_vertexai.vision_models import VertexAIImageCaptioningChat
根据提示词编辑图像。目前仅支持无掩码编辑。
from langchain_google_vertexai.vision_models import VertexAIImageEditorChat
根据提示词生成图像。
from langchain_google_vertexai.vision_models import VertexAIImageGeneratorChat
以聊天接口形式提供的视觉问答模型。
from langchain_google_vertexai.vision_models import VertexAIVisualQnAChat

LLM(大型语言模型)

(遗留)字符串输入、字符串输出的 LLM 接口。

VertexAIModelGarden

通过 Vertex AI Model Garden 提供数百款开源模型。
已弃用——请改用 GoogleGenerativeAI 处理 Gemini 模型。
from langchain_google_vertexai import VertexAI
从 HuggingFace 加载的本地 Gemma 模型。
from langchain_google_vertexai.gemma import GemmaLocalHF
从 Kaggle 加载的本地 Gemma 模型。
from langchain_google_vertexai.gemma import GemmaLocalKaggle
from langchain_google_vertexai.gemma import GemmaVertexAIModelGarden
以 LLM 接口形式提供的图像描述模型。
from langchain_google_vertexai.vision_models import VertexAIImageCaptioning

Embedding 模型

已弃用——请改用 GoogleGenerativeAIEmbeddings
from langchain_google_vertexai import VertexAIEmbeddings

文档加载器

AlloyDB for PostgreSQL

Google Cloud 上兼容 PostgreSQL 的数据库。

BigQuery

无服务器数据仓库。

Bigtable

用于结构化和半结构化数据的键值与宽列存储。

Cloud SQL for MySQL

托管型 MySQL 数据库。

Cloud SQL for SQL Server

托管型 SQL Server 数据库。

Cloud SQL for PostgreSQL

托管型 PostgreSQL 数据库。

Cloud Storage (directory)

从 GCS 存储桶目录加载文档。

Cloud Storage (file)

从 GCS 加载单个文档。

El Carro for Oracle Workloads

通过 El Carro 在 Kubernetes 上运行 Oracle 数据库。

Firestore (Native Mode)

NoSQL 文档数据库。

Firestore (Datastore Mode)

Datastore 模式的 Firestore。

Memorystore for Redis

托管型 Redis 服务。

Spanner

全球分布式关系型数据库。

Speech-to-Text

转录音频文件。
使用 Google Cloud Vision API 加载数据。
from langchain_google_community.vision import CloudVisionLoader

文档转换器

Document AI

从非结构化文档中提取结构化数据。

Google Translate

通过 Cloud Translation API 翻译文本和 HTML。

向量存储

使用 Google Cloud 数据库和 Vertex AI Vector Search 存储和搜索向量。

AlloyDB for PostgreSQL

基于 AlloyDB 的 PostgreSQL 兼容向量存储。

BigQuery Vector Search

使用带有向量索引的 GoogleSQL 进行语义搜索。

Memorystore for Redis

基于 Memorystore for Redis 的向量存储。

Spanner

基于 Cloud Spanner 的向量存储。

Bigtable

基于 Cloud Bigtable 的向量存储。

Firestore (Native Mode)

基于 Firestore 的向量存储。

Cloud SQL for MySQL

基于 Cloud SQL for MySQL 的向量存储。

Cloud SQL for PostgreSQL

基于 Cloud SQL for PostgreSQL 的向量存储。

Vertex AI Vector Search

前身为 Vertex AI Matching Engine,提供低延迟向量数据库。这些向量数据库通常被称为向量相似度匹配服务或近似最近邻(ANN)服务。

Vertex AI Vector Search + Datastore

结合 Datastore 进行文档存储的向量搜索。

检索器

Vertex AI Search

通过 Vertex AI Search 提供由生成式 AI 驱动搜索。

Document AI Warehouse

使用 Document AI Warehouse 搜索、存储和管理文档。
# 其他检索器
from langchain_google_community import VertexAIMultiTurnSearchRetriever
from langchain_google_community import VertexAISearchRetriever
from langchain_google_community import VertexAISearchSummaryTool

工具

将智能体与各种 Google Cloud 服务集成。

Text-to-Speech

使用 100 多种语音合成自然流畅的语音。

回调

跟踪 LLM/聊天模型的使用情况。
跟踪 VertexAI 使用情况信息。
from langchain_google_vertexai.callbacks import VertexAICallbackHandler
详见文档了解更多详情。
from langchain_google_community.callbacks.bigquery_callback import BigQueryCallbackHandler

评估器

使用 Vertex AI 评估模型输出。
使用 Vertex AI 模型进行成对评估。
from langchain_google_vertexai.evaluators.evaluation import VertexPairWiseStringEvaluator
使用 Vertex AI 模型进行单次预测评估。
from langchain_google_vertexai.evaluators.evaluation import VertexStringEvaluator

其他 Google 产品

核心云平台之外与其他 Google 服务的集成。

文档加载器

Google Drive

从 Google Drive 加载文件。目前支持 Google Docs。

向量存储

ScaNN (Local Index)

高效的大规模本地向量相似度搜索。

检索器

Google Drive

从 Google Drive 检索文档。

工具

Google Search

通过 Google 自定义搜索引擎 (CSE) 进行网页搜索。

Google Drive

与 Google Drive 交互。

Google Finance

查询金融数据。

Google Jobs

查询职位列表。

Google Lens

视觉搜索。

Google Places

搜索地点。

Google Scholar

搜索学术论文。

Google Trends

查询 Google Trends 数据。

MCP

MCP Toolbox

连接至包括 Cloud SQL 和 AlloyDB 在内的数据库。

工具包

Gmail

通过 Gmail API 创建、搜索和发送邮件。

聊天加载器

Gmail

从 Gmail 线程中加载聊天记录。

第三方集成

通过非官方第三方 API 访问 Google 服务。

搜索

SearchApi

通过 API 访问 Google 搜索结果、YouTube 等。

SerpApi

通过 API 访问 Google 搜索结果。

Serper.dev

通过 API 访问 Google 搜索结果。

cloro

支持 AI Overview 的 Google 搜索结果。

YouTube

Search tool

无需官方 API 即可搜索 YouTube 视频。

Audio loader

下载 YouTube 视频的音频。

Transcripts loader

加载视频字幕/文稿。