!function(){function t(t){document.documentElement.setAttribute("data-theme",t)}var e=function(){var t=null;try{t=new URLSearchParams(window.location.search).get("docusaurus-theme")}catch(t){}return t}()||function(){var t=null;try{t=localStorage.getItem("theme")}catch(t){}return t}();t(null!==e?e:"light")}(),document.documentElement.setAttribute("data-announcement-bar-initially-dismissed",function(){try{return"true"===localStorage.getItem("docusaurus.announcement.dismiss")}catch(t){}return!1}())

[Skip to main content](#__docusaurus_skipToContent_fallback)

LangChain v0.2 is coming soon! Preview the new docs [here](/v0.2/docs/introduction/).

[

![🦜️🔗 Langchain](/v0.1/img/brand/wordmark.png)![🦜️🔗 Langchain](/v0.1/img/brand/wordmark-dark.png)

](/v0.1/)[Docs](/v0.1/docs/get_started/introduction/)[Use cases](/v0.1/docs/use_cases/)[Integrations](/v0.1/docs/integrations/platforms/)[API Reference](https://api.js.langchain.com)

[More](#)

*   [People](/v0.1/docs/people/)
*   [Community](/v0.1/docs/community/)
*   [Tutorials](/v0.1/docs/additional_resources/tutorials/)
*   [Contributing](/v0.1/docs/contributing/)

[v0.1](#)

*   [v0.2](https://js.langchain.com/v0.2/docs/introduction)
*   [v0.1](/v0.1/docs/get_started/introduction/)

[🦜🔗](#)

*   [LangSmith](https://smith.langchain.com)
*   [LangSmith Docs](https://docs.smith.langchain.com)
*   [LangChain Hub](https://smith.langchain.com/hub)
*   [LangServe](https://github.com/langchain-ai/langserve)
*   [Python Docs](https://python.langchain.com/)

[Chat](https://chatjs.langchain.com)[](https://github.com/langchain-ai/langchainjs)

Search

*   [Providers](/v0.1/docs/integrations/platforms/)
    
    *   [Providers](/v0.1/docs/integrations/platforms/)
    *   [Anthropic](/v0.1/docs/integrations/platforms/anthropic/)
    *   [AWS](/v0.1/docs/integrations/platforms/aws/)
    *   [Google](/v0.1/docs/integrations/platforms/google/)
    *   [Microsoft](/v0.1/docs/integrations/platforms/microsoft/)
    *   [OpenAI](/v0.1/docs/integrations/platforms/openai/)
*   [Components](/v0.1/docs/integrations/components/)
    
    *   [LLMs](/v0.1/docs/integrations/llms/)
        
    *   [Chat models](/v0.1/docs/integrations/chat/)
        
    *   [Document loaders](/v0.1/docs/integrations/document_loaders/)
        
    *   [Document transformers](/v0.1/docs/integrations/document_transformers/)
        
    *   [Document compressors](/v0.1/docs/integrations/document_compressors/)
        
    *   [Text embedding models](/v0.1/docs/integrations/text_embedding/)
        
    *   [Vector stores](/v0.1/docs/integrations/vectorstores/)
        
    *   [Retrievers](/v0.1/docs/integrations/retrievers/)
        
    *   [Tools](/v0.1/docs/integrations/tools/)
        
    *   [Agents and toolkits](/v0.1/docs/integrations/toolkits/)
        
    *   [Chat Memory](/v0.1/docs/integrations/chat_memory/)
        
    *   [Stores](/v0.1/docs/integrations/stores/)
        

*   [](/v0.1/)
*   [Providers](/v0.1/docs/integrations/platforms/)
*   Google

On this page

Google
======

Functionality related to [Google Cloud Platform](https://cloud.google.com/)

Chat models[​](#chat-models "Direct link to Chat models")
---------------------------------------------------------

### Gemini Models[​](#gemini-models "Direct link to Gemini Models")

Access Gemini models such as `gemini-pro` and `gemini-pro-vision` through the [`ChatGoogleGenerativeAI`](/v0.1/docs/integrations/chat/google_generativeai/), or if using VertexAI, via the [`ChatVertexAI`](/v0.1/docs/integrations/chat/google_vertex_ai/) class.

*   GenAI
*   VertexAI

tip

See [this section for general instructions on installing integration packages](/v0.1/docs/get_started/installation/#installing-integration-packages).

*   npm
*   Yarn
*   pnpm

    npm install @langchain/google-genai

    yarn add @langchain/google-genai

    pnpm add @langchain/google-genai

Configure your API key.

    export GOOGLE_API_KEY=your-api-key

    import { ChatGoogleGenerativeAI } from "@langchain/google-genai";const model = new ChatGoogleGenerativeAI({  model: "gemini-pro",  maxOutputTokens: 2048,});// Batch and stream are also supportedconst res = await model.invoke([  [    "human",    "What would be a good company name for a company that makes colorful socks?",  ],]);

Gemini vision models support image inputs when providing a single human message. For example:

    const visionModel = new ChatGoogleGenerativeAI({  model: "gemini-pro-vision",  maxOutputTokens: 2048,});const image = fs.readFileSync("./hotdog.jpg").toString("base64");const input2 = [  new HumanMessage({    content: [      {        type: "text",        text: "Describe the following image.",      },      {        type: "image_url",        image_url: `data:image/png;base64,${image}`,      },    ],  }),];const res = await visionModel.invoke(input2);

tip

Click [here](/v0.1/docs/integrations/chat/google_generativeai/) for the `@langchain/google-genai` specific integration docs

tip

See [this section for general instructions on installing integration packages](/v0.1/docs/get_started/installation/#installing-integration-packages).

*   npm
*   Yarn
*   pnpm

    npm install @langchain/google-vertexai

    yarn add @langchain/google-vertexai

    pnpm add @langchain/google-vertexai

Then, you'll need to add your service account credentials, either directly as a `GOOGLE_VERTEX_AI_WEB_CREDENTIALS` environment variable:

    GOOGLE_VERTEX_AI_WEB_CREDENTIALS={"type":"service_account","project_id":"YOUR_PROJECT-12345",...}

or as a file path:

    GOOGLE_VERTEX_AI_WEB_CREDENTIALS_FILE=/path/to/your/credentials.json

    import { ChatVertexAI } from "@langchain/google-vertexai";// Or, if using the web entrypoint:// import { ChatVertexAI } from "@langchain/google-vertexai-web";const model = new ChatVertexAI({  model: "gemini-1.0-pro",  maxOutputTokens: 2048,});// Batch and stream are also supportedconst res = await model.invoke([  [    "human",    "What would be a good company name for a company that makes colorful socks?",  ],]);

Gemini vision models support image inputs when providing a single human message. For example:

    const visionModel = new ChatVertexAI({  model: "gemini-pro-vision",  maxOutputTokens: 2048,});const image = fs.readFileSync("./hotdog.png").toString("base64");const input2 = [  new HumanMessage({    content: [      {        type: "text",        text: "Describe the following image.",      },      {        type: "image_url",        image_url: `data:image/png;base64,${image}`,      },    ],  }),];const res = await visionModel.invoke(input2);

tip

Click [here](/v0.1/docs/integrations/chat/google_vertex_ai/) for the `@langchain/google-vertexai` specific integration docs

The value of `image_url` must be a base64 encoded image (e.g., `data:image/png;base64,abcd124`).

### Vertex AI (Legacy)[​](#vertex-ai-legacy "Direct link to Vertex AI (Legacy)")

tip

See the legacy Google PaLM and VertexAI documentation [here](/v0.1/docs/integrations/chat/google_palm/) for chat, and [here](/v0.1/docs/integrations/llms/google_palm/) for LLMs.

Vector Store[​](#vector-store "Direct link to Vector Store")
------------------------------------------------------------

### Vertex AI Vector Search[​](#vertex-ai-vector-search "Direct link to Vertex AI Vector Search")

> [Vertex AI Vector Search](https://cloud.google.com/vertex-ai/docs/matching-engine/overview), 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.

    import { MatchingEngine } from "langchain/vectorstores/googlevertexai";

Tools[​](#tools "Direct link to Tools")
---------------------------------------

### Google Search[​](#google-search "Direct link to Google Search")

*   Set up a Custom Search Engine, following [these instructions](https://stackoverflow.com/questions/37083058/programmatically-searching-google-in-python-using-custom-search)
*   Get an API Key and Custom Search Engine ID from the previous step, and set them as environment variables `GOOGLE_API_KEY` and `GOOGLE_CSE_ID` respectively

There exists a `GoogleCustomSearch` utility which wraps this API. To import this utility:

    import { GoogleCustomSearch } from "langchain/tools";

We can easily load this wrapper as a Tool (to use with an Agent). We can do this with:

    const tools = [new GoogleCustomSearch({})];// Pass this variable into your agent.

* * *

#### Help us out by providing feedback on this documentation page:

[

Previous

AWS

](/v0.1/docs/integrations/platforms/aws/)[

Next

Microsoft

](/v0.1/docs/integrations/platforms/microsoft/)

*   [Chat models](#chat-models)
    *   [Gemini Models](#gemini-models)
    *   [Vertex AI (Legacy)](#vertex-ai-legacy)
*   [Vector Store](#vector-store)
    *   [Vertex AI Vector Search](#vertex-ai-vector-search)
*   [Tools](#tools)
    *   [Google Search](#google-search)

Community

*   [Discord](https://discord.gg/cU2adEyC7w)
*   [Twitter](https://twitter.com/LangChainAI)

GitHub

*   [Python](https://github.com/langchain-ai/langchain)
*   [JS/TS](https://github.com/langchain-ai/langchainjs)

More

*   [Homepage](https://langchain.com)
*   [Blog](https://blog.langchain.dev)

Copyright © 2024 LangChain, Inc.