@ai-sdk/google-vertex 5.0.0-beta.2 → 5.0.0-beta.20

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 (37) hide show
  1. package/CHANGELOG.md +153 -8
  2. package/dist/anthropic/edge/index.d.mts +50 -5
  3. package/dist/anthropic/edge/index.d.ts +50 -5
  4. package/dist/anthropic/edge/index.js +29 -7
  5. package/dist/anthropic/edge/index.js.map +1 -1
  6. package/dist/anthropic/edge/index.mjs +26 -4
  7. package/dist/anthropic/edge/index.mjs.map +1 -1
  8. package/dist/anthropic/index.d.mts +50 -5
  9. package/dist/anthropic/index.d.ts +50 -5
  10. package/dist/anthropic/index.js +28 -6
  11. package/dist/anthropic/index.js.map +1 -1
  12. package/dist/anthropic/index.mjs +25 -3
  13. package/dist/anthropic/index.mjs.map +1 -1
  14. package/dist/edge/index.d.mts +12 -12
  15. package/dist/edge/index.d.ts +12 -12
  16. package/dist/edge/index.js +8 -8
  17. package/dist/edge/index.js.map +1 -1
  18. package/dist/edge/index.mjs +5 -5
  19. package/dist/edge/index.mjs.map +1 -1
  20. package/dist/index.d.mts +12 -12
  21. package/dist/index.d.ts +12 -12
  22. package/dist/index.js +8 -8
  23. package/dist/index.js.map +1 -1
  24. package/dist/index.mjs +5 -5
  25. package/dist/index.mjs.map +1 -1
  26. package/docs/16-google-vertex.mdx +10 -3
  27. package/package.json +5 -7
  28. package/src/anthropic/edge/google-vertex-anthropic-provider-edge.ts +1 -2
  29. package/src/anthropic/google-vertex-anthropic-provider-node.ts +1 -2
  30. package/src/anthropic/google-vertex-anthropic-provider.ts +32 -7
  31. package/src/edge/google-vertex-provider-edge.ts +1 -2
  32. package/src/google-vertex-embedding-model.ts +5 -5
  33. package/src/google-vertex-embedding-options.ts +2 -0
  34. package/src/google-vertex-image-model.ts +17 -17
  35. package/src/google-vertex-provider-node.ts +1 -2
  36. package/src/google-vertex-provider.ts +12 -12
  37. package/src/google-vertex-video-model.ts +7 -7
package/CHANGELOG.md CHANGED
@@ -1,5 +1,150 @@
1
1
  # @ai-sdk/google-vertex
2
2
 
3
+ ## 5.0.0-beta.20
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [18c1970]
8
+ - @ai-sdk/google@4.0.0-beta.15
9
+
10
+ ## 5.0.0-beta.19
11
+
12
+ ### Patch Changes
13
+
14
+ - Updated dependencies [3887c70]
15
+ - @ai-sdk/provider-utils@5.0.0-beta.6
16
+ - @ai-sdk/anthropic@4.0.0-beta.10
17
+ - @ai-sdk/provider@4.0.0-beta.4
18
+ - @ai-sdk/google@4.0.0-beta.14
19
+
20
+ ## 5.0.0-beta.18
21
+
22
+ ### Patch Changes
23
+
24
+ - Updated dependencies [776b617]
25
+ - @ai-sdk/provider-utils@5.0.0-beta.5
26
+ - @ai-sdk/provider@4.0.0-beta.3
27
+ - @ai-sdk/anthropic@4.0.0-beta.9
28
+ - @ai-sdk/google@4.0.0-beta.13
29
+
30
+ ## 5.0.0-beta.17
31
+
32
+ ### Patch Changes
33
+
34
+ - Updated dependencies [61753c3]
35
+ - @ai-sdk/provider-utils@5.0.0-beta.4
36
+ - @ai-sdk/anthropic@4.0.0-beta.8
37
+ - @ai-sdk/google@4.0.0-beta.12
38
+
39
+ ## 5.0.0-beta.16
40
+
41
+ ### Patch Changes
42
+
43
+ - ebb02ea: feat(google-vertex): add the anthropic tool search tools
44
+
45
+ ## 5.0.0-beta.15
46
+
47
+ ### Patch Changes
48
+
49
+ - Updated dependencies [f7d4f01]
50
+ - @ai-sdk/provider-utils@5.0.0-beta.3
51
+ - @ai-sdk/provider@4.0.0-beta.2
52
+ - @ai-sdk/google@4.0.0-beta.11
53
+ - @ai-sdk/anthropic@4.0.0-beta.7
54
+
55
+ ## 5.0.0-beta.14
56
+
57
+ ### Patch Changes
58
+
59
+ - Updated dependencies [21d1ee3]
60
+ - @ai-sdk/anthropic@4.0.0-beta.6
61
+
62
+ ## 5.0.0-beta.13
63
+
64
+ ### Patch Changes
65
+
66
+ - Updated dependencies [5c2a5a2]
67
+ - @ai-sdk/provider@4.0.0-beta.1
68
+ - @ai-sdk/anthropic@4.0.0-beta.5
69
+ - @ai-sdk/google@4.0.0-beta.10
70
+ - @ai-sdk/provider-utils@5.0.0-beta.2
71
+
72
+ ## 5.0.0-beta.12
73
+
74
+ ### Patch Changes
75
+
76
+ - f05a40d: fix(vertex): throw warning when strict: true for vertexAnthropic
77
+ - Updated dependencies [f05a40d]
78
+ - @ai-sdk/anthropic@4.0.0-beta.4
79
+
80
+ ## 5.0.0-beta.11
81
+
82
+ ### Patch Changes
83
+
84
+ - e59176c: chore(google): update v3 specs to v4
85
+ - Updated dependencies [e59176c]
86
+ - @ai-sdk/google@4.0.0-beta.9
87
+
88
+ ## 5.0.0-beta.10
89
+
90
+ ### Patch Changes
91
+
92
+ - e748b35: chore: update v3 specs to v4
93
+ - Updated dependencies [e748b35]
94
+ - @ai-sdk/anthropic@4.0.0-beta.3
95
+
96
+ ## 5.0.0-beta.9
97
+
98
+ ### Patch Changes
99
+
100
+ - Updated dependencies [4dac142]
101
+ - @ai-sdk/google@4.0.0-beta.8
102
+
103
+ ## 5.0.0-beta.8
104
+
105
+ ### Patch Changes
106
+
107
+ - 82288b0: feat(provider/google): add `gemini-embedding-2-preview` and fix multimodal embedding support with `embedMany`
108
+ - Updated dependencies [82288b0]
109
+ - @ai-sdk/google@4.0.0-beta.7
110
+
111
+ ## 5.0.0-beta.7
112
+
113
+ ### Patch Changes
114
+
115
+ - Updated dependencies [add4326]
116
+ - @ai-sdk/google@4.0.0-beta.6
117
+
118
+ ## 5.0.0-beta.6
119
+
120
+ ### Patch Changes
121
+
122
+ - Updated dependencies [ab43029]
123
+ - @ai-sdk/google@4.0.0-beta.5
124
+
125
+ ## 5.0.0-beta.5
126
+
127
+ ### Patch Changes
128
+
129
+ - Updated dependencies [2edd14e]
130
+ - @ai-sdk/google@4.0.0-beta.4
131
+
132
+ ## 5.0.0-beta.4
133
+
134
+ ### Patch Changes
135
+
136
+ - Updated dependencies [1fe058b]
137
+ - @ai-sdk/anthropic@4.0.0-beta.2
138
+
139
+ ## 5.0.0-beta.3
140
+
141
+ ### Patch Changes
142
+
143
+ - Updated dependencies [531251e]
144
+ - @ai-sdk/provider-utils@5.0.0-beta.1
145
+ - @ai-sdk/anthropic@4.0.0-beta.1
146
+ - @ai-sdk/google@4.0.0-beta.3
147
+
3
148
  ## 5.0.0-beta.2
