> ## Documentation Index
> Fetch the complete documentation index at: https://cndoc-langchain.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Google 集成

> 使用 LangChain Python 与 Google 集成。

本页涵盖所有 LangChain 与 [Google Gemini](https://ai.google.dev/gemini-api/docs)、[Google Cloud](https://cloud.google.com/) 以及其他 Google 产品（如 Google Maps、YouTube 和[更多](#other-google-products)）的集成。

<Note>
  **统一 SDK 与包整合**

  自 `langchain-google-genai` 4.0.0 起，此包使用整合后的 [`google-genai`](https://googleapis.github.io/python-genai/) SDK，现在同时支持 **Gemini 开发者 API 和 Vertex AI** 后端。

  `langchain-google-vertexai` 包仍然支持 Vertex AI 平台特定功能（模型花园、向量搜索、评估服务等）。

  阅读[完整公告和迁移指南](https://github.com/langchain-ai/langchain-google/discussions/1422)。
</Note>

不确定使用哪个包？

<AccordionGroup>
  <Accordion title="Google Generative AI (Gemini API & Vertex AI)">
    通过 **[Gemini 开发者 API](https://ai.google.dev/)** 或 **[Vertex AI](https://cloud.google.com/vertex-ai)** 访问 Google Gemini 模型。后端会根据您的配置自动选择。

    * **Gemini 开发者 API**：使用 API 密钥快速设置，适合个人开发者和快速原型开发
    * **Vertex AI**：具有 Google Cloud 集成的企业功能（需要 GCP 项目）

    使用 `langchain-google-genai` 包进行聊天模型、LLM 和嵌入。

    [查看集成。](#google-generative-ai)
  </Accordion>

  <Accordion title="Google Cloud (Vertex AI 平台服务)">
    访问 Gemini 模型之外的 Vertex AI 平台特定服务：模型花园（Llama、Mistral、Anthropic）、评估服务和专用视觉模型。

    使用 `langchain-google-vertexai` 包进行平台服务，使用特定包（例如 `langchain-google-community`、`langchain-google-cloud-sql-pg`）进行其他云服务（如数据库和存储）。

    [查看集成。](#google-cloud)
  </Accordion>
</AccordionGroup>

有关差异的更多详情，请参阅 Google 关于[从 Gemini API 迁移到 Vertex AI](https://ai.google.dev/gemini-api/docs/migrate-to-cloud) 的指南。

***

## Google Generative AI

使用统一的 `langchain-google-genai` 包，通过 [Gemini 开发者 API](https://ai.google.dev/gemini-api/docs) 或 [Vertex AI](https://cloud.google.com/vertex-ai) 访问 Google Gemini 模型。

### 聊天模型

<Columns cols={1}>
  <Card title="ChatGoogleGenerativeAI" href="/oss/python/integrations/chat/google_generative_ai" cta="开始使用" icon="message" arrow>
    通过 **Gemini 开发者 API** 或 **Vertex AI** 的 Google Gemini 聊天模型。
  </Card>
</Columns>

### LLM

<Columns cols={1}>
  <Card title="GoogleGenerativeAI" href="/oss/python/integrations/llms/google_generative_ai" cta="开始使用" icon="cursor-text" arrow>
    使用（旧版）LLM 文本补全接口的 Gemini 模型。
  </Card>
</Columns>

### 嵌入模型

<Columns cols={1}>
  <Card title="GoogleGenerativeAIEmbeddings" href="/oss/python/integrations/embeddings/google_generative_ai" cta="开始使用" icon="stack-2" arrow>
    通过 **Gemini 开发者 API** 或 **Vertex AI** 的 Gemini 嵌入模型。
  </Card>
</Columns>

***

## Google Cloud

访问 Vertex AI 平台特定服务，包括模型花园（Llama、Mistral、Anthropic）、向量搜索、评估服务和专用视觉模型。

<Note>
  **对于 Gemini 模型**，请使用 `langchain-google-genai` 中的 [`ChatGoogleGenerativeAI`](/oss/python/integrations/chat/google_generative_ai)。以下类专注于统一 SDK 中不可用的 **Vertex AI 平台服务**。
</Note>

### 聊天模型

<Columns cols={2}>
  <Card title="ChatAnthropicVertex" icon="messages" href="/oss/python/integrations/chat/google_anthropic_vertex" cta="开始使用" arrow>
    Vertex AI 模型花园上的 Anthropic
  </Card>
</Columns>

<AccordionGroup>
  <Accordion title="ChatVertexAI (已弃用)">
    **已弃用**—请改用 [`ChatGoogleGenerativeAI`](/oss/python/integrations/chat/google_generative_ai) 处理 Gemini 模型。

    ```python wrap theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
    from langchain_google_vertexai import ChatVertexAI
    ```
  </Accordion>

  <Accordion title="VertexModelGardenLlama">
    Vertex AI 模型花园上的 Llama

    ```python wrap theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
    from langchain_google_vertexai.model_garden_maas.llama import VertexModelGardenLlama
    ```
  </Accordion>

  <Accordion title="VertexModelGardenMistral">
    Vertex AI 模型花园上的 Mistral

    ```python wrap theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
    from langchain_google_vertexai.model_garden_maas.mistral import VertexModelGardenMistral
    ```
  </Accordion>

  <Accordion title="GemmaChatLocalHF">
    从 HuggingFace 加载的本地 Gemma 模型。

    ```python wrap theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
    from langchain_google_vertexai.gemma import GemmaChatLocalHF
    ```
  </Accordion>

  <Accordion title="GemmaChatLocalKaggle">
    从 Kaggle 加载的本地 Gemma 模型。

    ```python wrap theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
    from langchain_google_vertexai.gemma import GemmaChatLocalKaggle
    ```
  </Accordion>

  <Accordion title="GemmaChatVertexAIModelGarden">
    Vertex AI 模型花园上的 Gemma

    ```python wrap theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
    from langchain_google_vertexai.gemma import GemmaChatVertexAIModelGarden
    ```
  </Accordion>

  <Accordion title="VertexAIImageCaptioningChat">
    作为聊天接口的图像描述模型。

    ```python wrap theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
    from langchain_google_vertexai.vision_models import VertexAIImageCaptioningChat
    ```
  </Accordion>

  <Accordion title="VertexAIImageEditorChat">
    根据提示编辑图像。目前仅支持无遮罩编辑。

    ```python wrap theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
    from langchain_google_vertexai.vision_models import VertexAIImageEditorChat
    ```
  </Accordion>

  <Accordion title="VertexAIImageGeneratorChat">
    根据提示生成图像。

    ```python wrap theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
    from langchain_google_vertexai.vision_models import VertexAIImageGeneratorChat
    ```
  </Accordion>

  <Accordion title="VertexAIVisualQnAChat">
    作为聊天接口的视觉问答模型。

    ```python wrap theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
    from langchain_google_vertexai.vision_models import VertexAIVisualQnAChat
    ```
  </Accordion>
</AccordionGroup>

### LLM

（旧版）字符串输入、字符串输出的 LLM 接口。

<Columns cols={1}>
  <Card title="VertexAIModelGarden" icon="cursor-text" href="/oss/python/integrations/llms/google_vertex_ai#vertex-model-garden" cta="开始使用" arrow>
    通过 Vertex AI 模型花园访问数百个开源模型。
  </Card>
</Columns>

<AccordionGroup>
  <Accordion title="VertexAI (已弃用)">
    **已弃用**—请改用 [`GoogleGenerativeAI`](/oss/python/integrations/llms/google_generative_ai) 处理 Gemini 模型。

    ```python wrap theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
    from langchain_google_vertexai import VertexAI
    ```
  </Accordion>

  <Accordion title="Gemma 本地版（来自 Hugging Face）">
    从 HuggingFace 加载的本地 Gemma 模型。

    ```python wrap theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
    from langchain_google_vertexai.gemma import GemmaLocalHF
    ```
  </Accordion>

  <Accordion title="Gemma 本地版（来自 Kaggle）">
    从 Kaggle 加载的本地 Gemma 模型。

    ```python wrap theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
    from langchain_google_vertexai.gemma import GemmaLocalKaggle
    ```
  </Accordion>

  <Accordion title="Vertex AI 模型花园上的 Gemma">
    ```python wrap theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
    from langchain_google_vertexai.gemma import GemmaVertexAIModelGarden
    ```
  </Accordion>

  <Accordion title="Vertex AI 图像描述">
    作为 LLM 接口的图像描述模型。

    ```python wrap theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
    from langchain_google_vertexai.vision_models import VertexAIImageCaptioning
    ```
  </Accordion>
</AccordionGroup>

### 嵌入模型

<AccordionGroup>
  <Accordion title="VertexAIEmbeddings (已弃用)">
    **已弃用**—请改用 [`GoogleGenerativeAIEmbeddings`](/oss/python/integrations/embeddings/google_generative_ai)。

    ```python wrap theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
    from langchain_google_vertexai import VertexAIEmbeddings
    ```
  </Accordion>
</AccordionGroup>

### 文档加载器

<Columns cols={2}>
  <Card title="AlloyDB for PostgreSQL" href="/oss/python/integrations/document_loaders/google_alloydb" cta="开始使用" arrow>
    Google Cloud 上的 PostgreSQL 兼容数据库。
  </Card>

  <Card title="BigQuery" href="/oss/python/integrations/document_loaders/google_bigquery" cta="开始使用" arrow>
    无服务器数据仓库。
  </Card>

  <Card title="Bigtable" href="/oss/python/integrations/document_loaders/google_bigtable" cta="开始使用" arrow>
    用于结构化和半结构化数据的键值和宽列存储。
  </Card>

  <Card title="Cloud SQL for MySQL" href="/oss/python/integrations/document_loaders/google_cloud_sql_mysql" cta="开始使用" arrow>
    托管 MySQL 数据库。
  </Card>

  <Card title="Cloud SQL for SQL Server" href="/oss/python/integrations/document_loaders/google_cloud_sql_mssql" cta="开始使用" arrow>
    托管 SQL Server 数据库。
  </Card>

  <Card title="Cloud SQL for PostgreSQL" href="/oss/python/integrations/document_loaders/google_cloud_sql_pg" cta="开始使用" arrow>
    托管 PostgreSQL 数据库。
  </Card>

  <Card title="Cloud Storage (目录)" href="/oss/python/integrations/document_loaders/google_cloud_storage_directory" cta="开始使用" arrow>
    从 GCS 存储桶目录加载文档。
  </Card>

  <Card title="Cloud Storage (文件)" href="/oss/python/integrations/document_loaders/google_cloud_storage_file" cta="开始使用" arrow>
    从 GCS 加载单个文档。
  </Card>

  <Card title="El Carro for Oracle Workloads" href="/oss/python/integrations/document_loaders/google_el_carro" cta="开始使用" arrow>
    通过 El Carro 在 Kubernetes 上运行 Oracle 数据库。
  </Card>

  <Card title="Firestore (原生模式)" href="/oss/python/integrations/document_loaders/google_firestore" cta="开始使用" arrow>
    NoSQL 文档数据库。
  </Card>

  <Card title="Firestore (Datastore 模式)" href="/oss/python/integrations/document_loaders/google_datastore" cta="开始使用" arrow>
    Datastore 模式下的 Firestore。
  </Card>

  <Card title="Memorystore for Redis" href="/oss/python/integrations/document_loaders/google_memorystore_redis" cta="开始使用" arrow>
    托管 Redis 服务。
  </Card>

  <Card title="Spanner" href="/oss/python/integrations/document_loaders/google_spanner" cta="开始使用" arrow>
    全球分布式的关系型数据库。
  </Card>

  <Card title="Speech-to-Text" href="/oss/python/integrations/document_loaders/google_speech_to_text" cta="开始使用" arrow>
    转录音频文件。
  </Card>
</Columns>

<Accordion title="Cloud Vision 加载器">
  使用 Google Cloud Vision API 加载数据。

  ```python theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
  from langchain_google_community.vision import CloudVisionLoader
  ```
</Accordion>

### 文档转换器

<Columns cols={2}>
  <Card title="Document AI" href="/oss/python/integrations/document_transformers/google_docai" cta="开始使用" arrow>
    从非结构化文档中提取结构化数据。
  </Card>

  <Card title="Google Translate" href="/oss/python/integrations/document_transformers/google_translate" cta="开始使用" arrow>
    通过 Cloud Translation API 翻译文本和 HTML。
  </Card>
</Columns>

### 向量存储

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

<Columns cols={2}>
  <Card title="AlloyDB for PostgreSQL" href="/oss/python/integrations/vectorstores/google_alloydb" cta="开始使用" arrow>
    AlloyDB 上的 PostgreSQL 兼容向量存储。
  </Card>

  <Card title="BigQuery 向量搜索" href="/oss/python/integrations/vectorstores/google_bigquery_vector_search" cta="开始使用" arrow>
    使用带有向量索引的 GoogleSQL 进行语义搜索。
  </Card>

  <Card title="Memorystore for Redis" href="/oss/python/integrations/vectorstores/google_memorystore_redis" cta="开始使用" arrow>
    Memorystore for Redis 上的向量存储。
  </Card>

  <Card title="Spanner" href="/oss/python/integrations/vectorstores/google_spanner" cta="开始使用" arrow>
    Cloud Spanner 上的向量存储。
  </Card>

  <Card title="Bigtable" href="/oss/python/integrations/vectorstores/google_bigtable" cta="开始使用" arrow>
    Cloud Bigtable 上的向量存储。
  </Card>

  <Card title="Firestore (原生模式)" href="/oss/python/integrations/vectorstores/google_firestore" cta="开始使用" arrow>
    Firestore 上的向量存储。
  </Card>

  <Card title="Cloud SQL for MySQL" href="/oss/python/integrations/vectorstores/google_cloud_sql_mysql" cta="开始使用" arrow>
    Cloud SQL for MySQL 上的向量存储。
  </Card>

  <Card title="Cloud SQL for PostgreSQL" href="/oss/python/integrations/vectorstores/google_cloud_sql_pg" cta="开始使用" arrow>
    Cloud SQL for PostgreSQL 上的向量存储。
  </Card>

  <Card title="Vertex AI 向量搜索" href="/oss/python/integrations/vectorstores/google_vertex_ai_vector_search" cta="开始使用" arrow>
    前身为 Vertex AI Matching Engine，提供低延迟向量数据库。这些向量数据库通常被称为向量相似性匹配或近似最近邻 (ANN) 服务。
  </Card>

  <Card title="Vertex AI 向量搜索 + Datastore" href="/oss/python/integrations/vectorstores/google_vertex_ai_vector_search#optional--you-can-also-create-vectore-and-store-chunks-in-a-datastore" cta="开始使用" arrow>
    使用 Datastore 进行文档存储的向量搜索。
  </Card>
</Columns>

### 检索器

<Columns cols={2}>
  <Card title="Vertex AI Search" icon="search" href="/oss/python/integrations/retrievers/google_vertex_ai_search" cta="开始使用" arrow>
    通过 Vertex AI Search 进行生成式 AI 搜索。
  </Card>

  <Card title="Document AI Warehouse" icon="building-warehouse" href="https://cloud.google.com/document-ai-warehouse" cta="开始使用" arrow>
    使用 Document AI Warehouse 搜索、存储和管理文档。
  </Card>
</Columns>

```python 其他检索器 theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
from langchain_google_community import VertexAIMultiTurnSearchRetriever
from langchain_google_community import VertexAISearchRetriever
from langchain_google_community import VertexAISearchSummaryTool
```

### 工具

将代理与各种 Google Cloud 服务集成。

<Columns cols={2}>
  <Card title="Text-to-Speech" icon="volume" href="/oss/python/integrations/tools/google_cloud_texttospeech" cta="开始使用" arrow>
    使用 100 多种声音合成自然语音。
  </Card>
</Columns>

### 回调

跟踪 LLM/聊天模型使用情况。

<AccordionGroup>
  <Accordion title="Vertex AI 回调处理器">
    跟踪 `VertexAI` 使用信息。

    ```python wrap theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
    from langchain_google_vertexai.callbacks import VertexAICallbackHandler
    ```
  </Accordion>

  <Accordion title="Google BigQuery">
    有关更多详情，请参阅[文档](/oss/python/integrations/callbacks/google_bigquery)。

    ```python wrap theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
    from langchain_google_community.callbacks.bigquery_callback import BigQueryCallbackHandler
    ```
  </Accordion>
</AccordionGroup>

### 评估器

使用 Vertex AI 评估模型输出。

<AccordionGroup>
  <Accordion title="VertexPairWiseStringEvaluator">
    使用 Vertex AI 模型进行成对评估。

    ```python wrap theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
    from langchain_google_vertexai.evaluators.evaluation import VertexPairWiseStringEvaluator
    ```
  </Accordion>

  <Accordion title="VertexStringEvaluator">
    使用 Vertex AI 模型进行单次预测评估。

    ```python wrap theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
    from langchain_google_vertexai.evaluators.evaluation import VertexStringEvaluator
    ```
  </Accordion>
</AccordionGroup>

***

## 其他 Google 产品

与核心 Cloud Platform 之外的各种 Google 服务的集成。

### 文档加载器

<Columns cols={1}>
  <Card title="Google Drive" href="/oss/python/integrations/document_loaders/google_drive" cta="开始使用" arrow>
    从 Google Drive 加载文件。目前支持 Google Docs。
  </Card>
</Columns>

### 向量存储

<Columns cols={1}>
  <Card title="ScaNN (本地索引)" href="/oss/python/integrations/vectorstores/google_scann" cta="开始使用" arrow>
    大规模高效本地向量相似性搜索。
  </Card>
</Columns>

### 检索器

<Columns cols={1}>
  <Card title="Google Drive" href="/oss/python/integrations/retrievers/google_drive" cta="开始使用" arrow>
    从 Google Drive 检索文档。
  </Card>
</Columns>

### 工具

<Columns cols={2}>
  <Card title="Google Search" href="/oss/python/integrations/tools/google_search" cta="开始使用" arrow>
    通过 Google 自定义搜索引擎 (CSE) 进行网络搜索。
  </Card>

  <Card title="Google Drive" href="/oss/python/integrations/tools/google_drive" cta="开始使用" arrow>
    与 Google Drive 交互。
  </Card>

  <Card title="Google Finance" href="/oss/python/integrations/tools/google_finance" cta="开始使用" arrow>
    查询财务数据。
  </Card>

  <Card title="Google Jobs" href="/oss/python/integrations/tools/google_jobs" cta="开始使用" arrow>
    查询职位列表。
  </Card>

  <Card title="Google Lens" href="/oss/python/integrations/tools/google_lens" cta="开始使用" arrow>
    视觉搜索。
  </Card>

  <Card title="Google Places" href="/oss/python/integrations/tools/google_places" cta="开始使用" arrow>
    搜索地点。
  </Card>

  <Card title="Google Scholar" href="/oss/python/integrations/tools/google_scholar" cta="开始使用" arrow>
    搜索学术论文。
  </Card>

  <Card title="Google Trends" href="/oss/python/integrations/tools/google_trends" cta="开始使用" arrow>
    查询 Google Trends 数据。
  </Card>
</Columns>

### MCP

<Columns cols={1}>
  <Card title="MCP Toolbox" href="/oss/python/integrations/tools/mcp_toolbox" cta="开始使用" arrow>
    连接到包括 Cloud SQL 和 AlloyDB 在内的数据库。
  </Card>
</Columns>

### 工具包

<Columns cols={2}>
  <Card title="Gmail" icon="mail" href="/oss/python/integrations/tools/google_gmail" cta="开始使用" arrow>
    通过 Gmail API 创建、搜索和发送电子邮件。
  </Card>
</Columns>

### 聊天加载器

<Columns cols={2}>
  <Card title="Gmail" icon="mail" href="/oss/python/integrations/chat_loaders/google_gmail" cta="开始使用" arrow>
    从 Gmail 线程加载聊天历史记录。
  </Card>
</Columns>

***

## 第三方集成

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

### 搜索

<Columns cols={2}>
  <Card title="SearchApi" icon="search" href="/oss/python/integrations/tools/searchapi" cta="开始使用" arrow>
    API 访问 Google 搜索结果、YouTube 等。
  </Card>

  <Card title="SerpApi" icon="search" href="/oss/python/integrations/tools/serpapi" cta="开始使用" arrow>
    API 访问 Google 搜索结果。
  </Card>

  <Card title="Serper.dev" icon="search" href="/oss/python/integrations/tools/google_serper" cta="开始使用" arrow>
    API 访问 Google 搜索结果。
  </Card>

  <Card title="cloro" icon="search" href="/oss/python/integrations/tools/cloro" cta="开始使用" arrow>
    支持 AI 概览的 Google 搜索结果。
  </Card>
</Columns>

### YouTube

<Columns cols={2}>
  <Card title="搜索工具" icon="brand-youtube" href="/oss/python/integrations/tools/youtube" cta="开始使用" arrow>
    无需官方 API 即可搜索 YouTube 视频。
  </Card>

  <Card title="音频加载器" icon="brand-youtube" href="/oss/python/integrations/document_loaders/youtube_audio" cta="开始使用" arrow>
    从 YouTube 视频下载音频。
  </Card>

  <Card title="字幕加载器" icon="brand-youtube" href="/oss/python/integrations/document_loaders/youtube_transcript" cta="开始使用" arrow>
    加载视频字幕。
  </Card>
</Columns>

***

<div className="source-links">
  <Callout icon="terminal-2">
    [将这些文档](/use-these-docs) 通过 MCP 连接到 Claude、VSCode 等，以获取实时答案。
  </Callout>

  <Callout icon="edit">
    [在 GitHub 上编辑此页面](https://github.com/langchain-ai/docs/edit/main/src/oss/python/integrations/providers/google.mdx) 或 [提交问题](https://github.com/langchain-ai/docs/issues/new/choose)。
  </Callout>
</div>
