@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.
- package/CHANGELOG.md +24 -0
- package/dist/index.d.ts +16 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -5
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +18 -2
- package/dist/internal/index.d.ts.map +1 -1
- package/dist/internal/index.js +9 -2
- package/dist/internal/index.js.map +1 -1
- package/docs/15-google.mdx +20 -6
- package/package.json +5 -5
- package/src/google-batch.ts +4 -0
- package/src/google-image-model.ts +1 -0
- package/src/google-image-settings.ts +1 -0
- package/src/google-language-model-options.ts +1 -0
- package/src/google-language-model.ts +13 -0
- package/src/google-provider.ts +7 -0
- package/src/interactions/google-interactions-language-model-options.ts +1 -0
package/docs/15-google.mdx
CHANGED
|
@@ -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.
|
|
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.
|
|
39
|
-
"@ai-sdk/provider-utils": "5.0.
|
|
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.
|
|
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": "
|
|
46
|
+
"typescript": "6.0.3",
|
|
47
47
|
"zod": "3.25.76"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
package/src/google-batch.ts
CHANGED
|
@@ -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,
|
|
@@ -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
|
package/src/google-provider.ts
CHANGED
|
@@ -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.
|