@ai-sdk/google-vertex 5.0.92 → 5.0.95
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 +34 -0
- package/README.md +11 -11
- package/dist/anthropic/edge/index.js +23 -28
- package/dist/anthropic/edge/index.js.map +1 -1
- package/dist/anthropic/index.js +23 -29
- package/dist/anthropic/index.js.map +1 -1
- package/dist/edge/index.js +73 -107
- package/dist/edge/index.js.map +1 -1
- package/dist/index.js +74 -109
- package/dist/index.js.map +1 -1
- package/dist/maas/edge/index.js +6 -11
- package/dist/maas/edge/index.js.map +1 -1
- package/dist/maas/index.js +6 -12
- package/dist/maas/index.js.map +1 -1
- package/dist/xai/edge/index.js +10 -16
- package/dist/xai/edge/index.js.map +1 -1
- package/dist/xai/index.js +10 -17
- package/dist/xai/index.js.map +1 -1
- package/docs/16-google-vertex.mdx +51 -13
- package/package.json +6 -6
- package/src/google-vertex-provider-base.ts +1 -0
|
@@ -138,6 +138,8 @@ You can use the following optional settings to customize the provider instance:
|
|
|
138
138
|
- **toolResultDownloads** _object_
|
|
139
139
|
|
|
140
140
|
Settings for downloading remote files in tool results before sending them to Vertex as inline data.
|
|
141
|
+
Supported Google Cloud Storage URLs are forwarded directly for Gemini 3 and later models.
|
|
142
|
+
See [Tool Result Files](#tool-result-files) for the supported MIME types.
|
|
141
143
|
- **maxBytes** _number_
|
|
142
144
|
|
|
143
145
|
Maximum size in bytes for each downloaded file. Defaults to 7 MiB.
|
|
@@ -624,12 +626,12 @@ import { generateText, streamText } from 'ai';
|
|
|
624
626
|
|
|
625
627
|
// For generateText:
|
|
626
628
|
const { text, reasoningText, reasoning } = await generateText({
|
|
627
|
-
model: googleVertex('gemini-
|
|
629
|
+
model: googleVertex('gemini-3.8-flash'), // Or other supported model via Vertex
|
|
628
630
|
providerOptions: {
|
|
629
631
|
vertex: {
|
|
630
632
|
thinkingConfig: {
|
|
631
633
|
includeThoughts: true,
|
|
632
|
-
//
|
|
634
|
+
// thinkingLevel: 'high', // Optional
|
|
633
635
|
},
|
|
634
636
|
} satisfies GoogleLanguageModelOptions,
|
|
635
637
|
},
|
|
@@ -642,12 +644,12 @@ console.log('Final Text:', text);
|
|
|
642
644
|
|
|
643
645
|
// For streamText:
|
|
644
646
|
const result = streamText({
|
|
645
|
-
model: googleVertex('gemini-
|
|
647
|
+
model: googleVertex('gemini-3.8-flash'), // Or other supported model via Vertex
|
|
646
648
|
providerOptions: {
|
|
647
649
|
vertex: {
|
|
648
650
|
thinkingConfig: {
|
|
649
651
|
includeThoughts: true,
|
|
650
|
-
//
|
|
652
|
+
// thinkingLevel: 'high', // Optional
|
|
651
653
|
},
|
|
652
654
|
} satisfies GoogleLanguageModelOptions,
|
|
653
655
|
},
|
|
@@ -711,6 +713,42 @@ const { text } = await generateText({
|
|
|
711
713
|
|
|
712
714
|
See [File Parts](/docs/foundations/prompts#file-parts) for details on how to use files in prompts.
|
|
713
715
|
|
|
716
|
+
### Tool Result Files
|
|
717
|
+
|
|
718
|
+
For Gemini 3 and later models, tool results can include Google Cloud Storage
|
|
719
|
+
(`gs://`) file URLs. Vertex receives these references directly as
|
|
720
|
+
`functionResponse.parts[].fileData`, without downloading the files into the SDK
|
|
721
|
+
process. The supported MIME types are `image/png`, `image/jpeg`, `image/webp`,
|
|
722
|
+
`application/pdf`, and `text/plain`. Specify the full MIME type; a top-level type
|
|
723
|
+
such as `image` is not sufficient for GCS tool results.
|
|
724
|
+
|
|
725
|
+
Use a file part in the tool's `toModelOutput` result:
|
|
726
|
+
|
|
727
|
+
```ts
|
|
728
|
+
toModelOutput: ({ output }) => ({
|
|
729
|
+
type: 'content',
|
|
730
|
+
value: [
|
|
731
|
+
{
|
|
732
|
+
type: 'file',
|
|
733
|
+
mediaType: 'image/png',
|
|
734
|
+
data: {
|
|
735
|
+
type: 'url',
|
|
736
|
+
url: new URL(output.gcsUri),
|
|
737
|
+
originalUrl: output.gcsUri,
|
|
738
|
+
},
|
|
739
|
+
},
|
|
740
|
+
],
|
|
741
|
+
}),
|
|
742
|
+
```
|
|
743
|
+
|
|
744
|
+
Include `originalUrl` when URL parsing changes an opaque GCS URI, such as a path
|
|
745
|
+
containing spaces, so Vertex receives the exact object reference. The Vertex
|
|
746
|
+
caller must have access to the referenced object.
|
|
747
|
+
|
|
748
|
+
HTTP(S) tool-result files are downloaded and sent as inline data, subject to
|
|
749
|
+
`toolResultDownloads.maxBytes`. Direct GCS tool-result forwarding is not supported
|
|
750
|
+
for older Gemini models or MIME types outside the list above.
|
|
751
|
+
|
|
714
752
|
### Cached Content
|
|
715
753
|
|
|
716
754
|
Google Vertex AI supports both explicit and implicit caching to help reduce costs on repetitive content.
|
|
@@ -767,7 +805,7 @@ const ai = new GoogleGenAI({
|
|
|
767
805
|
location: process.env.GOOGLE_VERTEX_LOCATION,
|
|
768
806
|
});
|
|
769
807
|
|
|
770
|
-
const model = 'gemini-
|
|
808
|
+
const model = 'gemini-3.1-pro-preview';
|
|
771
809
|
|
|
772
810
|
// Create a cache with the content you want to reuse
|
|
773
811
|
const cache = await ai.caches.create({
|
|
@@ -1011,14 +1049,14 @@ For more on image generation with the AI SDK see
|
|
|
1011
1049
|
|
|
1012
1050
|
#### Gemini Image Models
|
|
1013
1051
|
|
|
1014
|
-
[Gemini image models](https://cloud.google.com/vertex-ai/generative-ai/docs/models/gemini/2-5-flash-image) (e.g. `gemini-
|
|
1052
|
+
[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
1053
|
|
|
1016
1054
|
```ts
|
|
1017
1055
|
import { googleVertex } from '@ai-sdk/google-vertex';
|
|
1018
1056
|
import { generateImage } from 'ai';
|
|
1019
1057
|
|
|
1020
1058
|
const { image } = await generateImage({
|
|
1021
|
-
model: googleVertex.image('gemini-
|
|
1059
|
+
model: googleVertex.image('gemini-3.1-flash-image-preview'),
|
|
1022
1060
|
prompt: 'A photorealistic image of a cat wearing a wizard hat',
|
|
1023
1061
|
aspectRatio: '1:1',
|
|
1024
1062
|
});
|
|
@@ -1034,7 +1072,7 @@ import fs from 'node:fs';
|
|
|
1034
1072
|
const sourceImage = fs.readFileSync('./cat.png');
|
|
1035
1073
|
|
|
1036
1074
|
const { image } = await generateImage({
|
|
1037
|
-
model: googleVertex.image('gemini-
|
|
1075
|
+
model: googleVertex.image('gemini-3.1-flash-image-preview'),
|
|
1038
1076
|
prompt: {
|
|
1039
1077
|
text: 'Add a small wizard hat to this cat',
|
|
1040
1078
|
images: [sourceImage],
|
|
@@ -1511,11 +1549,11 @@ You can use the following optional settings to customize the provider instance:
|
|
|
1511
1549
|
### Language Models
|
|
1512
1550
|
|
|
1513
1551
|
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-
|
|
1552
|
+
The first argument is the model id, e.g. `claude-sonnet-5`.
|
|
1515
1553
|
Some models have multi-modal capabilities.
|
|
1516
1554
|
|
|
1517
1555
|
```ts
|
|
1518
|
-
const model =
|
|
1556
|
+
const model = vertexAnthropic('claude-sonnet-5');
|
|
1519
1557
|
```
|
|
1520
1558
|
|
|
1521
1559
|
You can use Anthropic language models to generate text with the `generateText` function:
|
|
@@ -1525,7 +1563,7 @@ import { vertexAnthropic } from '@ai-sdk/google-vertex/anthropic';
|
|
|
1525
1563
|
import { generateText } from 'ai';
|
|
1526
1564
|
|
|
1527
1565
|
const { text } = await generateText({
|
|
1528
|
-
model: vertexAnthropic('claude-
|
|
1566
|
+
model: vertexAnthropic('claude-sonnet-5'),
|
|
1529
1567
|
prompt: 'Write a vegetarian lasagna recipe for 4 people.',
|
|
1530
1568
|
});
|
|
1531
1569
|
```
|
|
@@ -1610,7 +1648,7 @@ import { generateText } from 'ai';
|
|
|
1610
1648
|
const errorMessage = '... long error message ...';
|
|
1611
1649
|
|
|
1612
1650
|
const result = await generateText({
|
|
1613
|
-
model: vertexAnthropic('claude-
|
|
1651
|
+
model: vertexAnthropic('claude-sonnet-5'),
|
|
1614
1652
|
messages: [
|
|
1615
1653
|
{
|
|
1616
1654
|
role: 'user',
|
|
@@ -1644,7 +1682,7 @@ You can also use cache control on system messages by providing multiple system m
|
|
|
1644
1682
|
|
|
1645
1683
|
```ts highlight="3,7-9"
|
|
1646
1684
|
const result = await generateText({
|
|
1647
|
-
model: vertexAnthropic('claude-
|
|
1685
|
+
model: vertexAnthropic('claude-sonnet-5'),
|
|
1648
1686
|
messages: [
|
|
1649
1687
|
{
|
|
1650
1688
|
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.95",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -71,15 +71,15 @@
|
|
|
71
71
|
}
|
|
72
72
|
},
|
|
73
73
|
"dependencies": {
|
|
74
|
-
"@ai-sdk/anthropic": "4.0.
|
|
75
|
-
"@ai-sdk/google": "4.0.
|
|
76
|
-
"@ai-sdk/openai-compatible": "3.0.
|
|
74
|
+
"@ai-sdk/anthropic": "4.0.65",
|
|
75
|
+
"@ai-sdk/google": "4.0.82",
|
|
76
|
+
"@ai-sdk/openai-compatible": "3.0.57",
|
|
77
77
|
"@ai-sdk/provider": "4.0.18",
|
|
78
|
-
"@ai-sdk/provider-utils": "5.0.
|
|
78
|
+
"@ai-sdk/provider-utils": "5.0.49",
|
|
79
79
|
"google-auth-library": "^10.6.2"
|
|
80
80
|
},
|
|
81
81
|
"devDependencies": {
|
|
82
|
-
"@ai-sdk/test-server": "2.0.
|
|
82
|
+
"@ai-sdk/test-server": "2.0.2",
|
|
83
83
|
"@types/node": "22.19.19",
|
|
84
84
|
"@vercel/ai-tsconfig": "0.0.0",
|
|
85
85
|
"tsup": "^8.5.1",
|