@ai-sdk/google-vertex 5.0.121 → 5.0.123

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 CHANGED
@@ -1,5 +1,30 @@
1
1
  # @ai-sdk/google-vertex
2
2
 
3
+ ## 5.0.123
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [e64ed82]
8
+ - Updated dependencies [27a53b4]
9
+ - @ai-sdk/provider-utils@5.0.69
10
+ - @ai-sdk/openai-compatible@3.0.79
11
+ - @ai-sdk/anthropic@4.0.89
12
+ - @ai-sdk/google@4.0.106
13
+
14
+ ## 5.0.122
15
+
16
+ ### Patch Changes
17
+
18
+ - e729d58: chore(docs): update `README.md` for consistent format and to avoid duplication
19
+ - Updated dependencies [5475347]
20
+ - Updated dependencies [e729d58]
21
+ - Updated dependencies [bbe2bd1]
22
+ - @ai-sdk/provider@4.0.34
23
+ - @ai-sdk/openai-compatible@3.0.78
24
+ - @ai-sdk/provider-utils@5.0.68
25
+ - @ai-sdk/anthropic@4.0.88
26
+ - @ai-sdk/google@4.0.105
27
+
3
28
  ## 5.0.121
4
29
 
5
30
  ### Patch Changes
package/README.md CHANGED
@@ -2,16 +2,12 @@
2
2
 
