@ai-sdk/google-vertex 5.0.0-beta.10 → 5.0.0-beta.108

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.
Files changed (80) hide show
  1. package/CHANGELOG.md +930 -8
  2. package/README.md +65 -2
  3. package/dist/anthropic/edge/index.d.ts +18 -151
  4. package/dist/anthropic/edge/index.js +88 -70
  5. package/dist/anthropic/edge/index.js.map +1 -1
  6. package/dist/anthropic/index.d.ts +18 -151
  7. package/dist/anthropic/index.js +88 -81
  8. package/dist/anthropic/index.js.map +1 -1
  9. package/dist/edge/index.d.ts +58 -29
  10. package/dist/edge/index.js +581 -278
  11. package/dist/edge/index.js.map +1 -1
  12. package/dist/index.d.ts +70 -32
  13. package/dist/index.js +590 -296
  14. package/dist/index.js.map +1 -1
  15. package/dist/maas/edge/index.d.ts +76 -0
  16. package/dist/maas/edge/index.js +209 -0
  17. package/dist/maas/edge/index.js.map +1 -0
  18. package/dist/maas/index.d.ts +60 -0
  19. package/dist/maas/index.js +109 -0
  20. package/dist/maas/index.js.map +1 -0
  21. package/dist/xai/edge/index.d.ts +92 -0
  22. package/dist/xai/edge/index.js +259 -0
  23. package/dist/xai/edge/index.js.map +1 -0
  24. package/dist/xai/index.d.ts +76 -0
  25. package/dist/xai/index.js +159 -0
  26. package/dist/xai/index.js.map +1 -0
  27. package/docs/16-google-vertex.mdx +640 -102
  28. package/maas/edge.d.ts +1 -0
  29. package/maas/index.d.ts +1 -0
  30. package/package.json +49 -24
  31. package/src/anthropic/edge/google-vertex-anthropic-provider-edge.ts +17 -13
  32. package/src/anthropic/edge/index.ts +6 -2
  33. package/src/anthropic/{google-vertex-anthropic-messages-options.ts → google-vertex-anthropic-options.ts} +4 -1
  34. package/src/anthropic/google-vertex-anthropic-provider-node.ts +18 -13
  35. package/src/anthropic/google-vertex-anthropic-provider.ts +68 -19
  36. package/src/anthropic/index.ts +6 -2
  37. package/src/edge/google-vertex-provider-edge.ts +10 -12
  38. package/src/edge/index.ts +8 -1
  39. package/src/google-vertex-auth-google-auth-library.ts +13 -26
  40. package/src/google-vertex-config.ts +2 -2
  41. package/src/{google-vertex-embedding-options.ts → google-vertex-embedding-model-options.ts} +1 -0
  42. package/src/google-vertex-embedding-model.ts +35 -10
  43. package/src/google-vertex-image-model-options.ts +74 -0
  44. package/src/google-vertex-image-model.ts +106 -133
  45. package/src/google-vertex-options.ts +1 -1
  46. package/src/google-vertex-provider-base.ts +311 -0
  47. package/src/google-vertex-provider.ts +43 -233
  48. package/src/google-vertex-speech-model-options.ts +11 -0
  49. package/src/google-vertex-transcription-model-options.ts +46 -0
  50. package/src/google-vertex-transcription-model.ts +231 -0
  51. package/src/google-vertex-video-model-options.ts +49 -0
  52. package/src/google-vertex-video-model.ts +39 -75
  53. package/src/index.ts +20 -5
  54. package/src/maas/edge/google-vertex-maas-provider-edge.ts +64 -0
  55. package/src/maas/edge/index.ts +13 -0
  56. package/src/maas/google-vertex-maas-options.ts +15 -0
  57. package/src/maas/google-vertex-maas-provider-node.ts +65 -0
  58. package/src/maas/google-vertex-maas-provider.ts +122 -0
  59. package/src/maas/index.ts +13 -0
  60. package/src/xai/edge/google-vertex-xai-provider-edge.ts +61 -0
  61. package/src/xai/edge/index.ts +9 -0
  62. package/src/xai/google-vertex-xai-options.ts +7 -0
  63. package/src/xai/google-vertex-xai-provider-node.ts +62 -0
  64. package/src/xai/google-vertex-xai-provider.ts +212 -0
  65. package/src/xai/index.ts +9 -0
  66. package/xai/edge.d.ts +1 -0
  67. package/xai/index.d.ts +1 -0
  68. package/dist/anthropic/edge/index.d.mts +0 -231
  69. package/dist/anthropic/edge/index.mjs +0 -259
  70. package/dist/anthropic/edge/index.mjs.map +0 -1
  71. package/dist/anthropic/index.d.mts +0 -215
  72. package/dist/anthropic/index.mjs +0 -164
  73. package/dist/anthropic/index.mjs.map +0 -1
  74. package/dist/edge/index.d.mts +0 -160
  75. package/dist/edge/index.mjs +0 -1049
  76. package/dist/edge/index.mjs.map +0 -1
  77. package/dist/index.d.mts +0 -219
  78. package/dist/index.mjs +0 -960
  79. package/dist/index.mjs.map +0 -1
  80. package/src/google-vertex-provider-node.ts +0 -49
