@ai-sdk/google 4.0.49 → 4.0.51
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 +16 -0
- package/dist/index.d.ts +5 -5
- package/dist/index.js +1146 -558
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +146 -6
- package/dist/internal/index.js +43 -25
- package/dist/internal/index.js.map +1 -1
- package/docs/15-google.mdx +59 -0
- package/package.json +6 -6
- package/src/google-batch.ts +739 -0
- package/src/google-language-model.ts +58 -35
- package/src/google-provider.ts +7 -6
package/docs/15-google.mdx
CHANGED
|
@@ -1064,6 +1064,65 @@ The following Zod features are known to not work with Google:
|
|
|
1064
1064
|
available provider model ID as a string if needed.
|
|
1065
1065
|
</Note>
|
|
1066
1066
|
|
|
1067
|
+
### Text Batches
|
|
1068
|
+
|
|
1069
|
+
<Note type="warning">
|
|
1070
|
+
Text batch APIs are experimental and may change in future releases.
|
|
1071
|
+
</Note>
|
|
1072
|
+
|
|
1073
|
+
The Google provider supports the [Gemini Batch API](https://ai.google.dev/gemini-api/docs/batch-api) for text generation.
|
|
1074
|
+
|
|
1075
|
+
```ts
|
|
1076
|
+
import { google } from '@ai-sdk/google';
|
|
1077
|
+
import {
|
|
1078
|
+
experimental_getBatchResults as getBatchResults,
|
|
1079
|
+
experimental_getBatchStatus as getBatchStatus,
|
|
1080
|
+
experimental_startTextBatch as startTextBatch,
|
|
1081
|
+
} from 'ai';
|
|
1082
|
+
|
|
1083
|
+
const model = google('gemini-3.6-flash');
|
|
1084
|
+
|
|
1085
|
+
const batch = await startTextBatch({
|
|
1086
|
+
model,
|
|
1087
|
+
requests: [
|
|
1088
|
+
{ id: 'france', prompt: 'What is the capital of France?' },
|
|
1089
|
+
{ id: 'germany', prompt: 'What is the capital of Germany?' },
|
|
1090
|
+
],
|
|
1091
|
+
});
|
|
1092
|
+
|
|
1093
|
+
// Persist `batch` and check its status later, or poll for status updates.
|
|
1094
|
+
const { status } = await getBatchStatus({ model, batch });
|
|
1095
|
+
|
|
1096
|
+
if (status !== 'pending') {
|
|
1097
|
+
for await (const item of getBatchResults({ model, batch })) {
|
|
1098
|
+
if (item.status === 'succeeded') {
|
|
1099
|
+
console.log(item.id, item.text);
|
|
1100
|
+
} else {
|
|
1101
|
+
console.error(item.id, item.error);
|
|
1102
|
+
}
|
|
1103
|
+
}
|
|
1104
|
+
}
|
|
1105
|
+
```
|
|
1106
|
+
|
|
1107
|
+
Starting a batch returns a serializable reference that can be persisted and used to retrieve the batch results later, or poll for status updates.
|
|
1108
|
+
|
|
1109
|
+
You can pass a `webhookUrl` to receive a notification when the batch reaches a terminal state:
|
|
1110
|
+
|
|
1111
|
+
```ts
|
|
1112
|
+
const batch = await startTextBatch({
|
|
1113
|
+
model,
|
|
1114
|
+
requests: [
|
|
1115
|
+
{ id: 'france', prompt: 'What is the capital of France?' },
|
|
1116
|
+
{ id: 'germany', prompt: 'What is the capital of Germany?' },
|
|
1117
|
+
],
|
|
1118
|
+
webhookUrl: 'https://example.com/api/google-batch-webhook',
|
|
1119
|
+
});
|
|
1120
|
+
```
|
|
1121
|
+
|
|
1122
|
+
Google sends a thin event to the webhook URL. After receiving and verifying the event, use the persisted batch reference with `getBatchStatus` or `getBatchResults`. Your application is responsible for handling the webhook and [verifying Google's dynamic webhook signature](https://ai.google.dev/gemini-api/docs/webhooks#verify_dynamic_signatures_jwks).
|
|
1123
|
+
|
|
1124
|
+
When the serialized batch creation body is under 20 MB, the provider sends the requests inline. At 20 MB or more, it uploads a JSONL input file through the Gemini Files API.
|
|
1125
|
+
|
|
1067
1126
|
## Realtime Models
|
|
1068
1127
|
|
|
1069
1128
|
<Note type="warning">Realtime is an experimental feature.</Note>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-sdk/google",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.51",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -35,16 +35,16 @@
|
|
|
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.8",
|
|
39
|
+
"@ai-sdk/provider-utils": "5.0.30"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
+
"@ai-sdk/test-server": "2.0.1",
|
|
42
43
|
"@types/node": "22.19.19",
|
|
44
|
+
"@vercel/ai-tsconfig": "0.0.0",
|
|
43
45
|
"tsup": "^8.5.1",
|
|
44
46
|
"typescript": "5.8.3",
|
|
45
|
-
"zod": "3.25.76"
|
|
46
|
-
"@ai-sdk/test-server": "2.0.1",
|
|
47
|
-
"@vercel/ai-tsconfig": "0.0.0"
|
|
47
|
+
"zod": "3.25.76"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
50
|
"zod": "^3.25.76 || ^4.1.8"
|