@ai-sdk/google 3.0.23 → 3.0.25

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,17 @@
1
1
  # @ai-sdk/google
2
2
 
3
+ ## 3.0.25
4
+
5
+ ### Patch Changes
6
+
7
+ - 99fbed8: feat: normalize provider specific model options type names and ensure they are exported
8
+
9
+ ## 3.0.24
10
+
11
+ ### Patch Changes
12
+
13
+ - 3b3e32f: fix(google): handle thoughtSignature on empty-text parts in doGenerate and doStream
14
+
3
15
  ## 3.0.23
4
16
 
5
17
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -12,7 +12,7 @@ declare const googleErrorDataSchema: _ai_sdk_provider_utils.LazySchema<{
12
12
  type GoogleErrorData = InferSchema<typeof googleErrorDataSchema>;
13
13
 
14
14
  type GoogleGenerativeAIModelId = 'gemini-1.5-flash' | 'gemini-1.5-flash-latest' | 'gemini-1.5-flash-001' | 'gemini-1.5-flash-002' | 'gemini-1.5-flash-8b' | 'gemini-1.5-flash-8b-latest' | 'gemini-1.5-flash-8b-001' | 'gemini-1.5-pro' | 'gemini-1.5-pro-latest' | 'gemini-1.5-pro-001' | 'gemini-1.5-pro-002' | 'gemini-2.0-flash' | 'gemini-2.0-flash-001' | 'gemini-2.0-flash-live-001' | 'gemini-2.0-flash-lite' | 'gemini-2.0-pro-exp-02-05' | 'gemini-2.0-flash-thinking-exp-01-21' | 'gemini-2.0-flash-exp' | 'gemini-2.5-pro' | 'gemini-2.5-flash' | 'gemini-2.5-flash-image' | 'gemini-2.5-flash-lite' | 'gemini-2.5-flash-lite-preview-09-2025' | 'gemini-2.5-flash-preview-04-17' | 'gemini-2.5-flash-preview-09-2025' | 'gemini-3-pro-preview' | 'gemini-3-pro-image-preview' | 'gemini-3-flash-preview' | 'gemini-pro-latest' | 'gemini-flash-latest' | 'gemini-flash-lite-latest' | 'gemini-2.5-pro-exp-03-25' | 'gemini-exp-1206' | 'gemma-3-12b-it' | 'gemma-3-27b-it' | (string & {});
15
- declare const googleGenerativeAIProviderOptions: _ai_sdk_provider_utils.LazySchema<{
15
+ declare const googleLanguageModelOptions: _ai_sdk_provider_utils.LazySchema<{
16
16
  responseModalities?: ("TEXT" | "IMAGE")[] | undefined;
17
17
  thinkingConfig?: {
18
18
  thinkingBudget?: number | undefined;
@@ -40,7 +40,7 @@ declare const googleGenerativeAIProviderOptions: _ai_sdk_provider_utils.LazySche
40
40
  } | undefined;
41
41
  } | undefined;
42
42
  }>;
43
- type GoogleGenerativeAIProviderOptions = InferSchema<typeof googleGenerativeAIProviderOptions>;
43
+ type GoogleLanguageModelOptions = InferSchema<typeof googleLanguageModelOptions>;
44
44
 
45
45
  declare const responseSchema: _ai_sdk_provider_utils.LazySchema<{
46
46
  candidates: {
@@ -168,22 +168,22 @@ interface GoogleGenerativeAIImageSettings {
168
168
  maxImagesPerCall?: number;
169
169
  }
170
170
 
171
- declare const googleImageProviderOptionsSchema: _ai_sdk_provider_utils.LazySchema<{
171
+ declare const googleImageModelOptionsSchema: _ai_sdk_provider_utils.LazySchema<{
172
172
  personGeneration?: "dont_allow" | "allow_adult" | "allow_all" | null | undefined;
173
173
  aspectRatio?: "1:1" | "3:4" | "4:3" | "9:16" | "16:9" | null | undefined;
174
174
  }>;
175
- type GoogleGenerativeAIImageProviderOptions = InferSchema<typeof googleImageProviderOptionsSchema>;
175
+ type GoogleImageModelOptions = InferSchema<typeof googleImageModelOptionsSchema>;
176
176
 
177
177
  type GoogleGenerativeAIEmbeddingModelId = 'gemini-embedding-001' | 'text-embedding-004' | (string & {});
178
- declare const googleGenerativeAIEmbeddingProviderOptions: _ai_sdk_provider_utils.LazySchema<{
178
+ declare const googleEmbeddingModelOptions: _ai_sdk_provider_utils.LazySchema<{
179
179
  outputDimensionality?: number | undefined;
180
180
  taskType?: "SEMANTIC_SIMILARITY" | "CLASSIFICATION" | "CLUSTERING" | "RETRIEVAL_DOCUMENT" | "RETRIEVAL_QUERY" | "QUESTION_ANSWERING" | "FACT_VERIFICATION" | "CODE_RETRIEVAL_QUERY" | undefined;
181
181
  }>;
182
- type GoogleGenerativeAIEmbeddingProviderOptions = InferSchema<typeof googleGenerativeAIEmbeddingProviderOptions>;
182
+ type GoogleEmbeddingModelOptions = InferSchema<typeof googleEmbeddingModelOptions>;
183
183
 
184
184
  type GoogleGenerativeAIVideoModelId = 'veo-3.1-fast-generate-preview' | 'veo-3.1-generate-preview' | 'veo-3.1-generate' | 'veo-2.0-generate-001' | (string & {});
185
185
 
186
- type GoogleGenerativeAIVideoProviderOptions = {
186
+ type GoogleVideoModelOptions = {
187
187
  pollIntervalMs?: number | null;
188
188
  pollTimeoutMs?: number | null;
189
189
  personGeneration?: 'dont_allow' | 'allow_adult' | 'allow_all' | null;
@@ -350,4 +350,4 @@ declare const google: GoogleGenerativeAIProvider;
350
350
 
351
351
  declare const VERSION: string;
352
352
 
353
- export { type GoogleErrorData, type GoogleGenerativeAIEmbeddingProviderOptions, type GoogleGenerativeAIImageProviderOptions, type GoogleGenerativeAIProvider, type GoogleGenerativeAIProviderMetadata, type GoogleGenerativeAIProviderOptions, type GoogleGenerativeAIProviderSettings, type GoogleGenerativeAIVideoModelId, type GoogleGenerativeAIVideoProviderOptions, VERSION, createGoogleGenerativeAI, google };
353
+ export { type GoogleEmbeddingModelOptions, type GoogleErrorData, type GoogleEmbeddingModelOptions as GoogleGenerativeAIEmbeddingProviderOptions, type GoogleImageModelOptions as GoogleGenerativeAIImageProviderOptions, type GoogleGenerativeAIProvider, type GoogleGenerativeAIProviderMetadata, type GoogleLanguageModelOptions as GoogleGenerativeAIProviderOptions, type GoogleGenerativeAIProviderSettings, type GoogleGenerativeAIVideoModelId, type GoogleVideoModelOptions as GoogleGenerativeAIVideoProviderOptions, type GoogleImageModelOptions, type GoogleLanguageModelOptions, type GoogleVideoModelOptions, VERSION, createGoogleGenerativeAI, google };
package/dist/index.d.ts CHANGED
@@ -12,7 +12,7 @@ declare const googleErrorDataSchema: _ai_sdk_provider_utils.LazySchema<{
12
12
  type GoogleErrorData = InferSchema<typeof googleErrorDataSchema>;
13
13
 
14
14
  type GoogleGenerativeAIModelId = 'gemini-1.5-flash' | 'gemini-1.5-flash-latest' | 'gemini-1.5-flash-001' | 'gemini-1.5-flash-002' | 'gemini-1.5-flash-8b' | 'gemini-1.5-flash-8b-latest' | 'gemini-1.5-flash-8b-001' | 'gemini-1.5-pro' | 'gemini-1.5-pro-latest' | 'gemini-1.5-pro-001' | 'gemini-1.5-pro-002' | 'gemini-2.0-flash' | 'gemini-2.0-flash-001' | 'gemini-2.0-flash-live-001' | 'gemini-2.0-flash-lite' | 'gemini-2.0-pro-exp-02-05' | 'gemini-2.0-flash-thinking-exp-01-21' | 'gemini-2.0-flash-exp' | 'gemini-2.5-pro' | 'gemini-2.5-flash' | 'gemini-2.5-flash-image' | 'gemini-2.5-flash-lite' | 'gemini-2.5-flash-lite-preview-09-2025' | 'gemini-2.5-flash-preview-04-17' | 'gemini-2.5-flash-preview-09-2025' | 'gemini-3-pro-preview' | 'gemini-3-pro-image-preview' | 'gemini-3-flash-preview' | 'gemini-pro-latest' | 'gemini-flash-latest' | 'gemini-flash-lite-latest' | 'gemini-2.5-pro-exp-03-25' | 'gemini-exp-1206' | 'gemma-3-12b-it' | 'gemma-3-27b-it' | (string & {});
15
- declare const googleGenerativeAIProviderOptions: _ai_sdk_provider_utils.LazySchema<{
15
+ declare const googleLanguageModelOptions: _ai_sdk_provider_utils.LazySchema<{
16
16
  responseModalities?: ("TEXT" | "IMAGE")[] | undefined;
17
17
  thinkingConfig?: {
18
18
  thinkingBudget?: number | undefined;
@@ -40,7 +40,7 @@ declare const googleGenerativeAIProviderOptions: _ai_sdk_provider_utils.LazySche
40
40
  } | undefined;
41
41
  } | undefined;
42
42
  }>;
43
- type GoogleGenerativeAIProviderOptions = InferSchema<typeof googleGenerativeAIProviderOptions>;
43
+ type GoogleLanguageModelOptions = InferSchema<typeof googleLanguageModelOptions>;
44
44
 
45
45
  declare const responseSchema: _ai_sdk_provider_utils.LazySchema<{
46
46
  candidates: {
@@ -168,22 +168,22 @@ interface GoogleGenerativeAIImageSettings {
168
168
  maxImagesPerCall?: number;
169
169
  }
170
170
 
171
- declare const googleImageProviderOptionsSchema: _ai_sdk_provider_utils.LazySchema<{
171
+ declare const googleImageModelOptionsSchema: _ai_sdk_provider_utils.LazySchema<{
172
172
  personGeneration?: "dont_allow" | "allow_adult" | "allow_all" | null | undefined;
173
173
  aspectRatio?: "1:1" | "3:4" | "4:3" | "9:16" | "16:9" | null | undefined;
174
174
  }>;
175
- type GoogleGenerativeAIImageProviderOptions = InferSchema<typeof googleImageProviderOptionsSchema>;
175
+ type GoogleImageModelOptions = InferSchema<typeof googleImageModelOptionsSchema>;
176
176
 
177
177
  type GoogleGenerativeAIEmbeddingModelId = 'gemini-embedding-001' | 'text-embedding-004' | (string & {});
178
- declare const googleGenerativeAIEmbeddingProviderOptions: _ai_sdk_provider_utils.LazySchema<{
178
+ declare const googleEmbeddingModelOptions: _ai_sdk_provider_utils.LazySchema<{
179
179
  outputDimensionality?: number | undefined;
180
180
  taskType?: "SEMANTIC_SIMILARITY" | "CLASSIFICATION" | "CLUSTERING" | "RETRIEVAL_DOCUMENT" | "RETRIEVAL_QUERY" | "QUESTION_ANSWERING" | "FACT_VERIFICATION" | "CODE_RETRIEVAL_QUERY" | undefined;
181
181
  }>;
182
- type GoogleGenerativeAIEmbeddingProviderOptions = InferSchema<typeof googleGenerativeAIEmbeddingProviderOptions>;
182
+ type GoogleEmbeddingModelOptions = InferSchema<typeof googleEmbeddingModelOptions>;
183
183
 
184
184
  type GoogleGenerativeAIVideoModelId = 'veo-3.1-fast-generate-preview' | 'veo-3.1-generate-preview' | 'veo-3.1-generate' | 'veo-2.0-generate-001' | (string & {});
185
185
 
186
- type GoogleGenerativeAIVideoProviderOptions = {
186
+ type GoogleVideoModelOptions = {
187
187
  pollIntervalMs?: number | null;
188
188
  pollTimeoutMs?: number | null;
189
189
  personGeneration?: 'dont_allow' | 'allow_adult' | 'allow_all' | null;
@@ -350,4 +350,4 @@ declare const google: GoogleGenerativeAIProvider;
350
350
 
351
351
  declare const VERSION: string;
352
352
 
353
- export { type GoogleErrorData, type GoogleGenerativeAIEmbeddingProviderOptions, type GoogleGenerativeAIImageProviderOptions, type GoogleGenerativeAIProvider, type GoogleGenerativeAIProviderMetadata, type GoogleGenerativeAIProviderOptions, type GoogleGenerativeAIProviderSettings, type GoogleGenerativeAIVideoModelId, type GoogleGenerativeAIVideoProviderOptions, VERSION, createGoogleGenerativeAI, google };
353
+ export { type GoogleEmbeddingModelOptions, type GoogleErrorData, type GoogleEmbeddingModelOptions as GoogleGenerativeAIEmbeddingProviderOptions, type GoogleImageModelOptions as GoogleGenerativeAIImageProviderOptions, type GoogleGenerativeAIProvider, type GoogleGenerativeAIProviderMetadata, type GoogleLanguageModelOptions as GoogleGenerativeAIProviderOptions, type GoogleGenerativeAIProviderSettings, type GoogleGenerativeAIVideoModelId, type GoogleVideoModelOptions as GoogleGenerativeAIVideoProviderOptions, type GoogleImageModelOptions, type GoogleLanguageModelOptions, type GoogleVideoModelOptions, VERSION, createGoogleGenerativeAI, google };
package/dist/index.js CHANGED
@@ -30,7 +30,7 @@ module.exports = __toCommonJS(src_exports);
30
30
  var import_provider_utils16 = require("@ai-sdk/provider-utils");
31
31
 
32
32
  // src/version.ts
33
- var VERSION = true ? "3.0.23" : "0.0.0-test";
33
+ var VERSION = true ? "3.0.25" : "0.0.0-test";
34
34
 
35
35
  // src/google-generative-ai-embedding-model.ts
36
36
  var import_provider = require("@ai-sdk/provider");
@@ -59,7 +59,7 @@ var googleFailedResponseHandler = (0, import_provider_utils.createJsonErrorRespo
59
59
  // src/google-generative-ai-embedding-options.ts
60
60
  var import_provider_utils2 = require("@ai-sdk/provider-utils");
61
61
  var import_v42 = require("zod/v4");
62
- var googleGenerativeAIEmbeddingProviderOptions = (0, import_provider_utils2.lazySchema)(
62
+ var googleEmbeddingModelOptions = (0, import_provider_utils2.lazySchema)(
63
63
  () => (0, import_provider_utils2.zodSchema)(
64
64
  import_v42.z.object({
65
65
  /**
@@ -114,7 +114,7 @@ var GoogleGenerativeAIEmbeddingModel = class {
114
114
  const googleOptions = await (0, import_provider_utils3.parseProviderOptions)({
115
115
  provider: "google",
116
116
  providerOptions,
117
- schema: googleGenerativeAIEmbeddingProviderOptions
117
+ schema: googleEmbeddingModelOptions
118
118
  });
119
119
  if (values.length > this.maxEmbeddingsPerCall) {
120
120
  throw new import_provider.TooManyEmbeddingValuesForCallError({
@@ -542,7 +542,7 @@ function getModelPath(modelId) {
542
542
  // src/google-generative-ai-options.ts
543
543
  var import_provider_utils5 = require("@ai-sdk/provider-utils");
544
544
  var import_v44 = require("zod/v4");
545
- var googleGenerativeAIProviderOptions = (0, import_provider_utils5.lazySchema)(
545
+ var googleLanguageModelOptions = (0, import_provider_utils5.lazySchema)(
546
546
  () => (0, import_provider_utils5.zodSchema)(
547
547
  import_v44.z.object({
548
548
  responseModalities: import_v44.z.array(import_v44.z.enum(["TEXT", "IMAGE"])).optional(),
@@ -924,13 +924,13 @@ var GoogleGenerativeAILanguageModel = class {
924
924
  let googleOptions = await (0, import_provider_utils6.parseProviderOptions)({
925
925
  provider: providerOptionsName,
926
926
  providerOptions,
927
- schema: googleGenerativeAIProviderOptions
927
+ schema: googleLanguageModelOptions
928
928
  });
929
929
  if (googleOptions == null && providerOptionsName !== "google") {
930
930
  googleOptions = await (0, import_provider_utils6.parseProviderOptions)({
931
931
  provider: "google",
932
932
  providerOptions,
933
- schema: googleGenerativeAIProviderOptions
933
+ schema: googleLanguageModelOptions
934
934
  });
935
935
  }
936
936
  if ((tools == null ? void 0 : tools.some(
@@ -1051,16 +1051,24 @@ var GoogleGenerativeAILanguageModel = class {
1051
1051
  }
1052
1052
  });
1053
1053
  lastCodeExecutionToolCallId = void 0;
1054
- } else if ("text" in part && part.text != null && part.text.length > 0) {
1055
- content.push({
1056
- type: part.thought === true ? "reasoning" : "text",
1057
- text: part.text,
1058
- providerMetadata: part.thoughtSignature ? {
1059
- [providerOptionsName]: {
1060
- thoughtSignature: part.thoughtSignature
1061
- }
1062
- } : void 0
1063
- });
1054
+ } else if ("text" in part && part.text != null) {
1055
+ const thoughtSignatureMetadata = part.thoughtSignature ? {
1056
+ [providerOptionsName]: {
1057
+ thoughtSignature: part.thoughtSignature
1058
+ }
1059
+ } : void 0;
1060
+ if (part.text.length === 0) {
1061
+ if (thoughtSignatureMetadata != null && content.length > 0) {
1062
+ const lastContent = content[content.length - 1];
1063
+ lastContent.providerMetadata = thoughtSignatureMetadata;
1064
+ }
1065
+ } else {
1066
+ content.push({
1067
+ type: part.thought === true ? "reasoning" : "text",
1068
+ text: part.text,
1069
+ providerMetadata: thoughtSignatureMetadata
1070
+ });
1071
+ }
1064
1072
  } else if ("functionCall" in part) {
1065
1073
  content.push({
1066
1074
  type: "tool-call",
@@ -1218,8 +1226,22 @@ var GoogleGenerativeAILanguageModel = class {
1218
1226
  });
1219
1227
  lastCodeExecutionToolCallId = void 0;
1220
1228
  }
1221
- } else if ("text" in part && part.text != null && part.text.length > 0) {
1222
- if (part.thought === true) {
1229
+ } else if ("text" in part && part.text != null) {
1230
+ const thoughtSignatureMetadata = part.thoughtSignature ? {
1231
+ [providerOptionsName]: {
1232
+ thoughtSignature: part.thoughtSignature
1233
+ }
1234
+ } : void 0;
1235
+ if (part.text.length === 0) {
1236
+ if (thoughtSignatureMetadata != null && currentTextBlockId !== null) {
1237
+ controller.enqueue({
1238
+ type: "text-delta",
1239
+ id: currentTextBlockId,
1240
+ delta: "",
1241
+ providerMetadata: thoughtSignatureMetadata
1242
+ });
1243
+ }
1244
+ } else if (part.thought === true) {
1223
1245
  if (currentTextBlockId !== null) {
1224
1246
  controller.enqueue({
1225
1247
  type: "text-end",
@@ -1232,22 +1254,14 @@ var GoogleGenerativeAILanguageModel = class {
1232
1254
  controller.enqueue({
1233
1255
  type: "reasoning-start",
1234
1256
  id: currentReasoningBlockId,
1235
- providerMetadata: part.thoughtSignature ? {
1236
- [providerOptionsName]: {
1237
- thoughtSignature: part.thoughtSignature
1238
- }
1239
- } : void 0
1257
+ providerMetadata: thoughtSignatureMetadata
1240
1258
  });
1241
1259
  }
1242
1260
  controller.enqueue({
1243
1261
  type: "reasoning-delta",
1244
1262
  id: currentReasoningBlockId,
1245
1263
  delta: part.text,
1246
- providerMetadata: part.thoughtSignature ? {
1247
- [providerOptionsName]: {
1248
- thoughtSignature: part.thoughtSignature
1249
- }
1250
- } : void 0
1264
+ providerMetadata: thoughtSignatureMetadata
1251
1265
  });
1252
1266
  } else {
1253
1267
  if (currentReasoningBlockId !== null) {
@@ -1262,22 +1276,14 @@ var GoogleGenerativeAILanguageModel = class {
1262
1276
  controller.enqueue({
1263
1277
  type: "text-start",
1264
1278
  id: currentTextBlockId,
1265
- providerMetadata: part.thoughtSignature ? {
1266
- [providerOptionsName]: {
1267
- thoughtSignature: part.thoughtSignature
1268
- }
1269
- } : void 0
1279
+ providerMetadata: thoughtSignatureMetadata
1270
1280
  });
1271
1281
  }
1272
1282
  controller.enqueue({
1273
1283
  type: "text-delta",
1274
1284
  id: currentTextBlockId,
1275
1285
  delta: part.text,
1276
- providerMetadata: part.thoughtSignature ? {
1277
- [providerOptionsName]: {
1278
- thoughtSignature: part.thoughtSignature
1279
- }
1280
- } : void 0
1286
+ providerMetadata: thoughtSignatureMetadata
1281
1287
  });
1282
1288
  }
1283
1289
  } else if ("inlineData" in part) {
@@ -1828,7 +1834,7 @@ var GoogleGenerativeAIImageModel = class {
1828
1834
  const googleOptions = await (0, import_provider_utils14.parseProviderOptions)({
1829
1835
  provider: "google",
1830
1836
  providerOptions,
1831
- schema: googleImageProviderOptionsSchema
1837
+ schema: googleImageModelOptionsSchema
1832
1838
  });
1833
1839
  const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
1834
1840
  const parameters = {
@@ -1882,7 +1888,7 @@ var googleImageResponseSchema = (0, import_provider_utils14.lazySchema)(
1882
1888
  })
1883
1889
  )
1884
1890
  );
1885
- var googleImageProviderOptionsSchema = (0, import_provider_utils14.lazySchema)(
1891
+ var googleImageModelOptionsSchema = (0, import_provider_utils14.lazySchema)(
1886
1892
  () => (0, import_provider_utils14.zodSchema)(
1887
1893
  import_v413.z.object({
1888
1894
  personGeneration: import_v413.z.enum(["dont_allow", "allow_adult", "allow_all"]).nullish(),
@@ -1914,7 +1920,7 @@ var GoogleGenerativeAIVideoModel = class {
1914
1920
  const googleOptions = await (0, import_provider_utils15.parseProviderOptions)({
1915
1921
  provider: "google",
1916
1922
  providerOptions: options.providerOptions,
1917
- schema: googleVideoProviderOptionsSchema
1923
+ schema: googleVideoModelOptionsSchema
1918
1924
  });
1919
1925
  const instances = [{}];
1920
1926
  const instance = instances[0];
@@ -2126,7 +2132,7 @@ var googleOperationSchema = import_v414.z.object({
2126
2132
  }).nullish()
2127
2133
  }).nullish()
2128
2134
  });
2129
- var googleVideoProviderOptionsSchema = (0, import_provider_utils15.lazySchema)(
2135
+ var googleVideoModelOptionsSchema = (0, import_provider_utils15.lazySchema)(
2130
2136
  () => (0, import_provider_utils15.zodSchema)(
2131
2137
  import_v414.z.object({
2132
2138
  pollIntervalMs: import_v414.z.number().positive().nullish(),