@ai-sdk/google-vertex 1.0.4 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,27 @@
1
1
  # @ai-sdk/google-vertex
2
2
 
3
+ ## 2.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - bcd892e: feat (provider/google-vertex): Add support for Anthropic models.
8
+ - Updated dependencies [bcd892e]
9
+ - @ai-sdk/anthropic@1.0.4
10
+
11
+ ## 2.0.0
12
+
13
+ ### Major Changes
14
+
15
+ - 0984f0b: feat (provider/google-vertex): Rewrite for Edge runtime support.
16
+
17
+ ### Patch Changes
18
+
19
+ - 0984f0b: chore (providers/google-vertex): Remove unref'd base default provider.
20
+ - Updated dependencies [0984f0b]
21
+ - Updated dependencies [0984f0b]
22
+ - @ai-sdk/google@1.0.5
23
+ - @ai-sdk/provider-utils@2.0.3
24
+
3
25
  ## 1.0.4
4
26
 
5
27
  ### Patch Changes
package/README.md CHANGED
@@ -2,32 +2,164 @@
2
2
 
3
3
  The **[Google Vertex provider](https://sdk.vercel.ai/providers/ai-sdk-providers/google-vertex)** for the [AI SDK](https://sdk.vercel.ai/docs) contains language model support for the [Google Vertex AI](https://cloud.google.com/vertex-ai) APIs.
4
4
 
5
+ This library includes a Google Vertex Anthropic provider. This provider closely follows the core Google Vertex library's usage patterns. See more in the [Google Vertex Anthropic Provider](#google-vertex-anthropic-provider) section below.
6
+
5
7
  ## Setup
6
8
 
7
- The Google provider is available in the `@ai-sdk/google-vertex` module. You can install it with
9
+ The Google Vertex provider is available in the `@ai-sdk/google-vertex` module. You can install it with
8
10
 
9
11
  ```bash
10
12
  npm i @ai-sdk/google-vertex
11
13
  ```
12
14
 
13
- ## Provider Instance
15
+ ## Google Vertex Provider
16
+
17
+ The Google Vertex provider has two different authentication implementations depending on your runtime environment:
14
18
 
15
- You can import the default provider instance `vertex` from `@ai-sdk/google-vertex`:
19
+ ### Node.js Runtime
20
+
21
+ The Node.js runtime is the default runtime supported by the AI SDK. You can use the default provider instance to generate text with the `gemini-1.5-flash` model like this:
16
22
 
17
23
  ```ts
18
24
  import { vertex } from '@ai-sdk/google-vertex';
25
+ import { generateText } from 'ai';
26
+
27
+ const { text } = await generateText({
28
+ model: vertex('gemini-1.5-flash'),
29
+ prompt: 'Write a vegetarian lasagna recipe.',
30
+ });
31
+ ```
32
+
33
+ This provider supports all standard Google Cloud authentication options through the [`google-auth-library`](https://github.com/googleapis/google-auth-library-nodejs?tab=readme-ov-file#ways-to-authenticate). The most common authentication method is to set the path to a json credentials file in the `GOOGLE_APPLICATION_CREDENTIALS` environment variable. Credentials can be obtained from the [Google Cloud Console](https://console.cloud.google.com/apis/credentials).
34
+
35
+ ### Edge Runtime
36
+
37
+ The Edge runtime is supported through the `@ai-sdk/google-vertex/edge` module. Note the additional sub-module path `/edge` required to differentiate the Edge provider from the Node.js provider.
38
+
39
+ You can use the default provider instance to generate text with the `gemini-1.5-flash` model like this:
40
+
41
+ ```ts
42
+ import { vertex } from '@ai-sdk/google-vertex/edge';
43
+ import { generateText } from 'ai';
44
+
45
+ const { text } = await generateText({
46
+ model: vertex('gemini-1.5-flash'),
47
+ prompt: 'Write a vegetarian lasagna recipe.',
48
+ });
49
+ ```
50
+
51
+ This method supports Google's [Application Default Credentials](https://github.com/googleapis/google-auth-library-nodejs?tab=readme-ov-file#application-default-credentials) through the environment variables `GOOGLE_CLIENT_EMAIL`, `GOOGLE_PRIVATE_KEY`, and (optionally) `GOOGLE_PRIVATE_KEY_ID`. The values can be obtained from a json credentials file obtained from the [Google Cloud Console](https://console.cloud.google.com/apis/credentials).
52
+
53
+ ## Google Vertex Anthropic Provider
54
+
55
+ The Google Vertex Anthropic provider is available for both Node.js and Edge runtimes. It follows a similar usage pattern to the [core Google Vertex provider](#google-vertex-provider).
56
+
57
+ ### Node.js Runtime
58
+
59
+ ```ts
60
+ import { vertexAnthropic } from '@ai-sdk/google-vertex/anthropic';
61
+ import { generateText } from 'ai';
62
+
63
+ const { text } = await generateText({
64
+ model: vertexAnthropic('claude-3-5-sonnet@20240620'),
65
+ prompt: 'Write a vegetarian lasagna recipe.',
66
+ });
67
+ ```
68
+
69
+ ### Edge Runtime
70
+
71
+ ```ts
72
+ import { vertexAnthropic } from '@ai-sdk/google-vertex/anthropic/edge';
73
+ import { generateText } from 'ai';
74
+
75
+ const { text } = await generateText({
76
+ model: vertexAnthropic('claude-3-5-sonnet@20240620'),
77
+ prompt: 'Write a vegetarian lasagna recipe.',
78
+ });
79
+ ```
80
+
81
+ ## Custom Provider Configuration
82
+
83
+ You can create a custom provider instance using the `createVertex` function. This allows you to specify additional configuration options. Below is an example with the default Node.js provider which includes a `googleAuthOptions` object.
84
+
85
+ ```ts
86
+ import { createVertex } from '@ai-sdk/google-vertex';
87
+ import { generateText } from 'ai';
88
+
89
+ const customProvider = createVertex({
90
+ project: 'your-project-id',
91
+ location: 'us-central1',
92
+ googleAuthOptions: {
93
+ credentials: {
94
+ client_email: 'your-client-email',
95
+ private_key: 'your-private-key',
96
+ },
97
+ },
98
+ });
99
+
100
+ const { text } = await generateText({
101
+ model: customProvider('gemini-1.5-flash'),
102
+ prompt: 'Write a vegetarian lasagna recipe.',
103
+ });
19
104
  ```
20
105
 
21
- ## Example
106
+ The `googleAuthOptions` object is not present in the Edge provider options but custom provider creation is otherwise identical.
107
+
108
+ The Edge provider supports a `googleCredentials` option rather than `googleAuthOptions`. This can be used to specify the Google Cloud service account credentials and will take precedence over the environment variables used otherwise.
22
109
 
23
110
  ```ts
24
- import { vertex } from '@ai-sdk/google-vertex'
25
- import { generateText } from 'ai'
111
+ import { createVertex } from '@ai-sdk/google-vertex/edge';
112
+ import { generateText } from 'ai';
113
+
114
+ const customProvider = createVertex({
115
+ project: 'your-project-id',
116
+ location: 'us-central1',
117
+ googleCredentials: {
118
+ clientEmail: 'your-client-email',
119
+ privateKey: 'your-private-key',
120
+ },
121
+ });
122
+
123
+ const { text } = await generateText({
124
+ model: customProvider('gemini-1.5-flash'),
125
+ prompt: 'Write a vegetarian lasagna recipe.',
126
+ });
127
+ ```
128
+
129
+ ### Google Vertex Anthropic Provider Custom Configuration
130
+
131
+ The Google Vertex Anthropic provider custom configuration is analogous to the above:
132
+
133
+ ```ts
134
+ import { createVertexAnthropic } from '@ai-sdk/google-vertex/anthropic';
135
+ import { generateText } from 'ai';
136
+
137
+ const customProvider = createVertexAnthropic({
138
+ project: 'your-project-id',
139
+ location: 'us-east5',
140
+ });
141
+
142
+ const { text } = await generateText({
143
+ model: customProvider('claude-3-5-sonnet@20240620'),
144
+ prompt: 'Write a vegetarian lasagna recipe.',
145
+ });
146
+ ```
147
+
148
+ And for the Edge runtime:
149
+
150
+ ```ts
151
+ import { vertexAnthropic } from '@ai-sdk/google-vertex/anthropic/edge';
152
+ import { generateText } from 'ai';
153
+
154
+ const customProvider = createVertexAnthropic({
155
+ project: 'your-project-id',
156
+ location: 'us-east5',
157
+ });
26
158
 
27
159
  const { text } = await generateText({
28
- model: vertex('gemini-1.5-flash')
29
- prompt: 'Write a vegetarian lasagna recipe for 4 people.'
30
- })
160
+ model: customProvider('claude-3-5-sonnet@20240620'),
161
+ prompt: 'Write a vegetarian lasagna recipe.',
162
+ });
31
163
  ```
32
164
 
33
165
  ## Documentation
@@ -0,0 +1,62 @@
1
+ import { ProviderV1, LanguageModelV1 } from '@ai-sdk/provider';
2
+ import { Resolvable, FetchFunction } from '@ai-sdk/provider-utils';
3
+ import { AnthropicMessagesSettings, anthropicTools } from '@ai-sdk/anthropic/internal';
4
+ import { GoogleAuthOptions } from 'google-auth-library';
5
+
6
+ type GoogleVertexAnthropicMessagesModelId = '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
+
8
+ interface GoogleVertexAnthropicProvider extends ProviderV1 {
9
+ /**
10
+ Creates a model for text generation.
11
+ */
12
+ (modelId: GoogleVertexAnthropicMessagesModelId, settings?: AnthropicMessagesSettings): LanguageModelV1;
13
+ /**
14
+ Creates a model for text generation.
15
+ */
16
+ languageModel(modelId: GoogleVertexAnthropicMessagesModelId, settings?: AnthropicMessagesSettings): LanguageModelV1;
17
+ /**
18
+ Anthropic-specific computer use tool.
19
+ */
20
+ tools: typeof anthropicTools;
21
+ }
22
+ interface GoogleVertexAnthropicProviderSettings$1 {
23
+ /**
24
+ * Google Cloud project ID. Defaults to the value of the `GOOGLE_VERTEX_PROJECT` environment variable.
25
+ */
26
+ project?: string;
27
+ /**
28
+ * Google Cloud region. Defaults to the value of the `GOOGLE_VERTEX_LOCATION` environment variable.
29
+ */
30
+ location?: string;
31
+ /**
32
+ Use a different URL prefix for API calls, e.g. to use proxy servers.
33
+ The default prefix is `https://api.anthropic.com/v1`.
34
+ */
35
+ baseURL?: string;
36
+ /**
37
+ Custom headers to include in the requests.
38
+ */
39
+ headers?: Resolvable<Record<string, string | undefined>>;
40
+ /**
41
+ Custom fetch implementation. You can use it as a middleware to intercept requests,
42
+ or to provide a custom fetch implementation for e.g. testing.
43
+ */
44
+ fetch?: FetchFunction;
45
+ }
46
+
47
+ interface GoogleVertexAnthropicProviderSettings extends GoogleVertexAnthropicProviderSettings$1 {
48
+ /**
49
+ Optional. The Authentication options provided by google-auth-library.
50
+ Complete list of authentication options is documented in the
51
+ GoogleAuthOptions interface:
52
+ https://github.com/googleapis/google-auth-library-nodejs/blob/main/src/auth/googleauth.ts.
53
+ */
54
+ googleAuthOptions?: GoogleAuthOptions;
55
+ }
56
+ declare function createVertexAnthropic(options?: GoogleVertexAnthropicProviderSettings): GoogleVertexAnthropicProvider;
57
+ /**
58
+ Default Google Vertex Anthropic provider instance.
59
+ */
60
+ declare const vertexAnthropic: GoogleVertexAnthropicProvider;
61
+
62
+ export { type GoogleVertexAnthropicProvider, type GoogleVertexAnthropicProviderSettings, createVertexAnthropic, vertexAnthropic };
@@ -0,0 +1,62 @@
1
+ import { ProviderV1, LanguageModelV1 } from '@ai-sdk/provider';
2
+ import { Resolvable, FetchFunction } from '@ai-sdk/provider-utils';
3
+ import { AnthropicMessagesSettings, anthropicTools } from '@ai-sdk/anthropic/internal';
4
+ import { GoogleAuthOptions } from 'google-auth-library';
5
+
6
+ type GoogleVertexAnthropicMessagesModelId = '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
+
8
+ interface GoogleVertexAnthropicProvider extends ProviderV1 {
9
+ /**
10
+ Creates a model for text generation.
11
+ */
12
+ (modelId: GoogleVertexAnthropicMessagesModelId, settings?: AnthropicMessagesSettings): LanguageModelV1;
13
+ /**
14
+ Creates a model for text generation.
15
+ */
16
+ languageModel(modelId: GoogleVertexAnthropicMessagesModelId, settings?: AnthropicMessagesSettings): LanguageModelV1;
17
+ /**
18
+ Anthropic-specific computer use tool.
19
+ */
20
+ tools: typeof anthropicTools;
21
+ }
22
+ interface GoogleVertexAnthropicProviderSettings$1 {
23
+ /**
24
+ * Google Cloud project ID. Defaults to the value of the `GOOGLE_VERTEX_PROJECT` environment variable.
25
+ */
26
+ project?: string;
27
+ /**
28
+ * Google Cloud region. Defaults to the value of the `GOOGLE_VERTEX_LOCATION` environment variable.
29
+ */
30
+ location?: string;
31
+ /**
32
+ Use a different URL prefix for API calls, e.g. to use proxy servers.
33
+ The default prefix is `https://api.anthropic.com/v1`.
34
+ */
35
+ baseURL?: string;
36
+ /**
37
+ Custom headers to include in the requests.
38
+ */
39
+ headers?: Resolvable<Record<string, string | undefined>>;
40
+ /**
41
+ Custom fetch implementation. You can use it as a middleware to intercept requests,
42
+ or to provide a custom fetch implementation for e.g. testing.
43
+ */
44
+ fetch?: FetchFunction;
45
+ }
46
+
47
+ interface GoogleVertexAnthropicProviderSettings extends GoogleVertexAnthropicProviderSettings$1 {
48
+ /**
49
+ Optional. The Authentication options provided by google-auth-library.
50
+ Complete list of authentication options is documented in the
51
+ GoogleAuthOptions interface:
52
+ https://github.com/googleapis/google-auth-library-nodejs/blob/main/src/auth/googleauth.ts.
53
+ */
54
+ googleAuthOptions?: GoogleAuthOptions;
55
+ }
56
+ declare function createVertexAnthropic(options?: GoogleVertexAnthropicProviderSettings): GoogleVertexAnthropicProvider;
57
+ /**
58
+ Default Google Vertex Anthropic provider instance.
59
+ */
60
+ declare const vertexAnthropic: GoogleVertexAnthropicProvider;
61
+
62
+ export { type GoogleVertexAnthropicProvider, type GoogleVertexAnthropicProviderSettings, createVertexAnthropic, vertexAnthropic };
@@ -0,0 +1,121 @@
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
+ // src/google-vertex-auth-google-auth-library.ts
29
+ var import_google_auth_library = require("google-auth-library");
30
+ var authInstance = null;
31
+ var authOptions = null;
32
+ function getAuth(options) {
33
+ if (!authInstance || options !== authOptions) {
34
+ authInstance = new import_google_auth_library.GoogleAuth({
35
+ scopes: ["https://www.googleapis.com/auth/cloud-platform"],
36
+ ...options
37
+ });
38
+ authOptions = options;
39
+ }
40
+ return authInstance;
41
+ }
42
+ async function generateAuthToken(options) {
43
+ const auth = getAuth(options || {});
44
+ const client = await auth.getClient();
45
+ const token = await client.getAccessToken();
46
+ return (token == null ? void 0 : token.token) || null;
47
+ }
48
+
49
+ // src/anthropic/google-vertex-anthropic-provider.ts
50
+ var import_provider = require("@ai-sdk/provider");
51
+ var import_provider_utils = require("@ai-sdk/provider-utils");
52
+ var import_internal = require("@ai-sdk/anthropic/internal");
53
+ function createVertexAnthropic(options = {}) {
54
+ var _a;
55
+ const location = (0, import_provider_utils.loadOptionalSetting)({
56
+ settingValue: options.location,
57
+ environmentVariableName: "GOOGLE_VERTEX_LOCATION"
58
+ });
59
+ const project = (0, import_provider_utils.loadOptionalSetting)({
60
+ settingValue: options.project,
61
+ environmentVariableName: "GOOGLE_VERTEX_PROJECT"
62
+ });
63
+ const baseURL = (_a = (0, import_provider_utils.withoutTrailingSlash)(options.baseURL)) != null ? _a : `https://${location}-aiplatform.googleapis.com/v1/projects/${project}/locations/${location}/publishers/anthropic/models`;
64
+ const createChatModel = (modelId, settings = {}) => {
65
+ var _a2;
66
+ return new import_internal.AnthropicMessagesLanguageModel(
67
+ modelId,
68
+ settings,
69
+ {
70
+ provider: "vertex.anthropic.messages",
71
+ baseURL,
72
+ headers: (_a2 = options.headers) != null ? _a2 : {},
73
+ fetch: options.fetch,
74
+ buildRequestUrl: (baseURL2, isStreaming) => `${baseURL2}/${modelId}:${isStreaming ? "streamRawPredict" : "rawPredict"}`,
75
+ transformRequestBody: (args) => {
76
+ const { model, ...rest } = args;
77
+ return {
78
+ ...rest,
79
+ anthropic_version: "vertex-2023-10-16"
80
+ };
81
+ }
82
+ }
83
+ );
84
+ };
85
+ const provider = function(modelId, settings) {
86
+ if (new.target) {
87
+ throw new Error(
88
+ "The Anthropic model function cannot be called with the new keyword."
89
+ );
90
+ }
91
+ return createChatModel(modelId, settings);
92
+ };
93
+ provider.languageModel = createChatModel;
94
+ provider.chat = createChatModel;
95
+ provider.messages = createChatModel;
96
+ provider.textEmbeddingModel = (modelId) => {
97
+ throw new import_provider.NoSuchModelError({ modelId, modelType: "textEmbeddingModel" });
98
+ };
99
+ provider.tools = import_internal.anthropicTools;
100
+ return provider;
101
+ }
102
+
103
+ // src/anthropic/google-vertex-anthropic-provider-node.ts
104
+ function createVertexAnthropic2(options = {}) {
105
+ var _a;
106
+ return createVertexAnthropic({
107
+ ...options,
108
+ headers: (_a = options.headers) != null ? _a : async () => ({
109
+ Authorization: `Bearer ${await generateAuthToken(
110
+ options.googleAuthOptions
111
+ )}`
112
+ })
113
+ });
114
+ }
115
+ var vertexAnthropic = createVertexAnthropic2();
116
+ // Annotate the CommonJS export names for ESM import in node:
117
+ 0 && (module.exports = {
118
+ createVertexAnthropic,
119
+ vertexAnthropic
120
+ });
121
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/anthropic/index.ts","../../src/google-vertex-auth-google-auth-library.ts","../../src/anthropic/google-vertex-anthropic-provider.ts","../../src/anthropic/google-vertex-anthropic-provider-node.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 { 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 LanguageModelV1,\n NoSuchModelError,\n ProviderV1,\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 AnthropicMessagesModelId,\n AnthropicMessagesSettings,\n} from '@ai-sdk/anthropic/internal';\nimport {\n GoogleVertexAnthropicMessagesModelId,\n GoogleVertexAnthropicMessagesSettings,\n} from './google-vertex-anthropic-messages-settings';\nexport interface GoogleVertexAnthropicProvider extends ProviderV1 {\n /**\nCreates a model for text generation.\n*/\n (\n modelId: GoogleVertexAnthropicMessagesModelId,\n settings?: AnthropicMessagesSettings,\n ): LanguageModelV1;\n\n /**\nCreates a model for text generation.\n*/\n languageModel(\n modelId: GoogleVertexAnthropicMessagesModelId,\n settings?: AnthropicMessagesSettings,\n ): LanguageModelV1;\n\n /**\nAnthropic-specific computer use tool.\n */\n tools: typeof anthropicTools;\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 /**\nUse a different URL prefix for API calls, e.g. to use proxy servers.\nThe default prefix is `https://api.anthropic.com/v1`.\n */\n baseURL?: string;\n\n /**\nCustom headers to include in the requests.\n */\n headers?: Resolvable<Record<string, string | undefined>>;\n\n /**\nCustom fetch implementation. You can use it as a middleware to intercept requests,\nor to provide a custom fetch implementation for e.g. testing.\n */\n fetch?: FetchFunction;\n}\n\n/**\nCreate a Google Vertex Anthropic provider instance.\n */\nexport function createVertexAnthropic(\n options: GoogleVertexAnthropicProviderSettings = {},\n): GoogleVertexAnthropicProvider {\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 const baseURL =\n withoutTrailingSlash(options.baseURL) ??\n `https://${location}-aiplatform.googleapis.com/v1/projects/${project}/locations/${location}/publishers/anthropic/models`;\n\n const createChatModel = (\n modelId: GoogleVertexAnthropicMessagesModelId,\n settings: GoogleVertexAnthropicMessagesSettings = {},\n ) =>\n new AnthropicMessagesLanguageModel(\n modelId as AnthropicMessagesModelId,\n settings,\n {\n provider: 'vertex.anthropic.messages',\n baseURL,\n headers: options.headers ?? {},\n fetch: options.fetch,\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 },\n );\n\n const provider = function (\n modelId: GoogleVertexAnthropicMessagesModelId,\n settings?: GoogleVertexAnthropicMessagesSettings,\n ) {\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, settings);\n };\n\n provider.languageModel = createChatModel;\n provider.chat = createChatModel;\n provider.messages = createChatModel;\n provider.textEmbeddingModel = (modelId: string) => {\n throw new NoSuchModelError({ modelId, modelType: 'textEmbeddingModel' });\n };\n\n provider.tools = anthropicTools;\n\n return provider as GoogleVertexAnthropicProvider;\n}\n","import { 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';\nimport { GoogleAuthOptions } from 'google-auth-library';\n\nexport type { GoogleVertexAnthropicProvider };\n\nexport interface GoogleVertexAnthropicProviderSettings\n extends GoogleVertexAnthropicProviderSettingsOriginal {\n /**\n Optional. The Authentication options provided by google-auth-library.\nComplete list of authentication options is documented in the\nGoogleAuthOptions interface:\nhttps://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:\n options.headers ??\n (async () => ({\n Authorization: `Bearer ${await generateAuthToken(\n options.googleAuthOptions,\n )}`,\n })),\n });\n}\n\n/**\nDefault Google Vertex Anthropic provider instance.\n */\nexport const vertexAnthropic = createVertexAnthropic();\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,+BAAAA;AAAA,EAAA;AAAA;AAAA;;;ACAA,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,sBAKO;AA4DA,SAAS,sBACd,UAAiD,CAAC,GACnB;AA9EjC;AA+EE,QAAM,eAAW,2CAAoB;AAAA,IACnC,cAAc,QAAQ;AAAA,IACtB,yBAAyB;AAAA,EAC3B,CAAC;AACD,QAAM,cAAU,2CAAoB;AAAA,IAClC,cAAc,QAAQ;AAAA,IACtB,yBAAyB;AAAA,EAC3B,CAAC;AACD,QAAM,WACJ,qDAAqB,QAAQ,OAAO,MAApC,YACA,WAAW,QAAQ,0CAA0C,OAAO,cAAc,QAAQ;AAE5F,QAAM,kBAAkB,CACtB,SACA,WAAkD,CAAC,MACnD;AA9FJ,QAAAC;AA+FI,eAAI;AAAA,MACF;AAAA,MACA;AAAA,MACA;AAAA,QACE,UAAU;AAAA,QACV;AAAA,QACA,UAASA,MAAA,QAAQ,YAAR,OAAAA,MAAmB,CAAC;AAAA,QAC7B,OAAO,QAAQ;AAAA,QACf,iBAAiB,CAACC,UAAS,gBACzB,GAAGA,QAAO,IAAI,OAAO,IACnB,cAAc,qBAAqB,YACrC;AAAA,QACF,sBAAsB,UAAQ;AAE5B,gBAAM,EAAE,OAAO,GAAG,KAAK,IAAI;AAC3B,iBAAO;AAAA,YACL,GAAG;AAAA,YACH,mBAAmB;AAAA,UACrB;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA;AAEF,QAAM,WAAW,SACf,SACA,UACA;AACA,QAAI,YAAY;AACd,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AAAA,IACF;AAEA,WAAO,gBAAgB,SAAS,QAAQ;AAAA,EAC1C;AAEA,WAAS,gBAAgB;AACzB,WAAS,OAAO;AAChB,WAAS,WAAW;AACpB,WAAS,qBAAqB,CAAC,YAAoB;AACjD,UAAM,IAAI,iCAAiB,EAAE,SAAS,WAAW,qBAAqB,CAAC;AAAA,EACzE;AAEA,WAAS,QAAQ;AAEjB,SAAO;AACT;;;ACxHO,SAASC,uBACd,UAAiD,CAAC,GACnB;AAvBjC;AAwBE,SAAO,sBAA8B;AAAA,IACnC,GAAG;AAAA,IACH,UACE,aAAQ,YAAR,YACC,aAAa;AAAA,MACZ,eAAe,UAAU,MAAM;AAAA,QAC7B,QAAQ;AAAA,MACV,CAAC;AAAA,IACH;AAAA,EACJ,CAAC;AACH;AAKO,IAAM,kBAAkBA,uBAAsB;","names":["createVertexAnthropic","_a","baseURL","createVertexAnthropic"]}
@@ -0,0 +1,101 @@
1
+ // src/google-vertex-auth-google-auth-library.ts
2
+ import { GoogleAuth } from "google-auth-library";
3
+ var authInstance = null;
4
+ var authOptions = null;
5
+ function getAuth(options) {
6
+ if (!authInstance || options !== authOptions) {
7
+ authInstance = new GoogleAuth({
8
+ scopes: ["https://www.googleapis.com/auth/cloud-platform"],
9
+ ...options
10
+ });
11
+ authOptions = options;
12
+ }
13
+ return authInstance;
14
+ }
15
+ async function generateAuthToken(options) {
16
+ const auth = getAuth(options || {});
17
+ const client = await auth.getClient();
18
+ const token = await client.getAccessToken();
19
+ return (token == null ? void 0 : token.token) || null;
20
+ }
21
+
22
+ // src/anthropic/google-vertex-anthropic-provider.ts
23
+ import {
24
+ NoSuchModelError
25
+ } from "@ai-sdk/provider";
26
+ import {
27
+ loadOptionalSetting,
28
+ withoutTrailingSlash
29
+ } from "@ai-sdk/provider-utils";
30
+ import {
31
+ anthropicTools,
32
+ AnthropicMessagesLanguageModel
33
+ } from "@ai-sdk/anthropic/internal";
34
+ function createVertexAnthropic(options = {}) {
35
+ var _a;
36
+ const location = loadOptionalSetting({
37
+ settingValue: options.location,
38
+ environmentVariableName: "GOOGLE_VERTEX_LOCATION"
39
+ });
40
+ const project = loadOptionalSetting({
41
+ settingValue: options.project,
42
+ environmentVariableName: "GOOGLE_VERTEX_PROJECT"
43
+ });
44
+ const baseURL = (_a = withoutTrailingSlash(options.baseURL)) != null ? _a : `https://${location}-aiplatform.googleapis.com/v1/projects/${project}/locations/${location}/publishers/anthropic/models`;
45
+ const createChatModel = (modelId, settings = {}) => {
46
+ var _a2;
47
+ return new AnthropicMessagesLanguageModel(
48
+ modelId,
49
+ settings,
50
+ {
51
+ provider: "vertex.anthropic.messages",
52
+ baseURL,
53
+ headers: (_a2 = options.headers) != null ? _a2 : {},
54
+ fetch: options.fetch,
55
+ buildRequestUrl: (baseURL2, isStreaming) => `${baseURL2}/${modelId}:${isStreaming ? "streamRawPredict" : "rawPredict"}`,
56
+ transformRequestBody: (args) => {
57
+ const { model, ...rest } = args;
58
+ return {
59
+ ...rest,
60
+ anthropic_version: "vertex-2023-10-16"
61
+ };
62
+ }
63
+ }
64
+ );
65
+ };
66
+ const provider = function(modelId, settings) {
67
+ if (new.target) {
68
+ throw new Error(
69
+ "The Anthropic model function cannot be called with the new keyword."
70
+ );
71
+ }
72
+ return createChatModel(modelId, settings);
73
+ };
74
+ provider.languageModel = createChatModel;
75
+ provider.chat = createChatModel;
76
+ provider.messages = createChatModel;
77
+ provider.textEmbeddingModel = (modelId) => {
78
+ throw new NoSuchModelError({ modelId, modelType: "textEmbeddingModel" });
79
+ };
80
+ provider.tools = anthropicTools;
81
+ return provider;
82
+ }
83
+
84
+ // src/anthropic/google-vertex-anthropic-provider-node.ts
85
+ function createVertexAnthropic2(options = {}) {
86
+ var _a;
87
+ return createVertexAnthropic({
88
+ ...options,
89
+ headers: (_a = options.headers) != null ? _a : async () => ({
90
+ Authorization: `Bearer ${await generateAuthToken(
91
+ options.googleAuthOptions
92
+ )}`
93
+ })
94
+ });
95
+ }
96
+ var vertexAnthropic = createVertexAnthropic2();
97
+ export {
98
+ createVertexAnthropic2 as createVertexAnthropic,
99
+ vertexAnthropic
100
+ };
101
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/google-vertex-auth-google-auth-library.ts","../../src/anthropic/google-vertex-anthropic-provider.ts","../../src/anthropic/google-vertex-anthropic-provider-node.ts"],"sourcesContent":["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 LanguageModelV1,\n NoSuchModelError,\n ProviderV1,\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 AnthropicMessagesModelId,\n AnthropicMessagesSettings,\n} from '@ai-sdk/anthropic/internal';\nimport {\n GoogleVertexAnthropicMessagesModelId,\n GoogleVertexAnthropicMessagesSettings,\n} from './google-vertex-anthropic-messages-settings';\nexport interface GoogleVertexAnthropicProvider extends ProviderV1 {\n /**\nCreates a model for text generation.\n*/\n (\n modelId: GoogleVertexAnthropicMessagesModelId,\n settings?: AnthropicMessagesSettings,\n ): LanguageModelV1;\n\n /**\nCreates a model for text generation.\n*/\n languageModel(\n modelId: GoogleVertexAnthropicMessagesModelId,\n settings?: AnthropicMessagesSettings,\n ): LanguageModelV1;\n\n /**\nAnthropic-specific computer use tool.\n */\n tools: typeof anthropicTools;\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 /**\nUse a different URL prefix for API calls, e.g. to use proxy servers.\nThe default prefix is `https://api.anthropic.com/v1`.\n */\n baseURL?: string;\n\n /**\nCustom headers to include in the requests.\n */\n headers?: Resolvable<Record<string, string | undefined>>;\n\n /**\nCustom fetch implementation. You can use it as a middleware to intercept requests,\nor to provide a custom fetch implementation for e.g. testing.\n */\n fetch?: FetchFunction;\n}\n\n/**\nCreate a Google Vertex Anthropic provider instance.\n */\nexport function createVertexAnthropic(\n options: GoogleVertexAnthropicProviderSettings = {},\n): GoogleVertexAnthropicProvider {\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 const baseURL =\n withoutTrailingSlash(options.baseURL) ??\n `https://${location}-aiplatform.googleapis.com/v1/projects/${project}/locations/${location}/publishers/anthropic/models`;\n\n const createChatModel = (\n modelId: GoogleVertexAnthropicMessagesModelId,\n settings: GoogleVertexAnthropicMessagesSettings = {},\n ) =>\n new AnthropicMessagesLanguageModel(\n modelId as AnthropicMessagesModelId,\n settings,\n {\n provider: 'vertex.anthropic.messages',\n baseURL,\n headers: options.headers ?? {},\n fetch: options.fetch,\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 },\n );\n\n const provider = function (\n modelId: GoogleVertexAnthropicMessagesModelId,\n settings?: GoogleVertexAnthropicMessagesSettings,\n ) {\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, settings);\n };\n\n provider.languageModel = createChatModel;\n provider.chat = createChatModel;\n provider.messages = createChatModel;\n provider.textEmbeddingModel = (modelId: string) => {\n throw new NoSuchModelError({ modelId, modelType: 'textEmbeddingModel' });\n };\n\n provider.tools = anthropicTools;\n\n return provider as GoogleVertexAnthropicProvider;\n}\n","import { 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';\nimport { GoogleAuthOptions } from 'google-auth-library';\n\nexport type { GoogleVertexAnthropicProvider };\n\nexport interface GoogleVertexAnthropicProviderSettings\n extends GoogleVertexAnthropicProviderSettingsOriginal {\n /**\n Optional. The Authentication options provided by google-auth-library.\nComplete list of authentication options is documented in the\nGoogleAuthOptions interface:\nhttps://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:\n options.headers ??\n (async () => ({\n Authorization: `Bearer ${await generateAuthToken(\n options.googleAuthOptions,\n )}`,\n })),\n });\n}\n\n/**\nDefault Google Vertex Anthropic provider instance.\n */\nexport const vertexAnthropic = createVertexAnthropic();\n"],"mappings":";AAAA,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;AAAA,EACE;AAAA,EACA;AAAA,OAGK;AA4DA,SAAS,sBACd,UAAiD,CAAC,GACnB;AA9EjC;AA+EE,QAAM,WAAW,oBAAoB;AAAA,IACnC,cAAc,QAAQ;AAAA,IACtB,yBAAyB;AAAA,EAC3B,CAAC;AACD,QAAM,UAAU,oBAAoB;AAAA,IAClC,cAAc,QAAQ;AAAA,IACtB,yBAAyB;AAAA,EAC3B,CAAC;AACD,QAAM,WACJ,0BAAqB,QAAQ,OAAO,MAApC,YACA,WAAW,QAAQ,0CAA0C,OAAO,cAAc,QAAQ;AAE5F,QAAM,kBAAkB,CACtB,SACA,WAAkD,CAAC,MACnD;AA9FJ,QAAAA;AA+FI,eAAI;AAAA,MACF;AAAA,MACA;AAAA,MACA;AAAA,QACE,UAAU;AAAA,QACV;AAAA,QACA,UAASA,MAAA,QAAQ,YAAR,OAAAA,MAAmB,CAAC;AAAA,QAC7B,OAAO,QAAQ;AAAA,QACf,iBAAiB,CAACC,UAAS,gBACzB,GAAGA,QAAO,IAAI,OAAO,IACnB,cAAc,qBAAqB,YACrC;AAAA,QACF,sBAAsB,UAAQ;AAE5B,gBAAM,EAAE,OAAO,GAAG,KAAK,IAAI;AAC3B,iBAAO;AAAA,YACL,GAAG;AAAA,YACH,mBAAmB;AAAA,UACrB;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA;AAEF,QAAM,WAAW,SACf,SACA,UACA;AACA,QAAI,YAAY;AACd,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AAAA,IACF;AAEA,WAAO,gBAAgB,SAAS,QAAQ;AAAA,EAC1C;AAEA,WAAS,gBAAgB;AACzB,WAAS,OAAO;AAChB,WAAS,WAAW;AACpB,WAAS,qBAAqB,CAAC,YAAoB;AACjD,UAAM,IAAI,iBAAiB,EAAE,SAAS,WAAW,qBAAqB,CAAC;AAAA,EACzE;AAEA,WAAS,QAAQ;AAEjB,SAAO;AACT;;;ACxHO,SAASC,uBACd,UAAiD,CAAC,GACnB;AAvBjC;AAwBE,SAAO,sBAA8B;AAAA,IACnC,GAAG;AAAA,IACH,UACE,aAAQ,YAAR,YACC,aAAa;AAAA,MACZ,eAAe,UAAU,MAAM;AAAA,QAC7B,QAAQ;AAAA,MACV,CAAC;AAAA,IACH;AAAA,EACJ,CAAC;AACH;AAKO,IAAM,kBAAkBA,uBAAsB;","names":["_a","baseURL","createVertexAnthropic"]}
@@ -0,0 +1,78 @@
1
+ import { ProviderV1, LanguageModelV1 } from '@ai-sdk/provider';
2
+ import { Resolvable, FetchFunction } from '@ai-sdk/provider-utils';
3
+ import { AnthropicMessagesSettings, anthropicTools } from '@ai-sdk/anthropic/internal';
4
+
5
+ interface GoogleCredentials {
6
+ /**
7
+ * The client email for the Google Cloud service account. Defaults to the
8
+ * value of the `GOOGLE_CLIENT_EMAIL` environment variable.
9
+ */
10
+ clientEmail: string;
11
+ /**
12
+ * The private key for the Google Cloud service account. Defaults to the
13
+ * value of the `GOOGLE_PRIVATE_KEY` environment variable.
14
+ */
15
+ privateKey: string;
16
+ /**
17
+ * Optional. The private key ID for the Google Cloud service account. Defaults
18
+ * to the value of the `GOOGLE_PRIVATE_KEY_ID` environment variable.
19
+ */
20
+ privateKeyId?: string;
21
+ }
22
+
23
+ type GoogleVertexAnthropicMessagesModelId = 'claude-3-5-sonnet-v2@20241022' | 'claude-3-5-haiku@20241022' | 'claude-3-5-sonnet@20240620' | 'claude-3-haiku@20240307' | 'claude-3-sonnet@20240229' | 'claude-3-opus@20240229' | (string & {});
24
+
25
+ interface GoogleVertexAnthropicProvider extends ProviderV1 {
26
+ /**
27
+ Creates a model for text generation.
28
+ */
29
+ (modelId: GoogleVertexAnthropicMessagesModelId, settings?: AnthropicMessagesSettings): LanguageModelV1;
30
+ /**
31
+ Creates a model for text generation.
32
+ */
33
+ languageModel(modelId: GoogleVertexAnthropicMessagesModelId, settings?: AnthropicMessagesSettings): LanguageModelV1;
34
+ /**
35
+ Anthropic-specific computer use tool.
36
+ */
37
+ tools: typeof anthropicTools;
38
+ }
39
+ interface GoogleVertexAnthropicProviderSettings$1 {
40
+ /**
41
+ * Google Cloud project ID. Defaults to the value of the `GOOGLE_VERTEX_PROJECT` environment variable.
42
+ */
43
+ project?: string;
44
+ /**
45
+ * Google Cloud region. Defaults to the value of the `GOOGLE_VERTEX_LOCATION` environment variable.
46
+ */
47
+ location?: string;
48
+ /**
49
+ Use a different URL prefix for API calls, e.g. to use proxy servers.
50
+ The default prefix is `https://api.anthropic.com/v1`.
51
+ */
52
+ baseURL?: string;
53
+ /**
54
+ Custom headers to include in the requests.
55
+ */
56
+ headers?: Resolvable<Record<string, string | undefined>>;
57
+ /**
58
+ Custom fetch implementation. You can use it as a middleware to intercept requests,
59
+ or to provide a custom fetch implementation for e.g. testing.
60
+ */
61
+ fetch?: FetchFunction;
62
+ }
63
+
64
+ interface GoogleVertexAnthropicProviderSettings extends GoogleVertexAnthropicProviderSettings$1 {
65
+ /**
66
+ * Optional. The Google credentials for the Google Cloud service account. If
67
+ * not provided, the Google Vertex provider will use environment variables to
68
+ * load the credentials.
69
+ */
70
+ googleCredentials?: GoogleCredentials;
71
+ }
72
+ declare function createVertexAnthropic(options?: GoogleVertexAnthropicProviderSettings): GoogleVertexAnthropicProvider;
73
+ /**
74
+ * Default Google Vertex AI Anthropic provider instance.
75
+ */
76
+ declare const vertexAnthropic: GoogleVertexAnthropicProvider;
77
+
78
+ export { type GoogleVertexAnthropicProvider, type GoogleVertexAnthropicProviderSettings, createVertexAnthropic, vertexAnthropic };