@ai-sdk/google 2.0.55 → 2.0.57

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
+ ## 2.0.57
4
+
5
+ ### Patch Changes
6
+
7
+ - 4dda2a3: feat(google): add support for image search, replace obsolete google_search_retrieval implementation
8
+
9
+ ## 2.0.56
10
+
11
+ ### Patch Changes
12
+
13
+ - a1c0208: feat(provider/google): add support for new Google image model aspect ratios and sizes
14
+
3
15
  ## 2.0.55
4
16
 
5
17
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -30,8 +30,8 @@ declare const googleGenerativeAIProviderOptions: _ai_sdk_provider_utils.LazySche
30
30
  labels?: Record<string, string> | undefined;
31
31
  mediaResolution?: "MEDIA_RESOLUTION_UNSPECIFIED" | "MEDIA_RESOLUTION_LOW" | "MEDIA_RESOLUTION_MEDIUM" | "MEDIA_RESOLUTION_HIGH" | undefined;
32
32
  imageConfig?: {
33
- aspectRatio?: "1:1" | "2:3" | "3:2" | "3:4" | "4:3" | "4:5" | "5:4" | "9:16" | "16:9" | "21:9" | undefined;
34
- imageSize?: "1K" | "2K" | "4K" | undefined;
33
+ aspectRatio?: "1:1" | "2:3" | "3:2" | "3:4" | "4:3" | "4:5" | "5:4" | "9:16" | "16:9" | "21:9" | "1:8" | "8:1" | "1:4" | "4:1" | undefined;
34
+ imageSize?: "1K" | "2K" | "4K" | "512" | undefined;
35
35
  } | undefined;
