@ai-sdk/google-vertex 5.0.0-beta.6 → 5.0.0-beta.61
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 +523 -8
- package/README.md +65 -2
- package/dist/anthropic/edge/index.d.ts +69 -24
- package/dist/anthropic/edge/index.js +67 -60
- package/dist/anthropic/edge/index.js.map +1 -1
- package/dist/anthropic/index.d.ts +69 -24
- package/dist/anthropic/index.js +57 -55
- package/dist/anthropic/index.js.map +1 -1
- package/dist/edge/index.d.ts +35 -26
- package/dist/edge/index.js +217 -176
- package/dist/edge/index.js.map +1 -1
- package/dist/index.d.ts +35 -26
- package/dist/index.js +208 -173
- package/dist/index.js.map +1 -1
- package/dist/maas/edge/index.d.ts +76 -0
- package/dist/maas/edge/index.js +196 -0
- package/dist/maas/edge/index.js.map +1 -0
- package/dist/maas/index.d.ts +60 -0
- package/dist/maas/index.js +101 -0
- package/dist/maas/index.js.map +1 -0
- package/docs/16-google-vertex.mdx +236 -14
- package/maas/edge.d.ts +1 -0
- package/maas/index.d.ts +1 -0
- package/package.json +33 -20
- package/src/anthropic/edge/google-vertex-anthropic-provider-edge.ts +1 -2
- package/src/anthropic/{google-vertex-anthropic-messages-options.ts → google-vertex-anthropic-options.ts} +2 -1
- package/src/anthropic/google-vertex-anthropic-provider-node.ts +1 -2
- package/src/anthropic/google-vertex-anthropic-provider.ts +38 -13
- package/src/edge/google-vertex-provider-edge.ts +1 -2
- package/src/google-vertex-config.ts +1 -1
- package/src/google-vertex-embedding-model.ts +23 -6
- package/src/google-vertex-embedding-options.ts +2 -0
- package/src/google-vertex-image-model.ts +40 -20
- package/src/google-vertex-options.ts +0 -1
- package/src/google-vertex-provider-node.ts +1 -2
- package/src/google-vertex-provider.ts +14 -14
- package/src/google-vertex-video-model.ts +7 -7
- package/src/maas/edge/google-vertex-maas-provider-edge.ts +65 -0
- package/src/maas/edge/index.ts +9 -0
- package/src/maas/google-vertex-maas-options.ts +15 -0
- package/src/maas/google-vertex-maas-provider-node.ts +64 -0
- package/src/maas/google-vertex-maas-provider.ts +111 -0
- package/src/maas/index.ts +9 -0
- package/dist/anthropic/edge/index.d.mts +0 -231
- package/dist/anthropic/edge/index.mjs +0 -259
- package/dist/anthropic/edge/index.mjs.map +0 -1
- package/dist/anthropic/index.d.mts +0 -215
- package/dist/anthropic/index.mjs +0 -164
- package/dist/anthropic/index.mjs.map +0 -1
- package/dist/edge/index.d.mts +0 -160
- package/dist/edge/index.mjs +0 -1049
- package/dist/edge/index.mjs.map +0 -1
- package/dist/index.d.mts +0 -219
- package/dist/index.mjs +0 -960
- package/dist/index.mjs.map +0 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { GoogleAuthOptions } from 'google-auth-library';
|
|
2
2
|
import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
|
|
3
3
|
import { Resolvable, FetchFunction } from '@ai-sdk/provider-utils';
|
|
4
|
-
import {
|
|
4
|
+
import { ProviderV4, LanguageModelV4 } from '@ai-sdk/provider';
|
|
5
5
|
|
|
6
|
-
type
|
|
6
|
+
type GoogleVertexAnthropicModelId = '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 & {});
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Tools supported by Google Vertex Anthropic.
|
|
@@ -16,27 +16,27 @@ declare const vertexAnthropicTools: {
|
|
|
16
16
|
*
|
|
17
17
|
* Image results are supported.
|
|
18
18
|
*/
|
|
19
|
-
bash_20241022: _ai_sdk_provider_utils.
|
|
19
|
+
bash_20241022: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{
|
|
20
20
|
command: string;
|
|
21
21
|
restart?: boolean;
|
|
22
|
-
}, {}>;
|
|
22
|
+
}, {}, {}>;
|
|
23
23
|
/**
|
|
24
24
|
* The bash tool enables Claude to execute shell commands in a persistent bash session,
|
|
25
25
|
* allowing system operations, script execution, and command-line automation.
|
|
26
26
|
*
|
|
27
27
|
* Image results are supported.
|
|
28
28
|
*/
|
|
29
|
-
bash_20250124: _ai_sdk_provider_utils.
|
|
29
|
+
bash_20250124: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{
|
|
30
30
|
command: string;
|
|
31
31
|
restart?: boolean;
|
|
32
|
-
}, {}>;
|
|
32
|
+
}, {}, {}>;
|
|
33
33
|
/**
|
|
34
34
|
* Claude can use an Anthropic-defined text editor tool to view and modify text files,
|
|
35
35
|
* helping you debug, fix, and improve your code or other text documents.
|
|
36
36
|
*
|
|
37
37
|
* Supported models: Claude Sonnet 3.5
|
|
38
38
|
*/
|
|
39
|
-
textEditor_20241022: _ai_sdk_provider_utils.
|
|
39
|
+
textEditor_20241022: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{
|
|
40
40
|
command: "view" | "create" | "str_replace" | "insert" | "undo_edit";
|
|
41
41
|
path: string;
|
|
42
42
|
file_text?: string;
|
|
@@ -45,14 +45,14 @@ declare const vertexAnthropicTools: {
|
|
|
45
45
|
insert_text?: string;
|
|
46
46
|
old_str?: string;
|
|
47
47
|
view_range?: number[];
|
|
48
|
-
}, {}>;
|
|
48
|
+
}, {}, {}>;
|
|
49
49
|
/**
|
|
50
50
|
* Claude can use an Anthropic-defined text editor tool to view and modify text files,
|
|
51
51
|
* helping you debug, fix, and improve your code or other text documents.
|
|
52
52
|
*
|
|
53
53
|
* Supported models: Claude Sonnet 3.7
|
|
54
54
|
*/
|
|
55
|
-
textEditor_20250124: _ai_sdk_provider_utils.
|
|
55
|
+
textEditor_20250124: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{
|
|
56
56
|
command: "view" | "create" | "str_replace" | "insert" | "undo_edit";
|
|
57
57
|
path: string;
|
|
58
58
|
file_text?: string;
|
|
@@ -61,13 +61,13 @@ declare const vertexAnthropicTools: {
|
|
|
61
61
|
insert_text?: string;
|
|
62
62
|
old_str?: string;
|
|
63
63
|
view_range?: number[];
|
|
64
|
-
}, {}>;
|
|
64
|
+
}, {}, {}>;
|
|
65
65
|
/**
|
|
66
66
|
* Claude can use an Anthropic-defined text editor tool to view and modify text files.
|
|
67
67
|
* Note: This version does not support the "undo_edit" command.
|
|
68
68
|
* @deprecated Use textEditor_20250728 instead
|
|
69
69
|
*/
|
|
70
|
-
textEditor_20250429: _ai_sdk_provider_utils.
|
|
70
|
+
textEditor_20250429: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{
|
|
71
71
|
command: "view" | "create" | "str_replace" | "insert";
|
|
72
72
|
path: string;
|
|
73
73
|
file_text?: string;
|
|
@@ -76,13 +76,13 @@ declare const vertexAnthropicTools: {
|
|
|
76
76
|
insert_text?: string;
|
|
77
77
|
old_str?: string;
|
|
78
78
|
view_range?: number[];
|
|
79
|
-
}, {}>;
|
|
79
|
+
}, {}, {}>;
|
|
80
80
|
/**
|
|
81
81
|
* Claude can use an Anthropic-defined text editor tool to view and modify text files.
|
|
82
82
|
* Note: This version does not support the "undo_edit" command and adds optional max_characters parameter.
|
|
83
83
|
* Supported models: Claude Sonnet 4, Opus 4, and Opus 4.1
|
|
84
84
|
*/
|
|
85
|
-
textEditor_20250728: (args?: Parameters<_ai_sdk_provider_utils.
|
|
85
|
+
textEditor_20250728: (args?: Parameters<_ai_sdk_provider_utils.ProviderDefinedToolFactory<{
|
|
86
86
|
command: "view" | "create" | "str_replace" | "insert";
|
|
87
87
|
path: string;
|
|
88
88
|
file_text?: string;
|
|
@@ -93,7 +93,7 @@ declare const vertexAnthropicTools: {
|
|
|
93
93
|
view_range?: number[];
|
|
94
94
|
}, {
|
|
95
95
|
maxCharacters?: number;
|
|
96
|
-
}>>[0]) => _ai_sdk_provider_utils.Tool<{
|
|
96
|
+
}, {}>>[0]) => _ai_sdk_provider_utils.Tool<{
|
|
97
97
|
command: "view" | "create" | "str_replace" | "insert";
|
|
98
98
|
path: string;
|
|
99
99
|
file_text?: string;
|
|
@@ -102,14 +102,14 @@ declare const vertexAnthropicTools: {
|
|
|
102
102
|
insert_text?: string;
|
|
103
103
|
old_str?: string;
|
|
104
104
|
view_range?: number[];
|
|
105
|
-
}, unknown>;
|
|
105
|
+
}, unknown, {}>;
|
|
106
106
|
/**
|
|
107
107
|
* Claude can interact with computer environments through the computer use tool, which
|
|
108
108
|
* provides screenshot capabilities and mouse/keyboard control for autonomous desktop interaction.
|
|
109
109
|
*
|
|
110
110
|
* Image results are supported.
|
|
111
111
|
*/
|
|
112
|
-
computer_20241022: _ai_sdk_provider_utils.
|
|
112
|
+
computer_20241022: _ai_sdk_provider_utils.ProviderDefinedToolFactory<{
|
|
113
113
|
action: "key" | "type" | "mouse_move" | "left_click" | "left_click_drag" | "right_click" | "middle_click" | "double_click" | "screenshot" | "cursor_position";
|
|
114
114
|
coordinate?: number[];
|
|
115
115
|
text?: string;
|
|
@@ -117,11 +117,11 @@ declare const vertexAnthropicTools: {
|
|
|
117
117
|
displayWidthPx: number;
|
|
118
118
|
displayHeightPx: number;
|
|
119
119
|
displayNumber?: number;
|
|
120
|
-
}>;
|
|
120
|
+
}, {}>;
|
|
121
121
|
/**
|
|
122
122
|
* Creates a web search tool that gives Claude direct access to real-time web content.
|
|
123
123
|
*/
|
|
124
|
-
webSearch_20250305: (args?: Parameters<_ai_sdk_provider_utils.
|
|
124
|
+
webSearch_20250305: (args?: Parameters<_ai_sdk_provider_utils.ProviderExecutedToolFactory<{
|
|
125
125
|
query: string;
|
|
126
126
|
}, {
|
|
127
127
|
type: "web_search_result";
|
|
@@ -140,7 +140,7 @@ declare const vertexAnthropicTools: {
|
|
|
140
140
|
country?: string;
|
|
141
141
|
timezone?: string;
|
|
142
142
|
};
|
|
143
|
-
}>>[0]) => _ai_sdk_provider_utils.Tool<{
|
|
143
|
+
}, {}>>[0]) => _ai_sdk_provider_utils.Tool<{
|
|
144
144
|
query: string;
|
|
145
145
|
}, {
|
|
146
146
|
type: "web_search_result";
|
|
@@ -148,23 +148,68 @@ declare const vertexAnthropicTools: {
|
|
|
148
148
|
title: string | null;
|
|
149
149
|
pageAge: string | null;
|
|
150
150
|
encryptedContent: string;
|
|
151
|
-
}[]>;
|
|
151
|
+
}[], {}>;
|
|
152
|
+
/**
|
|
153
|
+
* Creates a tool search tool that uses regex patterns to find tools.
|
|
154
|
+
*
|
|
155
|
+
* The tool search tool enables Claude to work with hundreds or thousands of tools
|
|
156
|
+
* by dynamically discovering and loading them on-demand.
|
|
157
|
+
*
|
|
158
|
+
* Use `providerOptions: { anthropic: { deferLoading: true } }` on other tools
|
|
159
|
+
* to mark them for deferred loading.
|
|
160
|
+
*/
|
|
161
|
+
toolSearchRegex_20251119: (args?: Parameters<_ai_sdk_provider_utils.ProviderExecutedToolFactory<{
|
|
162
|
+
pattern: string;
|
|
163
|
+
limit?: number;
|
|
164
|
+
}, {
|
|
165
|
+
type: "tool_reference";
|
|
166
|
+
toolName: string;
|
|
167
|
+
}[], {}, {}>>[0]) => _ai_sdk_provider_utils.Tool<{
|
|
168
|
+
pattern: string;
|
|
169
|
+
limit?: number;
|
|
170
|
+
}, {
|
|
171
|
+
type: "tool_reference";
|
|
172
|
+
toolName: string;
|
|
173
|
+
}[], {}>;
|
|
174
|
+
/**
|
|
175
|
+
* Creates a tool search tool that uses BM25 (natural language) to find tools.
|
|
176
|
+
*
|
|
177
|
+
* The tool search tool enables Claude to work with hundreds or thousands of tools
|
|
178
|
+
* by dynamically discovering and loading them on-demand.
|
|
179
|
+
*
|
|
180
|
+
* Use `providerOptions: { anthropic: { deferLoading: true } }` on other tools
|
|
181
|
+
* to mark them for deferred loading.
|
|
182
|
+
*/
|
|
183
|
+
toolSearchBm25_20251119: (args?: Parameters<_ai_sdk_provider_utils.ProviderExecutedToolFactory<{
|
|
184
|
+
query: string;
|
|
185
|
+
limit?: number;
|
|
186
|
+
}, {
|
|
187
|
+
type: "tool_reference";
|
|
188
|
+
toolName: string;
|
|
189
|
+
}[], {}, {}>>[0]) => _ai_sdk_provider_utils.Tool<{
|
|
190
|
+
query: string;
|
|
191
|
+
limit?: number;
|
|
192
|
+
}, {
|
|
193
|
+
type: "tool_reference";
|
|
194
|
+
toolName: string;
|
|
195
|
+
}[], {}>;
|
|
152
196
|
};
|
|
153
|
-
interface GoogleVertexAnthropicProvider extends
|
|
197
|
+
interface GoogleVertexAnthropicProvider extends ProviderV4 {
|
|
154
198
|
/**
|
|
155
199
|
* Creates a model for text generation.
|
|
156
200
|
*/
|
|
157
|
-
(modelId:
|
|
201
|
+
(modelId: GoogleVertexAnthropicModelId): LanguageModelV4;
|
|
158
202
|
/**
|
|
159
203
|
* Creates a model for text generation.
|
|
160
204
|
*/
|
|
161
|
-
languageModel(modelId:
|
|
205
|
+
languageModel(modelId: GoogleVertexAnthropicModelId): LanguageModelV4;
|
|
162
206
|
/**
|
|
163
207
|
* Anthropic tools supported by Google Vertex.
|
|
164
208
|
* Note: Only a subset of Anthropic tools are available on Vertex.
|
|
165
209
|
* Supported tools: bash_20241022, bash_20250124, textEditor_20241022,
|
|
166
210
|
* textEditor_20250124, textEditor_20250429, textEditor_20250728,
|
|
167
|
-
* computer_20241022, webSearch_20250305
|
|
211
|
+
* computer_20241022, webSearch_20250305, toolSearchRegex_20251119,
|
|
212
|
+
* toolSearchBm25_20251119
|
|
168
213
|
*/
|
|
169
214
|
tools: typeof vertexAnthropicTools;
|
|
170
215
|
/**
|
package/dist/anthropic/index.js
CHANGED
|
@@ -1,40 +1,13 @@
|
|
|
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/index.ts
|
|
21
|
-
var anthropic_exports = {};
|
|
22
|
-
__export(anthropic_exports, {
|
|
23
|
-
createVertexAnthropic: () => createVertexAnthropic2,
|
|
24
|
-
vertexAnthropic: () => vertexAnthropic
|
|
25
|
-
});
|
|
26
|
-
module.exports = __toCommonJS(anthropic_exports);
|
|
27
|
-
|
|
28
1
|
// src/anthropic/google-vertex-anthropic-provider-node.ts
|
|
29
|
-
|
|
2
|
+
import { resolve } from "@ai-sdk/provider-utils";
|
|
30
3
|
|
|
31
4
|
// src/google-vertex-auth-google-auth-library.ts
|
|
32
|
-
|
|
5
|
+
import { GoogleAuth } from "google-auth-library";
|
|
33
6
|
var authInstance = null;
|
|
34
7
|
var authOptions = null;
|
|
35
8
|
function getAuth(options) {
|
|
36
9
|
if (!authInstance || options !== authOptions) {
|
|
37
|
-
authInstance = new
|
|
10
|
+
authInstance = new GoogleAuth({
|
|
38
11
|
scopes: ["https://www.googleapis.com/auth/cloud-platform"],
|
|
39
12
|
...options
|
|
40
13
|
});
|
|
@@ -50,9 +23,17 @@ async function generateAuthToken(options) {
|
|
|
50
23
|
}
|
|
51
24
|
|
|
52
25
|
// src/anthropic/google-vertex-anthropic-provider.ts
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
26
|
+
import {
|
|
27
|
+
NoSuchModelError
|
|
28
|
+
} from "@ai-sdk/provider";
|
|
29
|
+
import {
|
|
30
|
+
loadOptionalSetting,
|
|
31
|
+
withoutTrailingSlash
|
|
32
|
+
} from "@ai-sdk/provider-utils";
|
|
33
|
+
import {
|
|
34
|
+
anthropicTools,
|
|
35
|
+
AnthropicLanguageModel
|
|
36
|
+
} from "@ai-sdk/anthropic/internal";
|
|
56
37
|
var vertexAnthropicTools = {
|
|
57
38
|
/**
|
|
58
39
|
* The bash tool enables Claude to execute shell commands in a persistent bash session,
|
|
@@ -60,75 +41,95 @@ var vertexAnthropicTools = {
|
|
|
60
41
|
*
|
|
61
42
|
* Image results are supported.
|
|
62
43
|
*/
|
|
63
|
-
bash_20241022:
|
|
44
|
+
bash_20241022: anthropicTools.bash_20241022,
|
|
64
45
|
/**
|
|
65
46
|
* The bash tool enables Claude to execute shell commands in a persistent bash session,
|
|
66
47
|
* allowing system operations, script execution, and command-line automation.
|
|
67
48
|
*
|
|
68
49
|
* Image results are supported.
|
|
69
50
|
*/
|
|
70
|
-
bash_20250124:
|
|
51
|
+
bash_20250124: anthropicTools.bash_20250124,
|
|
71
52
|
/**
|
|
72
53
|
* Claude can use an Anthropic-defined text editor tool to view and modify text files,
|
|
73
54
|
* helping you debug, fix, and improve your code or other text documents.
|
|
74
55
|
*
|
|
75
56
|
* Supported models: Claude Sonnet 3.5
|
|
76
57
|
*/
|
|
77
|
-
textEditor_20241022:
|
|
58
|
+
textEditor_20241022: anthropicTools.textEditor_20241022,
|
|
78
59
|
/**
|
|
79
60
|
* Claude can use an Anthropic-defined text editor tool to view and modify text files,
|
|
80
61
|
* helping you debug, fix, and improve your code or other text documents.
|
|
81
62
|
*
|
|
82
63
|
* Supported models: Claude Sonnet 3.7
|
|
83
64
|
*/
|
|
84
|
-
textEditor_20250124:
|
|
65
|
+
textEditor_20250124: anthropicTools.textEditor_20250124,
|
|
85
66
|
/**
|
|
86
67
|
* Claude can use an Anthropic-defined text editor tool to view and modify text files.
|
|
87
68
|
* Note: This version does not support the "undo_edit" command.
|
|
88
69
|
* @deprecated Use textEditor_20250728 instead
|
|
89
70
|
*/
|
|
90
|
-
textEditor_20250429:
|
|
71
|
+
textEditor_20250429: anthropicTools.textEditor_20250429,
|
|
91
72
|
/**
|
|
92
73
|
* Claude can use an Anthropic-defined text editor tool to view and modify text files.
|
|
93
74
|
* Note: This version does not support the "undo_edit" command and adds optional max_characters parameter.
|
|
94
75
|
* Supported models: Claude Sonnet 4, Opus 4, and Opus 4.1
|
|
95
76
|
*/
|
|
96
|
-
textEditor_20250728:
|
|
77
|
+
textEditor_20250728: anthropicTools.textEditor_20250728,
|
|
97
78
|
/**
|
|
98
79
|
* Claude can interact with computer environments through the computer use tool, which
|
|
99
80
|
* provides screenshot capabilities and mouse/keyboard control for autonomous desktop interaction.
|
|
100
81
|
*
|
|
101
82
|
* Image results are supported.
|
|
102
83
|
*/
|
|
103
|
-
computer_20241022:
|
|
84
|
+
computer_20241022: anthropicTools.computer_20241022,
|
|
104
85
|
/**
|
|
105
86
|
* Creates a web search tool that gives Claude direct access to real-time web content.
|
|
106
87
|
*/
|
|
107
|
-
webSearch_20250305:
|
|
88
|
+
webSearch_20250305: anthropicTools.webSearch_20250305,
|
|
89
|
+
/**
|
|
90
|
+
* Creates a tool search tool that uses regex patterns to find tools.
|
|
91
|
+
*
|
|
92
|
+
* The tool search tool enables Claude to work with hundreds or thousands of tools
|
|
93
|
+
* by dynamically discovering and loading them on-demand.
|
|
94
|
+
*
|
|
95
|
+
* Use `providerOptions: { anthropic: { deferLoading: true } }` on other tools
|
|
96
|
+
* to mark them for deferred loading.
|
|
97
|
+
*/
|
|
98
|
+
toolSearchRegex_20251119: anthropicTools.toolSearchRegex_20251119,
|
|
99
|
+
/**
|
|
100
|
+
* Creates a tool search tool that uses BM25 (natural language) to find tools.
|
|
101
|
+
*
|
|
102
|
+
* The tool search tool enables Claude to work with hundreds or thousands of tools
|
|
103
|
+
* by dynamically discovering and loading them on-demand.
|
|
104
|
+
*
|
|
105
|
+
* Use `providerOptions: { anthropic: { deferLoading: true } }` on other tools
|
|
106
|
+
* to mark them for deferred loading.
|
|
107
|
+
*/
|
|
108
|
+
toolSearchBm25_20251119: anthropicTools.toolSearchBm25_20251119
|
|
108
109
|
};
|
|
109
110
|
function createVertexAnthropic(options = {}) {
|
|
110
111
|
const getBaseURL = () => {
|
|
111
112
|
var _a;
|
|
112
|
-
const location =
|
|
113
|
+
const location = loadOptionalSetting({
|
|
113
114
|
settingValue: options.location,
|
|
114
115
|
environmentVariableName: "GOOGLE_VERTEX_LOCATION"
|
|
115
116
|
});
|
|
116
|
-
const project =
|
|
117
|
+
const project = loadOptionalSetting({
|
|
117
118
|
settingValue: options.project,
|
|
118
119
|
environmentVariableName: "GOOGLE_VERTEX_PROJECT"
|
|
119
120
|
});
|
|
120
|
-
return (_a =
|
|
121
|
+
return (_a = withoutTrailingSlash(options.baseURL)) != null ? _a : `https://${location === "global" ? "" : location + "-"}aiplatform.googleapis.com/v1/projects/${project}/locations/${location}/publishers/anthropic/models`;
|
|
121
122
|
};
|
|
122
123
|
const createChatModel = (modelId) => {
|
|
123
124
|
var _a;
|
|
124
|
-
return new
|
|
125
|
+
return new AnthropicLanguageModel(modelId, {
|
|
125
126
|
provider: "vertex.anthropic.messages",
|
|
126
127
|
baseURL: getBaseURL(),
|
|
127
128
|
headers: (_a = options.headers) != null ? _a : {},
|
|
128
129
|
fetch: options.fetch,
|
|
129
130
|
buildRequestUrl: (baseURL, isStreaming) => `${baseURL}/${modelId}:${isStreaming ? "streamRawPredict" : "rawPredict"}`,
|
|
130
131
|
transformRequestBody: (args) => {
|
|
131
|
-
const { model, ...rest } = args;
|
|
132
|
+
const { model: _model, ...rest } = args;
|
|
132
133
|
return {
|
|
133
134
|
...rest,
|
|
134
135
|
anthropic_version: "vertex-2023-10-16"
|
|
@@ -137,7 +138,9 @@ function createVertexAnthropic(options = {}) {
|
|
|
137
138
|
// Google Vertex Anthropic doesn't support URL sources, force download and base64 conversion
|
|
138
139
|
supportedUrls: () => ({}),
|
|
139
140
|
// force the use of JSON tool fallback for structured outputs since beta header isn't supported
|
|
140
|
-
supportsNativeStructuredOutput: false
|
|
141
|
+
supportsNativeStructuredOutput: false,
|
|
142
|
+
// Vertex Anthropic doesn't support strict mode on tool definitions.
|
|
143
|
+
supportsStrictTools: false
|
|
141
144
|
});
|
|
142
145
|
};
|
|
143
146
|
const provider = function(modelId) {
|
|
@@ -148,16 +151,16 @@ function createVertexAnthropic(options = {}) {
|
|
|
148
151
|
}
|
|
149
152
|
return createChatModel(modelId);
|
|
150
153
|
};
|
|
151
|
-
provider.specificationVersion = "
|
|
154
|
+
provider.specificationVersion = "v4";
|
|
152
155
|
provider.languageModel = createChatModel;
|
|
153
156
|
provider.chat = createChatModel;
|
|
154
157
|
provider.messages = createChatModel;
|
|
155
158
|
provider.embeddingModel = (modelId) => {
|
|
156
|
-
throw new
|
|
159
|
+
throw new NoSuchModelError({ modelId, modelType: "embeddingModel" });
|
|
157
160
|
};
|
|
158
161
|
provider.textEmbeddingModel = provider.embeddingModel;
|
|
159
162
|
provider.imageModel = (modelId) => {
|
|
160
|
-
throw new
|
|
163
|
+
throw new NoSuchModelError({ modelId, modelType: "imageModel" });
|
|
161
164
|
};
|
|
162
165
|
provider.tools = vertexAnthropicTools;
|
|
163
166
|
return provider;
|
|
@@ -171,14 +174,13 @@ function createVertexAnthropic2(options = {}) {
|
|
|
171
174
|
Authorization: `Bearer ${await generateAuthToken(
|
|
172
175
|
options.googleAuthOptions
|
|
173
176
|
)}`,
|
|
174
|
-
...await
|
|
177
|
+
...await resolve(options.headers)
|
|
175
178
|
})
|
|
176
179
|
});
|
|
177
180
|
}
|
|
178
181
|
var vertexAnthropic = createVertexAnthropic2();
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
createVertexAnthropic,
|
|
182
|
+
export {
|
|
183
|
+
createVertexAnthropic2 as createVertexAnthropic,
|
|
182
184
|
vertexAnthropic
|
|
183
|
-
}
|
|
185
|
+
};
|
|
184
186
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/anthropic/index.ts","../../src/anthropic/google-vertex-anthropic-provider-node.ts","../../src/google-vertex-auth-google-auth-library.ts","../../src/anthropic/google-vertex-anthropic-provider.ts"],"sourcesContent":["export {\n vertexAnthropic,\n createVertexAnthropic,\n} from './google-vertex-anthropic-provider-node';\nexport type {\n GoogleVertexAnthropicProvider,\n GoogleVertexAnthropicProviderSettings,\n} from './google-vertex-anthropic-provider-node';\n","import { resolve } from '@ai-sdk/provider-utils';\nimport { GoogleAuthOptions } from 'google-auth-library';\nimport { generateAuthToken } from '../google-vertex-auth-google-auth-library';\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 Authentication options provided by google-auth-library.\n * Complete list of authentication options is documented in the\n * GoogleAuthOptions interface:\n * https://github.com/googleapis/google-auth-library-nodejs/blob/main/src/auth/googleauth.ts.\n */\n googleAuthOptions?: GoogleAuthOptions;\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.googleAuthOptions,\n )}`,\n ...(await resolve(options.headers)),\n }),\n });\n}\n\n/**\n * Default Google Vertex Anthropic provider instance.\n */\nexport const vertexAnthropic = createVertexAnthropic();\n","import { GoogleAuth, GoogleAuthOptions } from 'google-auth-library';\n\nlet authInstance: GoogleAuth | null = null;\nlet authOptions: GoogleAuthOptions | null = null;\n\nfunction getAuth(options: GoogleAuthOptions) {\n if (!authInstance || options !== authOptions) {\n authInstance = new GoogleAuth({\n scopes: ['https://www.googleapis.com/auth/cloud-platform'],\n ...options,\n });\n authOptions = options;\n }\n return authInstance;\n}\n\nexport async function generateAuthToken(options?: GoogleAuthOptions) {\n const auth = getAuth(options || {});\n const client = await auth.getClient();\n const token = await client.getAccessToken();\n return token?.token || null;\n}\n\n// For testing purposes only\nexport function _resetAuthInstance() {\n authInstance = null;\n}\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,iCAA8C;AAE9C,IAAI,eAAkC;AACtC,IAAI,cAAwC;AAE5C,SAAS,QAAQ,SAA4B;AAC3C,MAAI,CAAC,gBAAgB,YAAY,aAAa;AAC5C,mBAAe,IAAI,sCAAW;AAAA,MAC5B,QAAQ,CAAC,gDAAgD;AAAA,MACzD,GAAG;AAAA,IACL,CAAC;AACD,kBAAc;AAAA,EAChB;AACA,SAAO;AACT;AAEA,eAAsB,kBAAkB,SAA6B;AACnE,QAAM,OAAO,QAAQ,WAAW,CAAC,CAAC;AAClC,QAAM,SAAS,MAAM,KAAK,UAAU;AACpC,QAAM,QAAQ,MAAM,OAAO,eAAe;AAC1C,UAAO,+BAAO,UAAS;AACzB;;;ACrBA,sBAIO;AACP,4BAKO;AACP,sBAGO;AAOA,IAAM,uBAAuB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOlC,eAAe,+BAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQ9B,eAAe,+BAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQ9B,qBAAqB,+BAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQpC,qBAAqB,+BAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOpC,qBAAqB,+BAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOpC,qBAAqB,+BAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQpC,mBAAmB,+BAAe;AAAA;AAAA;AAAA;AAAA,EAKlC,oBAAoB,+BAAe;AACrC;AA2DO,SAAS,sBACd,UAAiD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C,UAAM,IAAI,iCAAiB,EAAE,SAAS,WAAW,aAAa,CAAC;AAAA,EACjE;AAEA,WAAS,QAAQ;AAEjB,SAAO;AACT;;;AF3LO,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","createVertexAnthropic"]}
|
|
1
|
+
{"version":3,"sources":["../../src/anthropic/google-vertex-anthropic-provider-node.ts","../../src/google-vertex-auth-google-auth-library.ts","../../src/anthropic/google-vertex-anthropic-provider.ts"],"sourcesContent":["import { resolve } from '@ai-sdk/provider-utils';\nimport { GoogleAuthOptions } from 'google-auth-library';\nimport { generateAuthToken } from '../google-vertex-auth-google-auth-library';\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 Authentication options provided by google-auth-library.\n * Complete list of authentication options is documented in the\n * GoogleAuthOptions interface:\n * https://github.com/googleapis/google-auth-library-nodejs/blob/main/src/auth/googleauth.ts.\n */\n googleAuthOptions?: GoogleAuthOptions;\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.googleAuthOptions,\n )}`,\n ...(await resolve(options.headers)),\n }),\n });\n}\n\n/**\n * Default Google Vertex Anthropic provider instance.\n */\nexport const vertexAnthropic = createVertexAnthropic();\n","import { GoogleAuth, GoogleAuthOptions } from 'google-auth-library';\n\nlet authInstance: GoogleAuth | null = null;\nlet authOptions: GoogleAuthOptions | null = null;\n\nfunction getAuth(options: GoogleAuthOptions) {\n if (!authInstance || options !== authOptions) {\n authInstance = new GoogleAuth({\n scopes: ['https://www.googleapis.com/auth/cloud-platform'],\n ...options,\n });\n authOptions = options;\n }\n return authInstance;\n}\n\nexport async function generateAuthToken(options?: GoogleAuthOptions) {\n const auth = getAuth(options || {});\n const client = await auth.getClient();\n const token = await client.getAccessToken();\n return token?.token || null;\n}\n\n// For testing purposes only\nexport function _resetAuthInstance() {\n authInstance = null;\n}\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 AnthropicLanguageModel,\n} from '@ai-sdk/anthropic/internal';\nimport { GoogleVertexAnthropicModelId } from './google-vertex-anthropic-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: GoogleVertexAnthropicModelId): LanguageModelV4;\n\n /**\n * Creates a model for text generation.\n */\n languageModel(modelId: GoogleVertexAnthropicModelId): 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: GoogleVertexAnthropicModelId) =>\n new AnthropicLanguageModel(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: _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: GoogleVertexAnthropicModelId) {\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,SAAS,eAAe;;;ACAxB,SAAS,kBAAqC;AAE9C,IAAI,eAAkC;AACtC,IAAI,cAAwC;AAE5C,SAAS,QAAQ,SAA4B;AAC3C,MAAI,CAAC,gBAAgB,YAAY,aAAa;AAC5C,mBAAe,IAAI,WAAW;AAAA,MAC5B,QAAQ,CAAC,gDAAgD;AAAA,MACzD,GAAG;AAAA,IACL,CAAC;AACD,kBAAc;AAAA,EAChB;AACA,SAAO;AACT;AAEA,eAAsB,kBAAkB,SAA6B;AACnE,QAAM,OAAO,QAAQ,WAAW,CAAC,CAAC;AAClC,QAAM,SAAS,MAAM,KAAK,UAAU;AACpC,QAAM,QAAQ,MAAM,OAAO,eAAe;AAC1C,UAAO,+BAAO,UAAS;AACzB;;;ACrBA;AAAA,EAEE;AAAA,OAEK;AACP;AAAA,EAGE;AAAA,EACA;AAAA,OACK;AACP;AAA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
import * as _ai_sdk_provider from '@ai-sdk/provider';
|
|
2
|
+
import { EmbeddingModelV4, ProviderV4, LanguageModelV4, ImageModelV4, Experimental_VideoModelV4 } from '@ai-sdk/provider';
|
|
2
3
|
import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
|
|
3
|
-
import { Resolvable, FetchFunction } from '@ai-sdk/provider-utils';
|
|
4
|
+
import { Resolvable, FetchFunction, WORKFLOW_SERIALIZE, WORKFLOW_DESERIALIZE } from '@ai-sdk/provider-utils';
|
|
4
5
|
|
|
5
|
-
type GoogleVertexEmbeddingModelId = 'textembedding-gecko' | 'textembedding-gecko@001' | 'textembedding-gecko@003' | 'textembedding-gecko-multilingual' | 'textembedding-gecko-multilingual@001' | 'text-multilingual-embedding-002' | 'text-embedding-004' | 'text-embedding-005' | (string & {});
|
|
6
|
+
type GoogleVertexEmbeddingModelId = 'textembedding-gecko' | 'textembedding-gecko@001' | 'textembedding-gecko@003' | 'textembedding-gecko-multilingual' | 'textembedding-gecko-multilingual@001' | 'text-multilingual-embedding-002' | 'text-embedding-004' | 'text-embedding-005' | 'gemini-embedding-001' | 'gemini-embedding-2-preview' | (string & {});
|
|
6
7
|
|
|
7
8
|
interface GoogleVertexConfig {
|
|
8
9
|
provider: string;
|
|
9
10
|
baseURL: string;
|
|
10
|
-
headers
|
|
11
|
+
headers?: Resolvable<Record<string, string | undefined>>;
|
|
11
12
|
fetch?: FetchFunction;
|
|
12
13
|
}
|
|
13
14
|
|
|
14
|
-
declare class GoogleVertexEmbeddingModel implements
|
|
15
|
-
readonly specificationVersion = "
|
|
15
|
+
declare class GoogleVertexEmbeddingModel implements EmbeddingModelV4 {
|
|
16
|
+
readonly specificationVersion = "v4";
|
|
16
17
|
readonly modelId: GoogleVertexEmbeddingModelId;
|
|
17
18
|
readonly maxEmbeddingsPerCall = 2048;
|
|
18
19
|
readonly supportsParallelCalls = true;
|
|
19
20
|
private readonly config;
|
|
21
|
+
static [WORKFLOW_SERIALIZE](model: GoogleVertexEmbeddingModel): {
|
|
22
|
+
modelId: string;
|
|
23
|
+
config: _ai_sdk_provider.JSONObject;
|
|
24
|
+
};
|
|
25
|
+
static [WORKFLOW_DESERIALIZE](options: {
|
|
26
|
+
modelId: string;
|
|
27
|
+
config: GoogleVertexConfig;
|
|
28
|
+
}): GoogleVertexEmbeddingModel;
|
|
20
29
|
get provider(): string;
|
|
21
30
|
constructor(modelId: GoogleVertexEmbeddingModelId, config: GoogleVertexConfig);
|
|
22
|
-
doEmbed({ values, headers, abortSignal, providerOptions, }: Parameters<
|
|
31
|
+
doEmbed({ values, headers, abortSignal, providerOptions, }: Parameters<EmbeddingModelV4['doEmbed']>[0]): Promise<Awaited<ReturnType<EmbeddingModelV4['doEmbed']>>>;
|
|
23
32
|
}
|
|
24
33
|
|
|
25
34
|
type GoogleVertexImageModelId = 'imagen-3.0-generate-001' | 'imagen-3.0-generate-002' | 'imagen-3.0-fast-generate-001' | 'imagen-4.0-generate-001' | 'imagen-4.0-ultra-generate-001' | 'imagen-4.0-fast-generate-001' | 'gemini-2.5-flash-image' | 'gemini-3-pro-image-preview' | 'gemini-3.1-flash-image-preview' | (string & {});
|
|
26
35
|
|
|
27
|
-
type GoogleVertexModelId = 'gemini-2.5-pro' | 'gemini-2.5-flash' | 'gemini-2.5-flash-lite' | 'gemini-2.0-flash-lite' | 'gemini-2.0-flash' | 'gemini-2.0-flash-001' | 'gemini-1.5-flash' | 'gemini-1.5-flash-001' | 'gemini-1.5-flash-002' | 'gemini-1.5-pro' | 'gemini-1.5-pro-001' | 'gemini-1.5-pro-002' | 'gemini-1.0-pro-001' | 'gemini-1.0-pro-vision-001' | 'gemini-1.0-pro' | 'gemini-1.0-pro-002' | 'gemini-2.0-flash-lite-preview-02-05' | 'gemini-2.5-flash-
|
|
36
|
+
type GoogleVertexModelId = 'gemini-2.5-pro' | 'gemini-2.5-flash' | 'gemini-2.5-flash-lite' | 'gemini-2.0-flash-lite' | 'gemini-2.0-flash' | 'gemini-2.0-flash-001' | 'gemini-1.5-flash' | 'gemini-1.5-flash-001' | 'gemini-1.5-flash-002' | 'gemini-1.5-pro' | 'gemini-1.5-pro-001' | 'gemini-1.5-pro-002' | 'gemini-1.0-pro-001' | 'gemini-1.0-pro-vision-001' | 'gemini-1.0-pro' | 'gemini-1.0-pro-002' | 'gemini-2.0-flash-lite-preview-02-05' | 'gemini-2.5-flash-preview-09-2025' | 'gemini-3-pro-preview' | 'gemini-3-pro-image-preview' | 'gemini-3-flash-preview' | 'gemini-3.1-pro-preview' | 'gemini-3.1-flash-image-preview' | 'gemini-3.1-flash-lite-preview' | 'gemini-2.0-pro-exp-02-05' | 'gemini-2.0-flash-exp' | (string & {});
|
|
28
37
|
|
|
29
38
|
declare const googleVertexTools: {
|
|
30
|
-
googleSearch: _ai_sdk_provider_utils.
|
|
39
|
+
googleSearch: _ai_sdk_provider_utils.ProviderExecutedToolFactory<{}, {}, {
|
|
31
40
|
[x: string]: unknown;
|
|
32
41
|
searchTypes?: {
|
|
33
42
|
webSearch?: Record<string, never> | undefined;
|
|
@@ -37,45 +46,45 @@ declare const googleVertexTools: {
|
|
|
37
46
|
startTime: string;
|
|
38
47
|
endTime: string;
|
|
39
48
|
} | undefined;
|
|
40
|
-
}>;
|
|
41
|
-
enterpriseWebSearch: _ai_sdk_provider_utils.
|
|
42
|
-
googleMaps: _ai_sdk_provider_utils.
|
|
43
|
-
urlContext: _ai_sdk_provider_utils.
|
|
44
|
-
fileSearch: _ai_sdk_provider_utils.
|
|
49
|
+
}, {}>;
|
|
50
|
+
enterpriseWebSearch: _ai_sdk_provider_utils.ProviderExecutedToolFactory<{}, {}, {}, {}>;
|
|
51
|
+
googleMaps: _ai_sdk_provider_utils.ProviderExecutedToolFactory<{}, {}, {}, {}>;
|
|
52
|
+
urlContext: _ai_sdk_provider_utils.ProviderExecutedToolFactory<{}, {}, {}, {}>;
|
|
53
|
+
fileSearch: _ai_sdk_provider_utils.ProviderExecutedToolFactory<{}, {}, {
|
|
45
54
|
[x: string]: unknown;
|
|
46
55
|
fileSearchStoreNames: string[];
|
|
47
56
|
topK?: number | undefined;
|
|
48
57
|
metadataFilter?: string | undefined;
|
|
49
|
-
}>;
|
|
50
|
-
codeExecution: _ai_sdk_provider_utils.
|
|
58
|
+
}, {}>;
|
|
59
|
+
codeExecution: _ai_sdk_provider_utils.ProviderExecutedToolFactory<{
|
|
51
60
|
language: string;
|
|
52
61
|
code: string;
|
|
53
62
|
}, {
|
|
54
63
|
outcome: string;
|
|
55
64
|
output: string;
|
|
56
|
-
}, {}>;
|
|
57
|
-
vertexRagStore: _ai_sdk_provider_utils.
|
|
65
|
+
}, {}, {}>;
|
|
66
|
+
vertexRagStore: _ai_sdk_provider_utils.ProviderExecutedToolFactory<{}, {}, {
|
|
58
67
|
ragCorpus: string;
|
|
59
68
|
topK?: number;
|
|
60
|
-
}>;
|
|
69
|
+
}, {}>;
|
|
61
70
|
};
|
|
62
71
|
|
|
63
72
|
type GoogleVertexVideoModelId = 'veo-2.0-generate-preview' | 'veo-2.0-generate-exp' | 'veo-2.0-generate-001' | 'veo-3.0-generate-001' | 'veo-3.0-fast-generate-001' | 'veo-3.0-generate-preview' | 'veo-3.0-fast-generate-preview' | 'veo-3.1-generate-001' | 'veo-3.1-fast-generate-001' | 'veo-3.1-generate-preview' | 'veo-3.1-fast-generate-preview' | (string & {});
|
|
64
73
|
|
|
65
|
-
interface GoogleVertexProvider extends
|
|
74
|
+
interface GoogleVertexProvider extends ProviderV4 {
|
|
66
75
|
/**
|
|
67
76
|
* Creates a model for text generation.
|
|
68
77
|
*/
|
|
69
|
-
(modelId: GoogleVertexModelId):
|
|
70
|
-
languageModel: (modelId: GoogleVertexModelId) =>
|
|
78
|
+
(modelId: GoogleVertexModelId): LanguageModelV4;
|
|
79
|
+
languageModel: (modelId: GoogleVertexModelId) => LanguageModelV4;
|
|
71
80
|
/**
|
|
72
81
|
* Creates a model for image generation.
|
|
73
82
|
*/
|
|
74
|
-
image(modelId: GoogleVertexImageModelId):
|
|
83
|
+
image(modelId: GoogleVertexImageModelId): ImageModelV4;
|
|
75
84
|
/**
|
|
76
85
|
* Creates a model for image generation.
|
|
77
86
|
*/
|
|
78
|
-
imageModel(modelId: GoogleVertexImageModelId):
|
|
87
|
+
imageModel(modelId: GoogleVertexImageModelId): ImageModelV4;
|
|
79
88
|
tools: typeof googleVertexTools;
|
|
80
89
|
/**
|
|
81
90
|
* @deprecated Use `embeddingModel` instead.
|
|
@@ -84,11 +93,11 @@ interface GoogleVertexProvider extends ProviderV3 {
|
|
|
84
93
|
/**
|
|
85
94
|
* Creates a model for video generation.
|
|
86
95
|
*/
|
|
87
|
-
video(modelId: GoogleVertexVideoModelId):
|
|
96
|
+
video(modelId: GoogleVertexVideoModelId): Experimental_VideoModelV4;
|
|
88
97
|
/**
|
|
89
98
|
* Creates a model for video generation.
|
|
90
99
|
*/
|
|
91
|
-
videoModel(modelId: GoogleVertexVideoModelId):
|
|
100
|
+
videoModel(modelId: GoogleVertexVideoModelId): Experimental_VideoModelV4;
|
|
92
101
|
}
|
|
93
102
|
interface GoogleVertexProviderSettings$1 {
|
|
94
103
|
/**
|