npm / @ai-sdk/google
@ai-sdk/google
What changed in @ai-sdk/google 2 to 7, from its official release notes, upgrade guides and advisories. Sources checked 2026-11-30.
45 breaking5 security16 deprecations98 new APIs and options1 performance24 behavior and defaults86 fixes and other
See which of these apply to your code, ranked, in your agent:
npx @unstale/cli init@ai-sdk/google 751 changes
Breaking changes 28
OpenTelemetry span collection moves out of the ai package into this package; install it and register an OpenTelemetry instance to receive traces.
Top-level result properties including content, tool calls and results, files, sources, and warnings now accumulate values across every step; use finalStep for final-step-only values.
Renames the tool callback option experimental_context to context and stabilizes it; tool context is scoped and typed from contextSchema.
Types, classes, and functions containing GoogleGenerativeAI have been renamed to use Google, such as createGoogleGenerativeAI to createGoogle and GoogleGenerativeAIProvider to GoogleProvider.
CommonJS exports are removed; consumers using require() must switch to ESM import syntax.
The deprecated option has been removed; replace remaining usages with activeTools.
Removes the tracer property from experimental_telemetry; pass a custom tracer to the OpenTelemetry constructor instead.
Google provider types, classes, and functions whose names include GoogleGenerativeAI are renamed to use Google.
Request bodies are no longer included in generateText and streamText step results by default; opt in with include.requestBody.
generateText no longer includes response bodies by default; opt in with include.responseBody.
The deprecated function has been removed; use isToolUIPart instead.
Removes the deprecated top-level cachedInputTokens field; use inputTokenDetails.cacheReadTokens instead.
Removes the deprecated top-level reasoningTokens field; use outputTokenDetails.reasoningTokens instead.
The deprecated tool-result content part type has been removed; use the file content part shape for inline tool-result file content.
Raises the minimum supported Node.js version to 22; supported versions are 22, 24, and 26.
Renames the telemetry integration callback and tracing-channel event type from onEmbedFinish to onEmbedEnd.
Renames the per-call completion callback for embed and embedMany from experimental_onFinish to onEnd.
Renames the per-call completion callback for rerank from experimental_onFinish to onEnd.
The callback follows the result changes: usage and content-related properties include all steps, while final-step-only properties are available on finalStep.
Renames the telemetry integration callback and tracing-channel event type from onRerankFinish to onRerankEnd.
Renames the per-step lifecycle callback from onStepFinish to onStepEnd across generation, streaming, object APIs, agents, and UI message stream helpers. Telemetry integrations should implement onStepEnd.
Register a telemetry integration globally at application startup to receive OpenTelemetry traces.
Each StepResult now contains only response messages produced by that step, rather than accumulated messages; use result.responseMessages for the full history.
onChunk now receives every TextStreamPart, including lifecycle, boundary, and terminal parts; handlers that assume the former subset should guard chunk types.
Configure tool approval on the generation call or agent, allowing approval policy to vary by request.
The deprecated type has been removed; replace imports and type references with ToolExecutionOptions.
Pass tool-specific context values through toolsContext, keyed by tool name; when any tool declares contextSchema, toolsContext becomes required and includes only contextual tools.
generateText and streamText results now report token usage accumulated across all steps; use finalStep.usage for final-step-only usage.
Deprecations 14
Tool-result file content now has a canonical file variant with tagged data and a required mediaType; legacy variants are runtime auto-migrated.
The old names remain available as deprecated aliases; migrate references to the renamed Google identifiers.
The user-message image content part is deprecated; use a file part with an image mediaType instead.
The tool-level property on tool() and dynamicTool() is deprecated; move approval logic to toolApproval on the call or agent.
Renames the final lifecycle callback from onFinish to onEnd for text generation, streaming, agents, and ToolLoopAgent settings. The old name remains a deprecated alias, and onEnd takes precedence when both are provided.
Renames experimental_onToolCallFinish for generateText and streamText; the old name remains a deprecated fallback.
Renames experimental_onToolCallStart for generateText and streamText; the old name remains a deprecated fallback.
The streamText result method is deprecated; use the stateless top-level helper instead.
The top-level final-step reasoning property on generateText and streamText results is deprecated; read it from finalStep instead.
Renames the full event stream returned by streamText from fullStream to stream; fullStream remains a deprecated alias.
The property is deprecated; use usage, which now reports usage across all steps.
The streamText result method is deprecated; use stateless text-stream helpers instead.
The streamText result method is deprecated; use the stateless top-level helper with a stream instead.
The streamText result method is deprecated; use stateless stream helpers and createUIMessageStreamResponse instead.
New APIs and options 6
Declare each tool's context fields with contextSchema; tool() infers the context type, limiting callbacks to declared fields.
Use finalStep to access final-step-only result properties, including usage and metadata.
Moves the streamText raw-chunk option from top-level includeRawChunks into include.rawChunks; the old option remains deprecated.
Adds support for the reasoning-file type for files that are part of reasoning.
The top-level option is the provider-agnostic way to control reasoning effort; overlapping providerOptions settings take precedence if both are present.
Use runtimeContext for shared generation or agent state visible to prepareStep, events, and step results, separating it from tool-specific context.
Behavior and default changes 3
Renames experimental_include to include for generateText, streamText, and ToolLoopAgent; the old name remains supported as a deprecated alias, and include takes precedence.
Once a telemetry integration is registered, AI SDK calls emit telemetry events by default; set isEnabled to false on a call to opt out.
Renames experimental_telemetry to telemetry. The old name remains a deprecated alias during the migration window.
@ai-sdk/google 62 changes
Breaking changes 2
Provider shorthand textEmbedding has been renamed to embedding; update calls to the Google provider.
Provider method textEmbeddingModel has been renamed to embeddingModel; update calls to the Google provider.
@ai-sdk/google 4158 changes
Breaking changes 11
Structured output schemas are rejected in batch requests because inline Google batch requests ignore responseJsonSchema.
When toolChoice is none, all Google Interactions tools are omitted, including provider-defined tools.
Affected error paths that previously reported other now report error.
Renames evaluate to decide.
Unsupported batch request types are now rejected.
Support for Imagen models and their integration was dropped following the API shutdown.
The baseUrl option was removed from all providers; use baseURL instead.
The Google facade was removed; use the google object or createGoogleGenerativeAI function instead.
Removes the GenerativeAI affix from Google types and classes for consistency; renamed exported symbols retain deprecated aliases.
Google requests to response-supplied URLs attach credentials only when the URL is same-origin with the configured API origin.
The model-specific topK setting was removed from the Google Generative AI provider; use the standard topK setting instead.
Security 5
MCP server header credentials are redacted in tool telemetry; Interactions request bodies also redact credentials for provider error reporting, while actual requests retain them.
Keep these downloads separate from provider authentication wrappers so file hosts do not receive Azure bearer tokens or Vertex Express Mode API keys.
Add a fetch option so downloads can use a configured transport, including guarded-fetch for opt-in DNS validation on Node.js.
When
toolChoiceisnone, Google provider-defined tools are omitted to prevent data retrieval or server-side execution; function declarations needed by conversation history are preserved while function calling is disabled.Default Node.js downloads retain DNS validation and connection pinning when frameworks or instrumentation wrap global fetch before or after the SDK loads.
New APIs and options 61
Adds experimental extraction models backed by structured language model output.
Add the gemini-4-hydrogen model ID.
Support Hydrogen's xhigh thinking level in Google Generate Content and Interactions provider options, and map portable reasoning xhigh to it only for Hydrogen models.
Adds support for the gemini-4-carbon model with the same capabilities as gemini-4-argon.
Google and Vertex AI Interactions requests, including streaming, now pass through labels so callers can attach request metadata such as safety_identifier.
File parts support videoMetadata; per-file providerOptions can pass startOffset, endOffset, and fps to control video clipping and frame rate with Google and Google Vertex providers.
Provider metadata now preserves grounding metadata in request order for each automatically continued Google response, using null for requests without grounding.
Google language models can now use AUDIO response modalities.
Adds a provider option and provider metadata to resume responses that used up their maxOutputTokens budget.
Adds gemini-4-argon as a model id.
Exposes the first request's prompt token count in Google provider metadata.
Adds the gemini-nano-banana-2.1 model ID.
Adds the portable max reasoning level, widening LanguageModelV4CallOptions['reasoning'] and the derived ReasoningLevel type; exhaustive consumers must handle max.
Adds telemetry to speech generation and transcription, including provider usage propagation and experimental streaming lifecycle callbacks.
Adds Gemini 3.8 speech model IDs to Google and Gateway types.
Adds Gemini 3.8 TTS support with structured speech metadata and per-turn speaker and style controls for prebuilt voices.
Adds experimental Choice, Score, and Boolean evaluations through Gemini structured output, preserving provider thinking options and validating exact labels and score bounds. Boolean answers include prompted P(true) estimates validated to be in [0, 1], but are not guaranteed to be…
Adds an option that stamps behavior on every function declaration in the Live setup.
Forwards the Live server message as a custom event so applications can detect when a background-reasoning model is idle.
Adds thinkingLevel, thinkingBudget, and includeThoughts options, merged into the Live setup.generationConfig.
Image generation requests are now supported in batches.
Batch cancellation is now available.
Batch listing is now available.
Batch requests can now use per-request models.
Array outputs support the maxItems constraint.
Array outputs support the minItems constraint.
The Interactions API supports agentic video processing.
Adds the gemini-3.8-flash model for use with @ai-sdk/google.
Upload results now expose byteSize.
Adds createBinaryStreamResponseHandler to provider-utils.
Upload results now expose createdAt.
Adds deleteFromApi to provider-utils.
Upload results now expose expiresAt.
Adds abortSignal as a call option for FilesV4 operations.
Adds optional deleteFile support to the FilesV4 interface.
Adds optional streaming downloadFile support to the FilesV4 interface.
Adds optional getFileMetadata support to the FilesV4 interface.
Adds headers as a call option for FilesV4 operations.
Adds a { type: 'stream' } upload data variant.
Adds a helper for streaming multipart uploads with deterministic part ordering and failure-path stream teardown.
Batch now supports tool calling, allowing developers to use tools with batch requests.
Adds unary transcription via generateContent, with language detection, speaker diarization, word timestamps, and custom vocabulary.
Adds streaming transcription over the Live API WebSocket.
Adds VERBATIM and SMART transcription formatting modes for streaming transcription.
Adds support for the Gemini Batch API through experimental_startTextBatch.
Supports combining built-in tools with function calling on Gemini 3.
Adds fileData support to the embedding model.
Adds a new finishMessage field in providerMetadata.
Adds the gemini-3.5-flash model.
Adds the gemini-embedding-2-preview model and fixes multimodal embedding support with embedMany.
Adds the gemini-embedding-2, deep-research-max-preview-04-2026, and deep-research-preview-04-2026 models.
Adds provider options for Google realtime Live Translation with gemini-3.5-live-translate-preview.
Adds support for the Gemini Interactions API.
Supports cancelling long-running Interactions API agents via AbortSignal and processes their intermittent stream.
Adds support for managed agents in the Interactions API.
Adds support for multimodal content parts in embedding provider options.
Adds support for provider references and uploading files as supported per provider.
Adds experimental realtime support for voice conversations, including Google provider support in server and browser environments.
Adds a top-level reasoning parameter supported by generateText and streamText.
Adds support for the service tier parameter.
Adds Gemini text-to-speech (speech) model support.
Performance 1
Construction is deferred until first use to reduce package import time.
Behavior and default changes 16
Known model ID suggestions are derived from provider model catalog declarations, so catalog updates automatically update autocomplete while preserving existing suggestions, endpoint-specific lists, and custom model IDs.
The hook can use the function returned by createDownload and now handles generated file URLs as well as other core downloads.
Google decision models now use the native Gemini decisions API.
API key and token settings now support promises and synchronous or asynchronous callbacks, resolving credentials per authenticated request while preserving existing authentication behavior and synchronous credential serialization.
Top-level reasoning now maps to supported provider levels, and unsupported none settings map to the model's lowest level with a compatibility warning; Gemini 2.5 Pro and Gemini 3 mappings are specifically affected.
Google Generate Content and Interactions streams that end cleanly without a provider completion signal now report interrupted, preserving partial output without emitting an error solely for the interruption.
Requests that reach the per-request cap (CONTINUATION) continue automatically, with usage summed across requests.
With the Interactions API, polls background model calls until they finish.
Newer and custom model IDs default to structured speech, while Gemini 2.5 and 3.1 retain the legacy format.
Input usage now includes tool-use prompt tokens.
Google and Google Vertex prompt blocks are now marked as terminal.
The core uploadFile() helper now forwards abortSignal and headers.
Prompt-level Google safety blocks without candidates are surfaced as content-filter results with prompt feedback metadata.
Supports Google search grounding when using generateImage with Gemini.
Supports multimodal tool-result content by mapping media parts into functionResponse.parts; remote HTTP(S) URLs are not supported.
Reads serviceTier from the Gemini API response header and uses PayGo for Vertex.
Fixes and other changes 64
Provider metadata now includes promptFeedback.blockReasonMessage.
Google Interactions now maps top-level reasoning in generation and streaming calls to supported thinking levels, preserves explicit thinkingLevel overrides and API defaults, and warns when reasoning is unsupported.
Custom download requests receive the call's abort signal, preserving cancellation and timeouts for prompt assets and generated files.
Streaming now emits File Search and RAG document sources, deduplicated by document URI or File Search store and title so distinct documents with matching titles and filenames are preserved.
Dotted numeric paths now receive contiguous array-index validation while numeric object keys and valid contiguous array updates are preserved.
Generated and streamed responses preserve the served service tier from this response header when usage metadata omits it.
Streamed tool-call array indexes that leave a gap are skipped, preventing a small response from building a huge sparse array.
Omits foreign-provider empty signature text when replaying history through Anthropic or Bedrock, preserving Bedrock’s native reasoning-history handling.
GoogleRealtimeModel now supports this contract, returning the unconstrained Gemini Live endpoint with resolved credential headers; each server connection can create its own event parser.
Explicit speech language codes are forwarded to Gemini TTS for single- and multi-speaker requests, including the shared Vertex Gemini adapter; omitted languages and 'auto' retain automatic detection.
Keeps provider metadata on empty text parts when converting results to response messages, allowing it to be passed back in subsequent requests.
Preserves the order of text and complete function calls, including standalone thought signatures on empty text or reasoning parts.
Realtime usage snapshots use custom events with rawType and typed usage; completion-frame usage is attached to response-done, preserving lifecycle ordering without inferring response associations.
Parses string functionCall arguments.
Handles cycles and BigInt values in functionResponse.
Maps Google RPC status names to HTTP status codes when streamed errors lack a numeric code, marking transient failures such as UNAVAILABLE and RESOURCE_EXHAUSTED retryable.
String values in streamed tool-call input are now closed on the final chunk.
Empty arrays and objects in tool-call input are now preserved when streamed, instead of being dropped.
Provider-returned identifiers are encoded in credentialed follow-up request paths.
In-stream errors are now surfaced.
Regional Gemini model IDs are handled.
Valid thinking configurations are handled.
Google tool errors and denied executions are sent under functionResponse.response.error.
JSONL rows are limited to 64 MB during batch result downloads.
Custom metadata is now preserved in retrieved context grounding chunks.
Uses a JSON response tool for structured outputs when tool calling is enabled.
Uses a standards-compliant User-Agent header.
Realtime user utterances retain independent IDs and cumulative transcripts.
Response IDs advance after interruption.
Text-free transcription completion markers are honored.
Gemini Live now sends the default thinkingLevel when thinkingConfig sets neither thinkingLevel nor thinkingBudget, and no longer overwrites a raw generationConfig.thinkingConfig.
Supported Vertex tool result URLs are forwarded as function response file data.
Fixes serialization of JSON Schema references in function responses.
Native WAV responses are preserved without adding a second header; explicit raw PCM, mu-law, and A-law output are supported, and headerless audio formats are identified correctly.
Code execution parts are preserved when messages are replayed.
Calls with more than 100 values keep per-value multimodal content aligned across automatic batches, including text-only entries; content length and each batch's provider options are validated before requests are sent.
Shares transcript and custom-voice inspection through the Google provider internal export.
Empty speech transcripts are rejected before a request is sent.
Preserve opaque file URI strings during provider serialization.
Image candidate finish reasons are preserved in provider metadata.
The provider now advertises the supported Gemini image per-call limit, helping developers determine the limit for image requests.
Default prompt block reasons are ignored in non-streaming responses.
Prompt feedback and metadata are preserved across streaming chunks.
On background-reasoning Live models, the provider sends thinkingLevel: 'low' when neither thinkingLevel nor thinkingBudget is set, meeting the requirement to provide exactly one.
Wraps non-object realtime tool results under output; object results pass through unchanged, as required by Gemini's Struct field.
Preserves JSON Schema instead of converting it to OpenAPI schema.
Fixes downloading file URLs from tool results.
Unclassified empty image results are now retried.
The Google provider maps the code execution tool name correctly.
Gemini Interactions now support video response formats.
Google Files URLs are now recognized when using a baseUrl.
Frequency and presence penalties are omitted from Gemini 2.5 requests because they are unsupported; warnings are returned instead.
Raw usage results preserve complete Google Generative Language usage metadata.
Local JSON Schema references are inlined in Google tool and structured-output schemas.
Handles empty string tool call IDs.
Uses low as the minimum reasoning level for full Gemini Flash 3.7 and later.
Emits Vertex no-argument streaming tool calls as complete tool calls with '{}' input and propagates thoughtSignature metadata.
Uses VALIDATED function calling mode when any tool has strict:true.
Supports functionCall.id returned by Gemini and provides the matching functionResponse.id.
Preserves groundingMetadata and urlContextMetadata when they arrive in a stream chunk before the finishReason chunk.
Correctly marks reasoning files as such and fixes related multi-turn errors.
Reads serviceTier from usageMetadata in both generate and stream paths, so streaming responses no longer report null.
Automatically injects skip_thought_signature_validator for Gemini 3 tool-call replays without a signature.
Preserves per-modality token details in usage data.
@ai-sdk/google 341 changes
Breaking changes 2
Schema conversion now enforces limits on visited JSON values, serialized size, and depth, failing with a controlled error when a schema exceeds them.
generateText with the Interactions API now polls background model calls until they finish.
Deprecations 2
The textEmbedding alias is deprecated in favor of embeddingModel.
The textEmbeddingModel alias is deprecated in favor of embeddingModel.
New APIs and options 19
Adds a download size limit for Google Vertex tool result files, defaulting to 7 MiB; raise it for larger files.
Adds support for Hydrogen's xhigh thinking level in Google Generate Content and Interactions provider options.
Adds an array that preserves grounding metadata in request order, including null for requests without grounding.
Google and Anthropic providers support a custom provider name.
Provides embeddingModel as the embedding model method; textEmbeddingModel and textEmbedding remain as deprecated aliases.
Adds the enterpriseWebSearch tool.
Adds Gemini 3 Flash support.
Adds Gemini 3 Pro support.
Adds the gemini-3-pro-image-preview model ID.
Adds the gemini-3-pro-preview model ID.
Adds Google Maps grounding tool support for location-aware Gemini responses.
Adds a Google Vertex RAG Engine grounding provider tool.
Adds the Google File Search tool.
Adds imageConfig.aspectRatio configuration for Gemini models.
Adds support for the imageSize provider option.
Adds mediaResolution and passes it to the Google API.
Exposes promptFeedback outputs.
Adds the thinking_level option for Gemini 3 models.
Adds support for trafficType in Vertex AI provider usageMetadata.
Fixes and other changes 18
Empty arrays and objects in streamed tool-call input are now preserved when Vertex sends a value-less partialArgs entry.
Converts type arrays containing "null" to a plain nullable node, so adjacent items and format remain valid for Gemini.
For Vertex Gemini 3 and later, supported GCS tool result URLs are forwarded as function response file data for image, PDF, and text MIME types; HTTP(S) downloads remain supported on all Gemini generations.
Keeps per-value multimodal content aligned across automatic batches of more than 100 values, including text-only entries.
Validates content length before sending requests.
Validates each batch's provider options after middleware transforms them.
Default prompt block reasons are ignored in non-streaming responses.
Google content-filtered results are marked terminal, so they are not retried.
Unsupported frequency penalties are omitted from Gemini 2.5 requests, and a warning is returned.
Unsupported presence penalties are omitted from Gemini 2.5 requests, and a warning is returned.
Enum values are converted to the Gemini schema format.
Google model calls now preserve recursive tool input schemas instead of aborting.
Preserves nested empty object schemas in tool parameters to fix validation errors for required properties with empty object types.
Fixes using Google Search together with URL context in Vertex AI.
Handles File Search retrievedContext using fileSearchStore as well as the older uri format, preventing Zod validation errors.
Preserves thoughtSignature through tool execution, fixing missing thought_signature errors with Gemini thinking models on Google Vertex.
Retrieves thoughtSignature using the dynamic providerOptionsName, fixing multi-step tool calls with Gemini thinking models on Google Vertex.
Preserves nested empty object schemas and descriptions in tool parameters, avoiding validation errors for required properties with empty object types.
@ai-sdk/google 223 changes
Breaking changes 2
Changes the Google search tool to a provider-defined tool.
Only native URL is supported.
New APIs and options 12
Adds a code execution provider-defined tool.
Exports the embedding provider options type.
Adds support for Gemini 2.5 Pro.
Adds the gemini-embedding-001 model.
Adds support for new Gemini models.
Allows OFF as a Google HarmBlockThreshold value.
Adds image models to the Google provider for Imagen 3 support.
Exposes Google's raw usageMetadata in providerMetadata.
Adds support for raw chunks.
Adds taskType support for text embedding models.
Adds thinking configuration to provider options.
Adds a URL context tool as a provider-defined tool.
Behavior and default changes 5
embed uses the single embeddings endpoint to avoid rate limits associated with batch requests; no code updates are needed.
Adds support for Gemini 2.5 Flash, now stable.
Adds Gemini 2.5 Flash Lite GA.
System messages are omitted for Gemma models, and system instructions are handled automatically.
Google embedding models switch to using providerOptions.
Fixes and other changes 4
Supports tool schemas that allow additional properties, such as z.record(z.string()).
Unsupported additionalProperties is omitted from schemas sent in Google API request payloads.
Fixes grounding streaming sources.
Accepts nullish values in safetyRatings.