3
3
  The **[Google Vertex provider](https://ai-sdk.dev/providers/ai-sdk-providers/google-vertex)** for the [AI SDK](https://ai-sdk.dev/docs) contains language model support for the [Google Vertex AI](https://cloud.google.com/vertex-ai) APIs.
4
4
 
5
- This library includes a Google Vertex Anthropic provider and a Google Vertex MaaS provider. These providers closely follow the core Google Vertex library's usage patterns. See more in the [Google Vertex Anthropic Provider](#google-vertex-anthropic-provider) and [Google Vertex MaaS Provider](#google-vertex-maas-provider) sections below.
6
-
7
5
  > **Deploying to Vercel?** With Vercel's AI Gateway you can access Google Vertex AI (and hundreds of models from other providers) — no additional packages, API keys, or extra cost. [Get started with AI Gateway](https://vercel.com/ai-gateway).
8
6
 
9
7
  ## Setup
10
8
 
11
- The Google Vertex provider is available in the `@ai-sdk/google-vertex` module. You can install it with
12
-
13
9
  ```bash
14
- npm i @ai-sdk/google-vertex
10
+ npm i ai @ai-sdk/google-vertex
15
11
  ```
16
12
 
17
13
  ## Skill for Coding Agents
@@ -22,13 +18,7 @@ If you use coding agents such as Claude Code or Cursor, we highly recommend addi
22
18
  npx skills add vercel/ai
23
19
  ```
24
20
 
25
- ## Google Vertex Provider
26
-
27
- The Google Vertex provider has two different authentication implementations depending on your runtime environment:
28
-
29
- ### Node.js Runtime
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-3.8-flash` model like this:
21
+ ## Usage
32
22
 
33
23
  ```ts
34
24
  import { vertex } from '@ai-sdk/google-vertex';
@@ -40,253 +30,4 @@ const { text } = await generateText({
40
30
  });
41
31
  ```
42
32
 
43
- This provider supports all standard Google Cloud authentication options through the [`google-auth-library`](https://github.com/googleapis/google-auth-library-nodejs?tab=readme-ov-file#ways-to-authenticate). The most common authentication method is to set the path to a json credentials file in the `GOOGLE_APPLICATION_CREDENTIALS` environment variable. Credentials can be obtained from the [Google Cloud Console](https://console.cloud.google.com/apis/credentials).
44
-
45
- ### Edge Runtime
46
-
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
-
49
- You can use the default provider instance to generate text with the `gemini-3.8-flash` model like this:
50
-
51
- ```ts
52
- import { vertex } from '@ai-sdk/google-vertex/edge';
53
- import { generateText } from 'ai';
54
-
55
- const { text } = await generateText({
56
- model: vertex('gemini-3.8-flash'),
57
- prompt: 'Write a vegetarian lasagna recipe.',
58
- });
59
- ```
60
-
61
- This method supports Google's [Application Default Credentials](https://github.com/googleapis/google-auth-library-nodejs?tab=readme-ov-file#application-default-credentials) through the environment variables `GOOGLE_CLIENT_EMAIL`, `GOOGLE_PRIVATE_KEY`, and (optionally) `GOOGLE_PRIVATE_KEY_ID`. The values can be obtained from a json credentials file obtained from the [Google Cloud Console](https://console.cloud.google.com/apis/credentials).
62
-
63
- ## Google Vertex Anthropic Provider
64
-
65
- The Google Vertex Anthropic provider is available for both Node.js and Edge runtimes. It follows a similar usage pattern to the [core Google Vertex provider](#google-vertex-provider).
66
-
67
- ### Node.js Runtime
68
-
69
- ```ts
70
- import { vertexAnthropic } from '@ai-sdk/google-vertex/anthropic';
71
- import { generateText } from 'ai';
72
-
73
- const { text } = await generateText({
74
- model: vertexAnthropic('claude-sonnet-5-5'),
75
- prompt: 'Write a vegetarian lasagna recipe.',
76
- });
77
- ```
78
-
79
- ### Edge Runtime
80
-
81
- ```ts
82
- import { vertexAnthropic } from '@ai-sdk/google-vertex/anthropic/edge';
83
- import { generateText } from 'ai';
84
-
85
- const { text } = await generateText({
86
- model: vertexAnthropic('claude-sonnet-5-5'),
87
- prompt: 'Write a vegetarian lasagna recipe.',
88
- });
89
- ```
90
-
91
- ## Prompt Caching Support for Anthropic Claude Models
92
-
93
- The Google Vertex Anthropic provider supports prompt caching for Anthropic Claude models. Prompt caching can help reduce latency and costs by reusing cached results for identical requests. Caches are unique to Google Cloud projects and have a five-minute lifetime.
94
-
95
- ### Enabling Prompt Caching
96
-
97
- To enable prompt caching, you can use the `cacheControl` property in the settings. Here is an example demonstrating how to enable prompt caching:
98
-
99
- ```ts
100
- import { vertexAnthropic } from '@ai-sdk/google-vertex/anthropic';
101
- import { generateText } from 'ai';
102
- import fs from 'node:fs';
103
-
104
- const errorMessage = fs.readFileSync('data/error-message.txt', 'utf8');
105
-
106
- async function main() {
107
- const result = await generateText({
108
- model: vertexAnthropic('claude-sonnet-5-5', {
109
- cacheControl: true,
110
- }),
111
- messages: [
112
- {
113
- role: 'user',
114
- content: [
115
- {
116
- type: 'text',
117
- text: 'You are a JavaScript expert.',
118
- },
119
- {
120
- type: 'text',
121
- text: `Error message: ${errorMessage}`,
122
- providerOptions: {
123
- anthropic: {
124
- cacheControl: { type: 'ephemeral' },
125
- },
126
- },
127
- },
128
- {
129
- type: 'text',
130
- text: 'Explain the error message.',
131
- },
132
- ],
133
- },
134
- ],
135
- });
136
-
137
- console.log(result.text);
138
- console.log(result.providerMetadata?.anthropic);
139
- }
140
-
141
- main().catch(console.error);
142
- ```
143
-
144
- ## Custom Provider Configuration
145
-
146
- You can create a custom provider instance using the `createVertex` function. This allows you to specify additional configuration options. Below is an example with the default Node.js provider which includes a `googleAuthOptions` object.
147
-
148
- ```ts
149
- import { createVertex } from '@ai-sdk/google-vertex';
150
- import { generateText } from 'ai';
151
-
152
- const customProvider = createVertex({
153
- project: 'your-project-id',
154
- location: 'us-central1',
155
- googleAuthOptions: {
156
- credentials: {
157
- client_email: 'your-client-email',
158
- private_key: 'your-private-key',
159
- },
160
- },
161
- });
162
-
163
- const { text } = await generateText({
164
- model: customProvider('gemini-3.8-flash'),
165
- prompt: 'Write a vegetarian lasagna recipe.',
166
- });
167
- ```
168
-
169
- The `googleAuthOptions` object is not present in the Edge provider options but custom provider creation is otherwise identical.
170
-
171
- The Edge provider supports a `googleCredentials` option rather than `googleAuthOptions`. This can be used to specify the Google Cloud service account credentials and will take precedence over the environment variables used otherwise.
172
-
173
- ```ts
174
- import { createVertex } from '@ai-sdk/google-vertex/edge';
175
- import { generateText } from 'ai';
176
-
177
- const customProvider = createVertex({
178
- project: 'your-project-id',
179
- location: 'us-central1',
180
- googleCredentials: {
181
- clientEmail: 'your-client-email',
182
- privateKey: 'your-private-key',
183
- },
184
- });
185
-
186
- const { text } = await generateText({
187
- model: customProvider('gemini-3.8-flash'),
188
- prompt: 'Write a vegetarian lasagna recipe.',
189
- });
190
- ```
191
-
192
- ### Google Vertex Anthropic Provider Custom Configuration
193
-
194
- The Google Vertex Anthropic provider custom configuration is analogous to the above:
195
-
196
- ```ts
197
- import { createVertexAnthropic } from '@ai-sdk/google-vertex/anthropic';
198
- import { generateText } from 'ai';
199
-
200
- const customProvider = createVertexAnthropic({
201
- project: 'your-project-id',
202
- location: 'us-east5',
203
- });
204
-
205
- const { text } = await generateText({
206
- model: customProvider('claude-sonnet-5-5'),
207
- prompt: 'Write a vegetarian lasagna recipe.',
208
- });
209
- ```
210
-
211
- And for the Edge runtime:
212
-
213
- ```ts
214
- import { vertexAnthropic } from '@ai-sdk/google-vertex/anthropic/edge';
215
- import { generateText } from 'ai';
216
-
217
- const customProvider = createVertexAnthropic({
218
- project: 'your-project-id',
219
- location: 'us-east5',
220
- });
221
-
222
- const { text } = await generateText({
223
- model: customProvider('claude-sonnet-5-5'),
224
- prompt: 'Write a vegetarian lasagna recipe.',
225
- });
226
- ```
227
-
228
- ## Google Vertex MaaS Provider
229
-
230
- The Google Vertex MaaS (Model as a Service) provider offers access to partner and open models hosted on Vertex AI through an OpenAI-compatible Chat Completions API. It is available for both Node.js and Edge runtimes.
231
-
232
- ### Node.js Runtime
233
-
234
- ```ts
235
- import { vertexMaas } from '@ai-sdk/google-vertex/maas';
236
- import { generateText } from 'ai';
237
-
238
- const { text } = await generateText({
239
- model: vertexMaas('deepseek-ai/deepseek-v3.2-maas'),
240
- prompt: 'Write a vegetarian lasagna recipe.',
241
- });
242
- ```
243
-
244
- ### Edge Runtime
245
-
246
- ```ts
247
- import { vertexMaas } from '@ai-sdk/google-vertex/maas/edge';
248
- import { generateText } from 'ai';
249
-
250
- const { text } = await generateText({
251
- model: vertexMaas('deepseek-ai/deepseek-v3.2-maas'),
252
- prompt: 'Write a vegetarian lasagna recipe.',
253
- });
254
- ```
255
-
256
- ### Google Vertex MaaS Provider Custom Configuration
257
-
258
- ```ts
259
- import { createVertexMaas } from '@ai-sdk/google-vertex/maas';
260
- import { generateText } from 'ai';
261
-
262
- const customProvider = createVertexMaas({
263
- project: 'your-project-id',
264
- location: 'us-east5',
265
- });
266
-
267
- const { text } = await generateText({
268
- model: customProvider('deepseek-ai/deepseek-v3.2-maas'),
269
- prompt: 'Write a vegetarian lasagna recipe.',
270
- });
271
- ```
272
-
273
- And for the Edge runtime:
274
-
275
- ```ts
276
- import { createVertexMaas } from '@ai-sdk/google-vertex/maas/edge';
277
- import { generateText } from 'ai';
278
-
279
- const customProvider = createVertexMaas({
280
- project: 'your-project-id',
281
- location: 'us-east5',
282
- });
283
-
284
- const { text } = await generateText({
285
- model: customProvider('deepseek-ai/deepseek-v3.2-maas'),
286
- prompt: 'Write a vegetarian lasagna recipe.',
287
- });
288
- ```
289
-
290
- ## Documentation
291
-
292
- Please check out the **[Google Vertex provider](https://ai-sdk.dev/providers/ai-sdk-providers/google-vertex)** for more information.
33
+ See the [Google Vertex AI Provider documentation](https://ai-sdk.dev/providers/ai-sdk-providers/google-vertex) for more information.
@@ -3,7 +3,7 @@ import { InvalidArgumentError, NoSuchModelError } from "@ai-sdk/provider";
3
3
  import { AnthropicLanguageModel, anthropicTools } from "@ai-sdk/anthropic/internal";
4
4
  import { z } from "zod/v4";
5
5
  //#region src/version.ts
6
- const VERSION = "5.0.121";
6
+ const VERSION = "5.0.123";
7
7
  //#endregion
8
8
  //#region src/edge/google-vertex-auth-edge.ts
9
9
  const loadCredentials = async () => {
@@ -3,7 +3,7 @@ import { GoogleInteractionsLanguageModel, GoogleLanguageModel, GoogleSpeechModel
3
3
  import { AISDKError, InvalidArgumentError, TooManyEmbeddingValuesForCallError } from "@ai-sdk/provider";
4
4
  import { z } from "zod/v4";
5
5
  //#region src/version.ts
6
- const VERSION = "5.0.121";
6
+ const VERSION = "5.0.123";
7
7
  //#endregion
8
8
  //#region src/google-vertex-error.ts
9
9
  const googleVertexErrorDataSchema = lazySchema(() => zodSchema(z.object({ error: z.object({
package/dist/index.js CHANGED
@@ -15,7 +15,7 @@ function createAuthTokenGenerator(options) {
15
15
  }
16
16
  //#endregion
17
17
  //#region src/version.ts
18
- const VERSION = "5.0.121";
18
+ const VERSION = "5.0.123";
19
19
  //#endregion
20
20
  //#region src/google-vertex-error.ts
21
21
  const googleVertexErrorDataSchema = lazySchema(() => zodSchema(z.object({ error: z.object({
@@ -2,7 +2,7 @@ import { getRuntimeEnvironmentUserAgent, isValidHostnamePart, loadOptionalSettin
2
2
  import { InvalidArgumentError } from "@ai-sdk/provider";
3
3
  import { createOpenAICompatible } from "@ai-sdk/openai-compatible";
4
4
  //#region src/version.ts
5
- const VERSION = "5.0.121";
5
+ const VERSION = "5.0.123";
6
6
  //#endregion
7
7
  //#region src/edge/google-vertex-auth-edge.ts
8
8
  const loadCredentials = async () => {
@@ -2,7 +2,7 @@ import { getRuntimeEnvironmentUserAgent, loadOptionalSetting, loadSetting, resol
2
2
  import { NoSuchModelError } from "@ai-sdk/provider";
3
3
  import { createOpenAICompatible } from "@ai-sdk/openai-compatible";
4
4
  //#region src/version.ts
5
- const VERSION = "5.0.121";
5
+ const VERSION = "5.0.123";
6
6
  //#endregion
7
7
  //#region src/edge/google-vertex-auth-edge.ts
8
8
  const loadCredentials = async () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-sdk/google-vertex",
3
- "version": "5.0.121",
3
+ "version": "5.0.123",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "sideEffects": false,
@@ -71,11 +71,11 @@
71
71
  }
72
72
  },
73
73
  "dependencies": {
74
- "@ai-sdk/anthropic": "4.0.87",
75
- "@ai-sdk/google": "4.0.104",
76
- "@ai-sdk/openai-compatible": "3.0.77",
77
- "@ai-sdk/provider": "4.0.33",
78
- "@ai-sdk/provider-utils": "5.0.67",
74
+ "@ai-sdk/anthropic": "4.0.89",
75
+ "@ai-sdk/google": "4.0.106",
76
+ "@ai-sdk/openai-compatible": "3.0.79",
77
+ "@ai-sdk/provider": "4.0.34",
78
+ "@ai-sdk/provider-utils": "5.0.69",
79
79
  "google-auth-library": "^10.6.2"
80
80
  },
81
81
  "devDependencies": {