@ai-sdk/google 4.0.88 → 4.0.89

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.
@@ -34,6 +34,15 @@ const google = createGoogle({
34
34
 
35
35
  You can use the following optional settings to customize the Google provider instance:
36
36
 
37
+ - **batchResultDownloads** _object_
38
+
39
+ Settings for downloading file-based JSON Lines batch results.
40
+ - **maxLineBytes** _number_
41
+
42
+ Maximum UTF-8 bytes per row, excluding the LF delimiter. Defaults to 64 MiB
43
+ (67,108,864 bytes). Must be a positive safe integer. Oversized rows throw a
44
+ `DownloadError` and cancel the download.
45
+
37
46
  - **baseURL** _string_
38
47
 
39
48
  Use a different URL prefix for API calls, e.g. to use proxy servers.
@@ -643,7 +652,7 @@ The [File Search tool](https://ai.google.dev/gemini-api/docs/file-search) lets G
643
652
  import { google } from '@ai-sdk/google';
644
653
  import { generateText } from 'ai';
645
654
 
646
- const { text, sources } = await generateText({
655
+ const { text, sources, providerMetadata } = await generateText({
647
656
  model: google('gemini-3.8-flash'),
648
657
  tools: {
649
658
  file_search: google.tools.fileSearch({
@@ -660,6 +669,9 @@ const { text, sources } = await generateText({
660
669
 
661
670
  File Search responses include citations via the normal `sources` field and expose raw [grounding metadata](#google-search) in `providerMetadata.google.groundingMetadata`.
662
671
 
672
+ Custom metadata attached to the indexed documents is available in
673
+ `groundingMetadata.groundingChunks[].retrievedContext.customMetadata`.
674
+
663
675
  ### URL Context
664
676
 
665
677
  Google provides a provider-defined URL context tool.
@@ -1046,6 +1058,7 @@ will still validate the response against the schema in `Output.object`.
1046
1058
 
1047
1059
  | Model | Image Input | Object Generation | Tool Usage | Tool Streaming | Google Search | URL Context |
1048
1060
  | ------------------------------------- | ----------- | ----------------- | ---------- | -------------- | ------------- | ----------- |
1061
+ | `gemini-nano-banana-2.1` | <Check /> | <Cross /> | <Cross /> | <Cross /> | <Check /> | <Cross /> |
1049
1062
  | `gemini-3.8-flash` | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> |
1050
1063
  | `gemini-3.7-flash` | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> |
1051
1064
  | `gemini-3.6-flash` | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> |
@@ -2232,11 +2245,12 @@ console.log(result.providerMetadata?.google?.groundingMetadata);
2232
2245
 
2233
2246
  #### Gemini Image Model Capabilities
2234
2247
 
2235
- | Model | Image Generation | Image Editing | Aspect Ratios |
2236
- | -------------------------------- | ---------------- | ------------- | --------------------------------------------------- |
2237
- | `gemini-2.5-flash-image` | <Check /> | <Check /> | 1:1, 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, 21:9 |
2238
- | `gemini-3-pro-image-preview` | <Check /> | <Check /> | 1:1, 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, 21:9 |
2239
- | `gemini-3.1-flash-image-preview` | <Check /> | <Check /> | 1:1, 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, 21:9 |
2248
+ | Model | Image Generation | Image Editing | Aspect Ratios |
2249
+ | -------------------------------- | ---------------- | ------------- | ----------------------------------------------------------------------- |
2250
+ | `gemini-2.5-flash-image` | <Check /> | <Check /> | 1:1, 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, 21:9 |
2251
+ | `gemini-3-pro-image-preview` | <Check /> | <Check /> | 1:1, 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, 21:9 |
2252
+ | `gemini-3.1-flash-image-preview` | <Check /> | <Check /> | 1:1, 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, 21:9 |
2253
+ | `gemini-nano-banana-2.1` | <Check /> | <Check /> | 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 |
2240
2254
 
2241
2255
  <Note>
2242
2256
  `gemini-3-pro-image-preview` supports additional features including up to 14
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-sdk/google",
3
- "version": "4.0.88",
3
+ "version": "4.0.89",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "sideEffects": false,
@@ -35,15 +35,15 @@
35
35
  }
36
36
  },
37
37
  "dependencies": {
38
- "@ai-sdk/provider": "4.0.22",
39
- "@ai-sdk/provider-utils": "5.0.54"
38
+ "@ai-sdk/provider": "4.0.23",
39
+ "@ai-sdk/provider-utils": "5.0.55"
40
40
  },
41
41
  "devDependencies": {
42
- "@ai-sdk/test-server": "2.0.3",
42
+ "@ai-sdk/test-server": "2.0.4",
43
43
  "@types/node": "22.19.19",
44
44
  "@vercel/ai-tsconfig": "0.0.0",
45
45
  "tsdown": "^0.23.0",
46
- "typescript": "5.8.3",
46
+ "typescript": "6.0.3",
47
47
  "zod": "3.25.76"
48
48
  },
49
49
  "peerDependencies": {
@@ -185,16 +185,19 @@ export class GoogleBatch implements BatchV4<GoogleBatchModelIds> {
185
185
  readonly supportedUrls: Record<string, RegExp[]>;
186
186
  private readonly batchConfig: GoogleLanguageModelConfig;
187
187
  private readonly batchGenerateId: () => string;
188
+ private readonly maxLineBytes?: number;
188
189
 
189
190
  constructor(options: {
190
191
  provider: string;
191
192
  config: GoogleLanguageModelConfig;
192
193
  supportedUrls: Record<string, RegExp[]>;
194
+ maxLineBytes?: number;
193
195
  }) {
194
196
  this.provider = options.provider;
195
197
  this.batchConfig = options.config;
196
198
  this.supportedUrls = options.supportedUrls;
197
199
  this.batchGenerateId = options.config.generateId ?? generateId;
200
+ this.maxLineBytes = options.maxLineBytes;
198
201
  }
199
202
 
200
203
  async doStartBatch(
@@ -511,6 +514,7 @@ export class GoogleBatch implements BatchV4<GoogleBatchModelIds> {
511
514
  failedResponseHandler: googleFailedResponseHandler,
512
515
  successfulResponseHandler: createJsonLinesResponseHandler(
513
516
  googleBatchResultLineSchema,
517
+ { maxLineBytes: this.maxLineBytes },
514
518
  ),
515
519
  abortSignal: options.abortSignal,
516
520
  fetch: this.batchConfig.fetch,
@@ -36,6 +36,7 @@ const googleImageModelsWithFileInputSupport = new Set<string>([
36
36
  'gemini-2.5-flash-image',
37
37
  'gemini-3-pro-image-preview',
38
38
  'gemini-3.1-flash-image-preview',
39
+ 'gemini-nano-banana-2.1',
39
40
  ]);
40
41
 
41
42
  export class GoogleImageModel implements ImageModelV4 {
@@ -3,6 +3,7 @@ export type GoogleImageModelId =
3
3
  | 'gemini-2.5-flash-image'
4
4
  | 'gemini-3-pro-image-preview'
5
5
  | 'gemini-3.1-flash-image-preview'
6
+ | 'gemini-nano-banana-2.1'
6
7
  | (string & {});
7
8
 
8
9
  export interface GoogleImageSettings {
@@ -35,6 +35,7 @@ export type GoogleModelId =
35
35
  | 'gemini-3.6-flash'
36
36
  | 'gemini-3.7-flash'
37
37
  | 'gemini-3.8-flash'
38
+ | 'gemini-nano-banana-2.1'
38
39
  // latest version
39
40
  // https://ai.google.dev/gemini-api/docs/models#latest
40
41
  | 'gemini-pro-latest'
@@ -1445,6 +1445,7 @@ function resolveGemini3ThinkingConfig({
1445
1445
  medium: 'medium',
1446
1446
  high: 'high',
1447
1447
  xhigh: 'high',
1448
+ max: 'high',
1448
1449
  },
1449
1450
  warnings,
1450
1451
  });
@@ -1646,6 +1647,18 @@ export const getGroundingMetadataSchema = () =>
1646
1647
  title: z.string().nullish(),
1647
1648
  text: z.string().nullish(),
1648
1649
  fileSearchStore: z.string().nullish(),
1650
+ customMetadata: z
1651
+ .array(
1652
+ z.object({
1653
+ key: z.string(),
1654
+ stringValue: z.string().nullish(),
1655
+ numericValue: z.number().nullish(),
1656
+ stringListValue: z
1657
+ .object({ values: z.array(z.string()).nullish() })
1658
+ .nullish(),
1659
+ }),
1660
+ )
1661
+ .nullish(),
1649
1662
  })
1650
1663
  .nullish(),
1651
1664
  maps: z
@@ -178,6 +178,12 @@ export interface GoogleProvider extends ProviderV4 {
178
178
  }
179
179
 
180
180
  export interface GoogleProviderSettings {
181
+ /** Settings for downloading JSON Lines batch results. */
182
+ batchResultDownloads?: {
183
+ /** Maximum UTF-8 bytes per row, excluding LF. Defaults to 64 MiB. */
184
+ maxLineBytes?: number;
185
+ };
186
+
181
187
  /**
182
188
  * Use a different URL prefix for API calls, e.g. to use proxy servers.
183
189
  * The default prefix is `https://generativelanguage.googleapis.com/v1beta`.
@@ -312,6 +318,7 @@ export function createGoogle(
312
318
  const createBatch = () =>
313
319
  new GoogleBatch({
314
320
  provider: `${providerName.replace(/\.generative-ai$/, '')}.batch`,
321
+ maxLineBytes: options.batchResultDownloads?.maxLineBytes,
315
322
  config: languageModelConfig,
316
323
  // Batch prompt conversion happens before the model is available to the
317
324
  // provider. Only advertise URL support shared by every batch model.
@@ -37,6 +37,7 @@ export type GoogleInteractionsModelId =
37
37
  | 'gemini-3.6-flash'
38
38
  | 'gemini-3.7-flash'
39
39
  | 'gemini-3.8-flash'
40
+ | 'gemini-nano-banana-2.1'
40
41
  | 'lyria-3-clip-preview'
41
42
  | 'lyria-3-pro-preview'
42
43
  | (string & {});