4
149
 
5
150
  ### Patch Changes
@@ -672,13 +817,13 @@
672
817
  Before
673
818
 
674
819
  ```ts
675
- model.textEmbeddingModel('my-model-id');
820
+ model.textEmbeddingModel("my-model-id");
676
821
  ```
677
822
 
678
823
  After
679
824
 
680
825
  ```ts
681
- model.embeddingModel('my-model-id');
826
+ model.embeddingModel("my-model-id");
682
827
  ```
683
828
 
684
829
  - 32a6c13: Add Google Maps grounding tool support for location-aware Gemini responses
@@ -1162,13 +1307,13 @@
1162
1307
  Before
1163
1308
 
1164
1309
  ```ts
1165
- model.textEmbeddingModel('my-model-id');
1310
+ model.textEmbeddingModel("my-model-id");
1166
1311
  ```
1167
1312
 
1168
1313
  After
1169
1314
 
1170
1315
  ```ts
1171
- model.embeddingModel('my-model-id');
1316
+ model.embeddingModel("my-model-id");
1172
1317
  ```
1173
1318
 
1174
1319
  - Updated dependencies [8d9e8ad]
@@ -2123,7 +2268,7 @@
2123
2268
 
2124
2269
  ```js
2125
2270
  await generateImage({
2126
- model: luma.image('photon-flash-1', {
2271
+ model: luma.image("photon-flash-1", {
2127
2272
  maxImagesPerCall: 5,
2128
2273
  pollIntervalMillis: 500,
2129
2274
  }),
@@ -2136,7 +2281,7 @@
2136
2281
 
2137
2282
  ```js