36
36
  retrievalConfig?: {
37
37
  latLng?: {
@@ -81,6 +81,7 @@ declare const responseSchema: _ai_sdk_provider_utils.LazySchema<{
81
81
  }[] | null | undefined;
82
82
  groundingMetadata?: {
83
83
  webSearchQueries?: string[] | null | undefined;
84
+ imageSearchQueries?: string[] | null | undefined;
84
85
  retrievalQueries?: string[] | null | undefined;
85
86
  searchEntryPoint?: {
86
87
  renderedContent: string;
@@ -90,6 +91,12 @@ declare const responseSchema: _ai_sdk_provider_utils.LazySchema<{
90
91
  uri: string;
91
92
  title?: string | null | undefined;
92
93
  } | null | undefined;
94
+ image?: {
95
+ sourceUri: string;
96
+ imageUri: string;
97
+ title?: string | null | undefined;
98
+ domain?: string | null | undefined;
99
+ } | null | undefined;
93
100
  retrievedContext?: {
94
101
  uri?: string | null | undefined;
95
102
  title?: string | null | undefined;
@@ -186,8 +193,15 @@ declare const googleTools: {
186
193
  * Must have name "google_search".
187
194
  */
188
195
  googleSearch: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{}, {
189
- mode?: "MODE_DYNAMIC" | "MODE_UNSPECIFIED";
190
- dynamicThreshold?: number;
196
+ [x: string]: unknown;
197
+ searchTypes?: {
198
+ webSearch?: Record<string, never> | undefined;
199
+ imageSearch?: Record<string, never> | undefined;
200
+ } | undefined;
201
+ timeRangeFilter?: {
202
+ startTime: string;
203
+ endTime: string;
204
+ } | undefined;
191
205
  }>;
192
206
  /**
193
207
  * Creates an Enterprise Web Search tool for grounding responses using a compliance-focused web index.
package/dist/index.d.ts CHANGED
@@ -30,8 +30,8 @@ declare const googleGenerativeAIProviderOptions: _ai_sdk_provider_utils.LazySche
30
30
  labels?: Record<string, string> | undefined;
31
31
  mediaResolution?: "MEDIA_RESOLUTION_UNSPECIFIED" | "MEDIA_RESOLUTION_LOW" | "MEDIA_RESOLUTION_MEDIUM" | "MEDIA_RESOLUTION_HIGH" | undefined;
32
32
  imageConfig?: {
33
- aspectRatio?: "1:1" | "2:3" | "3:2" | "3:4" | "4:3" | "4:5" | "5:4" | "9:16" | "16:9" | "21:9" | undefined;
34
- imageSize?: "1K" | "2K" | "4K" | undefined;
33
+ aspectRatio?: "1:1" | "2:3" | "3:2" | "3:4" | "4:3" | "4:5" | "5:4" | "9:16" | "16:9" | "21:9" | "1:8" | "8:1" | "1:4" | "4:1" | undefined;
34
+ imageSize?: "1K" | "2K" | "4K" | "512" | undefined;
35
35
  } | undefined;
36
36
  retrievalConfig?: {
37
37
  latLng?: {
@@ -81,6 +81,7 @@ declare const responseSchema: _ai_sdk_provider_utils.LazySchema<{
81
81
  }[] | null | undefined;
82
82
  groundingMetadata?: {
83
83
  webSearchQueries?: string[] | null | undefined;
84
+ imageSearchQueries?: string[] | null | undefined;
84
85
  retrievalQueries?: string[] | null | undefined;
85
86
  searchEntryPoint?: {
86
87
  renderedContent: string;
@@ -90,6 +91,12 @@ declare const responseSchema: _ai_sdk_provider_utils.LazySchema<{
90
91
  uri: string;
91
92
  title?: string | null | undefined;
92
93
  } | null | undefined;
94
+ image?: {
95
+ sourceUri: string;
96
+ imageUri: string;
97
+ title?: string | null | undefined;
98
+ domain?: string | null | undefined;
99
+ } | null | undefined;
93
100
  retrievedContext?: {
94
101
  uri?: string | null | undefined;
95
102
  title?: string | null | undefined;
@@ -186,8 +193,15 @@ declare const googleTools: {
186
193
  * Must have name "google_search".
187
194
  */
188
195
  googleSearch: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{}, {
189
- mode?: "MODE_DYNAMIC" | "MODE_UNSPECIFIED";
190
- dynamicThreshold?: number;
196
+ [x: string]: unknown;
197
+ searchTypes?: {
198
+ webSearch?: Record<string, never> | undefined;
199
+ imageSearch?: Record<string, never> | undefined;
200
+ } | undefined;
201
+ timeRangeFilter?: {
202
+ startTime: string;
203
+ endTime: string;
204
+ } | undefined;
191
205
  }>;
192
206
  /**
193
207
  * Creates an Enterprise Web Search tool for grounding responses using a compliance-focused web index.
package/dist/index.js CHANGED
@@ -30,7 +30,7 @@ module.exports = __toCommonJS(src_exports);
30
30
  var import_provider_utils15 = require("@ai-sdk/provider-utils");
31
31
 
32
32
  // src/version.ts
33
- var VERSION = true ? "2.0.55" : "0.0.0-test";
33
+ var VERSION = true ? "2.0.57" : "0.0.0-test";
34
34
 
35
35
  // src/google-generative-ai-embedding-model.ts
36
36
  var import_provider = require("@ai-sdk/provider");
@@ -595,9 +595,13 @@ var googleGenerativeAIProviderOptions = (0, import_provider_utils5.lazySchema)(
595
595
  "5:4",
596
596
  "9:16",
597
597
  "16:9",
598
- "21:9"
598
+ "21:9",
599
+ "1:8",
600
+ "8:1",
601
+ "1:4",
602
+ "4:1"
599
603
  ]).optional(),
600
- imageSize: import_v44.z.enum(["1K", "2K", "4K"]).optional()
604
+ imageSize: import_v44.z.enum(["1K", "2K", "4K", "512"]).optional()
601
605
  }).optional(),
602
606
  /**
603
607
  * Optional. Configuration for grounding retrieval.
@@ -630,9 +634,8 @@ function prepareTools({
630
634
  "gemini-flash-lite-latest",
631
635
  "gemini-pro-latest"
632
636
  ].some((id) => id === modelId);
633
- const isGemini2orNewer = modelId.includes("gemini-2") || modelId.includes("gemini-3") || isLatest;
634
- const supportsDynamicRetrieval = modelId.includes("gemini-1.5-flash") && !modelId.includes("-8b");
635
- const supportsFileSearch = modelId.includes("gemini-2.5");
637
+ const isGemini2orNewer = modelId.includes("gemini-2") || modelId.includes("gemini-3") || modelId.includes("nano-banana") || isLatest;
638
+ const supportsFileSearch = modelId.includes("gemini-2.5") || modelId.includes("gemini-3");
636
639
  if (tools == null) {
637
640
  return { tools: void 0, toolConfig: void 0, toolWarnings };
638
641
  }
@@ -657,18 +660,13 @@ function prepareTools({
657
660
  switch (tool.id) {
658
661
  case "google.google_search":
659
662
  if (isGemini2orNewer) {
660
- googleTools2.push({ googleSearch: {} });
661
- } else if (supportsDynamicRetrieval) {
662
- googleTools2.push({
663
- googleSearchRetrieval: {
664
- dynamicRetrievalConfig: {
665
- mode: tool.args.mode,
666
- dynamicThreshold: tool.args.dynamicThreshold
667
- }
668
- }
669
- });
663
+ googleTools2.push({ googleSearch: { ...tool.args } });
670
664
  } else {
671
- googleTools2.push({ googleSearchRetrieval: {} });
665
+ toolWarnings.push({
666
+ type: "unsupported-tool",
667
+ tool,
668
+ details: "Google Search requires Gemini 2.0 or newer."
669
+ });
672
670
  }
673
671
  break;
674
672
  case "google.enterprise_web_search":
@@ -1341,7 +1339,7 @@ function extractSources({
1341
1339
  groundingMetadata,
1342
1340
  generateId: generateId3
1343
1341
  }) {
1344
- var _a, _b, _c, _d, _e;
1342
+ var _a, _b, _c, _d, _e, _f;
1345
1343
  if (!(groundingMetadata == null ? void 0 : groundingMetadata.groundingChunks)) {
1346
1344
  return void 0;
1347
1345
  }
@@ -1355,6 +1353,16 @@ function extractSources({
1355
1353
  url: chunk.web.uri,
1356
1354
  title: (_a = chunk.web.title) != null ? _a : void 0
1357
1355
  });
1356
+ } else if (chunk.image != null) {
1357
+ sources.push({
1358
+ type: "source",
1359
+ sourceType: "url",
1360
+ id: generateId3(),
1361
+ // Google requires attribution to the source URI, not the actual image URI.
1362
+ // TODO: add another type in v7 to allow both the image and source URL to be included separately
1363
+ url: chunk.image.sourceUri,
1364
+ title: (_b = chunk.image.title) != null ? _b : void 0
1365
+ });
1358
1366
  } else if (chunk.retrievedContext != null) {
1359
1367
  const uri = chunk.retrievedContext.uri;
1360
1368
  const fileSearchStore = chunk.retrievedContext.fileSearchStore;
@@ -1364,10 +1372,10 @@ function extractSources({
1364
1372
  sourceType: "url",
1365
1373
  id: generateId3(),
1366
1374
  url: uri,
1367
- title: (_b = chunk.retrievedContext.title) != null ? _b : void 0
1375
+ title: (_c = chunk.retrievedContext.title) != null ? _c : void 0
1368
1376
  });
1369
1377
  } else if (uri) {
1370
- const title = (_c = chunk.retrievedContext.title) != null ? _c : "Unknown Document";
1378
+ const title = (_d = chunk.retrievedContext.title) != null ? _d : "Unknown Document";
1371
1379
  let mediaType = "application/octet-stream";
1372
1380
  let filename = void 0;
1373
1381
  if (uri.endsWith(".pdf")) {
@@ -1397,7 +1405,7 @@ function extractSources({
1397
1405
  filename
1398
1406
  });
1399
1407
  } else if (fileSearchStore) {
1400
- const title = (_d = chunk.retrievedContext.title) != null ? _d : "Unknown Document";
1408
+ const title = (_e = chunk.retrievedContext.title) != null ? _e : "Unknown Document";
1401
1409
  sources.push({
1402
1410
  type: "source",
1403
1411
  sourceType: "document",
@@ -1414,7 +1422,7 @@ function extractSources({
1414
1422
  sourceType: "url",
1415
1423
  id: generateId3(),
1416
1424
  url: chunk.maps.uri,
1417
- title: (_e = chunk.maps.title) != null ? _e : void 0
1425
+ title: (_f = chunk.maps.title) != null ? _f : void 0
1418
1426
  });
1419
1427
  }
1420
1428
  }
@@ -1423,11 +1431,18 @@ function extractSources({
1423
1431
  }
1424
1432
  var getGroundingMetadataSchema = () => import_v45.z.object({
1425
1433
  webSearchQueries: import_v45.z.array(import_v45.z.string()).nullish(),
1434
+ imageSearchQueries: import_v45.z.array(import_v45.z.string()).nullish(),
1426
1435
  retrievalQueries: import_v45.z.array(import_v45.z.string()).nullish(),
1427
1436
  searchEntryPoint: import_v45.z.object({ renderedContent: import_v45.z.string() }).nullish(),
1428
1437
  groundingChunks: import_v45.z.array(
1429
1438
  import_v45.z.object({
1430
1439
  web: import_v45.z.object({ uri: import_v45.z.string(), title: import_v45.z.string().nullish() }).nullish(),
1440
+ image: import_v45.z.object({
1441
+ sourceUri: import_v45.z.string(),
1442
+ imageUri: import_v45.z.string(),
1443
+ title: import_v45.z.string().nullish(),
1444
+ domain: import_v45.z.string().nullish()
1445
+ }).nullish(),
1431
1446
  retrievedContext: import_v45.z.object({
1432
1447
  uri: import_v45.z.string().nullish(),
1433
1448
  title: import_v45.z.string().nullish(),
@@ -1627,17 +1642,23 @@ var googleMaps = (0, import_provider_utils10.createProviderDefinedToolFactory)({
1627
1642
  // src/tool/google-search.ts
1628
1643
  var import_provider_utils11 = require("@ai-sdk/provider-utils");
1629
1644
  var import_v410 = require("zod/v4");
1645
+ var googleSearchToolArgsBaseSchema = import_v410.z.object({
1646
+ searchTypes: import_v410.z.object({
1647
+ webSearch: import_v410.z.object({}).optional(),
1648
+ imageSearch: import_v410.z.object({}).optional()
1649
+ }).optional(),
1650
+ timeRangeFilter: import_v410.z.object({
1651
+ startTime: import_v410.z.string(),
1652
+ endTime: import_v410.z.string()
1653
+ }).optional()
1654
+ }).passthrough();
1655
+ var googleSearchToolArgsSchema = (0, import_provider_utils11.lazySchema)(
1656
+ () => (0, import_provider_utils11.zodSchema)(googleSearchToolArgsBaseSchema)
1657
+ );
1630
1658
  var googleSearch = (0, import_provider_utils11.createProviderDefinedToolFactory)({
1631
1659
  id: "google.google_search",
1632
1660
  name: "google_search",
1633
- inputSchema: (0, import_provider_utils11.lazySchema)(
1634
- () => (0, import_provider_utils11.zodSchema)(
1635
- import_v410.z.object({
1636
- mode: import_v410.z.enum(["MODE_DYNAMIC", "MODE_UNSPECIFIED"]).default("MODE_UNSPECIFIED"),
1637
- dynamicThreshold: import_v410.z.number().default(1)
1638
- })
1639
- )
1640
- )
1661
+ inputSchema: googleSearchToolArgsSchema
1641
1662
  });
1642
1663
 
1643
1664
  // src/tool/url-context.ts