@ai-sdk/google 4.0.0-canary.81 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,148 @@
1
1
  # @ai-sdk/google
2
2
 
3
+ ## 4.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - a3757d7: chore(provider/google): remove useless GenerativeAI affix from types and classes for consistency
8
+ - f7d4f01: feat(provider): add support for `reasoning-file` type for files that are part of reasoning
9
+ - ef992f8: Remove CommonJS exports from all packages. All packages are now ESM-only (`"type": "module"`). Consumers using `require()` must switch to ESM `import` syntax.
10
+ - c29a26f: feat(provider): add support for provider references and uploading files as supported per provider
11
+ - 3887c70: feat(provider): add new top-level reasoning parameter to spec and support it in `generateText` and `streamText`
12
+ - 8359612: Start v7 pre-release
13
+ - 04e9009: chore: make provider implementations code patterns more consistent, including renaming certain exported symbols
14
+
15
+ For all externally exported symbols that were renamed, the old names continue to work via deprecated aliases.
16
+
17
+ ### Patch Changes
18
+
19
+ - 7f04802: feat(provider/google): add support for managed agents in the Interactions API
20
+ - 38fc777: Add AI Gateway hint to provider READMEs
21
+ - b71c0d7: feat(provider/google): support Google search grounding when using `generateImage` with Gemini
22
+ - 6190649: chore(provider/google): remove obsolete Google image model
23
+ - 55db546: fix(provider/google): fix Gemini service tier enum after upstream update
24
+ - 9a0a618: fix(google): fix `serviceTier` to be correctly formatted for Vertex API
25
+ - 00a0f36: feat(google, google-vertex): added `gemini-embedding-2`, `deep-research-max-preview-04-2026` and `deep-research-preview-04-2026`
26
+ - 9715ec7: feat(provider/google): add support for service tier parameter
27
+ - 41da50c: fix(provider/google): support `functionCall.id` when returned by Gemini API and provide matching `functionResponse.id`
28
+ - add4326: fix(provider/google): correct JSDoc for multimodal embedding content option
29
+ - a8d70b6: fix(google): auto-inject `skip_thought_signature_validator` for Gemini 3 tool-call replays without a signature
30
+ - 947cdab: Add Google realtime Live Translation provider options for `gemini-3.5-live-translate-preview`.
31
+ - 4e825f3: feat(google): update Interactions API implementation to cater for upstream breaking changes coming May 26
32
+ - b563707: feat(provider/google): add Gemini text-to-speech (speech) model support
33
+ - a05109d: feat(provider/google): preserve per-modality token details in usage data
34
+ - cfca634: fix(google): emit Vertex no-args streaming tool calls and preserve thoughtSignature
35
+
36
+ Vertex emits a no-args function call as a single chunk shaped `{ functionCall: { name: 'X' } }` with no `args`, no `partialArgs`, and no `willContinue`. The streaming parser had no branch for this shape, so the call was dropped along with any `thoughtSignature` it carried. For Gemini 3 thinking models this caused the next multi-turn step to 400 with `missing thought_signature`. The unary (`doGenerate`) path had the same drop.
37
+
38
+ Both paths now emit the call as a complete tool call with `'{}'` input and propagate `thoughtSignature` provider metadata.
39
+
40
+ Fixes #14847.
41
+
42
+ - c9c4661: fix(provider/google): preserve groundingMetadata and urlContextMetadata when they arrive in a stream chunk before the finishReason chunk
43
+ - 045d2e8: fix(google): read `serviceTier` from `usageMetadata.serviceTier` in both generate and stream paths
44
+
45
+ The previous implementation read `serviceTier` from the `x-gemini-service-tier`
46
+ response header, which is only populated on non-streaming responses. Gemini
47
+ streaming includes the value in `usageMetadata.serviceTier` on every chunk, so
48
+ `providerMetadata.google.serviceTier` was always `null` for streams. Read from
49
+ `usageMetadata` for both paths instead.
50
+
51
+ - 19b95f9: fix(google): use VALIDATED function calling mode when any tool has strict:true
52
+ - 2ce3c65: feat(provider/google-vertex): add Gemini text-to-speech (speech) model support
53
+ - 5878b40: fix(google): prevent prototype pollution when streaming tool args
54
+ - 46d1149: chore(provider-utils,google): fix grammar errors in error and warning messages
55
+ - 6a26901: feat(google): add `fileData` support to embedding model
56
+ - 01fa606: feat(provider/google): support combining built-in tools with function calling on Gemini 3
57
+ - 5036db8: feat(google-vertex): add support for streaming tool arguments input
58
+ - 9f0e36c: trigger release for all packages after provenance setup
59
+ - a2609df: fix(google): fix streaming tool call args
60
+ - ab43029: feat(provider/google): support multimodal content parts in embedding provider options
61
+ - 82288b0: feat(provider/google): add `gemini-embedding-2-preview` and fix multimodal embedding support with `embedMany`
62
+ - b04e23e: feat(provider/google): add support for the Gemini Interactions API
63
+ - 58a2ad7: fix: more precise default message for tool execution denial
64
+ - e59176c: chore(google): update v3 specs to v4
65
+ - ebbb0f2: fix(provider/google): fix lack of image consistency when using Interactions API in stateless mode
66
+ - aeda373: fix: only send provider credentials to same-origin response-supplied URLs
67
+
68
+ Several provider clients followed a URL taken from the provider's API response (a polling/status URL or a final media URL such as `polling_url`, `urls.get`, `result_url`, `result.sample`, or `video.uri`) and reused the authenticated headers — or appended `?key=<API_KEY>` — on that request. Because the host of the response-supplied URL was never validated, the long-lived API key was sent to whatever host the response named (a CDN in the benign case, or an attacker-chosen host if the provider response was tampered with), allowing credential exfiltration.
69
+
70
+ A new `isSameOrigin` helper is added to `@ai-sdk/provider-utils`, and the affected fetches in `@ai-sdk/black-forest-labs`, `@ai-sdk/fireworks`, `@ai-sdk/replicate`, `@ai-sdk/gladia`, `@ai-sdk/fal`, and `@ai-sdk/google` now attach credentials only when the followed URL is same-origin with the provider's configured API origin. Requests to a foreign origin are made without the credential.
71
+
72
+ - 7fc6bd6: Raise minimum supported Node.js version to 22. Supported versions: 22, 24, and 26.
73
+ - 0c4c275: trigger initial canary release
74
+ - bdb9ea1: chore(google): remove now obsolete Interactions API `Api-Revision` header
75
+ - db394ab: feat(provider/google): support cancelling long-running Interactions API agents via AbortSignal, and process their intermittent stream
76
+ - ce769dd: feat(provider): add experimental Realtime API support for voice conversations
77
+
78
+ Adds first-class support for realtime (speech-to-speech) APIs:
79
+
80
+ - `Experimental_RealtimeModelV4` spec in `@ai-sdk/provider` with normalized event types and factory
81
+ - OpenAI, Google, and xAI realtime provider implementations
82
+ - `openai.experimental_realtime()` / `google.experimental_realtime()` / `xai.experimental_realtime()` work in both server and browser
83
+ - `.getToken()` static method on each provider for server-side ephemeral token creation
84
+ - `experimental_getRealtimeToolDefinitions` helper for provider session tool definitions
85
+ - `experimental_useRealtime` hook in `@ai-sdk/react` returning `UIMessage[]` (aligned with `useChat`), with `onToolCall` and `addToolOutput` for client-driven tool execution
86
+ - `inputAudioTranscription` session config for showing transcribed user audio messages when supported by the provider
87
+
88
+ - 5b7e7c2: fix(google-vertex): don't send streamFunctionCallArguments for unary API calls and change default to false
89
+ - 2edd14e: fix(provider/google): correctly mark reasoning files as such and fix related multi-turn errors
90
+ - 9bd6512: feat(provider): change file part data property to be tagged with a type and remove the image part type
91
+ - 258c093: chore: ensure consistent import handling and avoid import duplicates or cycles
92
+ - 546cefe: feat(provider/google): add `gemini-3.5-flash`
93
+ - 5463d0d: feat(provider): align tool result output content file part types with top-level message file part types
94
+ - 55f0938: chore(provider/google): update available models
95
+ - b8396f0: trigger initial beta release
96
+ - 84f36e0: fix(google): omit passing includeServerSideToolInvocations for Vertex tool_config
97
+ - 90e2d8a: chore: fix unused vars not being flagged by our lint tooling
98
+ - 4dac142: feat(google): add new finishMessage field in providerMetadata
99
+ - aeea161: feat(google): read `serviceTier` from `x-gemini-service-tier` response header in Gemini API and use PayGo for Vertex
100
+ - 18c1970: feat(provider/google): Add multimodal tool-result support for Google function responses.
101
+
102
+ Tool results with `output.type = 'content'` now map media parts into
103
+ `functionResponse.parts` for Google models, including `image-data`,
104
+ `file-data`, and base64 `data:` URLs in URL-style content parts.
105
+ Remote HTTP(S) URLs in URL-style tool-result parts are not supported.
106
+
107
+ - b3976a2: Add workflow serialization support to all provider models.
108
+
109
+ **`@ai-sdk/provider-utils`:** New `serializeModel()` helper that extracts only serializable properties from a model instance, filtering out functions and objects containing functions. Third-party provider authors can use this to add workflow support to their own models.
110
+
111
+ **All providers:** `headers` is now optional in provider config types. This is non-breaking — existing code that passes `headers` continues to work. Custom provider implementations that construct model configs manually can now omit `headers`, which is useful when models are deserialized from a workflow step boundary where auth is provided separately.
112
+
113
+ All provider model classes now include `WORKFLOW_SERIALIZE` and `WORKFLOW_DESERIALIZE` static methods, enabling them to cross workflow step boundaries without serialization errors.
114
+
115
+ - ff5eba1: feat: roll `image-*` tool output types into their equivalent `file-*` types
116
+
117
+ ## 4.0.0-beta.85
118
+
119
+ ### Patch Changes
120
+
121
+ - Updated dependencies [0416e3e]
122
+ - @ai-sdk/provider@4.0.0-beta.20
123
+ - @ai-sdk/provider-utils@5.0.0-beta.50
124
+
125
+ ## 4.0.0-beta.84
126
+
127
+ ### Patch Changes
128
+
129
+ - 947cdab: Add Google realtime Live Translation provider options for `gemini-3.5-live-translate-preview`.
130
+
131
+ ## 4.0.0-beta.83
132
+
133
+ ### Patch Changes
134
+
135
+ - bdb9ea1: chore(google): remove now obsolete Interactions API `Api-Revision` header
136
+
137
+ ## 4.0.0-beta.82
138
+
139
+ ### Patch Changes
140
+
141
+ - b8396f0: trigger initial beta release
142
+ - Updated dependencies [b8396f0]
143
+ - @ai-sdk/provider-utils@5.0.0-beta.49
144
+ - @ai-sdk/provider@4.0.0-beta.19
145
+
3
146
  ## 4.0.0-canary.81
