@ai-sdk/google 2.0.19 → 2.0.21

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.
@@ -1,9 +1,7 @@
1
1
  "use strict";
2
- var __create = Object.create;
3
2
  var __defProp = Object.defineProperty;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
6
  var __export = (target, all) => {
9
7
  for (var name in all)
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
17
15
  }
18
16
  return to;
19
17
  };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
19
 
30
20
  // src/internal/index.ts
@@ -39,7 +29,7 @@ module.exports = __toCommonJS(internal_exports);
39
29
 
40
30
  // src/google-generative-ai-language-model.ts
41
31
  var import_provider_utils4 = require("@ai-sdk/provider-utils");
42
- var z3 = __toESM(require("zod/v4"));
32
+ var import_v43 = require("zod/v4");
43
33
 
44
34
  // src/convert-json-schema-to-openapi-schema.ts
45
35
  function convertJSONSchemaToOpenAPISchema(jsonSchema) {
@@ -312,14 +302,14 @@ function getModelPath(modelId) {
312
302
 
313
303
  // src/google-error.ts
314
304
  var import_provider_utils2 = require("@ai-sdk/provider-utils");
315
- var z = __toESM(require("zod/v4"));
305
+ var import_v4 = require("zod/v4");
316
306
  var googleErrorDataSchema = (0, import_provider_utils2.lazySchema)(
317
307
  () => (0, import_provider_utils2.zodSchema)(
318
- z.object({
319
- error: z.object({
320
- code: z.number().nullable(),
321
- message: z.string(),
322
- status: z.string()
308
+ import_v4.z.object({
309
+ error: import_v4.z.object({
310
+ code: import_v4.z.number().nullable(),
311
+ message: import_v4.z.string(),
312
+ status: import_v4.z.string()
323
313
  })
324
314
  })
325
315
  )
@@ -331,21 +321,21 @@ var googleFailedResponseHandler = (0, import_provider_utils2.createJsonErrorResp
331
321
 
332
322
  // src/google-generative-ai-options.ts
333
323
  var import_provider_utils3 = require("@ai-sdk/provider-utils");
334
- var z2 = __toESM(require("zod/v4"));
324
+ var import_v42 = require("zod/v4");
335
325
  var googleGenerativeAIProviderOptions = (0, import_provider_utils3.lazySchema)(
336
326
  () => (0, import_provider_utils3.zodSchema)(
337
- z2.object({
338
- responseModalities: z2.array(z2.enum(["TEXT", "IMAGE"])).optional(),
339
- thinkingConfig: z2.object({
340
- thinkingBudget: z2.number().optional(),
341
- includeThoughts: z2.boolean().optional()
327
+ import_v42.z.object({
328
+ responseModalities: import_v42.z.array(import_v42.z.enum(["TEXT", "IMAGE"])).optional(),
329
+ thinkingConfig: import_v42.z.object({
330
+ thinkingBudget: import_v42.z.number().optional(),
331
+ includeThoughts: import_v42.z.boolean().optional()
342
332
  }).optional(),
343
333
  /**
344
334
  * Optional.
345
335
  * The name of the cached content used as context to serve the prediction.
346
336
  * Format: cachedContents/{cachedContent}
347
337
  */
348
- cachedContent: z2.string().optional(),
338
+ cachedContent: import_v42.z.string().optional(),
349
339
  /**
350
340
  * Optional. Enable structured output. Default is true.
351
341
  *
@@ -354,13 +344,13 @@ var googleGenerativeAIProviderOptions = (0, import_provider_utils3.lazySchema)(
354
344
  * Google Generative AI uses. You can use this to disable
355
345
  * structured outputs if you need to.
356
346
  */
357
- structuredOutputs: z2.boolean().optional(),
347
+ structuredOutputs: import_v42.z.boolean().optional(),
358
348
  /**
359
349
  * Optional. A list of unique safety settings for blocking unsafe content.
360
350
  */
361
- safetySettings: z2.array(
362
- z2.object({
363
- category: z2.enum([
351
+ safetySettings: import_v42.z.array(
352
+ import_v42.z.object({
353
+ category: import_v42.z.enum([
364
354
  "HARM_CATEGORY_UNSPECIFIED",
365
355
  "HARM_CATEGORY_HATE_SPEECH",
366
356
  "HARM_CATEGORY_DANGEROUS_CONTENT",
@@ -368,7 +358,7 @@ var googleGenerativeAIProviderOptions = (0, import_provider_utils3.lazySchema)(
368
358
  "HARM_CATEGORY_SEXUALLY_EXPLICIT",
369
359
  "HARM_CATEGORY_CIVIC_INTEGRITY"
370
360
  ]),
371
- threshold: z2.enum([
361
+ threshold: import_v42.z.enum([
372
362
  "HARM_BLOCK_THRESHOLD_UNSPECIFIED",
373
363
  "BLOCK_LOW_AND_ABOVE",
374
364
  "BLOCK_MEDIUM_AND_ABOVE",
@@ -378,7 +368,7 @@ var googleGenerativeAIProviderOptions = (0, import_provider_utils3.lazySchema)(
378
368
  ])
379
369
  })
380
370
  ).optional(),
381
- threshold: z2.enum([
371
+ threshold: import_v42.z.enum([
382
372
  "HARM_BLOCK_THRESHOLD_UNSPECIFIED",
383
373
  "BLOCK_LOW_AND_ABOVE",
384
374
  "BLOCK_MEDIUM_AND_ABOVE",
@@ -391,24 +381,43 @@ var googleGenerativeAIProviderOptions = (0, import_provider_utils3.lazySchema)(
391
381
  *
392
382
  * https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/audio-understanding
393
383
  */
394
- audioTimestamp: z2.boolean().optional(),
384
+ audioTimestamp: import_v42.z.boolean().optional(),
395
385
  /**
396
386
  * Optional. Defines labels used in billing reports. Available on Vertex AI only.
397
387
  *
398
388
  * https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/add-labels-to-api-calls
399
389
  */
400
- labels: z2.record(z2.string(), z2.string()).optional(),
390
+ labels: import_v42.z.record(import_v42.z.string(), import_v42.z.string()).optional(),
401
391
  /**
402
392
  * Optional. If specified, the media resolution specified will be used.
403
393
  *
404
394
  * https://ai.google.dev/api/generate-content#MediaResolution
405
395
  */
406
- mediaResolution: z2.enum([
396
+ mediaResolution: import_v42.z.enum([
407
397
  "MEDIA_RESOLUTION_UNSPECIFIED",
408
398
  "MEDIA_RESOLUTION_LOW",
409
399
  "MEDIA_RESOLUTION_MEDIUM",
410
400
  "MEDIA_RESOLUTION_HIGH"
411
- ]).optional()
401
+ ]).optional(),
402
+ /**
403
+ * Optional. Configures the image generation aspect ratio for Gemini models.
404
+ *
405
+ * https://ai.google.dev/gemini-api/docs/image-generation#aspect_ratios
406
+ */
407
+ imageConfig: import_v42.z.object({
408
+ aspectRatio: import_v42.z.enum([
409
+ "1:1",
410
+ "2:3",
411
+ "3:2",
412
+ "3:4",
413
+ "4:3",
414
+ "4:5",
415
+ "5:4",
416
+ "9:16",
417
+ "16:9",
418
+ "21:9"
419
+ ]).optional()
420
+ }).optional()
412
421
  })
413
422
  )
414
423
  );
@@ -663,7 +672,10 @@ var GoogleGenerativeAILanguageModel = class {
663
672
  },
664
673
  // provider options:
665
674
  responseModalities: googleOptions == null ? void 0 : googleOptions.responseModalities,
666
- thinkingConfig: googleOptions == null ? void 0 : googleOptions.thinkingConfig
675
+ thinkingConfig: googleOptions == null ? void 0 : googleOptions.thinkingConfig,
676
+ ...(googleOptions == null ? void 0 : googleOptions.imageConfig) && {
677
+ imageConfig: googleOptions.imageConfig
678
+ }
667
679
  },
668
680
  contents,
669
681
  systemInstruction: isGemmaModel ? void 0 : systemInstruction,
@@ -1074,129 +1086,129 @@ function extractSources({
1074
1086
  title: chunk.web.title
1075
1087
  }));
1076
1088
  }
1077
- var getGroundingMetadataSchema = () => z3.object({
1078
- webSearchQueries: z3.array(z3.string()).nullish(),
1079
- retrievalQueries: z3.array(z3.string()).nullish(),
1080
- searchEntryPoint: z3.object({ renderedContent: z3.string() }).nullish(),
1081
- groundingChunks: z3.array(
1082
- z3.object({
1083
- web: z3.object({ uri: z3.string(), title: z3.string() }).nullish(),
1084
- retrievedContext: z3.object({ uri: z3.string(), title: z3.string() }).nullish()
1089
+ var getGroundingMetadataSchema = () => import_v43.z.object({
1090
+ webSearchQueries: import_v43.z.array(import_v43.z.string()).nullish(),
1091
+ retrievalQueries: import_v43.z.array(import_v43.z.string()).nullish(),
1092
+ searchEntryPoint: import_v43.z.object({ renderedContent: import_v43.z.string() }).nullish(),
1093
+ groundingChunks: import_v43.z.array(
1094
+ import_v43.z.object({
1095
+ web: import_v43.z.object({ uri: import_v43.z.string(), title: import_v43.z.string() }).nullish(),
1096
+ retrievedContext: import_v43.z.object({ uri: import_v43.z.string(), title: import_v43.z.string() }).nullish()
1085
1097
  })
1086
1098
  ).nullish(),
1087
- groundingSupports: z3.array(
1088
- z3.object({
1089
- segment: z3.object({
1090
- startIndex: z3.number().nullish(),
1091
- endIndex: z3.number().nullish(),
1092
- text: z3.string().nullish()
1099
+ groundingSupports: import_v43.z.array(
1100
+ import_v43.z.object({
1101
+ segment: import_v43.z.object({
1102
+ startIndex: import_v43.z.number().nullish(),
1103
+ endIndex: import_v43.z.number().nullish(),
1104
+ text: import_v43.z.string().nullish()
1093
1105
  }),
1094
- segment_text: z3.string().nullish(),
1095
- groundingChunkIndices: z3.array(z3.number()).nullish(),
1096
- supportChunkIndices: z3.array(z3.number()).nullish(),
1097
- confidenceScores: z3.array(z3.number()).nullish(),
1098
- confidenceScore: z3.array(z3.number()).nullish()
1106
+ segment_text: import_v43.z.string().nullish(),
1107
+ groundingChunkIndices: import_v43.z.array(import_v43.z.number()).nullish(),
1108
+ supportChunkIndices: import_v43.z.array(import_v43.z.number()).nullish(),
1109
+ confidenceScores: import_v43.z.array(import_v43.z.number()).nullish(),
1110
+ confidenceScore: import_v43.z.array(import_v43.z.number()).nullish()
1099
1111
  })
1100
1112
  ).nullish(),
1101
- retrievalMetadata: z3.union([
1102
- z3.object({
1103
- webDynamicRetrievalScore: z3.number()
1113
+ retrievalMetadata: import_v43.z.union([
1114
+ import_v43.z.object({
1115
+ webDynamicRetrievalScore: import_v43.z.number()
1104
1116
  }),
1105
- z3.object({})
1117
+ import_v43.z.object({})
1106
1118
  ]).nullish()
1107
1119
  });
1108
- var getContentSchema = () => z3.object({
1109
- parts: z3.array(
1110
- z3.union([
1120
+ var getContentSchema = () => import_v43.z.object({
1121
+ parts: import_v43.z.array(
1122
+ import_v43.z.union([
1111
1123
  // note: order matters since text can be fully empty
1112
- z3.object({
1113
- functionCall: z3.object({
1114
- name: z3.string(),
1115
- args: z3.unknown()
1124
+ import_v43.z.object({
1125
+ functionCall: import_v43.z.object({
1126
+ name: import_v43.z.string(),
1127
+ args: import_v43.z.unknown()
1116
1128
  }),
1117
- thoughtSignature: z3.string().nullish()
1129
+ thoughtSignature: import_v43.z.string().nullish()
1118
1130
  }),
1119
- z3.object({
1120
- inlineData: z3.object({
1121
- mimeType: z3.string(),
1122
- data: z3.string()
1131
+ import_v43.z.object({
1132
+ inlineData: import_v43.z.object({
1133
+ mimeType: import_v43.z.string(),
1134
+ data: import_v43.z.string()
1123
1135
  })
1124
1136
  }),
1125
- z3.object({
1126
- executableCode: z3.object({
1127
- language: z3.string(),
1128
- code: z3.string()
1137
+ import_v43.z.object({
1138
+ executableCode: import_v43.z.object({
1139
+ language: import_v43.z.string(),
1140
+ code: import_v43.z.string()
1129
1141
  }).nullish(),
1130
- codeExecutionResult: z3.object({
1131
- outcome: z3.string(),
1132
- output: z3.string()
1142
+ codeExecutionResult: import_v43.z.object({
1143
+ outcome: import_v43.z.string(),
1144
+ output: import_v43.z.string()
1133
1145
  }).nullish(),
1134
- text: z3.string().nullish(),
1135
- thought: z3.boolean().nullish(),
1136
- thoughtSignature: z3.string().nullish()
1146
+ text: import_v43.z.string().nullish(),
1147
+ thought: import_v43.z.boolean().nullish(),
1148
+ thoughtSignature: import_v43.z.string().nullish()
1137
1149
  })
1138
1150
  ])
1139
1151
  ).nullish()
1140
1152
  });
1141
- var getSafetyRatingSchema = () => z3.object({
1142
- category: z3.string().nullish(),
1143
- probability: z3.string().nullish(),
1144
- probabilityScore: z3.number().nullish(),
1145
- severity: z3.string().nullish(),
1146
- severityScore: z3.number().nullish(),
1147
- blocked: z3.boolean().nullish()
1153
+ var getSafetyRatingSchema = () => import_v43.z.object({
1154
+ category: import_v43.z.string().nullish(),
1155
+ probability: import_v43.z.string().nullish(),
1156
+ probabilityScore: import_v43.z.number().nullish(),
1157
+ severity: import_v43.z.string().nullish(),
1158
+ severityScore: import_v43.z.number().nullish(),
1159
+ blocked: import_v43.z.boolean().nullish()
1148
1160
  });
1149
- var usageSchema = z3.object({
1150
- cachedContentTokenCount: z3.number().nullish(),
1151
- thoughtsTokenCount: z3.number().nullish(),
1152
- promptTokenCount: z3.number().nullish(),
1153
- candidatesTokenCount: z3.number().nullish(),
1154
- totalTokenCount: z3.number().nullish()
1161
+ var usageSchema = import_v43.z.object({
1162
+ cachedContentTokenCount: import_v43.z.number().nullish(),
1163
+ thoughtsTokenCount: import_v43.z.number().nullish(),
1164
+ promptTokenCount: import_v43.z.number().nullish(),
1165
+ candidatesTokenCount: import_v43.z.number().nullish(),
1166
+ totalTokenCount: import_v43.z.number().nullish()
1155
1167
  });
1156
- var getUrlContextMetadataSchema = () => z3.object({
1157
- urlMetadata: z3.array(
1158
- z3.object({
1159
- retrievedUrl: z3.string(),
1160
- urlRetrievalStatus: z3.string()
1168
+ var getUrlContextMetadataSchema = () => import_v43.z.object({
1169
+ urlMetadata: import_v43.z.array(
1170
+ import_v43.z.object({
1171
+ retrievedUrl: import_v43.z.string(),
1172
+ urlRetrievalStatus: import_v43.z.string()
1161
1173
  })
1162
1174
  )
1163
1175
  });
1164
1176
  var responseSchema = (0, import_provider_utils4.lazySchema)(
1165
1177
  () => (0, import_provider_utils4.zodSchema)(
1166
- z3.object({
1167
- candidates: z3.array(
1168
- z3.object({
1169
- content: getContentSchema().nullish().or(z3.object({}).strict()),
1170
- finishReason: z3.string().nullish(),
1171
- safetyRatings: z3.array(getSafetyRatingSchema()).nullish(),
1178
+ import_v43.z.object({
1179
+ candidates: import_v43.z.array(
1180
+ import_v43.z.object({
1181
+ content: getContentSchema().nullish().or(import_v43.z.object({}).strict()),
1182
+ finishReason: import_v43.z.string().nullish(),
1183
+ safetyRatings: import_v43.z.array(getSafetyRatingSchema()).nullish(),
1172
1184
  groundingMetadata: getGroundingMetadataSchema().nullish(),
1173
1185
  urlContextMetadata: getUrlContextMetadataSchema().nullish()
1174
1186
  })
1175
1187
  ),
1176
1188
  usageMetadata: usageSchema.nullish(),
1177
- promptFeedback: z3.object({
1178
- blockReason: z3.string().nullish(),
1179
- safetyRatings: z3.array(getSafetyRatingSchema()).nullish()
1189
+ promptFeedback: import_v43.z.object({
1190
+ blockReason: import_v43.z.string().nullish(),
1191
+ safetyRatings: import_v43.z.array(getSafetyRatingSchema()).nullish()
1180
1192
  }).nullish()
1181
1193
  })
1182
1194
  )
1183
1195
  );
1184
1196
  var chunkSchema = (0, import_provider_utils4.lazySchema)(
1185
1197
  () => (0, import_provider_utils4.zodSchema)(
1186
- z3.object({
1187
- candidates: z3.array(
1188
- z3.object({
1198
+ import_v43.z.object({
1199
+ candidates: import_v43.z.array(
1200
+ import_v43.z.object({
1189
1201
  content: getContentSchema().nullish(),
1190
- finishReason: z3.string().nullish(),
1191
- safetyRatings: z3.array(getSafetyRatingSchema()).nullish(),
1202
+ finishReason: import_v43.z.string().nullish(),
1203
+ safetyRatings: import_v43.z.array(getSafetyRatingSchema()).nullish(),
1192
1204
  groundingMetadata: getGroundingMetadataSchema().nullish(),
1193
1205
  urlContextMetadata: getUrlContextMetadataSchema().nullish()
1194
1206
  })
1195
1207
  ).nullish(),
1196
1208
  usageMetadata: usageSchema.nullish(),
1197
- promptFeedback: z3.object({
1198
- blockReason: z3.string().nullish(),
1199
- safetyRatings: z3.array(getSafetyRatingSchema()).nullish()
1209
+ promptFeedback: import_v43.z.object({
1210
+ blockReason: import_v43.z.string().nullish(),
1211
+ safetyRatings: import_v43.z.array(getSafetyRatingSchema()).nullish()
1200
1212
  }).nullish()
1201
1213
  })
1202
1214
  )
@@ -1204,31 +1216,31 @@ var chunkSchema = (0, import_provider_utils4.lazySchema)(
1204
1216
 
1205
1217
  // src/tool/code-execution.ts
1206
1218
  var import_provider_utils5 = require("@ai-sdk/provider-utils");
1207
- var z4 = __toESM(require("zod/v4"));
1219
+ var import_v44 = require("zod/v4");
1208
1220
  var codeExecution = (0, import_provider_utils5.createProviderDefinedToolFactoryWithOutputSchema)({
1209
1221
  id: "google.code_execution",
1210
1222
  name: "code_execution",
1211
- inputSchema: z4.object({
1212
- language: z4.string().describe("The programming language of the code."),
1213
- code: z4.string().describe("The code to be executed.")
1223
+ inputSchema: import_v44.z.object({
1224
+ language: import_v44.z.string().describe("The programming language of the code."),
1225
+ code: import_v44.z.string().describe("The code to be executed.")
1214
1226
  }),
1215
- outputSchema: z4.object({
1216
- outcome: z4.string().describe('The outcome of the execution (e.g., "OUTCOME_OK").'),
1217
- output: z4.string().describe("The output from the code execution.")
1227
+ outputSchema: import_v44.z.object({
1228
+ outcome: import_v44.z.string().describe('The outcome of the execution (e.g., "OUTCOME_OK").'),
1229
+ output: import_v44.z.string().describe("The output from the code execution.")
1218
1230
  })
1219
1231
  });
1220
1232
 
1221
1233
  // src/tool/google-search.ts
1222
1234
  var import_provider_utils6 = require("@ai-sdk/provider-utils");
1223
- var z5 = __toESM(require("zod/v4"));
1235
+ var import_v45 = require("zod/v4");
1224
1236
  var googleSearch = (0, import_provider_utils6.createProviderDefinedToolFactory)({
1225
1237
  id: "google.google_search",
1226
1238
  name: "google_search",
1227
1239
  inputSchema: (0, import_provider_utils6.lazySchema)(
1228
1240
  () => (0, import_provider_utils6.zodSchema)(
1229
- z5.object({
1230
- mode: z5.enum(["MODE_DYNAMIC", "MODE_UNSPECIFIED"]).default("MODE_UNSPECIFIED"),
1231
- dynamicThreshold: z5.number().default(1)
1241
+ import_v45.z.object({
1242
+ mode: import_v45.z.enum(["MODE_DYNAMIC", "MODE_UNSPECIFIED"]).default("MODE_UNSPECIFIED"),
1243
+ dynamicThreshold: import_v45.z.number().default(1)
1232
1244
  })
1233
1245
  )
1234
1246
  )
@@ -1236,11 +1248,11 @@ var googleSearch = (0, import_provider_utils6.createProviderDefinedToolFactory)(
1236
1248
 
1237
1249
  // src/tool/url-context.ts
1238
1250
  var import_provider_utils7 = require("@ai-sdk/provider-utils");
1239
- var z6 = __toESM(require("zod/v4"));
1251
+ var import_v46 = require("zod/v4");
1240
1252
  var urlContext = (0, import_provider_utils7.createProviderDefinedToolFactory)({
1241
1253
  id: "google.url_context",
1242
1254
  name: "url_context",
1243
- inputSchema: (0, import_provider_utils7.lazySchema)(() => (0, import_provider_utils7.zodSchema)(z6.object({})))
1255
+ inputSchema: (0, import_provider_utils7.lazySchema)(() => (0, import_provider_utils7.zodSchema)(import_v46.z.object({})))
1244
1256
  });
1245
1257
 
1246
1258
  // src/google-tools.ts