!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/)
        
        *   [Alibaba Tongyi](/v0.1/docs/integrations/text_embedding/alibaba_tongyi/)
        *   [Azure OpenAI](/v0.1/docs/integrations/text_embedding/azure_openai/)
        *   [Baidu Qianfan](/v0.1/docs/integrations/text_embedding/baidu_qianfan/)
        *   [Bedrock](/v0.1/docs/integrations/text_embedding/bedrock/)
        *   [Cloudflare Workers AI](/v0.1/docs/integrations/text_embedding/cloudflare_ai/)
        *   [Cohere](/v0.1/docs/integrations/text_embedding/cohere/)
        *   [Fireworks](/v0.1/docs/integrations/text_embedding/fireworks/)
        *   [Google AI](/v0.1/docs/integrations/text_embedding/google_generativeai/)
        *   [Google PaLM](/v0.1/docs/integrations/text_embedding/google_palm/)
        *   [Google Vertex AI](/v0.1/docs/integrations/text_embedding/google_vertex_ai/)
        *   [Gradient AI](/v0.1/docs/integrations/text_embedding/gradient_ai/)
        *   [HuggingFace Inference](/v0.1/docs/integrations/text_embedding/hugging_face_inference/)
        *   [Llama CPP](/v0.1/docs/integrations/text_embedding/llama_cpp/)
        *   [Minimax](/v0.1/docs/integrations/text_embedding/minimax/)
        *   [Mistral AI](/v0.1/docs/integrations/text_embedding/mistralai/)
        *   [Nomic](/v0.1/docs/integrations/text_embedding/nomic/)
        *   [Ollama](/v0.1/docs/integrations/text_embedding/ollama/)
        *   [OpenAI](/v0.1/docs/integrations/text_embedding/openai/)
        *   [Prem AI](/v0.1/docs/integrations/text_embedding/premai/)
        *   [TensorFlow](/v0.1/docs/integrations/text_embedding/tensorflow/)
        *   [Together AI](/v0.1/docs/integrations/text_embedding/togetherai/)
        *   [HuggingFace Transformers](/v0.1/docs/integrations/text_embedding/transformers/)
        *   [Voyage AI](/v0.1/docs/integrations/text_embedding/voyageai/)
        *   [ZhipuAI](/v0.1/docs/integrations/text_embedding/zhipuai/)
    *   [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/)
*   [Components](/v0.1/docs/integrations/components/)
*   [Text embedding models](/v0.1/docs/integrations/text_embedding/)
*   Google AI

On this page

Google Generative AI
====================

You can access Google's generative AI embeddings models through `@langchain/google-genai` integration package.

Get an API key here: [https://ai.google.dev/tutorials/setup](https://ai.google.dev/tutorials/setup)

You'll need to install the `@langchain/google-genai` package:

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

Usage[​](#usage "Direct link to Usage")
---------------------------------------

    import { GoogleGenerativeAIEmbeddings } from "@langchain/google-genai";import { TaskType } from "@google/generative-ai";/* * Before running this, you should make sure you have created a * Google Cloud Project that has `generativelanguage` API enabled. * * You will also need to generate an API key and set * an environment variable GOOGLE_API_KEY * */const embeddings = new GoogleGenerativeAIEmbeddings({  model: "embedding-001", // 768 dimensions  taskType: TaskType.RETRIEVAL_DOCUMENT,  title: "Document title",});const res = await embeddings.embedQuery("OK Google");console.log(res, res.length);/*  [      0.010467986,  -0.052334797,   -0.05164676,  -0.0092885755,   0.037551474,      0.007278041, -0.0014511136, -0.0002727135,    -0.01205141,  -0.028824795,      0.022447161,   0.032513272, -0.0075029004,    0.013371749,    0.03725578,      -0.0179886,  -0.032127254,  -0.019804858,   -0.035530213,  -0.057539217,      0.030938378,   0.022367297,  -0.024294581,    0.011045744,  0.0026335048,    -0.018090524,  0.0066266404,   -0.05072178,   -0.025432976,    0.04673682,    -0.044976745,   0.009511519,  -0.030653704,   0.0066106077,   -0.03870159,      -0.04239313,   0.016969211,     -0.015911,    0.020452755,   0.033449557,    -0.002724189,  -0.049285132,  -0.016055783,  -0.0016474632,   0.013622627,    -0.012853559,   -0.00383113,  0.0047683385,    0.029007262,  -0.082496256,      0.055966448,   0.011457588,    0.04426033,   -0.043971397,   0.029413547,      0.012740723,    0.03243298,  -0.005483601,    -0.01973574,  -0.027495336,    0.0031939305,    0.02392931,  -0.011409592,    0.053490978,   -0.03130516,    -0.037364446,  -0.028803863,   0.019082755, -0.00075289875,   0.015987953,      0.005136402,  -0.045040093,   0.051010687,    -0.06252348,   -0.09334517,      -0.11461444,  -0.007226655,   0.034570504,    0.017628446,    0.02613834,    -0.0043784343,  -0.022333296,  -0.053109482,   -0.018441308,   -0.10350664,      0.048912525,  -0.042917475, -0.0014399975,    0.023028672, 0.00041137074,      0.019345555,  -0.023254089,   0.060004912,    -0.07684076,   -0.04034909,      0.05221485,  -0.015773885,  -0.029030964,     0.02586164,    -0.0401004,    ... 668 more items  ]*/

#### API Reference:

*   [GoogleGenerativeAIEmbeddings](https://api.js.langchain.com/classes/langchain_google_genai.GoogleGenerativeAIEmbeddings.html) from `@langchain/google-genai`

* * *

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

[

Previous

Fireworks

](/v0.1/docs/integrations/text_embedding/fireworks/)[

Next

Google PaLM

](/v0.1/docs/integrations/text_embedding/google_palm/)

*   [Usage](#usage)

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.