package/README.md CHANGED
@@ -2,7 +2,9 @@
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. This provider closely follows the core Google Vertex library's usage patterns. See more in the [Google Vertex Anthropic Provider](#google-vertex-anthropic-provider) section below.
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
+ > **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).
6
8
 
7
9
  ## Setup
8
10
 
@@ -134,7 +136,6 @@ async function main() {
134
136
 
135
137
  console.log(result.text);
136
138
  console.log(result.providerMetadata?.anthropic);
137
- // e.g. { cacheCreationInputTokens: 2118, cacheReadInputTokens: 0 }
138
139
  }
139
140
 
140
141
  main().catch(console.error);
@@ -224,6 +225,68 @@ const { text } = await generateText({
224
225
  });
225
226
  ```
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
+
227
290
  ## Documentation
228
291
 
229
292
  Please check out the **[Google Vertex provider](https://ai-sdk.dev/providers/ai-sdk-providers/google-vertex)** for more information.
@@ -1,6 +1,6 @@
1
- import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
2
- import { Resolvable, FetchFunction } from '@ai-sdk/provider-utils';
3
1
  import { ProviderV4, LanguageModelV4 } from '@ai-sdk/provider';
2
+ import { Resolvable, FetchFunction } from '@ai-sdk/provider-utils';
3
+ import { anthropicTools } from '@ai-sdk/anthropic/internal';
4
4
 
5
5
  interface GoogleCredentials {
6
6
  /**
@@ -20,170 +20,32 @@ interface GoogleCredentials {
20
20
  privateKeyId?: string;
21
21
  }
22
22
 
23
- type GoogleVertexAnthropicMessagesModelId = 'claude-opus-4-6' | 'claude-sonnet-4-6' | 'claude-opus-4-5@20251101' | 'claude-sonnet-4-5@20250929' | 'claude-opus-4-1@20250805' | 'claude-opus-4@20250514' | 'claude-sonnet-4@20250514' | 'claude-3-7-sonnet@20250219' | 'claude-3-5-sonnet-v2@20241022' | 'claude-3-5-haiku@20241022' | 'claude-3-5-sonnet@20240620' | 'claude-3-haiku@20240307' | 'claude-3-sonnet@20240229' | 'claude-3-opus@20240229' | (string & {});
23
+ type GoogleVertexAnthropicModelId = 'claude-fable-5' | 'claude-opus-4-8' | 'claude-opus-4-7' | 'claude-opus-4-6' | 'claude-sonnet-4-6' | 'claude-opus-4-5@20251101' | 'claude-sonnet-4-5@20250929' | 'claude-opus-4-1@20250805' | 'claude-opus-4@20250514' | 'claude-sonnet-4@20250514' | 'claude-3-7-sonnet@20250219' | 'claude-3-5-sonnet-v2@20241022' | 'claude-3-5-haiku@20241022' | 'claude-3-5-sonnet@20240620' | 'claude-3-haiku@20240307' | 'claude-3-sonnet@20240229' | 'claude-3-opus@20240229' | (string & {});
24
24
 
25
+ type GoogleVertexAnthropicTools = Pick<typeof anthropicTools, 'bash_20241022' | 'bash_20250124' | 'textEditor_20241022' | 'textEditor_20250124' | 'textEditor_20250429' | 'textEditor_20250728' | 'computer_20241022' | 'webSearch_20250305' | 'toolSearchRegex_20251119' | 'toolSearchBm25_20251119'>;
25
26
  /**
26
27
  * Tools supported by Google Vertex Anthropic.
27
28
  * This is a subset of the full Anthropic tools - only these are recognized by the Vertex API.
28
29
  */
29
- declare const vertexAnthropicTools: {
30
- /**
31
- * The bash tool enables Claude to execute shell commands in a persistent bash session,
32
- * allowing system operations, script execution, and command-line automation.
33
- *
34
- * Image results are supported.
35
- */
36
- bash_20241022: _ai_sdk_provider_utils.ProviderToolFactory<{
37
- command: string;
38
- restart?: boolean;
39
- }, {}>;
40
- /**
41
- * The bash tool enables Claude to execute shell commands in a persistent bash session,
42
- * allowing system operations, script execution, and command-line automation.
43
- *
44
- * Image results are supported.
45
- */
46
- bash_20250124: _ai_sdk_provider_utils.ProviderToolFactory<{
47
- command: string;
48
- restart?: boolean;
49
- }, {}>;
50
- /**
51
- * Claude can use an Anthropic-defined text editor tool to view and modify text files,
52
- * helping you debug, fix, and improve your code or other text documents.
53
- *
54
- * Supported models: Claude Sonnet 3.5
55
- */
56
- textEditor_20241022: _ai_sdk_provider_utils.ProviderToolFactory<{
57
- command: "view" | "create" | "str_replace" | "insert" | "undo_edit";
58
- path: string;
59
- file_text?: string;
60
- insert_line?: number;
61
- new_str?: string;
62
- insert_text?: string;
63
- old_str?: string;
64
- view_range?: number[];
65
- }, {}>;
66
- /**
67
- * Claude can use an Anthropic-defined text editor tool to view and modify text files,
68
- * helping you debug, fix, and improve your code or other text documents.
69
- *
70
- * Supported models: Claude Sonnet 3.7
71
- */
72
- textEditor_20250124: _ai_sdk_provider_utils.ProviderToolFactory<{
73
- command: "view" | "create" | "str_replace" | "insert" | "undo_edit";
74
- path: string;
75
- file_text?: string;
76
- insert_line?: number;
77
- new_str?: string;
78
- insert_text?: string;
79
- old_str?: string;
80
- view_range?: number[];
81
- }, {}>;
82
- /**
83
- * Claude can use an Anthropic-defined text editor tool to view and modify text files.
84
- * Note: This version does not support the "undo_edit" command.
85
- * @deprecated Use textEditor_20250728 instead
86
- */
87
- textEditor_20250429: _ai_sdk_provider_utils.ProviderToolFactory<{
88
- command: "view" | "create" | "str_replace" | "insert";
89
- path: string;
90
- file_text?: string;
91
- insert_line?: number;
92
- new_str?: string;
93
- insert_text?: string;
94
- old_str?: string;
95
- view_range?: number[];
96
- }, {}>;
97
- /**
98
- * Claude can use an Anthropic-defined text editor tool to view and modify text files.
99
- * Note: This version does not support the "undo_edit" command and adds optional max_characters parameter.
100
- * Supported models: Claude Sonnet 4, Opus 4, and Opus 4.1
101
- */
102
- textEditor_20250728: (args?: Parameters<_ai_sdk_provider_utils.ProviderToolFactory<{
103
- command: "view" | "create" | "str_replace" | "insert";
104
- path: string;
105
- file_text?: string;
106
- insert_line?: number;
107
- new_str?: string;
108
- insert_text?: string;
109
- old_str?: string;
110
- view_range?: number[];
111
- }, {
112
- maxCharacters?: number;
113
- }>>[0]) => _ai_sdk_provider_utils.Tool<{
114
- command: "view" | "create" | "str_replace" | "insert";
115
- path: string;
116
- file_text?: string;
117
- insert_line?: number;
118
- new_str?: string;
119
- insert_text?: string;
120
- old_str?: string;
121
- view_range?: number[];
122
- }, unknown>;
123
- /**
124
- * Claude can interact with computer environments through the computer use tool, which
125
- * provides screenshot capabilities and mouse/keyboard control for autonomous desktop interaction.
126
- *
127
- * Image results are supported.
128
- */
129
- computer_20241022: _ai_sdk_provider_utils.ProviderToolFactory<{
130
- action: "key" | "type" | "mouse_move" | "left_click" | "left_click_drag" | "right_click" | "middle_click" | "double_click" | "screenshot" | "cursor_position";
131
- coordinate?: number[];
132
- text?: string;
133
- }, {
134
- displayWidthPx: number;
135
- displayHeightPx: number;
136
- displayNumber?: number;
137
- }>;
138
- /**
139
- * Creates a web search tool that gives Claude direct access to real-time web content.
140
- */
141
- webSearch_20250305: (args?: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<{
142
- query: string;
143
- }, {
144
- type: "web_search_result";
145
- url: string;
146
- title: string | null;
147
- pageAge: string | null;
148
- encryptedContent: string;
149
- }[], {
150
- maxUses?: number;
151
- allowedDomains?: string[];
152
- blockedDomains?: string[];
153
- userLocation?: {
154
- type: "approximate";
155
- city?: string;
156
- region?: string;
157
- country?: string;
158
- timezone?: string;
159
- };
160
- }>>[0]) => _ai_sdk_provider_utils.Tool<{
161
- query: string;
162
- }, {
163
- type: "web_search_result";
164
- url: string;
165
- title: string | null;
166
- pageAge: string | null;
167
- encryptedContent: string;
168
- }[]>;
169
- };
30
+ declare const googleVertexAnthropicTools: GoogleVertexAnthropicTools;
170
31
  interface GoogleVertexAnthropicProvider extends ProviderV4 {
171
32
  /**
172
33
  * Creates a model for text generation.
173
34
  */
174
- (modelId: GoogleVertexAnthropicMessagesModelId): LanguageModelV4;
35
+ (modelId: GoogleVertexAnthropicModelId): LanguageModelV4;
175
36
  /**
176
37
  * Creates a model for text generation.
177
38
  */
178
- languageModel(modelId: GoogleVertexAnthropicMessagesModelId): LanguageModelV4;
39
+ languageModel(modelId: GoogleVertexAnthropicModelId): LanguageModelV4;
179
40
  /**
180
41
  * Anthropic tools supported by Google Vertex.
181
42
  * Note: Only a subset of Anthropic tools are available on Vertex.
182
43
  * Supported tools: bash_20241022, bash_20250124, textEditor_20241022,
183
44
  * textEditor_20250124, textEditor_20250429, textEditor_20250728,
184
- * computer_20241022, webSearch_20250305
45
+ * computer_20241022, webSearch_20250305, toolSearchRegex_20251119,
46
+ * toolSearchBm25_20251119
185
47
  */
186
- tools: typeof vertexAnthropicTools;
48
+ tools: typeof googleVertexAnthropicTools;
187
49
  /**
188
50
  * @deprecated Use `embeddingModel` instead.
189
51
  */
@@ -221,11 +83,16 @@ interface GoogleVertexAnthropicProviderSettings extends GoogleVertexAnthropicPro
221
83
  * load the credentials.
222
84
  */
223
85
  googleCredentials?: GoogleCredentials;
86
+ /**
87
+ * Optional. Override the Bearer token generator. Defaults to OAuth exchange
88
+ * with `googleCredentials`.
89
+ */
90
+ generateAuthToken?: () => Promise<string>;
224
91
  }
225
- declare function createVertexAnthropic(options?: GoogleVertexAnthropicProviderSettings): GoogleVertexAnthropicProvider;
92
+ declare function createGoogleVertexAnthropic(options?: GoogleVertexAnthropicProviderSettings): GoogleVertexAnthropicProvider;
226
93
  /**
227
94
  * Default Google Vertex AI Anthropic provider instance.
228
95
  */
229
- declare const vertexAnthropic: GoogleVertexAnthropicProvider;
96
+ declare const googleVertexAnthropic: GoogleVertexAnthropicProvider;
230
97
 
231
- export { type GoogleVertexAnthropicProvider, type GoogleVertexAnthropicProviderSettings, createVertexAnthropic, vertexAnthropic };
98
+ export { type GoogleVertexAnthropicProvider, type GoogleVertexAnthropicProviderSettings, createGoogleVertexAnthropic, createGoogleVertexAnthropic as createVertexAnthropic, googleVertexAnthropic, googleVertexAnthropic as vertexAnthropic };
@@ -1,56 +1,34 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/anthropic/edge/index.ts
21
- var edge_exports = {};
22
- __export(edge_exports, {
23
- createVertexAnthropic: () => createVertexAnthropic2,
24
- vertexAnthropic: () => vertexAnthropic
25
- });
26
- module.exports = __toCommonJS(edge_exports);
27
-
28
1
  // src/anthropic/edge/google-vertex-anthropic-provider-edge.ts
29
- var import_provider_utils3 = require("@ai-sdk/provider-utils");
2
+ import { resolve } from "@ai-sdk/provider-utils";
30
3
 
31
4
  // src/edge/google-vertex-auth-edge.ts
32
- var import_provider_utils = require("@ai-sdk/provider-utils");
5
+ import {
6
+ loadOptionalSetting,
7
+ loadSetting,
8
+ withUserAgentSuffix,
9
+ getRuntimeEnvironmentUserAgent
10
+ } from "@ai-sdk/provider-utils";
33
11
 
34
12
  // src/version.ts
35
- var VERSION = true ? "5.0.0-beta.10" : "0.0.0-test";
13
+ var VERSION = true ? "5.0.0-beta.108" : "0.0.0-test";
36
14
 
37
15
  // src/edge/google-vertex-auth-edge.ts
38
16
  var loadCredentials = async () => {
39
17
  try {
40
18
  return {
41
- clientEmail: (0, import_provider_utils.loadSetting)({
19
+ clientEmail: loadSetting({
42
20
  settingValue: void 0,
43
21
  settingName: "clientEmail",
44
22
  environmentVariableName: "GOOGLE_CLIENT_EMAIL",
45
23
  description: "Google client email"
46
24
  }),
47
- privateKey: (0, import_provider_utils.loadSetting)({
25
+ privateKey: loadSetting({
48
26
  settingValue: void 0,
49
27
  settingName: "privateKey",
50
28
  environmentVariableName: "GOOGLE_PRIVATE_KEY",
51
29
  description: "Google private key"
52
30
  }),
53
- privateKeyId: (0, import_provider_utils.loadOptionalSetting)({
31
+ privateKeyId: loadOptionalSetting({
54
32
  settingValue: void 0,
55
33
  environmentVariableName: "GOOGLE_PRIVATE_KEY_ID"
56
34
  })
@@ -119,10 +97,10 @@ async function generateAuthToken(credentials) {
119
97
  const jwt = await buildJwt(creds);
120
98
  const response = await fetch("https://oauth2.googleapis.com/token", {
121
99
  method: "POST",
122
- headers: (0, import_provider_utils.withUserAgentSuffix)(
100
+ headers: withUserAgentSuffix(
123
101
  { "Content-Type": "application/x-www-form-urlencoded" },
124
102
  `ai-sdk/google-vertex/${VERSION}`,
125
- (0, import_provider_utils.getRuntimeEnvironmentUserAgent)()
103
+ getRuntimeEnvironmentUserAgent()
126
104
  ),
127
105
  body: new URLSearchParams({
128
106
  grant_type: "urn:ietf:params:oauth:grant-type:jwt-bearer",
@@ -140,85 +118,122 @@ async function generateAuthToken(credentials) {
140
118
  }
141
119
 
142
120
  // src/anthropic/google-vertex-anthropic-provider.ts
143
- var import_provider = require("@ai-sdk/provider");
144
- var import_provider_utils2 = require("@ai-sdk/provider-utils");
145
- var import_internal = require("@ai-sdk/anthropic/internal");
146
- var vertexAnthropicTools = {
121
+ import {
122
+ NoSuchModelError
123
+ } from "@ai-sdk/provider";
124
+ import {
125
+ loadOptionalSetting as loadOptionalSetting2,
126
+ withoutTrailingSlash
127
+ } from "@ai-sdk/provider-utils";
128
+ import {
129
+ anthropicTools,
130
+ AnthropicLanguageModel
131
+ } from "@ai-sdk/anthropic/internal";
132
+ var googleVertexAnthropicTools = {
147
133
  /**
148
134
  * The bash tool enables Claude to execute shell commands in a persistent bash session,
149
135
  * allowing system operations, script execution, and command-line automation.
150
136
  *
151
137
  * Image results are supported.
152
138
  */
153
- bash_20241022: import_internal.anthropicTools.bash_20241022,
139
+ bash_20241022: anthropicTools.bash_20241022,
154
140
  /**
155
141
  * The bash tool enables Claude to execute shell commands in a persistent bash session,
156
142
  * allowing system operations, script execution, and command-line automation.
157
143
  *
158
144
  * Image results are supported.
159
145
  */
160
- bash_20250124: import_internal.anthropicTools.bash_20250124,
146
+ bash_20250124: anthropicTools.bash_20250124,
161
147
  /**
162
148
  * Claude can use an Anthropic-defined text editor tool to view and modify text files,
163
149
  * helping you debug, fix, and improve your code or other text documents.
164
150
  *
165
151
  * Supported models: Claude Sonnet 3.5
166
152
  */
167
- textEditor_20241022: import_internal.anthropicTools.textEditor_20241022,
153
+ textEditor_20241022: anthropicTools.textEditor_20241022,
168
154
  /**
169
155
  * Claude can use an Anthropic-defined text editor tool to view and modify text files,
170
156
  * helping you debug, fix, and improve your code or other text documents.
171
157
  *
172
158
  * Supported models: Claude Sonnet 3.7
173
159
  */
174
- textEditor_20250124: import_internal.anthropicTools.textEditor_20250124,
160
+ textEditor_20250124: anthropicTools.textEditor_20250124,
175
161
  /**
176
162
  * Claude can use an Anthropic-defined text editor tool to view and modify text files.
177
163
  * Note: This version does not support the "undo_edit" command.
178
164
  * @deprecated Use textEditor_20250728 instead
179
165
  */
180
- textEditor_20250429: import_internal.anthropicTools.textEditor_20250429,
166
+ textEditor_20250429: anthropicTools.textEditor_20250429,
181
167
  /**
182
168
  * Claude can use an Anthropic-defined text editor tool to view and modify text files.
183
169
  * Note: This version does not support the "undo_edit" command and adds optional max_characters parameter.
184
170
  * Supported models: Claude Sonnet 4, Opus 4, and Opus 4.1
185
171
  */
186
- textEditor_20250728: import_internal.anthropicTools.textEditor_20250728,
172
+ textEditor_20250728: anthropicTools.textEditor_20250728,
187
173
  /**
188
174
  * Claude can interact with computer environments through the computer use tool, which
189
175
  * provides screenshot capabilities and mouse/keyboard control for autonomous desktop interaction.
190
176
  *
191
177
  * Image results are supported.
192
178
  */
193
- computer_20241022: import_internal.anthropicTools.computer_20241022,
179
+ computer_20241022: anthropicTools.computer_20241022,
194
180
  /**
195
181
  * Creates a web search tool that gives Claude direct access to real-time web content.
196
182
  */
197
- webSearch_20250305: import_internal.anthropicTools.webSearch_20250305
183
+ webSearch_20250305: anthropicTools.webSearch_20250305,
184
+ /**
185
+ * Creates a tool search tool that uses regex patterns to find tools.
186
+ *
187
+ * The tool search tool enables Claude to work with hundreds or thousands of tools
188
+ * by dynamically discovering and loading them on-demand.
189
+ *
190
+ * Use `providerOptions: { anthropic: { deferLoading: true } }` on other tools
191
+ * to mark them for deferred loading.
192
+ */
193
+ toolSearchRegex_20251119: anthropicTools.toolSearchRegex_20251119,
194
+ /**
195
+ * Creates a tool search tool that uses BM25 (natural language) to find tools.
196
+ *
197
+ * The tool search tool enables Claude to work with hundreds or thousands of tools
198
+ * by dynamically discovering and loading them on-demand.
199
+ *
200
+ * Use `providerOptions: { anthropic: { deferLoading: true } }` on other tools
201
+ * to mark them for deferred loading.
202
+ */
203
+ toolSearchBm25_20251119: anthropicTools.toolSearchBm25_20251119
198
204
  };
199
- function createVertexAnthropic(options = {}) {
205
+ function createGoogleVertexAnthropic(options = {}) {
200
206
  const getBaseURL = () => {
201
207
  var _a;
202
- const location = (0, import_provider_utils2.loadOptionalSetting)({
208
+ const location = loadOptionalSetting2({
203
209
  settingValue: options.location,
204
210
  environmentVariableName: "GOOGLE_VERTEX_LOCATION"
205
211
  });
206
- const project = (0, import_provider_utils2.loadOptionalSetting)({
212
+ const project = loadOptionalSetting2({
207
213
  settingValue: options.project,
208
214
  environmentVariableName: "GOOGLE_VERTEX_PROJECT"
209
215
  });
210
- return (_a = (0, import_provider_utils2.withoutTrailingSlash)(options.baseURL)) != null ? _a : `https://${location === "global" ? "" : location + "-"}aiplatform.googleapis.com/v1/projects/${project}/locations/${location}/publishers/anthropic/models`;
216
+ const getHost = () => {
217
+ if (location === "global") {
218
+ return "aiplatform.googleapis.com";
219
+ } else if (location === "eu" || location === "us") {
220
+ return `aiplatform.${location}.rep.googleapis.com`;
221
+ } else {
222
+ return `${location}-aiplatform.googleapis.com`;
223
+ }
224
+ };
225
+ return (_a = withoutTrailingSlash(options.baseURL)) != null ? _a : `https://${getHost()}/v1/projects/${project}/locations/${location}/publishers/anthropic/models`;
211
226
  };