4
147
 
5
148
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -622,6 +622,28 @@ declare class GoogleRealtimeModel implements Experimental_RealtimeModelV4 {
622
622
  buildSessionConfig(config: Experimental_RealtimeModelV4SessionConfig): Record<string, unknown>;
623
623
  }
624
624
 
625
+ type GoogleRealtimeModelId = string;
626
+ type GoogleRealtimeModelOptions = {
627
+ /**
628
+ * Gemini Live Translation configuration.
629
+ *
630
+ * Required for `gemini-3.5-live-translate-preview` when translating speech
631
+ * to a target language.
632
+ */
633
+ translationConfig?: {
634
+ /**
635
+ * BCP-47 language code of the language to translate into.
636
+ * Defaults to `en` in the Gemini API.
637
+ */
638
+ targetLanguageCode?: string;
639
+ /**
640
+ * Whether input audio already in the target language should be echoed
641
+ * instead of producing silence.
642
+ */
643
+ echoTargetLanguage?: boolean;
644
+ };
645
+ };
646
+
625
647
  declare const VERSION: string;
626
648
 
627
- export { GoogleRealtimeModel as Experimental_GoogleRealtimeModel, type GoogleRealtimeModelConfig as Experimental_GoogleRealtimeModelConfig, type GoogleEmbeddingModelOptions, type GoogleErrorData, type GoogleFilesUploadOptions, type GoogleEmbeddingModelOptions as GoogleGenerativeAIEmbeddingProviderOptions, type GoogleImageModelOptions as GoogleGenerativeAIImageProviderOptions, type GoogleProvider as GoogleGenerativeAIProvider, type GoogleProviderMetadata as GoogleGenerativeAIProviderMetadata, type GoogleLanguageModelOptions as GoogleGenerativeAIProviderOptions, type GoogleProviderSettings as GoogleGenerativeAIProviderSettings, type GoogleVideoModelId as GoogleGenerativeAIVideoModelId, type GoogleVideoModelOptions as GoogleGenerativeAIVideoProviderOptions, type GoogleImageModelOptions, type GoogleInteractionsAgentName, type GoogleInteractionsModelId, type GoogleInteractionsProviderMetadata, type GoogleLanguageModelInteractionsOptions, type GoogleLanguageModelOptions, type GoogleProvider, type GoogleProviderMetadata, type GoogleProviderSettings, type GoogleSpeechModelId, type GoogleSpeechModelOptions, type GoogleVideoModelId, type GoogleVideoModelOptions, VERSION, createGoogle, createGoogle as createGoogleGenerativeAI, google };
649
+ export { GoogleRealtimeModel as Experimental_GoogleRealtimeModel, type GoogleRealtimeModelConfig as Experimental_GoogleRealtimeModelConfig, type GoogleRealtimeModelId as Experimental_GoogleRealtimeModelId, type GoogleRealtimeModelOptions as Experimental_GoogleRealtimeModelOptions, type GoogleEmbeddingModelOptions, type GoogleErrorData, type GoogleFilesUploadOptions, type GoogleEmbeddingModelOptions as GoogleGenerativeAIEmbeddingProviderOptions, type GoogleImageModelOptions as GoogleGenerativeAIImageProviderOptions, type GoogleProvider as GoogleGenerativeAIProvider, type GoogleProviderMetadata as GoogleGenerativeAIProviderMetadata, type GoogleLanguageModelOptions as GoogleGenerativeAIProviderOptions, type GoogleProviderSettings as GoogleGenerativeAIProviderSettings, type GoogleVideoModelId as GoogleGenerativeAIVideoModelId, type GoogleVideoModelOptions as GoogleGenerativeAIVideoProviderOptions, type GoogleImageModelOptions, type GoogleInteractionsAgentName, type GoogleInteractionsModelId, type GoogleInteractionsProviderMetadata, type GoogleLanguageModelInteractionsOptions, type GoogleLanguageModelOptions, type GoogleProvider, type GoogleProviderMetadata, type GoogleProviderSettings, type GoogleSpeechModelId, type GoogleSpeechModelOptions, type GoogleVideoModelId, type GoogleVideoModelOptions, VERSION, createGoogle, createGoogle as createGoogleGenerativeAI, google };
package/dist/index.js CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  } from "@ai-sdk/provider-utils";
8
8
 
