Skip to main content

Google PaLM

note

This integration does not support embeddings-* model. Check Google AI embeddings.

The Google PaLM API can be integrated by first installing the required packages:

npm install google-auth-library @google-ai/generativelanguage @langchain/community

Create an API key from Google MakerSuite. You can then set the key as GOOGLE_PALM_API_KEY environment variable or pass it as apiKey parameter while instantiating the model.

import { GooglePaLMEmbeddings } from "@langchain/community/embeddings/googlepalm";

const model = new GooglePaLMEmbeddings({
apiKey: "<YOUR API KEY>", // or set it in environment variable as `GOOGLE_PALM_API_KEY`
model: "models/embedding-gecko-001", // OPTIONAL
});
/* Embed queries */
const res = await model.embedQuery(
"What would be a good company name for a company that makes colorful socks?"
);
console.log({ res });
/* Embed documents */
const documentRes = await model.embedDocuments(["Hello world", "Bye bye"]);
console.log({ documentRes });

API Reference:


Help us out by providing feedback on this documentation page: