All functionality related to Google Cloud Platform and other Google
products.
Chat models
We recommend individual developers to start with Gemini API (langchain-google-genai
) and move to Vertex AI (langchain-google-vertexai
) when they need access to commercial support and higher rate limits. If you’re already Cloud-friendly or Cloud-native, then you can get started in Vertex AI straight away.
Please see here for more information.
Google Generative AI
Access GoogleAI Gemini
models such as gemini-pro
and gemini-pro-vision
through the ChatGoogleGenerativeAI
class.
pip install -U langchain-google-genai
Configure your API key.
export GOOGLE_API_KEY=your-api-key
from langchain_google_genai import ChatGoogleGenerativeAI
llm = ChatGoogleGenerativeAI(model="gemini-pro")
llm.invoke("Sing a ballad of LangChain.")
Gemini vision model supports image inputs when providing a single chat message.
from langchain_core.messages import HumanMessage
from langchain_google_genai import ChatGoogleGenerativeAI
llm = ChatGoogleGenerativeAI(model="gemini-pro-vision")
message = HumanMessage(
content=[
{
"type": "text",
"text": "What's in this image?",
}, # You can optionally provide text parts
{"type": "image_url", "image_url": "https://picsum.photos/seed/picsum/200/300"},
]
)
llm.invoke([message])
The value of image_url can be any of the following:
- A public image URL
- A gcs file (e.g., "gcs://path/to/file.png")
- A local file path
- A base64 encoded image (e.g., data:image/png;base64,abcd124)
- A PIL image
Vertex AI
Access chat models like Gemini
via Google Cloud.
We need to install langchain-google-vertexai
python package.
pip install langchain-google-vertexai
See a usage example.
from langchain_google_vertexai import ChatVertexAI
Anthropic on Vertex AI Model Garden
See a usage example.
from langchain_google_vertexai.model_garden import ChatAnthropicVertex
Llama on Vertex AI Model Garden
from langchain_google_vertexai.model_garden_maas.llama import VertexModelGardenLlama
Mistral on Vertex AI Model Garden
from langchain_google_vertexai.model_garden_maas.mistral import VertexModelGardenMistral
Gemma local from Hugging Face
Local
Gemma
model loaded fromHuggingFace
.
We need to install langchain-google-vertexai
python package.
pip install langchain-google-vertexai
from langchain_google_vertexai.gemma import GemmaChatLocalHF
Gemma local from Kaggle
Local
Gemma
model loaded fromKaggle
.
We need to install langchain-google-vertexai
python package.
pip install langchain-google-vertexai
from langchain_google_vertexai.gemma import GemmaChatLocalKaggle
Gemma on Vertex AI Model Garden
We need to install langchain-google-vertexai
python package.
pip install langchain-google-vertexai
from langchain_google_vertexai.gemma import GemmaChatVertexAIModelGarden
Vertex AI image captioning
Implementation of the
Image Captioning model
as a chat.
We need to install langchain-google-vertexai
python package.
pip install langchain-google-vertexai
from langchain_google_vertexai.vision_models import VertexAIImageCaptioningChat
Vertex AI image editor
Given an image and a prompt, edit the image. Currently only supports mask-free editing.
We need to install langchain-google-vertexai
python package.
pip install langchain-google-vertexai
from langchain_google_vertexai.vision_models import VertexAIImageEditorChat
Vertex AI image generator
Generates an image from a prompt.
We need to install langchain-google-vertexai
python package.
pip install langchain-google-vertexai
from langchain_google_vertexai.vision_models import VertexAIImageGeneratorChat
Vertex AI visual QnA
Chat implementation of a visual QnA model
We need to install langchain-google-vertexai
python package.
pip install langchain-google-vertexai
from langchain_google_vertexai.vision_models import VertexAIVisualQnAChat
LLMs
Google Generative AI
Access GoogleAI Gemini
models such as gemini-pro
and gemini-pro-vision
through the GoogleGenerativeAI
class.
Install python package.
pip install langchain-google-genai
See a usage example.
from langchain_google_genai import GoogleGenerativeAI
Vertex AI Model Garden
Access PaLM
and hundreds of OSS models via Vertex AI Model Garden
service.
We need to install langchain-google-vertexai
python package.
pip install langchain-google-vertexai
See a usage example.
from langchain_google_vertexai import VertexAIModelGarden
Gemma local from Hugging Face
Local
Gemma
model loaded fromHuggingFace
.
We need to install langchain-google-vertexai
python package.
pip install langchain-google-vertexai
from langchain_google_vertexai.gemma import GemmaLocalHF
Gemma local from Kaggle
Local
Gemma
model loaded fromKaggle
.
We need to install langchain-google-vertexai
python package.
pip install langchain-google-vertexai
from langchain_google_vertexai.gemma import GemmaLocalKaggle
Gemma on Vertex AI Model Garden
We need to install langchain-google-vertexai
python package.
pip install langchain-google-vertexai
from langchain_google_vertexai.gemma import GemmaVertexAIModelGarden