9
9
  // src/version.ts
10
- var VERSION = true ? "4.0.0-canary.81" : "0.0.0-test";
10
+ var VERSION = true ? "4.0.0" : "0.0.0-test";
11
11
 
12
12
  // src/google-embedding-model.ts
13
13
  import {
@@ -6496,7 +6496,6 @@ var GoogleInteractionsLanguageModel = class _GoogleInteractionsLanguageModel {
6496
6496
  const { args, warnings, isAgent, pollingTimeoutMs } = await this.getArgs(options);
6497
6497
  const url = `${this.config.baseURL}/interactions`;
6498
6498
  const mergedHeaders = combineHeaders8(
6499
- INTERACTIONS_API_REVISION_HEADER,
6500
6499
  this.config.headers ? await resolve6(this.config.headers) : void 0,
6501
6500
  options.headers
6502
6501
  );
@@ -6577,7 +6576,6 @@ var GoogleInteractionsLanguageModel = class _GoogleInteractionsLanguageModel {
6577
6576
  const { args, warnings, isBackground, pollingTimeoutMs } = await this.getArgs(options);
6578
6577
  const url = `${this.config.baseURL}/interactions`;
6579
6578
  const mergedHeaders = combineHeaders8(
6580
- INTERACTIONS_API_REVISION_HEADER,
6581
6579
  this.config.headers ? await resolve6(this.config.headers) : void 0,
6582
6580
  options.headers
6583
6581
  );
@@ -6697,9 +6695,6 @@ var GoogleInteractionsLanguageModel = class _GoogleInteractionsLanguageModel {
6697
6695
  };
6698
6696
  }
6699
6697
  };
6700
- var INTERACTIONS_API_REVISION_HEADER = {
6701
- "Api-Revision": "2026-05-20"
6702
- };
6703
6698
  function pruneUndefined(obj) {
6704
6699
  const result = {};
6705
6700
  for (const [key, value] of Object.entries(obj)) {
@@ -6711,6 +6706,9 @@ function pruneUndefined(obj) {
6711
6706
 
6712
6707
  // src/realtime/google-realtime-event-mapper.ts
6713
6708
  import { safeParseJSON } from "@ai-sdk/provider-utils";
6709
+ function isRecord(value) {
6710
+ return value != null && typeof value === "object" && !Array.isArray(value);
6711
+ }
6714
6712
  var GoogleRealtimeEventMapper = class {
6715
6713
  constructor() {
6716
6714
  this.turnCounter = 0;
@@ -6905,6 +6903,11 @@ var GoogleRealtimeEventMapper = class {
6905
6903
  }
6906
6904
  };
6907
6905
  case "input-audio-commit":
6906
+ return {
6907
+ realtimeInput: {
6908
+ audioStreamEnd: true
6909
+ }
6910
+ };
6908
6911
  case "input-audio-clear":
6909
6912
  case "response-create":
6910
6913
  case "response-cancel":
@@ -6989,8 +6992,18 @@ function buildGoogleSessionConfig(config, modelId) {
6989
6992
  if ((config == null ? void 0 : config.outputAudioTranscription) != null) {
6990
6993
  setup.outputAudioTranscription = {};
6991
6994
  }
6992
- if ((config == null ? void 0 : config.providerOptions) != null) {
6993
- Object.assign(setup, config.providerOptions);
6995
+ if ((config == null ? void 0 : config.providerOptions) == null) {
6996
+ return setup;
6997
+ }
6998
+ const { google: google2, ...providerOptions } = config.providerOptions;
6999
+ Object.assign(setup, providerOptions);
7000
+ const googleOptions = isRecord(google2) ? google2 : void 0;
7001
+ if ((googleOptions == null ? void 0 : googleOptions.translationConfig) != null) {
7002
+ const target = isRecord(setup.generationConfig) ? setup.generationConfig : generationConfig;
7003
+ setup.generationConfig = {
7004
+ ...target,
7005
+ translationConfig: googleOptions.translationConfig
7006
+ };
6994
7007
  }
6995
7008
  return setup;
6996
7009
  }