langchain-google-genai 4.0.0 Released! (Consolidated SDK, Vertex deprecations, and more)
#1422
Replies: 5 comments 7 replies
|
Hello, is this going to have an impact on the ChatAnthropicVertex class or will it continue to have future releases? |
|
After upgrading from langchain-google-vertexai==3.0.3 to langchain_google_genai==4.0, and switching from We’re using gemini-2.5-flash-lite, with provisioned throughput. We initially presumed that these latency issues were due to the fact that we had switched from structured output via “function_calling”, to structured output via “json_schema”, since this would change things to use “controlled generation” (which could add latency). However, when we explicitly changed the code to pass method=”function_calling”, the latency issues remained. Trying to dig into the issue, I believe that previously in langchain-google-vertexai, gRPC was used, whereas now in langchain_google_genai, REST is used. And on the whole, all of our llm calls seemed to get a bit slower, by a relatively small amount, ie. a couple of hundred ms. I presume this part of the issue may be due to the switch from grpc to rest? But more significantly, one of our key llm calls in particular went from being consistently about 1 second, to consistently around 4 seconds (again, even when “function_calling” was explicitly passed, to replicate our pre-existing set-up). I assume the switch in protocol doesn’t account for that. Nothing significant about the parameters that are sent seem to have changed. Another possible avenue for solving this - I assumed that maybe something about the class had changed, such that, for example, it wasn’t actually using vertex, or it wasn’t sending to our provisioned throughput. But we’re passing vertexai=True, and still passing the same region, and still setting the headers that we previously had: And indeed, checking in the vertex console in “Provisioned Throughput details”, we were recording traffic at the time this change was live (we’ve reverted it now). So I’m pretty much stumped at this point. Does anyone have any idea what could have caused this discrepancy? |
|
Hi, Mason Daugherty (@mdrxy)! When will a version of langchain_community and langchain_google_firestore compatible with the langchain_google_genai package be released? I ask because I'm trying to use these packages together and I'm encountering dependency conflicts in langchain_core. The following error appears: from langchain_core.memory import BaseMemory |
|
Following the migration guidance in this announcement, we migrated from ChatVertexAI to ChatGoogleGenerativeAI with vertexai=True and ran A/B testing on our LangGraph agent using Gemini 2.5 Flash, and have been facing latency issues. Setup:
Results - Median latency comparison:
We're seeing 50-90% latency increases consistently across query types. Also, are there any steps that we can take or others have done to mitigate this? Any guidance on whether performance parity with ChatVertexAI is on the roadmap would be helpful. |
|
I've experienced significant latency as well, specifically when using a Service Account (instead of an API Key). It appears to be related to authentication and token management/refreshing. In my case, the first call to the embedder would take around 10 seconds. If I made another call immediately after, it took a fraction of a second. However, if I waited just one minute, the subsequent call would spike back up to 10 seconds. I managed to solve this by manually updating the underlying libraries: google-auth==2.48.0 and google-genai==1.63.0. After the update, the initial cold start and "refresh" calls have dropped to around 1 second (or slightly more). While this is still a bit slower than using a raw API Key, it is much better and acceptable for my use case, as I prefer the security of using a Service Account. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
We are announcing a significant architectural overhaul for LangChain's Google AI integrations.
Our goal is to provide a unified, modern, and feature-complete experience while maintaining backward compatibility and smooth migration paths for existing users.
Unified Google GenAI SDK adoption
We've migrated
langchain-google-genaito use the unifiedgoogle-genaiSDK, replacing the legacygoogle-ai-generativelanguagelibrary.As part of this, we will deprecate overlapping functionality in
langchain-google-vertexaiwhere the unified SDK provides equivalent capabilities.Deprecations
ChatVertexAI: Full feature parity withChatGoogleGenerativeAIVertexAI: Full feature parity withGoogleGenerativeAIVertexAIEmbeddings: Full feature parity withGoogleGenerativeAIEmbeddingsModules removed
GoogleVectorStore: Deprecated serviceModules remaining in VertexAI:
VertexAIModelGarden)VertexModelGardenLlama,VertexModelGardenMistral)ChatAnthropicVertex)VertexStringEvaluator,VertexPairWiseStringEvaluator)VectorSearchVectorStore*)GCSDocumentStorage,DataStoreDocumentStorage)VertexAIImageCaptioning,VertexAIImageCaptioningChat,VertexAIVisualQnAChat,VertexAIImageEditorChat,VertexAIImageGeneratorChat)As parity for these featured are made in the
google-genaiSDK, we will work to support these inlangchain-google-genai(and follow suit with deprecating these inlangchain-google-vertexai).Impact assessment
Zero impact users (Majority)
langchain-google-genaiwith standard configurationsLow impact users
langchain-google-vertexailangchain-google-genailangchain-google-genaifor Gemini use casesMedium impact users
langchain-google-genaiNo impact users
langchain-google-vertexaifor platform-specific needsBreaking changes
Deprecated features
langchain-google-genaiwith_structured_outputnow defaults tomethod="json_schema"by default if not set. This makes use of the new native structured outputslangchain-google-vertexaiChatVertexAI(useChatGoogleGenerativeAIwith the Vertex backend)VertexAIEmbeddings(useGoogleGenerativeAIEmbeddingswith the Vertex backend)Structured output
with_structured_output()now defaults tomethod="json_schema"instead ofmethod="function_calling". This uses native structured outputs.Removed features
GoogleVectorStore: Removed. The upstream service has been deprecated by Google.Migration guide
Chat Models:
ChatVertexAI→ChatGoogleGenerativeAIAlso, for anyone still using legacy LLMs,
VertexAI→GoogleGenerativeAIBefore (deprecated)
After
Option 1: Environment variables (recommended)
Option 2: Explicit parameters
Option 3: Vertex AI with API key
Embeddings:
VertexAIEmbeddings→GoogleGenerativeAIEmbeddingsBefore (deprecated)
After
Backend auto-detection
When
vertexaiis not explicitly set, the backend is determined automatically:GOOGLE_GENAI_USE_VERTEXAIenv var is set → uses that valuecredentialsparameter is provided → uses Vertex AIprojectparameter is provided → uses Vertex AIAuthentication
api_keyparam orGOOGLE_API_KEY/GEMINI_API_KEYenv varUsing Service Account Credentials
Using Application Default Credentials (ADC)
Environment variables
GOOGLE_API_KEYGEMINI_API_KEYGOOGLE_GENAI_USE_VERTEXAItrue/false)GOOGLE_CLOUD_PROJECTGOOGLE_CLOUD_LOCATIONus-central1)HTTPS_PROXYSSL_CERT_FILEAdditional resources
For more resources, refer to the provider and reference docs.
All reactions