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

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,154 @@
1
1
  # @ai-sdk/google
2
2
 
3
+ ## 4.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - ba6d510: chore: fix deprecated use of zod `.passthrough()`
8
+
9
+ ## 4.0.0
10
+
11
+ ### Major Changes
12
+
13
+ - a3757d7: chore(provider/google): remove useless GenerativeAI affix from types and classes for consistency
14
+ - f7d4f01: feat(provider): add support for `reasoning-file` type for files that are part of reasoning
15
+ - ef992f8: Remove CommonJS exports from all packages. All packages are now ESM-only (`"type": "module"`). Consumers using `require()` must switch to ESM `import` syntax.
16
+ - c29a26f: feat(provider): add support for provider references and uploading files as supported per provider
17
+ - 3887c70: feat(provider): add new top-level reasoning parameter to spec and support it in `generateText` and `streamText`
18
+ - 8359612: Start v7 pre-release
19
+ - 04e9009: chore: make provider implementations code patterns more consistent, including renaming certain exported symbols
20
+
21
+ For all externally exported symbols that were renamed, the old names continue to work via deprecated aliases.
22
+
23
+ ### Patch Changes
24
+
25
+ - 7f04802: feat(provider/google): add support for managed agents in the Interactions API
26
+ - 38fc777: Add AI Gateway hint to provider READMEs
27
+ - b71c0d7: feat(provider/google): support Google search grounding when using `generateImage` with Gemini
28
+ - 6190649: chore(provider/google): remove obsolete Google image model
29
+ - 55db546: fix(provider/google): fix Gemini service tier enum after upstream update
30
+ - 9a0a618: fix(google): fix `serviceTier` to be correctly formatted for Vertex API
31
+ - 00a0f36: feat(google, google-vertex): added `gemini-embedding-2`, `deep-research-max-preview-04-2026` and `deep-research-preview-04-2026`
32
+ - 9715ec7: feat(provider/google): add support for service tier parameter
33
+ - 41da50c: fix(provider/google): support `functionCall.id` when returned by Gemini API and provide matching `functionResponse.id`
34
+ - add4326: fix(provider/google): correct JSDoc for multimodal embedding content option
35
+ - a8d70b6: fix(google): auto-inject `skip_thought_signature_validator` for Gemini 3 tool-call replays without a signature
36
+ - 947cdab: Add Google realtime Live Translation provider options for `gemini-3.5-live-translate-preview`.
37
+ - 4e825f3: feat(google): update Interactions API implementation to cater for upstream breaking changes coming May 26
38
+ - b563707: feat(provider/google): add Gemini text-to-speech (speech) model support
39
+ - a05109d: feat(provider/google): preserve per-modality token details in usage data
40
+ - cfca634: fix(google): emit Vertex no-args streaming tool calls and preserve thoughtSignature
41
+
42
+ 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.
43
+
44
+ Both paths now emit the call as a complete tool call with `'{}'` input and propagate `thoughtSignature` provider metadata.
45
+
46
+ Fixes #14847.
47
+
48
+ - c9c4661: fix(provider/google): preserve groundingMetadata and urlContextMetadata when they arrive in a stream chunk before the finishReason chunk
49
+ - 045d2e8: fix(google): read `serviceTier` from `usageMetadata.serviceTier` in both generate and stream paths
50
+
51
+ The previous implementation read `serviceTier` from the `x-gemini-service-tier`
52
+ response header, which is only populated on non-streaming responses. Gemini
53
+ streaming includes the value in `usageMetadata.serviceTier` on every chunk, so
54
+ `providerMetadata.google.serviceTier` was always `null` for streams. Read from
55
+ `usageMetadata` for both paths instead.
56
+
57
+ - 19b95f9: fix(google): use VALIDATED function calling mode when any tool has strict:true
58
+ - 2ce3c65: feat(provider/google-vertex): add Gemini text-to-speech (speech) model support
59
+ - 5878b40: fix(google): prevent prototype pollution when streaming tool args
60
+ - 46d1149: chore(provider-utils,google): fix grammar errors in error and warning messages
61
+ - 6a26901: feat(google): add `fileData` support to embedding model
62
+ - 01fa606: feat(provider/google): support combining built-in tools with function calling on Gemini 3
63
+ - 5036db8: feat(google-vertex): add support for streaming tool arguments input
64
+ - 9f0e36c: trigger release for all packages after provenance setup
65
+ - a2609df: fix(google): fix streaming tool call args
66
+ - ab43029: feat(provider/google): support multimodal content parts in embedding provider options
67
+ - 82288b0: feat(provider/google): add `gemini-embedding-2-preview` and fix multimodal embedding support with `embedMany`
68
+ - b04e23e: feat(provider/google): add support for the Gemini Interactions API
69
+ - 58a2ad7: fix: more precise default message for tool execution denial
70
+ - e59176c: chore(google): update v3 specs to v4
71
+ - ebbb0f2: fix(provider/google): fix lack of image consistency when using Interactions API in stateless mode
72
+ - aeda373: fix: only send provider credentials to same-origin response-supplied URLs
73
+
74
+ 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.
75
+
76
+ 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.
77
+
78
+ - 7fc6bd6: Raise minimum supported Node.js version to 22. Supported versions: 22, 24, and 26.
79
+ - 0c4c275: trigger initial canary release
80
+ - bdb9ea1: chore(google): remove now obsolete Interactions API `Api-Revision` header
81
+ - db394ab: feat(provider/google): support cancelling long-running Interactions API agents via AbortSignal, and process their intermittent stream
82
+ - ce769dd: feat(provider): add experimental Realtime API support for voice conversations
83
+
84
+ Adds first-class support for realtime (speech-to-speech) APIs:
85
+
86
+ - `Experimental_RealtimeModelV4` spec in `@ai-sdk/provider` with normalized event types and factory
87
+ - OpenAI, Google, and xAI realtime provider implementations
88
+ - `openai.experimental_realtime()` / `google.experimental_realtime()` / `xai.experimental_realtime()` work in both server and browser
89
+ - `.getToken()` static method on each provider for server-side ephemeral token creation
90
+ - `experimental_getRealtimeToolDefinitions` helper for provider session tool definitions
91
+ - `experimental_useRealtime` hook in `@ai-sdk/react` returning `UIMessage[]` (aligned with `useChat`), with `onToolCall` and `addToolOutput` for client-driven tool execution
92
+ - `inputAudioTranscription` session config for showing transcribed user audio messages when supported by the provider
93
+
94
+ - 5b7e7c2: fix(google-vertex): don't send streamFunctionCallArguments for unary API calls and change default to false
95
+ - 2edd14e: fix(provider/google): correctly mark reasoning files as such and fix related multi-turn errors
96
+ - 9bd6512: feat(provider): change file part data property to be tagged with a type and remove the image part type
97
+ - 258c093: chore: ensure consistent import handling and avoid import duplicates or cycles
98
+ - 546cefe: feat(provider/google): add `gemini-3.5-flash`
99
+ - 5463d0d: feat(provider): align tool result output content file part types with top-level message file part types
100
+ - 55f0938: chore(provider/google): update available models
101
+ - b8396f0: trigger initial beta release
102
+ - 84f36e0: fix(google): omit passing includeServerSideToolInvocations for Vertex tool_config
103
+ - 90e2d8a: chore: fix unused vars not being flagged by our lint tooling
104
+ - 4dac142: feat(google): add new finishMessage field in providerMetadata
105
+ - aeea161: feat(google): read `serviceTier` from `x-gemini-service-tier` response header in Gemini API and use PayGo for Vertex
106
+ - 18c1970: feat(provider/google): Add multimodal tool-result support for Google function responses.
107
+
108
+ Tool results with `output.type = 'content'` now map media parts into
109
+ `functionResponse.parts` for Google models, including `image-data`,
110
+ `file-data`, and base64 `data:` URLs in URL-style content parts.
111
+ Remote HTTP(S) URLs in URL-style tool-result parts are not supported.
112
+
113
+ - b3976a2: Add workflow serialization support to all provider models.
114
+
115
+ **`@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.
116
+
117
+ **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.
118
+
119
+ All provider model classes now include `WORKFLOW_SERIALIZE` and `WORKFLOW_DESERIALIZE` static methods, enabling them to cross workflow step boundaries without serialization errors.
120
+
121
+ - ff5eba1: feat: roll `image-*` tool output types into their equivalent `file-*` types
122
+
123
+ ## 4.0.0-beta.85
124
+
125
+ ### Patch Changes
126
+
127
+ - Updated dependencies [0416e3e]
128
+ - @ai-sdk/provider@4.0.0-beta.20
129
+ - @ai-sdk/provider-utils@5.0.0-beta.50
130
+
131
+ ## 4.0.0-beta.84
132
+
133
+ ### Patch Changes
134
+
135
+ - 947cdab: Add Google realtime Live Translation provider options for `gemini-3.5-live-translate-preview`.
136
+
137
+ ## 4.0.0-beta.83
138
+
139
+ ### Patch Changes
140
+
141
+ - bdb9ea1: chore(google): remove now obsolete Interactions API `Api-Revision` header
142
+
143
+ ## 4.0.0-beta.82
144
+
145
+ ### Patch Changes
146
+
147
+ - b8396f0: trigger initial beta release
148
+ - Updated dependencies [b8396f0]
149
+ - @ai-sdk/provider-utils@5.0.0-beta.49
150
+ - @ai-sdk/provider@4.0.0-beta.19
151
+
3
152
  ## 4.0.0-canary.81
4
153
 
5
154
  ### 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.1" : "0.0.0-test";
11
11
 
12
12
  // src/google-embedding-model.ts
13
13
  import {
@@ -2703,7 +2703,7 @@ import {
2703
2703
  zodSchema as zodSchema7
2704
2704
  } from "@ai-sdk/provider-utils";
2705
2705
  import { z as z8 } from "zod/v4";
2706
- var fileSearchArgsBaseSchema = z8.object({
2706
+ var fileSearchArgsBaseSchema = z8.looseObject({
2707
2707
  /** The names of the file_search_stores to retrieve from.
2708
2708
  * Example: `fileSearchStores/my-file-search-store-123`
2709
2709
  */
@@ -2718,7 +2718,7 @@ var fileSearchArgsBaseSchema = z8.object({
2718
2718
  metadataFilter: z8.string().describe(
2719
2719
  "Metadata filter to apply to the file search retrieval documents. See https://google.aip.dev/160 for the syntax of the filter expression."
2720
2720
  ).optional()
2721
- }).passthrough();
2721
+ });
2722
2722
  var fileSearch = createProviderExecutedToolFactory3({
2723
2723
  id: "google.file_search",
2724
2724
  inputSchema: lazySchema7(() => zodSchema7(z8.object({}))),
@@ -2745,7 +2745,7 @@ import {
2745
2745
  zodSchema as zodSchema9
2746
2746
  } from "@ai-sdk/provider-utils";
2747
2747
  import { z as z10 } from "zod/v4";
2748
- var googleSearchToolArgsBaseSchema = z10.object({
2748
+ var googleSearchToolArgsBaseSchema = z10.looseObject({
2749
2749
  searchTypes: z10.object({
2750
2750
  webSearch: z10.object({}).optional(),
2751
2751
  imageSearch: z10.object({}).optional()
@@ -2754,7 +2754,7 @@ var googleSearchToolArgsBaseSchema = z10.object({
2754
2754
  startTime: z10.string(),
2755
2755
  endTime: z10.string()
2756
2756
  }).optional()
2757
- }).passthrough();
2757
+ });
2758
2758
  var googleSearch = createProviderExecutedToolFactory5({
2759
2759
  id: "google.google_search",
2760
2760
  inputSchema: lazySchema9(() => zodSchema9(z10.object({}))),
@@ -3314,11 +3314,11 @@ var googleFileResponseSchema = lazySchema14(
3314
3314
  );
3315
3315
  var googleFilesUploadOptionsSchema = lazySchema14(
3316
3316
  () => zodSchema14(
3317
- z15.object({
3317
+ z15.looseObject({
3318
3318
  displayName: z15.string().nullish(),
3319
3319
  pollIntervalMs: z15.number().positive().nullish(),
3320
3320
  pollTimeoutMs: z15.number().positive().nullish()
3321
- }).passthrough()
3321
+ })
3322
3322
  )
3323
3323
  );
3324
3324
 
@@ -3344,7 +3344,7 @@ import { lazySchema as lazySchema15, zodSchema as zodSchema15 } from "@ai-sdk/pr
3344
3344
  import { z as z16 } from "zod/v4";
3345
3345
  var googleVideoModelOptionsSchema = lazySchema15(
3346
3346
  () => zodSchema15(
3347
- z16.object({
3347
+ z16.looseObject({
3348
3348
  pollIntervalMs: z16.number().positive().nullish(),
3349
3349
  pollTimeoutMs: z16.number().positive().nullish(),
3350
3350
  personGeneration: z16.enum(["dont_allow", "allow_adult", "allow_all"]).nullish(),
@@ -3355,7 +3355,7 @@ var googleVideoModelOptionsSchema = lazySchema15(
3355
3355
  gcsUri: z16.string().nullish()
3356
3356
  })
3357
3357
  ).nullish()
3358
- }).passthrough()
3358
+ })
3359
3359
  )
3360
3360
  );
3361
3361
 
@@ -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
  }