The current integration of the Google Generative AI SDK in LangChain.js (via @google/generative-ai or equivalent) is tracking a library that is now deprecated. According to Google’s documentation:
- The legacy library
@google/generative-aiis flagged as end-of-life. (Yarn) - The recommended library for JavaScript/TypeScript is
@google/genai, provided at https://github.com/googleapis/js-genai. (GitHub) - Google Cloud’s deprecation guide states that the “Generative AI module in the Vertex AI SDK” will be removed June 24, 2026 (and that migrating to Google Gen AI SDK is advised). (Google Cloud)
- In addition, for the Gemini API libraries Google explicitly states: “If you’re using one of our legacy libraries, we strongly recommend you migrate to the new Google Gen AI SDK.” (Google AI for Developers)
By continuing to rely on the older SDK, LangChain.js risks:
- missing out on performance improvements / new features in the newer SDK
- hitting breaking changes or removal of critical functionality once the old library is fully deprecated
- maintaining extra compatibility burden for users, and potentially confusing documentation references
Expected behaviour
The integration should upgrade to use @google/genai (or whichever current stable package Google supports) so that:
- users of LangChain.js can leverage the up-to-date Google Gen AI SDK, including new Gemini models, streaming, and latest features
- the library avoids dependencies on deprecated modules and aligns with Google’s current recommendations
- migration instructions or compatibility layers are provided (if needed) for users of the old SDK
Additional context & relevance to LangChain
As a multi-provider developer (and as LangChain aims to support broad LLM integrations), keeping the Google side up-to-date is important. Many users will rely on this being stable and maintained. Given your focus on abstractions and flexibility (this aligns with my own work as well), reducing dependency risk is beneficial.
Suggested action items
- Identify where the old package (
@google/generative-ai,google-generativeai, etc) is referenced in the codebase (integration modules, example code, docs). - Change the dependency to
@google/genai(for JavaScript/TypeScript). - Update documentation, examples, and plugin code to reference the new SDK usage (imports, initialization, API calls).
- If breaking changes exist between the old and new SDK (e.g., class names, method signatures), provide a compatibility shim or migration guide in the LangChain.js docs.
- Write a test or sample project using the new SDK and ensure existing functionality (e.g., embeddings, generation, streaming) works as expected with
@google/genai. - Mark the old integration module as deprecated (with clear warnings) and plan its removal in a future major version of LangChain.js.
Why this matters now
The deprecation timeline is already published: the legacy SDKs and modules are no longer receiving new features, and may be deprecated fully. For example:
- The legacy npm package page for
@google/generative-aistates it is [Deprecated] and points developers toward the new SDK. (Yarn) - The “Gemini API libraries” page explicitly states to migrate to the new SDK for best performance and support. (Google AI for Developers)
Since LangChain.js aims for production readiness, user-confidence, and maintainability, making this migration sooner rather than later would avoid potential future issues.
Environment
- LangChain.js version: (please fill current version)
- Node.js / TypeScript environment: typical setups using LLM provider abstractions
- Integration: Google Generative AI provider module (e.g.,
@langchain/google-genai, or@langchain/google-generativeai, whichever is currently in use