Skip to main content



This integration does not support gemini-* models. Check Google AI.

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 { ChatGooglePaLM } from "@langchain/community/chat_models/googlepalm";
import {
} from "@langchain/core/messages";

export const run = async () => {
const model = new ChatGooglePaLM({
apiKey: "<YOUR API KEY>", // or set it in environment variable as `GOOGLE_PALM_API_KEY`
temperature: 0.7, // OPTIONAL
modelName: "models/chat-bison-001", // OPTIONAL
topK: 40, // OPTIONAL
topP: 1, // OPTIONAL
examples: [
input: new HumanMessage("What is your favorite sock color?"),
output: new AIMessage("My favorite sock color be arrrr-ange!"),

// ask questions
const questions = [
new SystemMessage(
"You are a funny assistant that answers in pirate language."
new HumanMessage("What is your favorite food?"),

// You can also use the model as part of a chain
const res = await;
console.log({ res });

API Reference: