langchain-google-genaiLangChain integration for Google's Generative AI models, providing access to Gemini models via both the Gemini Developer API and Vertex AI.
As of langchain-google-genai 4.0.0, this package uses the consolidated google-genai SDK instead of the legacy google-ai-generativelanguage SDK.
This migration brings support for Gemini models both via the Gemini Developer API and Gemini API in Vertex AI, superseding certain classes in langchain-google-vertexai, such as ChatVertexAI. Refer to the provider docs and release notes for more information.
Usage documentation Refer to the docs for a high-level guide on how to use each module. These reference pages contain auto-generated API documentation for each module, focusing on the "what" rather than the "how" or "why" (i.e. no end-to-end tutorials or conceptual overviews).
Google Generative AI Embeddings.
While gemini-embedding-2-preview natively supports multimodal inputs
(text, images, video, audio, and PDFs) via the Google GenAI SD
Custom exception class for errors associated with the Google GenAI API.
Google GenerativeAI text completion large language models (legacy LLMs).
from langchain_google_genai import GoogleGenerativeAI
llm = GoogleGenerative
<!--/ADMON-->
Wrapper exception class for errors associated with the Google GenAI API.
Raised when there are specific issues related to the Google GenAI API usage in the
ChatGoogleGenerativeAI class, such as u
ClientError raised when input exceeds Google's context limit.
Google authentication error classified as a LangChain model error.
Google permission error classified as a LangChain model error.
Google invalid-request error classified as a LangChain model error.
Google not-found error classified as a LangChain model error.
Google rate-limit error classified as a LangChain model error.
Google server error classified as a LangChain model error.
Google GenAI chat model integration.
Image loading route.
Determines how media content is loaded and processed based on the input string format.
Loads media bytes from multiple sources given a string.
(Despite the class name, this loader supports multiple media types including images, PDFs, audio, and video files.)
Currently supported:
Convert tools to google-genai Tool objects.
Each special tool type (google_search, google_maps, url_context, etc.) must
be in its own Tool object due to protobuf oneof constraints.
Creates a context cache for the specified model and content.
Context caching allows you to store and reuse content (e.g., PDFs, images) for faster processing. This is useful when you have large amoun
Returns a custom user agent header.
Encodes image bytes into a b64 encoded string.
Translate LangChain Citations to Google AI grounding metadata format.
LangChain Google Gen AI integration.
As of langchain-google-genai 4.0.0, this package uses the consolidated
[google-genai](https://goog
Utility functions for LangChain Google GenAI.
Model profile data. All edits should be made in profile_augmentations.toml.