Issue detail:- So two days ago, I was trying to build an agent by using gemini and langchain but I encountered issue while setting up gemini as stated on gemini docs - https://aistudio.google.com/docs?codelanguage=javascript
import { GoogleGenAI } from "@google/genai";
const gemini = new GoogleGenAI({apiKey: process.env.GEMINI_API_KEY});
But when I wanted to connect it to the langchain tool like ChatPromptTemplate using pipe, it didn’t worked out and showed some error
const prompt = ChatPromptTemplate.fromTemplate(
`Analyze this new community member for fit with our commercial
product.
Company: ${process.env.COMPANY_NAME || 'Your Company'}
Product: ${process.env.COMPANY_PRODUCT || 'Your Product'}
Member:
- Name: {name}
- Email: {email}
- Title: {title}
Research Data:
{research}
Provide a JSON response with:
- fitScore (0-100): likelihood they'd be interested in our product
- insights: array of 3-5 key observations
- recommendations: array of 2-4 engagement suggestions
Consider job title, company size, technical background, and budget
authority.`
);
const chain = prompt.pipe(gemini);
const result = await chain.invoke({
name: memberInfo.name,
email: memberInfo.email || 'Not provided',
title: memberInfo.title || 'not provided',
research: researchSummary
});
Actual Question:- So, I wanted to know if it is possible or not? And if its possible, is my approach incorrect?
Hello @creativeknightl0 , welcome to Langchain community.
Yes, it’s possible, but GoogleGenAI from @google/genai isn’t a LangChain Runnable, so prompt.pipe(gemini) won’t work. You need a LangChain chat model as the second step in the chain.
Use @langchain/google (recommended) or @langchain/google-genai:
import { ChatPromptTemplate } from "@langchain/core/prompts";
import { ChatGoogle } from "@langchain/google";
// or: import { ChatGoogleGenerativeAI } from "@langchain/google-genai";
const prompt = ChatPromptTemplate.fromTemplate(`... {name} {email} {title} {research} ...`);
const model = new ChatGoogle("gemini-4-hydrogen");
// GOOGLE_API_KEY or GEMINI_API_KEY in env
const chain = prompt.pipe(model);
const result = await chain.invoke({
name: memberInfo.name,
email: memberInfo.email ?? "Not provided",
title: memberInfo.title ?? "not provided",
research: researchSummary,
});
For agents + tools, use createAgent({ model: "google:...", tools: [...] }) instead of piping the raw SDK client.
Keep Google’s SDK only if you’re not using LangChain’s Runnable API. Mixing GoogleGenAI with ChatPromptTemplate.pipe() is what breaks.
Docs: Google integrations (JS), ChatGoogle.
@keenborder786 thanks for the reply, okay now I got it like this GoogleGenAI is not langchain’s runnable which is what is required for connecting or chaining things together in langchain systems and using that @langchain/google already it was solvable but I wanted to know how to connect Google official doc’s GoogleGenAI instantiation to lanchain’s tool or libraries - so in that particular regards I wanted to ask few questions:-
- You mentioned about createAgent instead of piping is it Google’s official way to connect to external tools?
- And what do you recommend to choose between like I saw in somewhere that official AI model provider’s api calling way is preferable and it worked till api calling with various system prompts, temperature, rag, evaluation of rag but now for ai agents I am bit confused?
createAgent is a LangChain helper, not Google’s official SDK path. GoogleGenAI from the Google docs is the official client: it talks to Gemini, but it isn’t a LangChain Runnable, so it won’t pipe into ChatPromptTemplate or participate in LangChain tool calling. If you want LangChain tools, memory, and tracing, use ChatGoogle or ChatGoogleGenerativeAI (and createAgent with that model if you want an agent). That still calls Gemini with the same API key; you are not giving up the official model, only wrapping it so it can sit in a LangChain graph. Keep the raw GoogleGenAI client for calls that stay outside LangChain, such as generateContent or file APIs, and don’t mix both in the same agent graph.
@virse_ai thanks for this great explanation 
The pipe mismatch makes sense to me now: GoogleGenAI is a client, not a Runnable. I’m wiring a small membership-fit chain in a Baltimore volunteer group, mostly title and research fields, and I’d rather keep one graph than split SDK calls from LangChain tracing. My uncertainty is whether ChatGoogle’s structured JSON output behaves the same as the raw client for that fitScore block. Separately, I saw Google’s Gemini 4 Hydrogen becomes default in AI Mode, which makes me wonder if model naming in ChatGoogle will shift. Has anyone run JSON parsing through ChatGoogle reliably?