2138
2283
  await generateImage({
2139
- model: luma.image('photon-flash-1'),
2284
+ model: luma.image("photon-flash-1"),
2140
2285
  prompt,
2141
2286
  n: 10,
2142
2287
  maxImagesPerCall: 5,
@@ -2526,7 +2671,7 @@
2526
2671
 
2527
2672
  ```js
2528
2673
  await generateImage({
2529
- model: luma.image('photon-flash-1', {
2674
+ model: luma.image("photon-flash-1", {
2530
2675
  maxImagesPerCall: 5,
2531
2676
  pollIntervalMillis: 500,
2532
2677
  }),
@@ -2539,7 +2684,7 @@
2539
2684
 
2540
2685
  ```js
2541
2686
  await generateImage({
2542
- model: luma.image('photon-flash-1'),
2687
+ model: luma.image("photon-flash-1"),
2543
2688
  prompt,
2544
2689
  n: 10,
2545
2690
  maxImagesPerCall: 5,
@@ -1,6 +1,6 @@
1
1
  import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
2
2
  import { Resolvable, FetchFunction } from '@ai-sdk/provider-utils';
3
- import { ProviderV3, LanguageModelV3 } from '@ai-sdk/provider';
3
+ import { ProviderV4, LanguageModelV4 } from '@ai-sdk/provider';
4
4
 
5
5
  interface GoogleCredentials {
6
6
  /**
@@ -166,22 +166,67 @@ declare const vertexAnthropicTools: {
166
166
  pageAge: string | null;
167
167
  encryptedContent: string;
168
168
  }[]>;
169
+ /**
170
+ * Creates a tool search tool that uses regex patterns to find tools.
171
+ *
172
+ * The tool search tool enables Claude to work with hundreds or thousands of tools
173
+ * by dynamically discovering and loading them on-demand.
174
+ *
175
+ * Use `providerOptions: { anthropic: { deferLoading: true } }` on other tools
176
+ * to mark them for deferred loading.
177
+ */
178
+ toolSearchRegex_20251119: (args?: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<{
179
+ pattern: string;
180
+ limit?: number;
181
+ }, {
182
+ type: "tool_reference";
183
+ toolName: string;
184
+ }[], {}>>[0]) => _ai_sdk_provider_utils.Tool<{
185
+ pattern: string;
186
+ limit?: number;
187
+ }, {
188
+ type: "tool_reference";
189
+ toolName: string;
190
+ }[]>;
191
+ /**
192
+ * Creates a tool search tool that uses BM25 (natural language) to find tools.
193
+ *
194
+ * The tool search tool enables Claude to work with hundreds or thousands of tools
195
+ * by dynamically discovering and loading them on-demand.
196
+ *
197
+ * Use `providerOptions: { anthropic: { deferLoading: true } }` on other tools
198
+ * to mark them for deferred loading.
199
+ */
200
+ toolSearchBm25_20251119: (args?: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<{
201
+ query: string;
202
+ limit?: number;
203
+ }, {
204
+ type: "tool_reference";
205
+ toolName: string;
206
+ }[], {}>>[0]) => _ai_sdk_provider_utils.Tool<{
207
+ query: string;
208
+ limit?: number;
209
+ }, {
210
+ type: "tool_reference";
211
+ toolName: string;
212
+ }[]>;
169
213
  };
170
- interface GoogleVertexAnthropicProvider extends ProviderV3 {
214
+ interface GoogleVertexAnthropicProvider extends ProviderV4 {
171
215
  /**
172
216
  * Creates a model for text generation.
173
217
  */
174
- (modelId: GoogleVertexAnthropicMessagesModelId): LanguageModelV3;
218
+ (modelId: GoogleVertexAnthropicMessagesModelId): LanguageModelV4;
175
219
  /**
176
220
  * Creates a model for text generation.
177
221
  */
178
- languageModel(modelId: GoogleVertexAnthropicMessagesModelId): LanguageModelV3;
222
+ languageModel(modelId: GoogleVertexAnthropicMessagesModelId): LanguageModelV4;
179
223
  /**
180
224
  * Anthropic tools supported by Google Vertex.
181
225
  * Note: Only a subset of Anthropic tools are available on Vertex.
182
226
  * Supported tools: bash_20241022, bash_20250124, textEditor_20241022,
183
227
  * textEditor_20250124, textEditor_20250429, textEditor_20250728,
184
- * computer_20241022, webSearch_20250305
228
+ * computer_20241022, webSearch_20250305, toolSearchRegex_20251119,
229
+ * toolSearchBm25_20251119
185
230
  */
186
231
  tools: typeof vertexAnthropicTools;
187
232
  /**
@@ -1,6 +1,6 @@
1
1
  import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
2
2
  import { Resolvable, FetchFunction } from '@ai-sdk/provider-utils';
3
- import { ProviderV3, LanguageModelV3 } from '@ai-sdk/provider';
3
+ import { ProviderV4, LanguageModelV4 } from '@ai-sdk/provider';
4
4
 
5
5
  interface GoogleCredentials {
6
6
  /**
@@ -166,22 +166,67 @@ declare const vertexAnthropicTools: {
166
166
  pageAge: string | null;
167
167
  encryptedContent: string;
168
168
  }[]>;
169
+ /**
170
+ * Creates a tool search tool that uses regex patterns to find tools.
171
+ *
172
+ * The tool search tool enables Claude to work with hundreds or thousands of tools
173
+ * by dynamically discovering and loading them on-demand.
174
+ *
175
+ * Use `providerOptions: { anthropic: { deferLoading: true } }` on other tools
176
+ * to mark them for deferred loading.
177
+ */
178
+ toolSearchRegex_20251119: (args?: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<{
179
+ pattern: string;
180
+ limit?: number;
181
+ }, {
182
+ type: "tool_reference";
183
+ toolName: string;
184
+ }[], {}>>[0]) => _ai_sdk_provider_utils.Tool<{
185
+ pattern: string;
186
+ limit?: number;
187
+ }, {
188
+ type: "tool_reference";
189
+ toolName: string;
190
+ }[]>;
191
+ /**
192
+ * Creates a tool search tool that uses BM25 (natural language) to find tools.
193
+ *
194
+ * The tool search tool enables Claude to work with hundreds or thousands of tools
195
+ * by dynamically discovering and loading them on-demand.
196
+ *
197
+ * Use `providerOptions: { anthropic: { deferLoading: true } }` on other tools
198
+ * to mark them for deferred loading.
199
+ */
200
+ toolSearchBm25_20251119: (args?: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<{
201
+ query: string;
202
+ limit?: number;
203
+ }, {
204
+ type: "tool_reference";
205
+ toolName: string;
206
+ }[], {}>>[0]) => _ai_sdk_provider_utils.Tool<{
207
+ query: string;
208
+ limit?: number;
209
+ }, {
210
+ type: "tool_reference";
211
+ toolName: string;
212
+ }[]>;
169
213
  };
170
- interface GoogleVertexAnthropicProvider extends ProviderV3 {
214
+ interface GoogleVertexAnthropicProvider extends ProviderV4 {
171
215
  /**
172
216
  * Creates a model for text generation.
173
217
  */
174
- (modelId: GoogleVertexAnthropicMessagesModelId): LanguageModelV3;
218
+ (modelId: GoogleVertexAnthropicMessagesModelId): LanguageModelV4;
175
219
  /**
176
220
  * Creates a model for text generation.
177
221
  */
178
- languageModel(modelId: GoogleVertexAnthropicMessagesModelId): LanguageModelV3;
222
+ languageModel(modelId: GoogleVertexAnthropicMessagesModelId): LanguageModelV4;
179
223
  /**
180
224
  * Anthropic tools supported by Google Vertex.
181
225
  * Note: Only a subset of Anthropic tools are available on Vertex.
182
226
  * Supported tools: bash_20241022, bash_20250124, textEditor_20241022,
183
227
  * textEditor_20250124, textEditor_20250429, textEditor_20250728,
184
- * computer_20241022, webSearch_20250305
228
+ * computer_20241022, webSearch_20250305, toolSearchRegex_20251119,
229
+ * toolSearchBm25_20251119
185
230
  */
186
231
  tools: typeof vertexAnthropicTools;
187
232
  /**
@@ -18,12 +18,12 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
 
20
20
  // src/anthropic/edge/index.ts
21
- var edge_exports = {};
22
- __export(edge_exports, {
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
23
  createVertexAnthropic: () => createVertexAnthropic2,
24
24
  vertexAnthropic: () => vertexAnthropic
25
25
  });
26
- module.exports = __toCommonJS(edge_exports);
26
+ module.exports = __toCommonJS(index_exports);
27
27
 
28
28
  // src/anthropic/edge/google-vertex-anthropic-provider-edge.ts
29
29
  var import_provider_utils3 = require("@ai-sdk/provider-utils");
@@ -32,7 +32,7 @@ var import_provider_utils3 = require("@ai-sdk/provider-utils");
32
32
  var import_provider_utils = require("@ai-sdk/provider-utils");
33
33
 
34
34
  // src/version.ts
35
- var VERSION = true ? "5.0.0-beta.2" : "0.0.0-test";
35
+ var VERSION = true ? "5.0.0-beta.20" : "0.0.0-test";
36
36
 
37
37
  // src/edge/google-vertex-auth-edge.ts
38
38
  var loadCredentials = async () => {
@@ -194,7 +194,27 @@ var vertexAnthropicTools = {
194
194
  /**
195
195
  * Creates a web search tool that gives Claude direct access to real-time web content.
196
196
  */
197
- webSearch_20250305: import_internal.anthropicTools.webSearch_20250305
197
+ webSearch_20250305: import_internal.anthropicTools.webSearch_20250305,
198
+ /**
199
+ * Creates a tool search tool that uses regex patterns to find tools.
200
+ *
201
+ * The tool search tool enables Claude to work with hundreds or thousands of tools
202
+ * by dynamically discovering and loading them on-demand.
203
+ *
204
+ * Use `providerOptions: { anthropic: { deferLoading: true } }` on other tools
205
+ * to mark them for deferred loading.
206
+ */
207
+ toolSearchRegex_20251119: import_internal.anthropicTools.toolSearchRegex_20251119,
208
+ /**
209
+ * Creates a tool search tool that uses BM25 (natural language) to find tools.
210
+ *
211
+ * The tool search tool enables Claude to work with hundreds or thousands of tools
212
+ * by dynamically discovering and loading them on-demand.
213
+ *
214
+ * Use `providerOptions: { anthropic: { deferLoading: true } }` on other tools
215
+ * to mark them for deferred loading.
216
+ */
217
+ toolSearchBm25_20251119: import_internal.anthropicTools.toolSearchBm25_20251119
198
218
  };
199
219
  function createVertexAnthropic(options = {}) {
200
220
  const getBaseURL = () => {
@@ -227,7 +247,9 @@ function createVertexAnthropic(options = {}) {
227
247
  // Google Vertex Anthropic doesn't support URL sources, force download and base64 conversion
228
248
  supportedUrls: () => ({}),
229
249
  // force the use of JSON tool fallback for structured outputs since beta header isn't supported
230
- supportsNativeStructuredOutput: false
250
+ supportsNativeStructuredOutput: false,
251
+ // Vertex Anthropic doesn't support strict mode on tool definitions.
252
+ supportsStrictTools: false
231
253
  });
232
254
  };
233
255
  const provider = function(modelId) {
@@ -238,7 +260,7 @@ function createVertexAnthropic(options = {}) {
238
260
  }
239
261
  return createChatModel(modelId);
240
262
  };
241
- provider.specificationVersion = "v3";
263
+ provider.specificationVersion = "v4";
242
264
  provider.languageModel = createChatModel;
243
265
  provider.chat = createChatModel;
244
266
  provider.messages = createChatModel;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/anthropic/edge/index.ts","../../../src/anthropic/edge/google-vertex-anthropic-provider-edge.ts","../../../src/edge/google-vertex-auth-edge.ts","../../../src/version.ts","../../../src/anthropic/google-vertex-anthropic-provider.ts"],"sourcesContent":["export {\n createVertexAnthropic,\n vertexAnthropic,\n} from './google-vertex-anthropic-provider-edge';\nexport type {\n GoogleVertexAnthropicProviderSettings,\n GoogleVertexAnthropicProvider,\n} from './google-vertex-anthropic-provider-edge';\n","import { resolve } from '@ai-sdk/provider-utils';\nimport {\n generateAuthToken,\n GoogleCredentials,\n} from '../../edge/google-vertex-auth-edge';\nimport {\n createVertexAnthropic as createVertexAnthropicOriginal,\n GoogleVertexAnthropicProvider,\n GoogleVertexAnthropicProviderSettings as GoogleVertexAnthropicProviderSettingsOriginal,\n} from '../google-vertex-anthropic-provider';\n\nexport type { GoogleVertexAnthropicProvider };\n\nexport interface GoogleVertexAnthropicProviderSettings\n extends GoogleVertexAnthropicProviderSettingsOriginal {\n /**\n * Optional. The Google credentials for the Google Cloud service account. If\n * not provided, the Google Vertex provider will use environment variables to\n * load the credentials.\n */\n googleCredentials?: GoogleCredentials;\n}\n\nexport function createVertexAnthropic(\n options: GoogleVertexAnthropicProviderSettings = {},\n): GoogleVertexAnthropicProvider {\n return createVertexAnthropicOriginal({\n ...options,\n headers: async () => ({\n Authorization: `Bearer ${await generateAuthToken(\n options.googleCredentials,\n )}`,\n ...(await resolve(options.headers)),\n }),\n });\n}\n\n/**\n * Default Google Vertex AI Anthropic provider instance.\n */\nexport const vertexAnthropic = createVertexAnthropic();\n","import {\n loadOptionalSetting,\n loadSetting,\n withUserAgentSuffix,\n getRuntimeEnvironmentUserAgent,\n} from '@ai-sdk/provider-utils';\nimport { VERSION } from '../version';\n\nexport interface GoogleCredentials {\n /**\n * The client email for the Google Cloud service account. Defaults to the\n * value of the `GOOGLE_CLIENT_EMAIL` environment variable.\n */\n clientEmail: string;\n\n /**\n * The private key for the Google Cloud service account. Defaults to the\n * value of the `GOOGLE_PRIVATE_KEY` environment variable.\n */\n privateKey: string;\n\n /**\n * Optional. The private key ID for the Google Cloud service account. Defaults\n * to the value of the `GOOGLE_PRIVATE_KEY_ID` environment variable.\n */\n privateKeyId?: string;\n}\n\nconst loadCredentials = async (): Promise<GoogleCredentials> => {\n try {\n return {\n clientEmail: loadSetting({\n settingValue: undefined,\n settingName: 'clientEmail',\n environmentVariableName: 'GOOGLE_CLIENT_EMAIL',\n description: 'Google client email',\n }),\n privateKey: loadSetting({\n settingValue: undefined,\n settingName: 'privateKey',\n environmentVariableName: 'GOOGLE_PRIVATE_KEY',\n description: 'Google private key',\n }),\n privateKeyId: loadOptionalSetting({\n settingValue: undefined,\n environmentVariableName: 'GOOGLE_PRIVATE_KEY_ID',\n }),\n };\n } catch (error: any) {\n throw new Error(`Failed to load Google credentials: ${error.message}`);\n }\n};\n\n// Convert a string to base64url\nconst base64url = (str: string) => {\n return btoa(str).replace(/\\+/g, '-').replace(/\\//g, '_').replace(/=/g, '');\n};\nconst importPrivateKey = async (pemKey: string) => {\n const pemHeader = '-----BEGIN PRIVATE KEY-----';\n const pemFooter = '-----END PRIVATE KEY-----';\n\n // Remove header, footer, and any whitespace/newlines\n const pemContents = pemKey\n .replace(pemHeader, '')\n .replace(pemFooter, '')\n .replace(/\\s/g, '');\n\n // Decode base64 to binary\n const binaryString = atob(pemContents);\n\n // Convert binary string to Uint8Array\n const binaryData = new Uint8Array(binaryString.length);\n for (let i = 0; i < binaryString.length; i++) {\n binaryData[i] = binaryString.charCodeAt(i);\n }\n\n return await crypto.subtle.importKey(\n 'pkcs8',\n binaryData,\n { name: 'RSASSA-PKCS1-v1_5', hash: 'SHA-256' },\n true,\n ['sign'],\n );\n};\n\nconst buildJwt = async (credentials: GoogleCredentials) => {\n const now = Math.floor(Date.now() / 1000);\n\n // Only include kid in header if privateKeyId is provided\n const header: { alg: string; typ: string; kid?: string } = {\n alg: 'RS256',\n typ: 'JWT',\n };\n\n if (credentials.privateKeyId) {\n header.kid = credentials.privateKeyId;\n }\n\n const payload = {\n iss: credentials.clientEmail,\n scope: 'https://www.googleapis.com/auth/cloud-platform',\n aud: 'https://oauth2.googleapis.com/token',\n exp: now + 3600,\n iat: now,\n };\n\n const privateKey = await importPrivateKey(credentials.privateKey);\n\n const signingInput = `${base64url(JSON.stringify(header))}.${base64url(\n JSON.stringify(payload),\n )}`;\n const encoder = new TextEncoder();\n const data = encoder.encode(signingInput);\n\n const signature = await crypto.subtle.sign(\n 'RSASSA-PKCS1-v1_5',\n privateKey,\n data,\n );\n\n const signatureBase64 = base64url(\n String.fromCharCode(...new Uint8Array(signature)),\n );\n\n return `${base64url(JSON.stringify(header))}.${base64url(\n JSON.stringify(payload),\n )}.${signatureBase64}`;\n};\n\n/**\n * Generate an authentication token for Google Vertex AI in a manner compatible\n * with the Edge runtime.\n */\nexport async function generateAuthToken(credentials?: GoogleCredentials) {\n try {\n const creds = credentials || (await loadCredentials());\n const jwt = await buildJwt(creds);\n\n const response = await fetch('https://oauth2.googleapis.com/token', {\n method: 'POST',\n headers: withUserAgentSuffix(\n { 'Content-Type': 'application/x-www-form-urlencoded' },\n `ai-sdk/google-vertex/${VERSION}`,\n getRuntimeEnvironmentUserAgent(),\n ),\n body: new URLSearchParams({\n grant_type: 'urn:ietf:params:oauth:grant-type:jwt-bearer',\n assertion: jwt,\n }),\n });\n\n if (!response.ok) {\n throw new Error(`Token request failed: ${response.statusText}`);\n }\n\n const data = await response.json();\n return data.access_token;\n } catch (error) {\n throw error;\n }\n}\n","// Version string of this package injected at build time.\ndeclare const __PACKAGE_VERSION__: string | undefined;\nexport const VERSION: string =\n typeof __PACKAGE_VERSION__ !== 'undefined'\n ? __PACKAGE_VERSION__\n : '0.0.0-test';\n","import {\n LanguageModelV3,\n NoSuchModelError,\n ProviderV3,\n} from '@ai-sdk/provider';\nimport {\n FetchFunction,\n Resolvable,\n loadOptionalSetting,\n withoutTrailingSlash,\n} from '@ai-sdk/provider-utils';\nimport {\n anthropicTools,\n AnthropicMessagesLanguageModel,\n} from '@ai-sdk/anthropic/internal';\nimport { GoogleVertexAnthropicMessagesModelId } from './google-vertex-anthropic-messages-options';\n\n/**\n * Tools supported by Google Vertex Anthropic.\n * This is a subset of the full Anthropic tools - only these are recognized by the Vertex API.\n */\nexport const vertexAnthropicTools = {\n /**\n * The bash tool enables Claude to execute shell commands in a persistent bash session,\n * allowing system operations, script execution, and command-line automation.\n *\n * Image results are supported.\n */\n bash_20241022: anthropicTools.bash_20241022,\n\n /**\n * The bash tool enables Claude to execute shell commands in a persistent bash session,\n * allowing system operations, script execution, and command-line automation.\n *\n * Image results are supported.\n */\n bash_20250124: anthropicTools.bash_20250124,\n\n /**\n * Claude can use an Anthropic-defined text editor tool to view and modify text files,\n * helping you debug, fix, and improve your code or other text documents.\n *\n * Supported models: Claude Sonnet 3.5\n */\n textEditor_20241022: anthropicTools.textEditor_20241022,\n\n /**\n * Claude can use an Anthropic-defined text editor tool to view and modify text files,\n * helping you debug, fix, and improve your code or other text documents.\n *\n * Supported models: Claude Sonnet 3.7\n */\n textEditor_20250124: anthropicTools.textEditor_20250124,\n\n /**\n * Claude can use an Anthropic-defined text editor tool to view and modify text files.\n * Note: This version does not support the \"undo_edit\" command.\n * @deprecated Use textEditor_20250728 instead\n */\n textEditor_20250429: anthropicTools.textEditor_20250429,\n\n /**\n * Claude can use an Anthropic-defined text editor tool to view and modify text files.\n * Note: This version does not support the \"undo_edit\" command and adds optional max_characters parameter.\n * Supported models: Claude Sonnet 4, Opus 4, and Opus 4.1\n */\n textEditor_20250728: anthropicTools.textEditor_20250728,\n\n /**\n * Claude can interact with computer environments through the computer use tool, which\n * provides screenshot capabilities and mouse/keyboard control for autonomous desktop interaction.\n *\n * Image results are supported.\n */\n computer_20241022: anthropicTools.computer_20241022,\n\n /**\n * Creates a web search tool that gives Claude direct access to real-time web content.\n */\n webSearch_20250305: anthropicTools.webSearch_20250305,\n};\nexport interface GoogleVertexAnthropicProvider extends ProviderV3 {\n /**\n * Creates a model for text generation.\n */\n (modelId: GoogleVertexAnthropicMessagesModelId): LanguageModelV3;\n\n /**\n * Creates a model for text generation.\n */\n languageModel(modelId: GoogleVertexAnthropicMessagesModelId): LanguageModelV3;\n\n /**\n * Anthropic tools supported by Google Vertex.\n * Note: Only a subset of Anthropic tools are available on Vertex.\n * Supported tools: bash_20241022, bash_20250124, textEditor_20241022,\n * textEditor_20250124, textEditor_20250429, textEditor_20250728,\n * computer_20241022, webSearch_20250305\n */\n tools: typeof vertexAnthropicTools;\n\n /**\n * @deprecated Use `embeddingModel` instead.\n */\n textEmbeddingModel(modelId: string): never;\n}\n\nexport interface GoogleVertexAnthropicProviderSettings {\n /**\n * Google Cloud project ID. Defaults to the value of the `GOOGLE_VERTEX_PROJECT` environment variable.\n */\n project?: string;\n\n /**\n * Google Cloud region. Defaults to the value of the `GOOGLE_VERTEX_LOCATION` environment variable.\n */\n location?: string;\n\n /**\n * Use a different URL prefix for API calls, e.g. to use proxy servers.\n * The default prefix is `https://api.anthropic.com/v1`.\n */\n baseURL?: string;\n\n /**\n * Custom headers to include in the requests.\n */\n headers?: Resolvable<Record<string, string | undefined>>;\n\n /**\n * Custom fetch implementation. You can use it as a middleware to intercept requests,\n * or to provide a custom fetch implementation for e.g. testing.\n */\n fetch?: FetchFunction;\n}\n\n/**\n * Create a Google Vertex Anthropic provider instance.\n */\nexport function createVertexAnthropic(\n options: GoogleVertexAnthropicProviderSettings = {},\n): GoogleVertexAnthropicProvider {\n const getBaseURL = () => {\n const location = loadOptionalSetting({\n settingValue: options.location,\n environmentVariableName: 'GOOGLE_VERTEX_LOCATION',\n });\n const project = loadOptionalSetting({\n settingValue: options.project,\n environmentVariableName: 'GOOGLE_VERTEX_PROJECT',\n });\n\n return (\n withoutTrailingSlash(options.baseURL) ??\n `https://${location === 'global' ? '' : location + '-'}aiplatform.googleapis.com/v1/projects/${project}/locations/${location}/publishers/anthropic/models`\n );\n };\n\n const createChatModel = (modelId: GoogleVertexAnthropicMessagesModelId) =>\n new AnthropicMessagesLanguageModel(modelId, {\n provider: 'vertex.anthropic.messages',\n baseURL: getBaseURL(),\n headers: options.headers ?? {},\n fetch: options.fetch,\n\n buildRequestUrl: (baseURL, isStreaming) =>\n `${baseURL}/${modelId}:${\n isStreaming ? 'streamRawPredict' : 'rawPredict'\n }`,\n transformRequestBody: args => {\n // Remove model from args and add anthropic version\n const { model, ...rest } = args;\n return {\n ...rest,\n anthropic_version: 'vertex-2023-10-16',\n };\n },\n // Google Vertex Anthropic doesn't support URL sources, force download and base64 conversion\n supportedUrls: () => ({}),\n // force the use of JSON tool fallback for structured outputs since beta header isn't supported\n supportsNativeStructuredOutput: false,\n });\n\n const provider = function (modelId: GoogleVertexAnthropicMessagesModelId) {\n if (new.target) {\n throw new Error(\n 'The Anthropic model function cannot be called with the new keyword.',\n );\n }\n\n return createChatModel(modelId);\n };\n\n provider.specificationVersion = 'v3' as const;\n provider.languageModel = createChatModel;\n provider.chat = createChatModel;\n provider.messages = createChatModel;\n\n provider.embeddingModel = (modelId: string) => {\n throw new NoSuchModelError({ modelId, modelType: 'embeddingModel' });\n };\n provider.textEmbeddingModel = provider.embeddingModel;\n provider.imageModel = (modelId: string) => {\n throw new NoSuchModelError({ modelId, modelType: 'imageModel' });\n };\n\n provider.tools = vertexAnthropicTools;\n\n return provider;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,+BAAAA;AAAA,EAAA;AAAA;AAAA;;;ACAA,IAAAC,yBAAwB;;;ACAxB,4BAKO;;;ACHA,IAAM,UACX,OACI,iBACA;;;ADuBN,IAAM,kBAAkB,YAAwC;AAC9D,MAAI;AACF,WAAO;AAAA,MACL,iBAAa,mCAAY;AAAA,QACvB,cAAc;AAAA,QACd,aAAa;AAAA,QACb,yBAAyB;AAAA,QACzB,aAAa;AAAA,MACf,CAAC;AAAA,MACD,gBAAY,mCAAY;AAAA,QACtB,cAAc;AAAA,QACd,aAAa;AAAA,QACb,yBAAyB;AAAA,QACzB,aAAa;AAAA,MACf,CAAC;AAAA,MACD,kBAAc,2CAAoB;AAAA,QAChC,cAAc;AAAA,QACd,yBAAyB;AAAA,MAC3B,CAAC;AAAA,IACH;AAAA,EACF,SAAS,OAAY;AACnB,UAAM,IAAI,MAAM,sCAAsC,MAAM,OAAO,EAAE;AAAA,EACvE;AACF;AA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WAAS,OAAO;AAChB,WAAS,WAAW;AAEpB,WAAS,iBAAiB,CAAC,YAAoB;AAC7C,UAAM,IAAI,iCAAiB,EAAE,SAAS,WAAW,iBAAiB,CAAC;AAAA,EACrE;AACA,WAAS,qBAAqB,SAAS;AACvC,WAAS,aAAa,CAAC,YAAoB;AACzC,UAAM,IAAI,iCAAiB,EAAE,SAAS,WAAW,aAAa,CAAC;AAAA,EACjE;AAEA,WAAS,QAAQ;AAEjB,SAAO;AACT;;;AH1LO,SAASC,uBACd,UAAiD,CAAC,GACnB;AAC/B,SAAO,sBAA8B;AAAA,IACnC,GAAG;AAAA,IACH,SAAS,aAAa;AAAA,MACpB,eAAe,UAAU,MAAM;AAAA,QAC7B,QAAQ;AAAA,MACV,CAAC;AAAA,MACD,GAAI,UAAM,gCAAQ,QAAQ,OAAO;AAAA,IACnC;AAAA,EACF,CAAC;AACH;AAKO,IAAM,kBAAkBA,uBAAsB;","names":["createVertexAnthropic","import_provider_utils","import_provider_utils","createVertexAnthropic"]}
1
+ {"version":3,"sources":["../../../src/anthropic/edge/index.ts","../../../src/anthropic/edge/google-vertex-anthropic-provider-edge.ts","../../../src/edge/google-vertex-auth-edge.ts","../../../src/version.ts","../../../src/anthropic/google-vertex-anthropic-provider.ts"],"sourcesContent":["export {\n createVertexAnthropic,\n vertexAnthropic,\n} from './google-vertex-anthropic-provider-edge';\nexport type {\n GoogleVertexAnthropicProviderSettings,\n GoogleVertexAnthropicProvider,\n} from './google-vertex-anthropic-provider-edge';\n","import { resolve } from '@ai-sdk/provider-utils';\nimport {\n generateAuthToken,\n GoogleCredentials,\n} from '../../edge/google-vertex-auth-edge';\nimport {\n createVertexAnthropic as createVertexAnthropicOriginal,\n GoogleVertexAnthropicProvider,\n GoogleVertexAnthropicProviderSettings as GoogleVertexAnthropicProviderSettingsOriginal,\n} from '../google-vertex-anthropic-provider';\n\nexport type { GoogleVertexAnthropicProvider };\n\nexport interface GoogleVertexAnthropicProviderSettings extends GoogleVertexAnthropicProviderSettingsOriginal {\n /**\n * Optional. The Google credentials for the Google Cloud service account. If\n * not provided, the Google Vertex provider will use environment variables to\n * load the credentials.\n */\n googleCredentials?: GoogleCredentials;\n}\n\nexport function createVertexAnthropic(\n options: GoogleVertexAnthropicProviderSettings = {},\n): GoogleVertexAnthropicProvider {\n return createVertexAnthropicOriginal({\n ...options,\n headers: async () => ({\n Authorization: `Bearer ${await generateAuthToken(\n options.googleCredentials,\n )}`,\n ...(await resolve(options.headers)),\n }),\n });\n}\n\n/**\n * Default Google Vertex AI Anthropic provider instance.\n */\nexport const vertexAnthropic = createVertexAnthropic();\n","import {\n loadOptionalSetting,\n loadSetting,\n withUserAgentSuffix,\n getRuntimeEnvironmentUserAgent,\n} from '@ai-sdk/provider-utils';\nimport { VERSION } from '../version';\n\nexport interface GoogleCredentials {\n /**\n * The client email for the Google Cloud service account. Defaults to the\n * value of the `GOOGLE_CLIENT_EMAIL` environment variable.\n */\n clientEmail: string;\n\n /**\n * The private key for the Google Cloud service account. Defaults to the\n * value of the `GOOGLE_PRIVATE_KEY` environment variable.\n */\n privateKey: string;\n\n /**\n * Optional. The private key ID for the Google Cloud service account. Defaults\n * to the value of the `GOOGLE_PRIVATE_KEY_ID` environment variable.\n */\n privateKeyId?: string;\n}\n\nconst loadCredentials = async (): Promise<GoogleCredentials> => {\n try {\n return {\n clientEmail: loadSetting({\n settingValue: undefined,\n settingName: 'clientEmail',\n environmentVariableName: 'GOOGLE_CLIENT_EMAIL',\n description: 'Google client email',\n }),\n privateKey: loadSetting({\n settingValue: undefined,\n settingName: 'privateKey',\n environmentVariableName: 'GOOGLE_PRIVATE_KEY',\n description: 'Google private key',\n }),\n privateKeyId: loadOptionalSetting({\n settingValue: undefined,\n environmentVariableName: 'GOOGLE_PRIVATE_KEY_ID',\n }),\n };\n } catch (error: any) {\n throw new Error(`Failed to load Google credentials: ${error.message}`);\n }\n};\n\n// Convert a string to base64url\nconst base64url = (str: string) => {\n return btoa(str).replace(/\\+/g, '-').replace(/\\//g, '_').replace(/=/g, '');\n};\nconst importPrivateKey = async (pemKey: string) => {\n const pemHeader = '-----BEGIN PRIVATE KEY-----';\n const pemFooter = '-----END PRIVATE KEY-----';\n\n // Remove header, footer, and any whitespace/newlines\n const pemContents = pemKey\n .replace(pemHeader, '')\n .replace(pemFooter, '')\n .replace(/\\s/g, '');\n\n // Decode base64 to binary\n const binaryString = atob(pemContents);\n\n // Convert binary string to Uint8Array\n const binaryData = new Uint8Array(binaryString.length);\n for (let i = 0; i < binaryString.length; i++) {\n binaryData[i] = binaryString.charCodeAt(i);\n }\n\n return await crypto.subtle.importKey(\n 'pkcs8',\n binaryData,\n { name: 'RSASSA-PKCS1-v1_5', hash: 'SHA-256' },\n true,\n ['sign'],\n );\n};\n\nconst buildJwt = async (credentials: GoogleCredentials) => {\n const now = Math.floor(Date.now() / 1000);\n\n // Only include kid in header if privateKeyId is provided\n const header: { alg: string; typ: string; kid?: string } = {\n alg: 'RS256',\n typ: 'JWT',\n };\n\n if (credentials.privateKeyId) {\n header.kid = credentials.privateKeyId;\n }\n\n const payload = {\n iss: credentials.clientEmail,\n scope: 'https://www.googleapis.com/auth/cloud-platform',\n aud: 'https://oauth2.googleapis.com/token',\n exp: now + 3600,\n iat: now,\n };\n\n const privateKey = await importPrivateKey(credentials.privateKey);\n\n const signingInput = `${base64url(JSON.stringify(header))}.${base64url(\n JSON.stringify(payload),\n )}`;\n const encoder = new TextEncoder();\n const data = encoder.encode(signingInput);\n\n const signature = await crypto.subtle.sign(\n 'RSASSA-PKCS1-v1_5',\n privateKey,\n data,\n );\n\n const signatureBase64 = base64url(\n String.fromCharCode(...new Uint8Array(signature)),\n );\n\n return `${base64url(JSON.stringify(header))}.${base64url(\n JSON.stringify(payload),\n )}.${signatureBase64}`;\n};\n\n/**\n * Generate an authentication token for Google Vertex AI in a manner compatible\n * with the Edge runtime.\n */\nexport async function generateAuthToken(credentials?: GoogleCredentials) {\n try {\n const creds = credentials || (await loadCredentials());\n const jwt = await buildJwt(creds);\n\n const response = await fetch('https://oauth2.googleapis.com/token', {\n method: 'POST',\n headers: withUserAgentSuffix(\n { 'Content-Type': 'application/x-www-form-urlencoded' },\n `ai-sdk/google-vertex/${VERSION}`,\n getRuntimeEnvironmentUserAgent(),\n ),\n body: new URLSearchParams({\n grant_type: 'urn:ietf:params:oauth:grant-type:jwt-bearer',\n assertion: jwt,\n }),\n });\n\n if (!response.ok) {\n throw new Error(`Token request failed: ${response.statusText}`);\n }\n\n const data = await response.json();\n return data.access_token;\n } catch (error) {\n throw error;\n }\n}\n","// Version string of this package injected at build time.\ndeclare const __PACKAGE_VERSION__: string | undefined;\nexport const VERSION: string =\n typeof __PACKAGE_VERSION__ !== 'undefined'\n ? __PACKAGE_VERSION__\n : '0.0.0-test';\n","import {\n LanguageModelV4,\n NoSuchModelError,\n ProviderV4,\n} from '@ai-sdk/provider';\nimport {\n FetchFunction,\n Resolvable,\n loadOptionalSetting,\n withoutTrailingSlash,\n} from '@ai-sdk/provider-utils';\nimport {\n anthropicTools,\n AnthropicMessagesLanguageModel,\n} from '@ai-sdk/anthropic/internal';\nimport { GoogleVertexAnthropicMessagesModelId } from './google-vertex-anthropic-messages-options';\n\n/**\n * Tools supported by Google Vertex Anthropic.\n * This is a subset of the full Anthropic tools - only these are recognized by the Vertex API.\n */\nexport const vertexAnthropicTools = {\n /**\n * The bash tool enables Claude to execute shell commands in a persistent bash session,\n * allowing system operations, script execution, and command-line automation.\n *\n * Image results are supported.\n */\n bash_20241022: anthropicTools.bash_20241022,\n\n /**\n * The bash tool enables Claude to execute shell commands in a persistent bash session,\n * allowing system operations, script execution, and command-line automation.\n *\n * Image results are supported.\n */\n bash_20250124: anthropicTools.bash_20250124,\n\n /**\n * Claude can use an Anthropic-defined text editor tool to view and modify text files,\n * helping you debug, fix, and improve your code or other text documents.\n *\n * Supported models: Claude Sonnet 3.5\n */\n textEditor_20241022: anthropicTools.textEditor_20241022,\n\n /**\n * Claude can use an Anthropic-defined text editor tool to view and modify text files,\n * helping you debug, fix, and improve your code or other text documents.\n *\n * Supported models: Claude Sonnet 3.7\n */\n textEditor_20250124: anthropicTools.textEditor_20250124,\n\n /**\n * Claude can use an Anthropic-defined text editor tool to view and modify text files.\n * Note: This version does not support the \"undo_edit\" command.\n * @deprecated Use textEditor_20250728 instead\n */\n textEditor_20250429: anthropicTools.textEditor_20250429,\n\n /**\n * Claude can use an Anthropic-defined text editor tool to view and modify text files.\n * Note: This version does not support the \"undo_edit\" command and adds optional max_characters parameter.\n * Supported models: Claude Sonnet 4, Opus 4, and Opus 4.1\n */\n textEditor_20250728: anthropicTools.textEditor_20250728,\n\n /**\n * Claude can interact with computer environments through the computer use tool, which\n * provides screenshot capabilities and mouse/keyboard control for autonomous desktop interaction.\n *\n * Image results are supported.\n */\n computer_20241022: anthropicTools.computer_20241022,\n\n /**\n * Creates a web search tool that gives Claude direct access to real-time web content.\n */\n webSearch_20250305: anthropicTools.webSearch_20250305,\n\n /**\n * Creates a tool search tool that uses regex patterns to find tools.\n *\n * The tool search tool enables Claude to work with hundreds or thousands of tools\n * by dynamically discovering and loading them on-demand.\n *\n * Use `providerOptions: { anthropic: { deferLoading: true } }` on other tools\n * to mark them for deferred loading.\n */\n toolSearchRegex_20251119: anthropicTools.toolSearchRegex_20251119,\n\n /**\n * Creates a tool search tool that uses BM25 (natural language) to find tools.\n *\n * The tool search tool enables Claude to work with hundreds or thousands of tools\n * by dynamically discovering and loading them on-demand.\n *\n * Use `providerOptions: { anthropic: { deferLoading: true } }` on other tools\n * to mark them for deferred loading.\n */\n toolSearchBm25_20251119: anthropicTools.toolSearchBm25_20251119,\n};\nexport interface GoogleVertexAnthropicProvider extends ProviderV4 {\n /**\n * Creates a model for text generation.\n */\n (modelId: GoogleVertexAnthropicMessagesModelId): LanguageModelV4;\n\n /**\n * Creates a model for text generation.\n */\n languageModel(modelId: GoogleVertexAnthropicMessagesModelId): LanguageModelV4;\n\n /**\n * Anthropic tools supported by Google Vertex.\n * Note: Only a subset of Anthropic tools are available on Vertex.\n * Supported tools: bash_20241022, bash_20250124, textEditor_20241022,\n * textEditor_20250124, textEditor_20250429, textEditor_20250728,\n * computer_20241022, webSearch_20250305, toolSearchRegex_20251119,\n * toolSearchBm25_20251119\n */\n tools: typeof vertexAnthropicTools;\n\n /**\n * @deprecated Use `embeddingModel` instead.\n */\n textEmbeddingModel(modelId: string): never;\n}\n\nexport interface GoogleVertexAnthropicProviderSettings {\n /**\n * Google Cloud project ID. Defaults to the value of the `GOOGLE_VERTEX_PROJECT` environment variable.\n */\n project?: string;\n\n /**\n * Google Cloud region. Defaults to the value of the `GOOGLE_VERTEX_LOCATION` environment variable.\n */\n location?: string;\n\n /**\n * Use a different URL prefix for API calls, e.g. to use proxy servers.\n * The default prefix is `https://api.anthropic.com/v1`.\n */\n baseURL?: string;\n\n /**\n * Custom headers to include in the requests.\n */\n headers?: Resolvable<Record<string, string | undefined>>;\n\n /**\n * Custom fetch implementation. You can use it as a middleware to intercept requests,\n * or to provide a custom fetch implementation for e.g. testing.\n */\n fetch?: FetchFunction;\n}\n\n/**\n * Create a Google Vertex Anthropic provider instance.\n */\nexport function createVertexAnthropic(\n options: GoogleVertexAnthropicProviderSettings = {},\n): GoogleVertexAnthropicProvider {\n const getBaseURL = () => {\n const location = loadOptionalSetting({\n settingValue: options.location,\n environmentVariableName: 'GOOGLE_VERTEX_LOCATION',\n });\n const project = loadOptionalSetting({\n settingValue: options.project,\n environmentVariableName: 'GOOGLE_VERTEX_PROJECT',\n });\n\n return (\n withoutTrailingSlash(options.baseURL) ??\n `https://${location === 'global' ? '' : location + '-'}aiplatform.googleapis.com/v1/projects/${project}/locations/${location}/publishers/anthropic/models`\n );\n };\n\n const createChatModel = (modelId: GoogleVertexAnthropicMessagesModelId) =>\n new AnthropicMessagesLanguageModel(modelId, {\n provider: 'vertex.anthropic.messages',\n baseURL: getBaseURL(),\n headers: options.headers ?? {},\n fetch: options.fetch,\n\n buildRequestUrl: (baseURL, isStreaming) =>\n `${baseURL}/${modelId}:${\n isStreaming ? 'streamRawPredict' : 'rawPredict'\n }`,\n transformRequestBody: args => {\n // Remove model from args and add anthropic version\n const { model, ...rest } = args;\n return {\n ...rest,\n anthropic_version: 'vertex-2023-10-16',\n };\n },\n // Google Vertex Anthropic doesn't support URL sources, force download and base64 conversion\n supportedUrls: () => ({}),\n // force the use of JSON tool fallback for structured outputs since beta header isn't supported\n supportsNativeStructuredOutput: false,\n // Vertex Anthropic doesn't support strict mode on tool definitions.\n supportsStrictTools: false,\n });\n\n const provider = function (modelId: GoogleVertexAnthropicMessagesModelId) {\n if (new.target) {\n throw new Error(\n 'The Anthropic model function cannot be called with the new keyword.',\n );\n }\n\n return createChatModel(modelId);\n };\n\n provider.specificationVersion = 'v4' as const;\n provider.languageModel = createChatModel;\n provider.chat = createChatModel;\n provider.messages = createChatModel;\n\n provider.embeddingModel = (modelId: string) => {\n throw new NoSuchModelError({ modelId, modelType: 'embeddingModel' });\n };\n provider.textEmbeddingModel = provider.embeddingModel;\n provider.imageModel = (modelId: string) => {\n throw new NoSuchModelError({ modelId, modelType: 'imageModel' });\n };\n\n provider.tools = vertexAnthropicTools;\n\n return provider;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,+BAAAA;AAAA,EAAA;AAAA;AAAA;;;ACAA,IAAAC,yBAAwB;;;ACAxB,4BAKO;;;ACHA,IAAM,UACX,OACI,kBACA;;;ADuBN,IAAM,kBAAkB,YAAwC;AAC9D,MAAI;AACF,WAAO;AAAA,MACL,iBAAa,mCAAY;AAAA,QACvB,cAAc;AAAA,QACd,aAAa;AAAA,QACb,yBAAyB;AAAA,QACzB,aAAa;AAAA,MACf,CAAC;AAAA,MACD,gBAAY,mCAAY;AAAA,QACtB,cAAc;AAAA,QACd,aAAa;AAAA,QACb,yBAAyB;AAAA,QACzB,aAAa;AAAA,MACf,CAAC;AAAA,MACD,kBAAc,2CAAoB;AAAA,QAChC,cAAc;AAAA,QACd,yBAAyB;A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ACrB;AAAA,MACF;AAAA;AAAA,MAEA,eAAe,OAAO,CAAC;AAAA;AAAA,MAEvB,gCAAgC;AAAA;AAAA,MAEhC,qBAAqB;AAAA,IACvB,CAAC;AAAA;AAEH,QAAM,WAAW,SAAU,SAA+C;AACxE,QAAI,YAAY;AACd,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AAAA,IACF;AAEA,WAAO,gBAAgB,OAAO;AAAA,EAChC;AAEA,WAAS,uBAAuB;AAChC,WAAS,gBAAgB;AACzB,WAAS,OAAO;AAChB,WAAS,WAAW;AAEpB,WAAS,iBAAiB,CAAC,YAAoB;AAC7C,UAAM,IAAI,iCAAiB,EAAE,SAAS,WAAW,iBAAiB,CAAC;AAAA,EACrE;AACA,WAAS,qBAAqB,SAAS;AACvC,WAAS,aAAa,CAAC,YAAoB;AACzC,UAAM,IAAI,iCAAiB,EAAE,SAAS,WAAW,aAAa,CAAC;AAAA,EACjE;AAEA,WAAS,QAAQ;AAEjB,SAAO;AACT;;;AHpNO,SAASC,uBACd,UAAiD,CAAC,GACnB;AAC/B,SAAO,sBAA8B;AAAA,IACnC,GAAG;AAAA,IACH,SAAS,aAAa;AAAA,MACpB,eAAe,UAAU,MAAM;AAAA,QAC7B,QAAQ;AAAA,MACV,CAAC;AAAA,MACD,GAAI,UAAM,gCAAQ,QAAQ,OAAO;AAAA,IACnC;AAAA,EACF,CAAC;AACH;AAKO,IAAM,kBAAkBA,uBAAsB;","names":["createVertexAnthropic","import_provider_utils","import_provider_utils","createVertexAnthropic"]}
@@ -10,7 +10,7 @@ import {
10
10
  } from "@ai-sdk/provider-utils";
11
11
 
12
12
  // src/version.ts
13
- var VERSION = true ? "5.0.0-beta.2" : "0.0.0-test";
13
+ var VERSION = true ? "5.0.0-beta.20" : "0.0.0-test";
14
14
 
15
15
  // src/edge/google-vertex-auth-edge.ts
16
16
  var loadCredentials = async () => {
@@ -180,7 +180,27 @@ var vertexAnthropicTools = {
180
180
  /**
181
181
  * Creates a web search tool that gives Claude direct access to real-time web content.
182
182
  */
183
- webSearch_20250305: 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
184
204
  };
185
205
  function createVertexAnthropic(options = {}) {
186
206
  const getBaseURL = () => {
@@ -213,7 +233,9 @@ function createVertexAnthropic(options = {}) {
213
233
  // Google Vertex Anthropic doesn't support URL sources, force download and base64 conversion
214
234
  supportedUrls: () => ({}),
215
235
  // force the use of JSON tool fallback for structured outputs since beta header isn't supported
216
- supportsNativeStructuredOutput: false
236
+ supportsNativeStructuredOutput: false,
237
+ // Vertex Anthropic doesn't support strict mode on tool definitions.
238
+ supportsStrictTools: false
217
239
  });
218
240
  };
219
241
  const provider = function(modelId) {
@@ -224,7 +246,7 @@ function createVertexAnthropic(options = {}) {
224
246
  }
225
247
  return createChatModel(modelId);
226
248
  };
227
- provider.specificationVersion = "v3";
249
+ provider.specificationVersion = "v4";
228
250
  provider.languageModel = createChatModel;
229
251
  provider.chat = createChatModel;
230
252
  provider.messages = createChatModel;