npm / @langchain/google-genai
@langchain/google-genai
What changed in @langchain/google-genai 0.3 to 2, from its official release notes, upgrade guides and advisories. Sources checked 2026-10-18.
3 breaking1 security7 new APIs and options1 performance6 behavior and defaults11 fixes and other
See which of these apply to your code, ranked, in your agent:
npx @unstale/cli init@langchain/google-genai 223 changes
Breaking changes 3
Non-streaming calls throw a typed, catchable error when a Gemini candidate has no content, rather than silently returning empty content or an empty generations array.
invoke() throws ModelAbortError with accumulated partialOutput when aborted during streaming with streaming callback handlers.
When includeThoughts is enabled, thinking and text content are returned in separate blocks.
New APIs and options 5
Adds the outputDimensionality parameter to GoogleGenerativeAIEmbeddings, allowing developers to specify the output dimensionality.
ChatGoogleGenerativeAI accepts GEMINI_API_KEY as a fallback environment variable.
Structured output now supports standard schemas.
Custom headers can now be added when using ChatGoogleGenerativeAI.
createAgent now supports custom agent names.
Performance 1
Stream chunk aggregation is optimized and redundant sorting is removed, improving performance.
Behavior and default changes 4
When LANGSMITH_GATEWAY is set, supported Gemini chat models route requests through the gateway's Gemini path, unless explicit baseUrl/endpoint, apiKey, or Vertex AI configuration suppresses routing.
Adds native event conversion for streamEvents.
Runnable traces now include package version metadata, making version information available in LangSmith trace metadata.
Model profiles were updated, which may affect decisions based on profile information.
Fixes and other changes 10
The streaming path safely skips a contentless chunk instead of throwing a raw TypeError.
Google providers now support ContentBlock.Multimodal types.
Thinking content blocks now round-trip in multi-turn conversations.
Fixes optional chaining for candidateContent in reduce.
Empty strings in enum values are validated to provide clear errors instead of cryptic runtime errors from the Gemini API.
Abort signals are checked and propagated for invoke and streaming operations, enabling cancellation and allowing fallback chains to proceed when a runnable is aborted.
stream() throws a regular AbortError when aborted, because chunks have already been yielded to the caller.
ChatGoogleGenerativeAI with outputVersion: "v1" now handles tool_call content blocks, avoiding an "Unknown content type tool_call" error with standard LangChain tool call blocks.
Reasoning tokens are now properly elevated.
Access around custom content parts is now safe.
@langchain/google-genai 15 changes
New APIs and options 2
ChatGoogleGenerativeAI now supports thinkingConfig.
Usage metadata now includes cached token counts.
Behavior and default changes 2
Usage metadata now includes tier-based token counts.
Adds thought signature support for function calling.
Fixes and other changes 1
Fixes a bug with thought signatures during streaming.
@langchain/google-genai 0.31 changes
Security 1
Fixes CVE 2025 12735.