212
227
  const createChatModel = (modelId) => {
213
228
  var _a;
214
- return new import_internal.AnthropicMessagesLanguageModel(modelId, {
215
- provider: "vertex.anthropic.messages",
229
+ return new AnthropicLanguageModel(modelId, {
230
+ provider: "googleVertex.anthropic.messages",
216
231
  baseURL: getBaseURL(),
217
232
  headers: (_a = options.headers) != null ? _a : {},
218
233
  fetch: options.fetch,
219
234
  buildRequestUrl: (baseURL, isStreaming) => `${baseURL}/${modelId}:${isStreaming ? "streamRawPredict" : "rawPredict"}`,
220
235
  transformRequestBody: (args) => {
221
- const { model, ...rest } = args;
236
+ const { model: _model, ...rest } = args;
222
237
  return {
223
238
  ...rest,
224
239
  anthropic_version: "vertex-2023-10-16"
@@ -227,7 +242,9 @@ function createVertexAnthropic(options = {}) {
227
242
  // Google Vertex Anthropic doesn't support URL sources, force download and base64 conversion
228
243
  supportedUrls: () => ({}),
229
244
  // force the use of JSON tool fallback for structured outputs since beta header isn't supported
230
- supportsNativeStructuredOutput: false
245
+ supportsNativeStructuredOutput: false,
246
+ // Vertex Anthropic doesn't support strict mode on tool definitions.
247
+ supportsStrictTools: false
231
248
  });
232
249
  };
233
250
  const provider = function(modelId) {
@@ -243,32 +260,33 @@ function createVertexAnthropic(options = {}) {
243
260
  provider.chat = createChatModel;
244
261
  provider.messages = createChatModel;
245
262
  provider.embeddingModel = (modelId) => {
246
- throw new import_provider.NoSuchModelError({ modelId, modelType: "embeddingModel" });
263
+ throw new NoSuchModelError({ modelId, modelType: "embeddingModel" });
247
264
  };
248
265
  provider.textEmbeddingModel = provider.embeddingModel;
249
266
  provider.imageModel = (modelId) => {
250
- throw new import_provider.NoSuchModelError({ modelId, modelType: "imageModel" });
267
+ throw new NoSuchModelError({ modelId, modelType: "imageModel" });
251
268
  };
252
- provider.tools = vertexAnthropicTools;
269
+ provider.tools = googleVertexAnthropicTools;
253
270
  return provider;
254
271
  }
255
272
 
256
273
  // src/anthropic/edge/google-vertex-anthropic-provider-edge.ts
257
- function createVertexAnthropic2(options = {}) {
258
- return createVertexAnthropic({
274
+ function createGoogleVertexAnthropic2(options = {}) {
275
+ var _a;
276
+ const generateAuthToken2 = (_a = options.generateAuthToken) != null ? _a : (() => generateAuthToken(options.googleCredentials));
277
+ return createGoogleVertexAnthropic({
259
278
  ...options,
260
279
  headers: async () => ({
261
- Authorization: `Bearer ${await generateAuthToken(
262
- options.googleCredentials
263
- )}`,
264
- ...await (0, import_provider_utils3.resolve)(options.headers)
280
+ Authorization: `Bearer ${await generateAuthToken2()}`,
281
+ ...await resolve(options.headers)
265
282
  })
266
283
  });
267
284
  }
268
- var vertexAnthropic = createVertexAnthropic2();
269
- // Annotate the CommonJS export names for ESM import in node:
270
- 0 && (module.exports = {
271
- createVertexAnthropic,
272
- vertexAnthropic
273
- });
285
+ var googleVertexAnthropic = createGoogleVertexAnthropic2();
286
+ export {
287
+ createGoogleVertexAnthropic2 as createGoogleVertexAnthropic,
288
+ createGoogleVertexAnthropic2 as createVertexAnthropic,
289
+ googleVertexAnthropic,
290
+ googleVertexAnthropic as vertexAnthropic
291
+ };
274
292
  //# sourceMappingURL=index.js.map