@ai-sdk/google-vertex 4.0.118 → 4.0.120

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,18 @@
1
1
  # @ai-sdk/google-vertex
2
2
 
3
+ ## 4.0.120
4
+
5
+ ### Patch Changes
6
+
7
+ - 5859749: fix(google-vertex): include CJS output for xai sub-module build
8
+
9
+ ## 4.0.119
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies [38966ab]
14
+ - @ai-sdk/openai-compatible@2.0.46
15
+
3
16
  ## 4.0.118
4
17
 
5
18
  ### Patch Changes
@@ -32,7 +32,7 @@ var import_provider_utils3 = require("@ai-sdk/provider-utils");
32
32
  var import_provider_utils = require("@ai-sdk/provider-utils");
33
33
 
34
34
  // src/version.ts
35
- var VERSION = true ? "4.0.118" : "0.0.0-test";
35
+ var VERSION = true ? "4.0.120" : "0.0.0-test";
36
36
 
37
37
  // src/edge/google-vertex-auth-edge.ts
38
38
  var loadCredentials = async () => {
@@ -10,7 +10,7 @@ import {
10
10
  } from "@ai-sdk/provider-utils";
11
11
 
12
12
  // src/version.ts
13
- var VERSION = true ? "4.0.118" : "0.0.0-test";
13
+ var VERSION = true ? "4.0.120" : "0.0.0-test";
14
14
 
15
15
  // src/edge/google-vertex-auth-edge.ts
16
16
  var loadCredentials = async () => {
@@ -33,7 +33,7 @@ var import_internal3 = require("@ai-sdk/google/internal");
33
33
  var import_provider_utils5 = require("@ai-sdk/provider-utils");
34
34
 
35
35
  // src/version.ts
36
- var VERSION = true ? "4.0.118" : "0.0.0-test";
36
+ var VERSION = true ? "4.0.120" : "0.0.0-test";
37
37
 
38
38
  // src/google-vertex-embedding-model.ts
39
39
  var import_provider = require("@ai-sdk/provider");
@@ -14,7 +14,7 @@ import {
14
14
  } from "@ai-sdk/provider-utils";
15
15
 
16
16
  // src/version.ts
17
- var VERSION = true ? "4.0.118" : "0.0.0-test";
17
+ var VERSION = true ? "4.0.120" : "0.0.0-test";
18
18
 
19
19
  // src/google-vertex-embedding-model.ts
20
20
  import {
package/dist/index.js CHANGED
@@ -49,7 +49,7 @@ var import_internal3 = require("@ai-sdk/google/internal");
49
49
  var import_provider_utils5 = require("@ai-sdk/provider-utils");
50
50
 
51
51
  // src/version.ts
52
- var VERSION = true ? "4.0.118" : "0.0.0-test";
52
+ var VERSION = true ? "4.0.120" : "0.0.0-test";
53
53
 
54
54
  // src/google-vertex-embedding-model.ts
55
55
  var import_provider = require("@ai-sdk/provider");
package/dist/index.mjs CHANGED
@@ -29,7 +29,7 @@ import {
29
29
  } from "@ai-sdk/provider-utils";
30
30
 
31
31
  // src/version.ts
32
- var VERSION = true ? "4.0.118" : "0.0.0-test";
32
+ var VERSION = true ? "4.0.120" : "0.0.0-test";
33
33
 
34
34
  // src/google-vertex-embedding-model.ts
35
35
  import {
@@ -32,7 +32,7 @@ var import_provider_utils3 = require("@ai-sdk/provider-utils");
32
32
  var import_provider_utils = require("@ai-sdk/provider-utils");
33
33
 
34
34
  // src/version.ts
35
- var VERSION = true ? "4.0.118" : "0.0.0-test";
35
+ var VERSION = true ? "4.0.120" : "0.0.0-test";
36
36
 
37
37
  // src/edge/google-vertex-auth-edge.ts
38
38
  var loadCredentials = async () => {
@@ -10,7 +10,7 @@ import {
10
10
  } from "@ai-sdk/provider-utils";
11
11
 
12
12
  // src/version.ts
13
- var VERSION = true ? "4.0.118" : "0.0.0-test";
13
+ var VERSION = true ? "4.0.120" : "0.0.0-test";
14
14
 
15
15
  // src/edge/google-vertex-auth-edge.ts
16
16
  var loadCredentials = async () => {
@@ -0,0 +1,92 @@
1
+ import { ProviderV3, LanguageModelV3 } from '@ai-sdk/provider';
2
+ import { Resolvable, FetchFunction } from '@ai-sdk/provider-utils';
3
+
4
+ interface GoogleCredentials {
5
+ /**
6
+ * The client email for the Google Cloud service account. Defaults to the
7
+ * value of the `GOOGLE_CLIENT_EMAIL` environment variable.
8
+ */
9
+ clientEmail: string;
10
+ /**
11
+ * The private key for the Google Cloud service account. Defaults to the
12
+ * value of the `GOOGLE_PRIVATE_KEY` environment variable.
13
+ */
14
+ privateKey: string;
15
+ /**
16
+ * Optional. The private key ID for the Google Cloud service account. Defaults
17
+ * to the value of the `GOOGLE_PRIVATE_KEY_ID` environment variable.
18
+ */
19
+ privateKeyId?: string;
20
+ }
21
+
22
+ type GoogleVertexXaiModelId = 'xai/grok-4.20-reasoning' | 'xai/grok-4.20-non-reasoning' | 'xai/grok-4.1-fast-reasoning' | 'xai/grok-4.1-fast-non-reasoning' | (string & {});
23
+
24
+ interface GoogleVertexXaiProvider extends ProviderV3 {
25
+ /**
26
+ * Creates a model for text generation.
27
+ */
28
+ (modelId: GoogleVertexXaiModelId): LanguageModelV3;
29
+ /**
30
+ * Creates a model for text generation.
31
+ */
32
+ languageModel(modelId: GoogleVertexXaiModelId): LanguageModelV3;
33
+ /**
34
+ * Creates a chat model for text generation.
35
+ */
36
+ chatModel(modelId: GoogleVertexXaiModelId): LanguageModelV3;
37
+ /**
38
+ * @deprecated Use `embeddingModel` instead.
39
+ */
40
+ textEmbeddingModel(modelId: string): never;
41
+ }
42
+ interface GoogleVertexXaiProviderSettings$1 {
43
+ /**
44
+ * Google Cloud project ID. Defaults to the value of the `GOOGLE_VERTEX_PROJECT` environment variable.
45
+ */
46
+ project?: string;
47
+ /**
48
+ * Google Cloud location/region. Defaults to the value of the `GOOGLE_VERTEX_LOCATION` environment variable.
49
+ * Use 'global' for the global endpoint.
50
+ */
51
+ location?: string;
52
+ /**
53
+ * Base URL for the API calls. If not provided, will be constructed from project and location.
54
+ */
55
+ baseURL?: string;
56
+ /**
57
+ * Headers to use for requests. Can be:
58
+ * - A headers object
59
+ * - A Promise that resolves to a headers object
60
+ * - A function that returns a headers object
61
+ * - A function that returns a Promise of a headers object
62
+ */
63
+ headers?: Resolvable<Record<string, string | undefined>>;
64
+ /**
65
+ * Custom fetch implementation. You can use it as a middleware to intercept requests,
66
+ * or to provide a custom fetch implementation for e.g. testing.
67
+ */
68
+ fetch?: FetchFunction;
69
+ }
70
+
71
+ interface GoogleVertexXaiProviderSettings extends GoogleVertexXaiProviderSettings$1 {
72
+ /**
73
+ * Optional. The Google credentials for the Google Cloud service account. If
74
+ * not provided, the Google Vertex provider will use environment variables to
75
+ * load the credentials.
76
+ */
77
+ googleCredentials?: GoogleCredentials;
78
+ }
79
+ /**
80
+ * Create a Google Vertex AI xAI provider instance for Edge runtimes.
81
+ * Uses the OpenAI-compatible Chat Completions API for Grok partner models.
82
+ * Automatically handles Google Cloud authentication.
83
+ *
84
+ * @see https://cloud.google.com/vertex-ai/generative-ai/docs/partner-models/grok
85
+ */
86
+ declare function createGoogleVertexXai(options?: GoogleVertexXaiProviderSettings): GoogleVertexXaiProvider;
87
+ /**
88
+ * Default Google Vertex AI xAI provider instance for Edge runtimes.
89
+ */
90
+ declare const googleVertexXai: GoogleVertexXaiProvider;
91
+
92
+ export { type GoogleVertexXaiModelId, type GoogleVertexXaiProvider, type GoogleVertexXaiProviderSettings, createGoogleVertexXai, googleVertexXai };
@@ -0,0 +1,274 @@
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/xai/edge/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ createGoogleVertexXai: () => createGoogleVertexXai2,
24
+ googleVertexXai: () => googleVertexXai
25
+ });
26
+ module.exports = __toCommonJS(index_exports);
27
+
28
+ // src/xai/edge/google-vertex-xai-provider-edge.ts
29
+ var import_provider_utils3 = require("@ai-sdk/provider-utils");
30
+
31
+ // src/edge/google-vertex-auth-edge.ts
32
+ var import_provider_utils = require("@ai-sdk/provider-utils");
33
+
34
+ // src/version.ts
35
+ var VERSION = true ? "4.0.120" : "0.0.0-test";
36
+
37
+ // src/edge/google-vertex-auth-edge.ts
38
+ var loadCredentials = async () => {
39
+ try {
40
+ return {
41
+ clientEmail: (0, import_provider_utils.loadSetting)({
42
+ settingValue: void 0,
43
+ settingName: "clientEmail",
44
+ environmentVariableName: "GOOGLE_CLIENT_EMAIL",
45
+ description: "Google client email"
46
+ }),
47
+ privateKey: (0, import_provider_utils.loadSetting)({
48
+ settingValue: void 0,
49
+ settingName: "privateKey",
50
+ environmentVariableName: "GOOGLE_PRIVATE_KEY",
51
+ description: "Google private key"
52
+ }),
53
+ privateKeyId: (0, import_provider_utils.loadOptionalSetting)({
54
+ settingValue: void 0,
55
+ environmentVariableName: "GOOGLE_PRIVATE_KEY_ID"
56
+ })
57
+ };
58
+ } catch (error) {
59
+ throw new Error(`Failed to load Google credentials: ${error.message}`);
60
+ }
61
+ };
62
+ var base64url = (str) => {
63
+ return btoa(str).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
64
+ };
65
+ var importPrivateKey = async (pemKey) => {
66
+ const pemHeader = "-----BEGIN PRIVATE KEY-----";
67
+ const pemFooter = "-----END PRIVATE KEY-----";
68
+ const pemContents = pemKey.replace(pemHeader, "").replace(pemFooter, "").replace(/\s/g, "");
69
+ const binaryString = atob(pemContents);
70
+ const binaryData = new Uint8Array(binaryString.length);
71
+ for (let i = 0; i < binaryString.length; i++) {
72
+ binaryData[i] = binaryString.charCodeAt(i);
73
+ }
74
+ return await crypto.subtle.importKey(
75
+ "pkcs8",
76
+ binaryData,
77
+ { name: "RSASSA-PKCS1-v1_5", hash: "SHA-256" },
78
+ true,
79
+ ["sign"]
80
+ );
81
+ };
82
+ var buildJwt = async (credentials) => {
83
+ const now = Math.floor(Date.now() / 1e3);
84
+ const header = {
85
+ alg: "RS256",
86
+ typ: "JWT"
87
+ };
88
+ if (credentials.privateKeyId) {
89
+ header.kid = credentials.privateKeyId;
90
+ }
91
+ const payload = {
92
+ iss: credentials.clientEmail,
93
+ scope: "https://www.googleapis.com/auth/cloud-platform",
94
+ aud: "https://oauth2.googleapis.com/token",
95
+ exp: now + 3600,
96
+ iat: now
97
+ };
98
+ const privateKey = await importPrivateKey(credentials.privateKey);
99
+ const signingInput = `${base64url(JSON.stringify(header))}.${base64url(
100
+ JSON.stringify(payload)
101
+ )}`;
102
+ const encoder = new TextEncoder();
103
+ const data = encoder.encode(signingInput);
104
+ const signature = await crypto.subtle.sign(
105
+ "RSASSA-PKCS1-v1_5",
106
+ privateKey,
107
+ data
108
+ );
109
+ const signatureBase64 = base64url(
110
+ String.fromCharCode(...new Uint8Array(signature))
111
+ );
112
+ return `${base64url(JSON.stringify(header))}.${base64url(
113
+ JSON.stringify(payload)
114
+ )}.${signatureBase64}`;
115
+ };
116
+ async function generateAuthToken(credentials) {
117
+ try {
118
+ const creds = credentials || await loadCredentials();
119
+ const jwt = await buildJwt(creds);
120
+ const response = await fetch("https://oauth2.googleapis.com/token", {
121
+ method: "POST",
122
+ headers: (0, import_provider_utils.withUserAgentSuffix)(
123
+ { "Content-Type": "application/x-www-form-urlencoded" },
124
+ `ai-sdk/google-vertex/${VERSION}`,
125
+ (0, import_provider_utils.getRuntimeEnvironmentUserAgent)()
126
+ ),
127
+ body: new URLSearchParams({
128
+ grant_type: "urn:ietf:params:oauth:grant-type:jwt-bearer",
129
+ assertion: jwt
130
+ })
131
+ });
132
+ if (!response.ok) {
133
+ throw new Error(`Token request failed: ${response.statusText}`);
134
+ }
135
+ const data = await response.json();
136
+ return data.access_token;
137
+ } catch (error) {
138
+ throw error;
139
+ }
140
+ }
141
+
142
+ // src/xai/google-vertex-xai-provider.ts
143
+ var import_provider = require("@ai-sdk/provider");
144
+ var import_openai_compatible = require("@ai-sdk/openai-compatible");
145
+ var import_provider_utils2 = require("@ai-sdk/provider-utils");
146
+ function convertGoogleVertexXaiUsage(usage) {
147
+ var _a, _b, _c, _d, _e, _f;
148
+ if (usage == null) {
149
+ return {
150
+ inputTokens: {
151
+ total: void 0,
152
+ noCache: void 0,
153
+ cacheRead: void 0,
154
+ cacheWrite: void 0
155
+ },
156
+ outputTokens: {
157
+ total: void 0,
158
+ text: void 0,
159
+ reasoning: void 0
160
+ },
161
+ raw: void 0
162
+ };
163
+ }
164
+ const promptTokens = (_a = usage.prompt_tokens) != null ? _a : 0;
165
+ const completionTokens = (_b = usage.completion_tokens) != null ? _b : 0;
166
+ const cacheReadTokens = (_d = (_c = usage.prompt_tokens_details) == null ? void 0 : _c.cached_tokens) != null ? _d : 0;
167
+ const reasoningTokens = (_f = (_e = usage.completion_tokens_details) == null ? void 0 : _e.reasoning_tokens) != null ? _f : 0;
168
+ return {
169
+ inputTokens: {
170
+ total: promptTokens,
171
+ noCache: promptTokens - cacheReadTokens,
172
+ cacheRead: cacheReadTokens,
173
+ cacheWrite: void 0
174
+ },
175
+ outputTokens: {
176
+ total: completionTokens + reasoningTokens,
177
+ text: completionTokens,
178
+ reasoning: reasoningTokens
179
+ },
180
+ raw: usage
181
+ };
182
+ }
183
+ function transformGoogleVertexXaiRequestBody(args) {
184
+ const { reasoning_effort: _reasoningEffort, ...rest } = args;
185
+ return rest;
186
+ }
187
+ function createGoogleVertexXai(options = {}) {
188
+ const loadLocation = () => (0, import_provider_utils2.loadOptionalSetting)({
189
+ settingValue: options.location,
190
+ environmentVariableName: "GOOGLE_VERTEX_LOCATION"
191
+ });
192
+ const loadProject = () => (0, import_provider_utils2.loadSetting)({
193
+ settingValue: options.project,
194
+ settingName: "project",
195
+ environmentVariableName: "GOOGLE_VERTEX_PROJECT",
196
+ description: "Google Vertex project"
197
+ });
198
+ const constructBaseURL = () => {
199
+ var _a;
200
+ const projectId = loadProject();
201
+ const location = (_a = loadLocation()) != null ? _a : "global";
202
+ return `https://aiplatform.googleapis.com/v1/projects/${projectId}/locations/${location}/endpoints/openapi`;
203
+ };
204
+ const loadBaseURL = () => {
205
+ var _a;
206
+ return (0, import_provider_utils2.withoutTrailingSlash)((_a = options.baseURL) != null ? _a : "") || constructBaseURL();
207
+ };
208
+ let cachedProvider;
209
+ const getProvider = () => cachedProvider != null ? cachedProvider : cachedProvider = (0, import_openai_compatible.createOpenAICompatible)({
210
+ name: "googleVertex.xai",
211
+ baseURL: loadBaseURL(),
212
+ fetch: options.fetch,
213
+ includeUsage: true,
214
+ supportsStructuredOutputs: true,
215
+ supportedUrls: () => ({
216
+ "image/*": [/^https?:\/\/.*$/]
217
+ }),
218
+ transformRequestBody: transformGoogleVertexXaiRequestBody,
219
+ convertUsage: convertGoogleVertexXaiUsage
220
+ });
221
+ const createChatModel = (modelId) => getProvider().languageModel(modelId);
222
+ const provider = function(modelId) {
223
+ if (new.target) {
224
+ throw new Error(
225
+ "The Google Vertex xAI model function cannot be called with the new keyword."
226
+ );
227
+ }
228
+ return createChatModel(modelId);
229
+ };
230
+ provider.specificationVersion = "v3";
231
+ provider.languageModel = createChatModel;
232
+ provider.chatModel = (modelId) => getProvider().chatModel(modelId);
233
+ provider.embeddingModel = (modelId) => {
234
+ throw new import_provider.NoSuchModelError({ modelId, modelType: "embeddingModel" });
235
+ };
236
+ provider.textEmbeddingModel = provider.embeddingModel;
237
+ provider.imageModel = (modelId) => {
238
+ throw new import_provider.NoSuchModelError({ modelId, modelType: "imageModel" });
239
+ };
240
+ return provider;
241
+ }
242
+
243
+ // src/xai/edge/google-vertex-xai-provider-edge.ts
244
+ function createGoogleVertexXai2(options = {}) {
245
+ const customFetch = async (url, init) => {
246
+ var _a;
247
+ const token = await generateAuthToken(options.googleCredentials);
248
+ const resolvedHeaders = await (0, import_provider_utils3.resolve)(options.headers);
249
+ const authHeaders = {
250
+ ...resolvedHeaders,
251
+ Authorization: `Bearer ${token}`
252
+ };
253
+ const fetchInit = {
254
+ ...init,
255
+ headers: {
256
+ ...init == null ? void 0 : init.headers,
257
+ ...authHeaders
258
+ }
259
+ };
260
+ return ((_a = options.fetch) != null ? _a : fetch)(url, fetchInit);
261
+ };
262
+ return createGoogleVertexXai({
263
+ ...options,
264
+ fetch: customFetch,
265
+ headers: void 0
266
+ });
267
+ }
268
+ var googleVertexXai = createGoogleVertexXai2();
269
+ // Annotate the CommonJS export names for ESM import in node:
270
+ 0 && (module.exports = {
271
+ createGoogleVertexXai,
272
+ googleVertexXai
273
+ });
274
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/xai/edge/index.ts","../../../src/xai/edge/google-vertex-xai-provider-edge.ts","../../../src/edge/google-vertex-auth-edge.ts","../../../src/version.ts","../../../src/xai/google-vertex-xai-provider.ts"],"sourcesContent":["export {\n createGoogleVertexXai,\n googleVertexXai,\n} from './google-vertex-xai-provider-edge';\nexport type {\n GoogleVertexXaiProvider,\n GoogleVertexXaiProviderSettings,\n} from './google-vertex-xai-provider-edge';\nexport type { GoogleVertexXaiModelId } from '../google-vertex-xai-options';\n","import { resolve, type FetchFunction } from '@ai-sdk/provider-utils';\nimport {\n generateAuthToken,\n type GoogleCredentials,\n} from '../../edge/google-vertex-auth-edge';\nimport {\n createGoogleVertexXai as createGoogleVertexXaiOriginal,\n type GoogleVertexXaiProvider,\n type GoogleVertexXaiProviderSettings as GoogleVertexXaiProviderSettingsOriginal,\n} from '../google-vertex-xai-provider';\nexport type { GoogleVertexXaiProvider };\n\nexport interface GoogleVertexXaiProviderSettings extends GoogleVertexXaiProviderSettingsOriginal {\n /**\n * Optional. The Google credentials for the Google Cloud service account. If\n * not provided, the Google Vertex provider will use environment variables to\n * load the credentials.\n */\n googleCredentials?: GoogleCredentials;\n}\n\n/**\n * Create a Google Vertex AI xAI provider instance for Edge runtimes.\n * Uses the OpenAI-compatible Chat Completions API for Grok partner models.\n * Automatically handles Google Cloud authentication.\n *\n * @see https://cloud.google.com/vertex-ai/generative-ai/docs/partner-models/grok\n */\nexport function createGoogleVertexXai(\n options: GoogleVertexXaiProviderSettings = {},\n): GoogleVertexXaiProvider {\n const customFetch: FetchFunction = async (url, init) => {\n const token = await generateAuthToken(options.googleCredentials);\n const resolvedHeaders = await resolve(options.headers);\n const authHeaders = {\n ...resolvedHeaders,\n Authorization: `Bearer ${token}`,\n };\n\n const fetchInit = {\n ...init,\n headers: {\n ...init?.headers,\n ...authHeaders,\n },\n };\n\n return (options.fetch ?? fetch)(url, fetchInit);\n };\n\n return createGoogleVertexXaiOriginal({\n ...options,\n fetch: customFetch,\n headers: undefined,\n });\n}\n\n/**\n * Default Google Vertex AI xAI provider instance for Edge runtimes.\n */\nexport const googleVertexXai = createGoogleVertexXai();\n","import {\n loadOptionalSetting,\n loadSetting,\n withUserAgentSuffix,\n getRuntimeEnvironmentUserAgent,\n} from '@ai-sdk/provider-utils';\nimport { VERSION } from '../version';\n\nexport interface GoogleCredentials {\n /**\n * The client email for the Google Cloud service account. Defaults to the\n * value of the `GOOGLE_CLIENT_EMAIL` environment variable.\n */\n clientEmail: string;\n\n /**\n * The private key for the Google Cloud service account. Defaults to the\n * value of the `GOOGLE_PRIVATE_KEY` environment variable.\n */\n privateKey: string;\n\n /**\n * Optional. The private key ID for the Google Cloud service account. Defaults\n * to the value of the `GOOGLE_PRIVATE_KEY_ID` environment variable.\n */\n privateKeyId?: string;\n}\n\nconst loadCredentials = async (): Promise<GoogleCredentials> => {\n try {\n return {\n clientEmail: loadSetting({\n settingValue: undefined,\n settingName: 'clientEmail',\n environmentVariableName: 'GOOGLE_CLIENT_EMAIL',\n description: 'Google client email',\n }),\n privateKey: loadSetting({\n settingValue: undefined,\n settingName: 'privateKey',\n environmentVariableName: 'GOOGLE_PRIVATE_KEY',\n description: 'Google private key',\n }),\n privateKeyId: loadOptionalSetting({\n settingValue: undefined,\n environmentVariableName: 'GOOGLE_PRIVATE_KEY_ID',\n }),\n };\n } catch (error: any) {\n throw new Error(`Failed to load Google credentials: ${error.message}`);\n }\n};\n\n// Convert a string to base64url\nconst base64url = (str: string) => {\n return btoa(str).replace(/\\+/g, '-').replace(/\\//g, '_').replace(/=/g, '');\n};\nconst importPrivateKey = async (pemKey: string) => {\n const pemHeader = '-----BEGIN PRIVATE KEY-----';\n const pemFooter = '-----END PRIVATE KEY-----';\n\n // Remove header, footer, and any whitespace/newlines\n const pemContents = pemKey\n .replace(pemHeader, '')\n .replace(pemFooter, '')\n .replace(/\\s/g, '');\n\n // Decode base64 to binary\n const binaryString = atob(pemContents);\n\n // Convert binary string to Uint8Array\n const binaryData = new Uint8Array(binaryString.length);\n for (let i = 0; i < binaryString.length; i++) {\n binaryData[i] = binaryString.charCodeAt(i);\n }\n\n return await crypto.subtle.importKey(\n 'pkcs8',\n binaryData,\n { name: 'RSASSA-PKCS1-v1_5', hash: 'SHA-256' },\n true,\n ['sign'],\n );\n};\n\nconst buildJwt = async (credentials: GoogleCredentials) => {\n const now = Math.floor(Date.now() / 1000);\n\n // Only include kid in header if privateKeyId is provided\n const header: { alg: string; typ: string; kid?: string } = {\n alg: 'RS256',\n typ: 'JWT',\n };\n\n if (credentials.privateKeyId) {\n header.kid = credentials.privateKeyId;\n }\n\n const payload = {\n iss: credentials.clientEmail,\n scope: 'https://www.googleapis.com/auth/cloud-platform',\n aud: 'https://oauth2.googleapis.com/token',\n exp: now + 3600,\n iat: now,\n };\n\n const privateKey = await importPrivateKey(credentials.privateKey);\n\n const signingInput = `${base64url(JSON.stringify(header))}.${base64url(\n JSON.stringify(payload),\n )}`;\n const encoder = new TextEncoder();\n const data = encoder.encode(signingInput);\n\n const signature = await crypto.subtle.sign(\n 'RSASSA-PKCS1-v1_5',\n privateKey,\n data,\n );\n\n const signatureBase64 = base64url(\n String.fromCharCode(...new Uint8Array(signature)),\n );\n\n return `${base64url(JSON.stringify(header))}.${base64url(\n JSON.stringify(payload),\n )}.${signatureBase64}`;\n};\n\n/**\n * Generate an authentication token for Google Vertex AI in a manner compatible\n * with the Edge runtime.\n */\nexport async function generateAuthToken(credentials?: GoogleCredentials) {\n try {\n const creds = credentials || (await loadCredentials());\n const jwt = await buildJwt(creds);\n\n const response = await fetch('https://oauth2.googleapis.com/token', {\n method: 'POST',\n headers: withUserAgentSuffix(\n { 'Content-Type': 'application/x-www-form-urlencoded' },\n `ai-sdk/google-vertex/${VERSION}`,\n getRuntimeEnvironmentUserAgent(),\n ),\n body: new URLSearchParams({\n grant_type: 'urn:ietf:params:oauth:grant-type:jwt-bearer',\n assertion: jwt,\n }),\n });\n\n if (!response.ok) {\n throw new Error(`Token request failed: ${response.statusText}`);\n }\n\n const data = await response.json();\n return data.access_token;\n } catch (error) {\n throw error;\n }\n}\n","// Version string of this package injected at build time.\ndeclare const __PACKAGE_VERSION__: string | undefined;\nexport const VERSION: string =\n typeof __PACKAGE_VERSION__ !== 'undefined'\n ? __PACKAGE_VERSION__\n : '0.0.0-test';\n","import {\n NoSuchModelError,\n type LanguageModelV3,\n type LanguageModelV3Usage,\n type ProviderV3,\n} from '@ai-sdk/provider';\nimport {\n createOpenAICompatible,\n type OpenAICompatibleProvider,\n} from '@ai-sdk/openai-compatible';\nimport {\n loadOptionalSetting,\n loadSetting,\n withoutTrailingSlash,\n type FetchFunction,\n type Resolvable,\n} from '@ai-sdk/provider-utils';\nimport type { GoogleVertexXaiModelId } from './google-vertex-xai-options';\n\nexport interface GoogleVertexXaiProvider extends ProviderV3 {\n /**\n * Creates a model for text generation.\n */\n (modelId: GoogleVertexXaiModelId): LanguageModelV3;\n\n /**\n * Creates a model for text generation.\n */\n languageModel(modelId: GoogleVertexXaiModelId): LanguageModelV3;\n\n /**\n * Creates a chat model for text generation.\n */\n chatModel(modelId: GoogleVertexXaiModelId): LanguageModelV3;\n\n /**\n * @deprecated Use `embeddingModel` instead.\n */\n textEmbeddingModel(modelId: string): never;\n}\n\nexport interface GoogleVertexXaiProviderSettings {\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 location/region. Defaults to the value of the `GOOGLE_VERTEX_LOCATION` environment variable.\n * Use 'global' for the global endpoint.\n */\n location?: string;\n\n /**\n * Base URL for the API calls. If not provided, will be constructed from project and location.\n */\n baseURL?: string;\n\n /**\n * Headers to use for requests. Can be:\n * - A headers object\n * - A Promise that resolves to a headers object\n * - A function that returns a headers object\n * - A function that returns a Promise of a headers object\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\ntype GoogleVertexXaiUsage =\n | {\n prompt_tokens?: number | null;\n completion_tokens?: number | null;\n prompt_tokens_details?: {\n cached_tokens?: number | null;\n } | null;\n completion_tokens_details?: {\n reasoning_tokens?: number | null;\n } | null;\n }\n | undefined\n | null;\n\nfunction convertGoogleVertexXaiUsage(\n usage: GoogleVertexXaiUsage,\n): LanguageModelV3Usage {\n if (usage == null) {\n return {\n inputTokens: {\n total: undefined,\n noCache: undefined,\n cacheRead: undefined,\n cacheWrite: undefined,\n },\n outputTokens: {\n total: undefined,\n text: undefined,\n reasoning: undefined,\n },\n raw: undefined,\n };\n }\n\n const promptTokens = usage.prompt_tokens ?? 0;\n const completionTokens = usage.completion_tokens ?? 0;\n const cacheReadTokens = usage.prompt_tokens_details?.cached_tokens ?? 0;\n const reasoningTokens =\n usage.completion_tokens_details?.reasoning_tokens ?? 0;\n\n return {\n inputTokens: {\n total: promptTokens,\n noCache: promptTokens - cacheReadTokens,\n cacheRead: cacheReadTokens,\n cacheWrite: undefined,\n },\n outputTokens: {\n total: completionTokens + reasoningTokens,\n text: completionTokens,\n reasoning: reasoningTokens,\n },\n raw: usage,\n };\n}\n\nfunction transformGoogleVertexXaiRequestBody(args: Record<string, any>) {\n const { reasoning_effort: _reasoningEffort, ...rest } = args;\n return rest;\n}\n\n/**\n * Create a Google Vertex AI xAI provider instance.\n * Uses the OpenAI-compatible Chat Completions API for Grok partner models.\n *\n * @see https://cloud.google.com/vertex-ai/generative-ai/docs/partner-models/grok\n */\nexport function createGoogleVertexXai(\n options: GoogleVertexXaiProviderSettings = {},\n): GoogleVertexXaiProvider {\n const loadLocation = () =>\n loadOptionalSetting({\n settingValue: options.location,\n environmentVariableName: 'GOOGLE_VERTEX_LOCATION',\n });\n\n const loadProject = () =>\n loadSetting({\n settingValue: options.project,\n settingName: 'project',\n environmentVariableName: 'GOOGLE_VERTEX_PROJECT',\n description: 'Google Vertex project',\n });\n\n const constructBaseURL = () => {\n const projectId = loadProject();\n const location = loadLocation() ?? 'global';\n\n return `https://aiplatform.googleapis.com/v1/projects/${projectId}/locations/${location}/endpoints/openapi`;\n };\n\n const loadBaseURL = () =>\n withoutTrailingSlash(options.baseURL ?? '') || constructBaseURL();\n\n let cachedProvider:\n | OpenAICompatibleProvider<GoogleVertexXaiModelId, string, string, string>\n | undefined;\n const getProvider = () =>\n (cachedProvider ??= createOpenAICompatible({\n name: 'googleVertex.xai',\n baseURL: loadBaseURL(),\n fetch: options.fetch,\n includeUsage: true,\n supportsStructuredOutputs: true,\n supportedUrls: () => ({\n 'image/*': [/^https?:\\/\\/.*$/],\n }),\n transformRequestBody: transformGoogleVertexXaiRequestBody,\n convertUsage: convertGoogleVertexXaiUsage,\n }));\n\n const createChatModel = (modelId: GoogleVertexXaiModelId) =>\n getProvider().languageModel(modelId);\n\n const provider = function (modelId: GoogleVertexXaiModelId) {\n if (new.target) {\n throw new Error(\n 'The Google Vertex xAI 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.chatModel = (modelId: GoogleVertexXaiModelId) =>\n getProvider().chatModel(modelId);\n provider.embeddingModel = (modelId: string): never => {\n throw new NoSuchModelError({ modelId, modelType: 'embeddingModel' });\n };\n provider.textEmbeddingModel = provider.embeddingModel;\n provider.imageModel = (modelId: string): never => {\n throw new NoSuchModelError({ modelId, modelType: 'imageModel' });\n };\n\n return provider;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,+BAAAA;AAAA,EAAA;AAAA;AAAA;;;ACAA,IAAAC,yBAA4C;;;ACA5C,4BAKO;;;ACHA,IAAM,UACX,OACI,YACA;;;ADuBN,IAAM,kBAAkB,YAAwC;AAC9D,MAAI;AACF,WAAO;AAAA,MACL,iBAAa,mCAAY;AAAA,QACvB,cAAc;AAAA,QACd,aAAa;AAAA,QACb,yBAAyB;AAAA,QACzB,aAAa;AAAA,MACf,CAAC;AAAA,MACD,gBAAY,mCAAY;AAAA,QACtB,cAAc;AAAA,QACd,aAAa;AAAA,QACb,yBAAyB;AAAA,QACzB,aAAa;AAAA,MACf,CAAC;AAAA,MACD,kBAAc,2CAAoB;AAAA,QAChC,cAAc;AAAA,QACd,yBAAyB;AAAA,MAC3B,CAAC;AAAA,IACH;AAAA,EACF,SAAS,OAAY;AACnB,UAAM,IAAI,MAAM,sCAAsC,MAAM,OAAO,EAAE;AAAA,EACvE;AACF;AAGA,IAAM,YAAY,CAAC,QAAgB;AACjC,SAAO,KAAK,GAAG,EAAE,QAAQ,OAAO,GAAG,EAAE,QAAQ,OAAO,GAAG,EAAE,QAAQ,MAAM,EAAE;AAC3E;AACA,IAAM,mBAAmB,OAAO,WAAmB;AACjD,QAAM,YAAY;AAClB,QAAM,YAAY;AAGlB,QAAM,cAAc,OACjB,QAAQ,WAAW,EAAE,EACrB,QAAQ,WAAW,EAAE,EACrB,QAAQ,OAAO,EAAE;AAGpB,QAAM,eAAe,KAAK,WAAW;AAGrC,QAAM,aAAa,IAAI,WAAW,aAAa,MAAM;AACrD,WAAS,IAAI,GAAG,IAAI,aAAa,QAAQ,KAAK;AAC5C,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AACA,WAAS,qBAAqB,SAAS;AACvC,WAAS,aAAa,CAAC,YAA2B;AAChD,UAAM,IAAI,iCAAiB,EAAE,SAAS,WAAW,aAAa,CAAC;AAAA,EACjE;AAEA,SAAO;AACT;;;AHvLO,SAASC,uBACd,UAA2C,CAAC,GACnB;AACzB,QAAM,cAA6B,OAAO,KAAK,SAAS;AA/B1D;AAgCI,UAAM,QAAQ,MAAM,kBAAkB,QAAQ,iBAAiB;AAC/D,UAAM,kBAAkB,UAAM,gCAAQ,QAAQ,OAAO;AACrD,UAAM,cAAc;AAAA,MAClB,GAAG;AAAA,MACH,eAAe,UAAU,KAAK;AAAA,IAChC;AAEA,UAAM,YAAY;AAAA,MAChB,GAAG;AAAA,MACH,SAAS;AAAA,QACP,GAAG,6BAAM;AAAA,QACT,GAAG;AAAA,MACL;AAAA,IACF;AAEA,aAAQ,aAAQ,UAAR,YAAiB,OAAO,KAAK,SAAS;AAAA,EAChD;AAEA,SAAO,sBAA8B;AAAA,IACnC,GAAG;AAAA,IACH,OAAO;AAAA,IACP,SAAS;AAAA,EACX,CAAC;AACH;AAKO,IAAM,kBAAkBA,uBAAsB;","names":["createGoogleVertexXai","import_provider_utils","import_provider_utils","createGoogleVertexXai"]}
@@ -10,7 +10,7 @@ import {
10
10
  } from "@ai-sdk/provider-utils";
11
11
 
12
12
  // src/version.ts
13
- var VERSION = true ? "4.0.118" : "0.0.0-test";
13
+ var VERSION = true ? "4.0.120" : "0.0.0-test";
14
14
 
15
15
  // src/edge/google-vertex-auth-edge.ts
16
16
  var loadCredentials = async () => {
@@ -0,0 +1,76 @@
1
+ import { GoogleAuthOptions } from 'google-auth-library';
2
+ import { ProviderV3, LanguageModelV3 } from '@ai-sdk/provider';
3
+ import { Resolvable, FetchFunction } from '@ai-sdk/provider-utils';
4
+
5
+ type GoogleVertexXaiModelId = 'xai/grok-4.20-reasoning' | 'xai/grok-4.20-non-reasoning' | 'xai/grok-4.1-fast-reasoning' | 'xai/grok-4.1-fast-non-reasoning' | (string & {});
6
+
7
+ interface GoogleVertexXaiProvider extends ProviderV3 {
8
+ /**
9
+ * Creates a model for text generation.
10
+ */
11
+ (modelId: GoogleVertexXaiModelId): LanguageModelV3;
12
+ /**
13
+ * Creates a model for text generation.
14
+ */
15
+ languageModel(modelId: GoogleVertexXaiModelId): LanguageModelV3;
16
+ /**
17
+ * Creates a chat model for text generation.
18
+ */
19
+ chatModel(modelId: GoogleVertexXaiModelId): LanguageModelV3;
20
+ /**
21
+ * @deprecated Use `embeddingModel` instead.
22
+ */
23
+ textEmbeddingModel(modelId: string): never;
24
+ }
25
+ interface GoogleVertexXaiProviderSettings$1 {
26
+ /**
27
+ * Google Cloud project ID. Defaults to the value of the `GOOGLE_VERTEX_PROJECT` environment variable.
28
+ */
29
+ project?: string;
30
+ /**
31
+ * Google Cloud location/region. Defaults to the value of the `GOOGLE_VERTEX_LOCATION` environment variable.
32
+ * Use 'global' for the global endpoint.
33
+ */
34
+ location?: string;
35
+ /**
36
+ * Base URL for the API calls. If not provided, will be constructed from project and location.
37
+ */
38
+ baseURL?: string;
39
+ /**
40
+ * Headers to use for requests. Can be:
41
+ * - A headers object
42
+ * - A Promise that resolves to a headers object
43
+ * - A function that returns a headers object
44
+ * - A function that returns a Promise of a headers object
45
+ */
46
+ headers?: Resolvable<Record<string, string | undefined>>;
47
+ /**
48
+ * Custom fetch implementation. You can use it as a middleware to intercept requests,
49
+ * or to provide a custom fetch implementation for e.g. testing.
50
+ */
51
+ fetch?: FetchFunction;
52
+ }
53
+
54
+ interface GoogleVertexXaiProviderSettings extends GoogleVertexXaiProviderSettings$1 {
55
+ /**
56
+ * Optional. The Authentication options provided by google-auth-library.
57
+ * Complete list of authentication options is documented in the
58
+ * GoogleAuthOptions interface:
59
+ * https://github.com/googleapis/google-auth-library-nodejs/blob/main/src/auth/googleauth.ts.
60
+ */
61
+ googleAuthOptions?: GoogleAuthOptions;
62
+ }
63
+ /**
64
+ * Create a Google Vertex AI xAI provider instance for Node.js.
65
+ * Uses the OpenAI-compatible Chat Completions API for Grok partner models.
66
+ * Automatically handles Google Cloud authentication.
67
+ *
68
+ * @see https://cloud.google.com/vertex-ai/generative-ai/docs/partner-models/grok
69
+ */
70
+ declare function createGoogleVertexXai(options?: GoogleVertexXaiProviderSettings): GoogleVertexXaiProvider;
71
+ /**
72
+ * Default Google Vertex AI xAI provider instance for Node.js.
73
+ */
74
+ declare const googleVertexXai: GoogleVertexXaiProvider;
75
+
76
+ export { type GoogleVertexXaiModelId, type GoogleVertexXaiProvider, type GoogleVertexXaiProviderSettings, createGoogleVertexXai, googleVertexXai };
@@ -0,0 +1,179 @@
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/xai/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ createGoogleVertexXai: () => createGoogleVertexXai2,
24
+ googleVertexXai: () => googleVertexXai
25
+ });
26
+ module.exports = __toCommonJS(index_exports);
27
+
28
+ // src/xai/google-vertex-xai-provider-node.ts
29
+ var import_provider_utils2 = require("@ai-sdk/provider-utils");
30
+
31
+ // src/google-vertex-auth-google-auth-library.ts
32
+ var import_google_auth_library = require("google-auth-library");
33
+ function createAuthTokenGenerator(options) {
34
+ const auth = new import_google_auth_library.GoogleAuth({
35
+ scopes: ["https://www.googleapis.com/auth/cloud-platform"],
36
+ ...options
37
+ });
38
+ return async function generateAuthToken() {
39
+ var _a;
40
+ const client = await auth.getClient();
41
+ const token = await client.getAccessToken();
42
+ return (_a = token == null ? void 0 : token.token) != null ? _a : null;
43
+ };
44
+ }
45
+
46
+ // src/xai/google-vertex-xai-provider.ts
47
+ var import_provider = require("@ai-sdk/provider");
48
+ var import_openai_compatible = require("@ai-sdk/openai-compatible");
49
+ var import_provider_utils = require("@ai-sdk/provider-utils");
50
+ function convertGoogleVertexXaiUsage(usage) {
51
+ var _a, _b, _c, _d, _e, _f;
52
+ if (usage == null) {
53
+ return {
54
+ inputTokens: {
55
+ total: void 0,
56
+ noCache: void 0,
57
+ cacheRead: void 0,
58
+ cacheWrite: void 0
59
+ },
60
+ outputTokens: {
61
+ total: void 0,
62
+ text: void 0,
63
+ reasoning: void 0
64
+ },
65
+ raw: void 0
66
+ };
67
+ }
68
+ const promptTokens = (_a = usage.prompt_tokens) != null ? _a : 0;
69
+ const completionTokens = (_b = usage.completion_tokens) != null ? _b : 0;
70
+ const cacheReadTokens = (_d = (_c = usage.prompt_tokens_details) == null ? void 0 : _c.cached_tokens) != null ? _d : 0;
71
+ const reasoningTokens = (_f = (_e = usage.completion_tokens_details) == null ? void 0 : _e.reasoning_tokens) != null ? _f : 0;
72
+ return {
73
+ inputTokens: {
74
+ total: promptTokens,
75
+ noCache: promptTokens - cacheReadTokens,
76
+ cacheRead: cacheReadTokens,
77
+ cacheWrite: void 0
78
+ },
79
+ outputTokens: {
80
+ total: completionTokens + reasoningTokens,
81
+ text: completionTokens,
82
+ reasoning: reasoningTokens
83
+ },
84
+ raw: usage
85
+ };
86
+ }
87
+ function transformGoogleVertexXaiRequestBody(args) {
88
+ const { reasoning_effort: _reasoningEffort, ...rest } = args;
89
+ return rest;
90
+ }
91
+ function createGoogleVertexXai(options = {}) {
92
+ const loadLocation = () => (0, import_provider_utils.loadOptionalSetting)({
93
+ settingValue: options.location,
94
+ environmentVariableName: "GOOGLE_VERTEX_LOCATION"
95
+ });
96
+ const loadProject = () => (0, import_provider_utils.loadSetting)({
97
+ settingValue: options.project,
98
+ settingName: "project",
99
+ environmentVariableName: "GOOGLE_VERTEX_PROJECT",
100
+ description: "Google Vertex project"
101
+ });
102
+ const constructBaseURL = () => {
103
+ var _a;
104
+ const projectId = loadProject();
105
+ const location = (_a = loadLocation()) != null ? _a : "global";
106
+ return `https://aiplatform.googleapis.com/v1/projects/${projectId}/locations/${location}/endpoints/openapi`;
107
+ };
108
+ const loadBaseURL = () => {
109
+ var _a;
110
+ return (0, import_provider_utils.withoutTrailingSlash)((_a = options.baseURL) != null ? _a : "") || constructBaseURL();
111
+ };
112
+ let cachedProvider;
113
+ const getProvider = () => cachedProvider != null ? cachedProvider : cachedProvider = (0, import_openai_compatible.createOpenAICompatible)({
114
+ name: "googleVertex.xai",
115
+ baseURL: loadBaseURL(),
116
+ fetch: options.fetch,
117
+ includeUsage: true,
118
+ supportsStructuredOutputs: true,
119
+ supportedUrls: () => ({
120
+ "image/*": [/^https?:\/\/.*$/]
121
+ }),
122
+ transformRequestBody: transformGoogleVertexXaiRequestBody,
123
+ convertUsage: convertGoogleVertexXaiUsage
124
+ });
125
+ const createChatModel = (modelId) => getProvider().languageModel(modelId);
126
+ const provider = function(modelId) {
127
+ if (new.target) {
128
+ throw new Error(
129
+ "The Google Vertex xAI model function cannot be called with the new keyword."
130
+ );
131
+ }
132
+ return createChatModel(modelId);
133
+ };
134
+ provider.specificationVersion = "v3";
135
+ provider.languageModel = createChatModel;
136
+ provider.chatModel = (modelId) => getProvider().chatModel(modelId);
137
+ provider.embeddingModel = (modelId) => {
138
+ throw new import_provider.NoSuchModelError({ modelId, modelType: "embeddingModel" });
139
+ };
140
+ provider.textEmbeddingModel = provider.embeddingModel;
141
+ provider.imageModel = (modelId) => {
142
+ throw new import_provider.NoSuchModelError({ modelId, modelType: "imageModel" });
143
+ };
144
+ return provider;
145
+ }
146
+
147
+ // src/xai/google-vertex-xai-provider-node.ts
148
+ function createGoogleVertexXai2(options = {}) {
149
+ const generateAuthToken = createAuthTokenGenerator(options.googleAuthOptions);
150
+ const customFetch = async (url, init) => {
151
+ var _a;
152
+ const token = await generateAuthToken();
153
+ const resolvedHeaders = await (0, import_provider_utils2.resolve)(options.headers);
154
+ const authHeaders = {
155
+ ...resolvedHeaders,
156
+ Authorization: `Bearer ${token}`
157
+ };
158
+ const fetchInit = {
159
+ ...init,
160
+ headers: {
161
+ ...init == null ? void 0 : init.headers,
162
+ ...authHeaders
163
+ }
164
+ };
165
+ return ((_a = options.fetch) != null ? _a : fetch)(url, fetchInit);
166
+ };
167
+ return createGoogleVertexXai({
168
+ ...options,
169
+ fetch: customFetch,
170
+ headers: void 0
171
+ });
172
+ }
173
+ var googleVertexXai = createGoogleVertexXai2();
174
+ // Annotate the CommonJS export names for ESM import in node:
175
+ 0 && (module.exports = {
176
+ createGoogleVertexXai,
177
+ googleVertexXai
178
+ });
179
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/xai/index.ts","../../src/xai/google-vertex-xai-provider-node.ts","../../src/google-vertex-auth-google-auth-library.ts","../../src/xai/google-vertex-xai-provider.ts"],"sourcesContent":["export {\n createGoogleVertexXai,\n googleVertexXai,\n} from './google-vertex-xai-provider-node';\nexport type {\n GoogleVertexXaiProvider,\n GoogleVertexXaiProviderSettings,\n} from './google-vertex-xai-provider-node';\nexport type { GoogleVertexXaiModelId } from './google-vertex-xai-options';\n","import { resolve, type FetchFunction } from '@ai-sdk/provider-utils';\nimport type { GoogleAuthOptions } from 'google-auth-library';\nimport { createAuthTokenGenerator } from '../google-vertex-auth-google-auth-library';\nimport {\n createGoogleVertexXai as createGoogleVertexXaiOriginal,\n type GoogleVertexXaiProvider,\n type GoogleVertexXaiProviderSettings as GoogleVertexXaiProviderSettingsOriginal,\n} from './google-vertex-xai-provider';\nexport type { GoogleVertexXaiProvider };\n\nexport interface GoogleVertexXaiProviderSettings extends GoogleVertexXaiProviderSettingsOriginal {\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\n/**\n * Create a Google Vertex AI xAI provider instance for Node.js.\n * Uses the OpenAI-compatible Chat Completions API for Grok partner models.\n * Automatically handles Google Cloud authentication.\n *\n * @see https://cloud.google.com/vertex-ai/generative-ai/docs/partner-models/grok\n */\nexport function createGoogleVertexXai(\n options: GoogleVertexXaiProviderSettings = {},\n): GoogleVertexXaiProvider {\n const generateAuthToken = createAuthTokenGenerator(options.googleAuthOptions);\n\n const customFetch: FetchFunction = async (url, init) => {\n const token = await generateAuthToken();\n const resolvedHeaders = await resolve(options.headers);\n const authHeaders = {\n ...resolvedHeaders,\n Authorization: `Bearer ${token}`,\n };\n\n const fetchInit = {\n ...init,\n headers: {\n ...init?.headers,\n ...authHeaders,\n },\n };\n\n return (options.fetch ?? fetch)(url, fetchInit);\n };\n\n return createGoogleVertexXaiOriginal({\n ...options,\n fetch: customFetch,\n headers: undefined,\n });\n}\n\n/**\n * Default Google Vertex AI xAI provider instance for Node.js.\n */\nexport const googleVertexXai = createGoogleVertexXai();\n","import { GoogleAuth, type GoogleAuthOptions } from 'google-auth-library';\n\nexport function createAuthTokenGenerator(options?: GoogleAuthOptions) {\n const auth = new GoogleAuth({\n scopes: ['https://www.googleapis.com/auth/cloud-platform'],\n ...options,\n });\n\n return async function generateAuthToken() {\n const client = await auth.getClient();\n const token = await client.getAccessToken();\n return token?.token ?? null;\n };\n}\n","import {\n NoSuchModelError,\n type LanguageModelV3,\n type LanguageModelV3Usage,\n type ProviderV3,\n} from '@ai-sdk/provider';\nimport {\n createOpenAICompatible,\n type OpenAICompatibleProvider,\n} from '@ai-sdk/openai-compatible';\nimport {\n loadOptionalSetting,\n loadSetting,\n withoutTrailingSlash,\n type FetchFunction,\n type Resolvable,\n} from '@ai-sdk/provider-utils';\nimport type { GoogleVertexXaiModelId } from './google-vertex-xai-options';\n\nexport interface GoogleVertexXaiProvider extends ProviderV3 {\n /**\n * Creates a model for text generation.\n */\n (modelId: GoogleVertexXaiModelId): LanguageModelV3;\n\n /**\n * Creates a model for text generation.\n */\n languageModel(modelId: GoogleVertexXaiModelId): LanguageModelV3;\n\n /**\n * Creates a chat model for text generation.\n */\n chatModel(modelId: GoogleVertexXaiModelId): LanguageModelV3;\n\n /**\n * @deprecated Use `embeddingModel` instead.\n */\n textEmbeddingModel(modelId: string): never;\n}\n\nexport interface GoogleVertexXaiProviderSettings {\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 location/region. Defaults to the value of the `GOOGLE_VERTEX_LOCATION` environment variable.\n * Use 'global' for the global endpoint.\n */\n location?: string;\n\n /**\n * Base URL for the API calls. If not provided, will be constructed from project and location.\n */\n baseURL?: string;\n\n /**\n * Headers to use for requests. Can be:\n * - A headers object\n * - A Promise that resolves to a headers object\n * - A function that returns a headers object\n * - A function that returns a Promise of a headers object\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\ntype GoogleVertexXaiUsage =\n | {\n prompt_tokens?: number | null;\n completion_tokens?: number | null;\n prompt_tokens_details?: {\n cached_tokens?: number | null;\n } | null;\n completion_tokens_details?: {\n reasoning_tokens?: number | null;\n } | null;\n }\n | undefined\n | null;\n\nfunction convertGoogleVertexXaiUsage(\n usage: GoogleVertexXaiUsage,\n): LanguageModelV3Usage {\n if (usage == null) {\n return {\n inputTokens: {\n total: undefined,\n noCache: undefined,\n cacheRead: undefined,\n cacheWrite: undefined,\n },\n outputTokens: {\n total: undefined,\n text: undefined,\n reasoning: undefined,\n },\n raw: undefined,\n };\n }\n\n const promptTokens = usage.prompt_tokens ?? 0;\n const completionTokens = usage.completion_tokens ?? 0;\n const cacheReadTokens = usage.prompt_tokens_details?.cached_tokens ?? 0;\n const reasoningTokens =\n usage.completion_tokens_details?.reasoning_tokens ?? 0;\n\n return {\n inputTokens: {\n total: promptTokens,\n noCache: promptTokens - cacheReadTokens,\n cacheRead: cacheReadTokens,\n cacheWrite: undefined,\n },\n outputTokens: {\n total: completionTokens + reasoningTokens,\n text: completionTokens,\n reasoning: reasoningTokens,\n },\n raw: usage,\n };\n}\n\nfunction transformGoogleVertexXaiRequestBody(args: Record<string, any>) {\n const { reasoning_effort: _reasoningEffort, ...rest } = args;\n return rest;\n}\n\n/**\n * Create a Google Vertex AI xAI provider instance.\n * Uses the OpenAI-compatible Chat Completions API for Grok partner models.\n *\n * @see https://cloud.google.com/vertex-ai/generative-ai/docs/partner-models/grok\n */\nexport function createGoogleVertexXai(\n options: GoogleVertexXaiProviderSettings = {},\n): GoogleVertexXaiProvider {\n const loadLocation = () =>\n loadOptionalSetting({\n settingValue: options.location,\n environmentVariableName: 'GOOGLE_VERTEX_LOCATION',\n });\n\n const loadProject = () =>\n loadSetting({\n settingValue: options.project,\n settingName: 'project',\n environmentVariableName: 'GOOGLE_VERTEX_PROJECT',\n description: 'Google Vertex project',\n });\n\n const constructBaseURL = () => {\n const projectId = loadProject();\n const location = loadLocation() ?? 'global';\n\n return `https://aiplatform.googleapis.com/v1/projects/${projectId}/locations/${location}/endpoints/openapi`;\n };\n\n const loadBaseURL = () =>\n withoutTrailingSlash(options.baseURL ?? '') || constructBaseURL();\n\n let cachedProvider:\n | OpenAICompatibleProvider<GoogleVertexXaiModelId, string, string, string>\n | undefined;\n const getProvider = () =>\n (cachedProvider ??= createOpenAICompatible({\n name: 'googleVertex.xai',\n baseURL: loadBaseURL(),\n fetch: options.fetch,\n includeUsage: true,\n supportsStructuredOutputs: true,\n supportedUrls: () => ({\n 'image/*': [/^https?:\\/\\/.*$/],\n }),\n transformRequestBody: transformGoogleVertexXaiRequestBody,\n convertUsage: convertGoogleVertexXaiUsage,\n }));\n\n const createChatModel = (modelId: GoogleVertexXaiModelId) =>\n getProvider().languageModel(modelId);\n\n const provider = function (modelId: GoogleVertexXaiModelId) {\n if (new.target) {\n throw new Error(\n 'The Google Vertex xAI 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.chatModel = (modelId: GoogleVertexXaiModelId) =>\n getProvider().chatModel(modelId);\n provider.embeddingModel = (modelId: string): never => {\n throw new NoSuchModelError({ modelId, modelType: 'embeddingModel' });\n };\n provider.textEmbeddingModel = provider.embeddingModel;\n provider.imageModel = (modelId: string): never => {\n throw new NoSuchModelError({ modelId, modelType: 'imageModel' });\n };\n\n return provider;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,+BAAAA;AAAA,EAAA;AAAA;AAAA;;;ACAA,IAAAC,yBAA4C;;;ACA5C,iCAAmD;AAE5C,SAAS,yBAAyB,SAA6B;AACpE,QAAM,OAAO,IAAI,sCAAW;AAAA,IAC1B,QAAQ,CAAC,gDAAgD;AAAA,IACzD,GAAG;AAAA,EACL,CAAC;AAED,SAAO,eAAe,oBAAoB;AAR5C;AASI,UAAM,SAAS,MAAM,KAAK,UAAU;AACpC,UAAM,QAAQ,MAAM,OAAO,eAAe;AAC1C,YAAO,oCAAO,UAAP,YAAgB;AAAA,EACzB;AACF;;;ACbA,sBAKO;AACP,+BAGO;AACP,4BAMO;AAwEP,SAAS,4BACP,OACsB;AA1FxB;AA2FE,MAAI,SAAS,MAAM;AACjB,WAAO;AAAA,MACL,aAAa;AAAA,QACX,OAAO;AAAA,QACP,SAAS;AAAA,QACT,WAAW;AAAA,QACX,YAAY;AAAA,MACd;AAAA,MACA,cAAc;AAAA,QACZ,OAAO;AAAA,QACP,MAAM;AAAA,QACN,WAAW;AAAA,MAC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AACH;AAKO,IAAM,kBAAkBA,uBAAsB;","names":["createGoogleVertexXai","import_provider_utils","createGoogleVertexXai"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-sdk/google-vertex",
3
- "version": "4.0.118",
3
+ "version": "4.0.120",
4
4
  "license": "Apache-2.0",
5
5
  "sideEffects": false,
6
6
  "main": "./dist/index.js",
@@ -56,27 +56,27 @@
56
56
  },
57
57
  "./maas/edge": {
58
58
  "types": "./dist/maas/edge/index.d.ts",
59
- "import": "./dist/maas/edge/index.js",
60
- "default": "./dist/maas/edge/index.js"
59
+ "import": "./dist/maas/edge/index.mjs",
60
+ "require": "./dist/maas/edge/index.js"
61
61
  },
62
62
  "./xai": {
63
63
  "types": "./dist/xai/index.d.ts",
64
- "import": "./dist/xai/index.js",
65
- "default": "./dist/xai/index.js"
64
+ "import": "./dist/xai/index.mjs",
65
+ "require": "./dist/xai/index.js"
66
66
  },
67
67
  "./xai/edge": {
68
68
  "types": "./dist/xai/edge/index.d.ts",
69
- "import": "./dist/xai/edge/index.js",
70
- "default": "./dist/xai/edge/index.js"
69
+ "import": "./dist/xai/edge/index.mjs",
70
+ "require": "./dist/xai/edge/index.js"
71
71
  }
72
72
  },
73
73
  "dependencies": {
74
74
  "google-auth-library": "^10.5.0",
75
75
  "@ai-sdk/anthropic": "3.0.74",
76
76
  "@ai-sdk/google": "3.0.67",
77
- "@ai-sdk/openai-compatible": "2.0.45",
78
77
  "@ai-sdk/provider": "3.0.10",
79
- "@ai-sdk/provider-utils": "4.0.26"
78
+ "@ai-sdk/provider-utils": "4.0.26",
79
+ "@ai-sdk/openai-compatible": "2.0.46"
80
80
  },
81
81
  "devDependencies": {
82
82
  "@types/node": "20.17.24",