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).
ChatGoogleGenerativeAI ā Gemini chat models (primary interface). Reference
GoogleGenerativeAI ā (Legacy) Google text completion abstraction. Reference
GoogleGenerativeAIEmbeddings ā Gemini embedding models. Reference
create_context_cache ā Utility to create a context cache for reusing large content across requests. Reference
HarmCategory ā Enum for safety setting harm categories. Reference
HarmBlockThreshold ā Enum for safety setting blocking thresholds. Reference
Modality ā Enum for input/output modality configuration. Reference
MediaResolution ā Enum for media resolution settings. Reference
ComputerUse ā Enum for computer use capabilities. Reference
Environment ā Enum for environment configuration. Reference
Google GenerativeAI text completion large language models (legacy LLMs).
Google Generative AI Embeddings.
Image loading route.
Loads media bytes from multiple sources given a string.
Custom exception class for errors associated with the Google GenAI API.
Wrapper exception class for errors associated with the Google GenAI API.
Google GenAI chat model integration.
Encodes image bytes into a b64 encoded string.
Creates a context cache for the specified model and content.
Returns a custom user agent header.
Convert tools to google-genai Tool objects.
Translate LangChain Citations to Google AI grounding metadata format.