@ai-sdk/google-vertex 5.0.92 → 5.0.93
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 +9 -0
- package/README.md +11 -11
- package/dist/anthropic/edge/index.js +1 -1
- package/dist/edge/index.js +1 -1
- package/dist/index.js +1 -1
- package/dist/maas/edge/index.js +1 -1
- package/dist/xai/edge/index.js +1 -1
- package/docs/16-google-vertex.mdx +13 -13
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -28,14 +28,14 @@ The Google Vertex provider has two different authentication implementations depe
|
|
|
28
28
|
|
|
29
29
|
### Node.js Runtime
|
|
30
30
|
|
|
31
|
-
The Node.js runtime is the default runtime supported by the AI SDK. You can use the default provider instance to generate text with the `gemini-
|
|
31
|
+
The Node.js runtime is the default runtime supported by the AI SDK. You can use the default provider instance to generate text with the `gemini-3.8-flash` model like this:
|
|
32
32
|
|
|
33
33
|
```ts
|
|
34
34
|
import { vertex } from '@ai-sdk/google-vertex';
|
|
35
35
|
import { generateText } from 'ai';
|
|
36
36
|
|
|
37
37
|
const { text } = await generateText({
|
|
38
|
-
model: vertex('gemini-
|
|
38
|
+
model: vertex('gemini-3.8-flash'),
|
|
39
39
|
prompt: 'Write a vegetarian lasagna recipe.',
|
|
40
40
|
});
|
|
41
41
|
```
|
|
@@ -46,14 +46,14 @@ This provider supports all standard Google Cloud authentication options through
|
|
|
46
46
|
|
|
47
47
|
The Edge runtime is supported through the `@ai-sdk/google-vertex/edge` module. Note the additional sub-module path `/edge` required to differentiate the Edge provider from the Node.js provider.
|
|
48
48
|
|
|
49
|
-
You can use the default provider instance to generate text with the `gemini-
|
|
49
|
+
You can use the default provider instance to generate text with the `gemini-3.8-flash` model like this:
|
|
50
50
|
|
|
51
51
|
```ts
|
|
52
52
|
import { vertex } from '@ai-sdk/google-vertex/edge';
|
|
53
53
|
import { generateText } from 'ai';
|
|
54
54
|
|
|
55
55
|
const { text } = await generateText({
|
|
56
|
-
model: vertex('gemini-
|
|
56
|
+
model: vertex('gemini-3.8-flash'),
|
|
57
57
|
prompt: 'Write a vegetarian lasagna recipe.',
|
|
58
58
|
});
|
|
59
59
|
```
|
|
@@ -71,7 +71,7 @@ import { vertexAnthropic } from '@ai-sdk/google-vertex/anthropic';
|
|
|
71
71
|
import { generateText } from 'ai';
|
|
72
72
|
|
|
73
73
|
const { text } = await generateText({
|
|
74
|
-
model: vertexAnthropic('claude-
|
|
74
|
+
model: vertexAnthropic('claude-sonnet-5'),
|
|
75
75
|
prompt: 'Write a vegetarian lasagna recipe.',
|
|
76
76
|
});
|
|
77
77
|
```
|
|
@@ -83,7 +83,7 @@ import { vertexAnthropic } from '@ai-sdk/google-vertex/anthropic/edge';
|
|
|
83
83
|
import { generateText } from 'ai';
|
|
84
84
|
|
|
85
85
|
const { text } = await generateText({
|
|
86
|
-
model: vertexAnthropic('claude-
|
|
86
|
+
model: vertexAnthropic('claude-sonnet-5'),
|
|
87
87
|
prompt: 'Write a vegetarian lasagna recipe.',
|
|
88
88
|
});
|
|
89
89
|
```
|
|
@@ -105,7 +105,7 @@ const errorMessage = fs.readFileSync('data/error-message.txt', 'utf8');
|
|
|
105
105
|
|
|
106
106
|
async function main() {
|
|
107
107
|
const result = await generateText({
|
|
108
|
-
model: vertexAnthropic('claude-
|
|
108
|
+
model: vertexAnthropic('claude-sonnet-5', {
|
|
109
109
|
cacheControl: true,
|
|
110
110
|
}),
|
|
111
111
|
messages: [
|
|
@@ -161,7 +161,7 @@ const customProvider = createVertex({
|
|
|
161
161
|
});
|
|
162
162
|
|
|
163
163
|
const { text } = await generateText({
|
|
164
|
-
model: customProvider('gemini-
|
|
164
|
+
model: customProvider('gemini-3.8-flash'),
|
|
165
165
|
prompt: 'Write a vegetarian lasagna recipe.',
|
|
166
166
|
});
|
|
167
167
|
```
|
|
@@ -184,7 +184,7 @@ const customProvider = createVertex({
|
|
|
184
184
|
});
|
|
185
185
|
|
|
186
186
|
const { text } = await generateText({
|
|
187
|
-
model: customProvider('gemini-
|
|
187
|
+
model: customProvider('gemini-3.8-flash'),
|
|
188
188
|
prompt: 'Write a vegetarian lasagna recipe.',
|
|
189
189
|
});
|
|
190
190
|
```
|
|
@@ -203,7 +203,7 @@ const customProvider = createVertexAnthropic({
|
|
|
203
203
|
});
|
|
204
204
|
|
|
205
205
|
const { text } = await generateText({
|
|
206
|
-
model: customProvider('claude-
|
|
206
|
+
model: customProvider('claude-sonnet-5'),
|
|
207
207
|
prompt: 'Write a vegetarian lasagna recipe.',
|
|
208
208
|
});
|
|
209
209
|
```
|
|
@@ -220,7 +220,7 @@ const customProvider = createVertexAnthropic({
|
|
|
220
220
|
});
|
|
221
221
|
|
|
222
222
|
const { text } = await generateText({
|
|
223
|
-
model: customProvider('claude-
|
|
223
|
+
model: customProvider('claude-sonnet-5'),
|
|
224
224
|
prompt: 'Write a vegetarian lasagna recipe.',
|
|
225
225
|
});
|
|
226
226
|
```
|
package/dist/edge/index.js
CHANGED
package/dist/index.js
CHANGED
package/dist/maas/edge/index.js
CHANGED
package/dist/xai/edge/index.js
CHANGED
|
@@ -624,12 +624,12 @@ import { generateText, streamText } from 'ai';
|
|
|
624
624
|
|
|
625
625
|
// For generateText:
|
|
626
626
|
const { text, reasoningText, reasoning } = await generateText({
|
|
627
|
-
model: googleVertex('gemini-
|
|
627
|
+
model: googleVertex('gemini-3.8-flash'), // Or other supported model via Vertex
|
|
628
628
|
providerOptions: {
|
|
629
629
|
vertex: {
|
|
630
630
|
thinkingConfig: {
|
|
631
631
|
includeThoughts: true,
|
|
632
|
-
//
|
|
632
|
+
// thinkingLevel: 'high', // Optional
|
|
633
633
|
},
|
|
634
634
|
} satisfies GoogleLanguageModelOptions,
|
|
635
635
|
},
|
|
@@ -642,12 +642,12 @@ console.log('Final Text:', text);
|
|
|
642
642
|
|
|
643
643
|
// For streamText:
|
|
644
644
|
const result = streamText({
|
|
645
|
-
model: googleVertex('gemini-
|
|
645
|
+
model: googleVertex('gemini-3.8-flash'), // Or other supported model via Vertex
|
|
646
646
|
providerOptions: {
|
|
647
647
|
vertex: {
|
|
648
648
|
thinkingConfig: {
|
|
649
649
|
includeThoughts: true,
|
|
650
|
-
//
|
|
650
|
+
// thinkingLevel: 'high', // Optional
|
|
651
651
|
},
|
|
652
652
|
} satisfies GoogleLanguageModelOptions,
|
|
653
653
|
},
|
|
@@ -767,7 +767,7 @@ const ai = new GoogleGenAI({
|
|
|
767
767
|
location: process.env.GOOGLE_VERTEX_LOCATION,
|
|
768
768
|
});
|
|
769
769
|
|
|
770
|
-
const model = 'gemini-
|
|
770
|
+
const model = 'gemini-3.1-pro-preview';
|
|
771
771
|
|
|
772
772
|
// Create a cache with the content you want to reuse
|
|
773
773
|
const cache = await ai.caches.create({
|
|
@@ -1011,14 +1011,14 @@ For more on image generation with the AI SDK see
|
|
|
1011
1011
|
|
|
1012
1012
|
#### Gemini Image Models
|
|
1013
1013
|
|
|
1014
|
-
[Gemini image models](https://cloud.google.com/vertex-ai/generative-ai/docs/models/gemini/2-5-flash-image) (e.g. `gemini-
|
|
1014
|
+
[Gemini image models](https://cloud.google.com/vertex-ai/generative-ai/docs/models/gemini/2-5-flash-image) (e.g. `gemini-3.1-flash-image-preview`) are multimodal output language models that can be used with `generateImage()` for a simpler image generation experience. Internally, the provider calls the language model API with `responseModalities: ['IMAGE']`.
|
|
1015
1015
|
|
|
1016
1016
|
```ts
|
|
1017
1017
|
import { googleVertex } from '@ai-sdk/google-vertex';
|
|
1018
1018
|
import { generateImage } from 'ai';
|
|
1019
1019
|
|
|
1020
1020
|
const { image } = await generateImage({
|
|
1021
|
-
model: googleVertex.image('gemini-
|
|
1021
|
+
model: googleVertex.image('gemini-3.1-flash-image-preview'),
|
|
1022
1022
|
prompt: 'A photorealistic image of a cat wearing a wizard hat',
|
|
1023
1023
|
aspectRatio: '1:1',
|
|
1024
1024
|
});
|
|
@@ -1034,7 +1034,7 @@ import fs from 'node:fs';
|
|
|
1034
1034
|
const sourceImage = fs.readFileSync('./cat.png');
|
|
1035
1035
|
|
|
1036
1036
|
const { image } = await generateImage({
|
|
1037
|
-
model: googleVertex.image('gemini-
|
|
1037
|
+
model: googleVertex.image('gemini-3.1-flash-image-preview'),
|
|
1038
1038
|
prompt: {
|
|
1039
1039
|
text: 'Add a small wizard hat to this cat',
|
|
1040
1040
|
images: [sourceImage],
|
|
@@ -1511,11 +1511,11 @@ You can use the following optional settings to customize the provider instance:
|
|
|
1511
1511
|
### Language Models
|
|
1512
1512
|
|
|
1513
1513
|
You can create models that call the [Anthropic Messages API](https://docs.anthropic.com/claude/reference/messages_post) using the provider instance.
|
|
1514
|
-
The first argument is the model id, e.g. `claude-
|
|
1514
|
+
The first argument is the model id, e.g. `claude-sonnet-5`.
|
|
1515
1515
|
Some models have multi-modal capabilities.
|
|
1516
1516
|
|
|
1517
1517
|
```ts
|
|
1518
|
-
const model =
|
|
1518
|
+
const model = vertexAnthropic('claude-sonnet-5');
|
|
1519
1519
|
```
|
|
1520
1520
|
|
|
1521
1521
|
You can use Anthropic language models to generate text with the `generateText` function:
|
|
@@ -1525,7 +1525,7 @@ import { vertexAnthropic } from '@ai-sdk/google-vertex/anthropic';
|
|
|
1525
1525
|
import { generateText } from 'ai';
|
|
1526
1526
|
|
|
1527
1527
|
const { text } = await generateText({
|
|
1528
|
-
model: vertexAnthropic('claude-
|
|
1528
|
+
model: vertexAnthropic('claude-sonnet-5'),
|
|
1529
1529
|
prompt: 'Write a vegetarian lasagna recipe for 4 people.',
|
|
1530
1530
|
});
|
|
1531
1531
|
```
|
|
@@ -1610,7 +1610,7 @@ import { generateText } from 'ai';
|
|
|
1610
1610
|
const errorMessage = '... long error message ...';
|
|
1611
1611
|
|
|
1612
1612
|
const result = await generateText({
|
|
1613
|
-
model: vertexAnthropic('claude-
|
|
1613
|
+
model: vertexAnthropic('claude-sonnet-5'),
|
|
1614
1614
|
messages: [
|
|
1615
1615
|
{
|
|
1616
1616
|
role: 'user',
|
|
@@ -1644,7 +1644,7 @@ You can also use cache control on system messages by providing multiple system m
|
|
|
1644
1644
|
|
|
1645
1645
|
```ts highlight="3,7-9"
|
|
1646
1646
|
const result = await generateText({
|
|
1647
|
-
model: vertexAnthropic('claude-
|
|
1647
|
+
model: vertexAnthropic('claude-sonnet-5'),
|
|
1648
1648
|
messages: [
|
|
1649
1649
|
{
|
|
1650
1650
|
role: 'system',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-sdk/google-vertex",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.93",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -71,8 +71,8 @@
|
|
|
71
71
|
}
|
|
72
72
|
},
|
|
73
73
|
"dependencies": {
|
|
74
|
-
"@ai-sdk/anthropic": "4.0.
|
|
75
|
-
"@ai-sdk/google": "4.0.
|
|
74
|
+
"@ai-sdk/anthropic": "4.0.63",
|
|
75
|
+
"@ai-sdk/google": "4.0.80",
|
|
76
76
|
"@ai-sdk/openai-compatible": "3.0.55",
|
|
77
77
|
"@ai-sdk/provider": "4.0.18",
|
|
78
78
|
"@ai-sdk/provider-utils": "5.0.47",
|