@ai-sdk/google-vertex 5.0.97 → 5.0.99

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/dist/anthropic/edge/index.d.ts +84 -80
  3. package/dist/anthropic/edge/index.d.ts.map +1 -0
  4. package/dist/anthropic/edge/index.js +232 -272
  5. package/dist/anthropic/edge/index.js.map +1 -1
  6. package/dist/anthropic/index.d.ts +69 -66
  7. package/dist/anthropic/index.d.ts.map +1 -0
  8. package/dist/anthropic/index.js +166 -177
  9. package/dist/anthropic/index.js.map +1 -1
  10. package/dist/edge/index.d.ts +206 -194
  11. package/dist/edge/index.d.ts.map +1 -0
  12. package/dist/edge/index.js +1408 -1846
  13. package/dist/edge/index.js.map +1 -1
  14. package/dist/index.d.ts +265 -252
  15. package/dist/index.d.ts.map +1 -0
  16. package/dist/index.js +1349 -1761
  17. package/dist/index.js.map +1 -1
  18. package/dist/maas/edge/index.d.ts +62 -59
  19. package/dist/maas/edge/index.d.ts.map +1 -0
  20. package/dist/maas/edge/index.js +166 -196
  21. package/dist/maas/edge/index.js.map +1 -1
  22. package/dist/maas/index.d.ts +47 -45
  23. package/dist/maas/index.d.ts.map +1 -0
  24. package/dist/maas/index.js +101 -102
  25. package/dist/maas/index.js.map +1 -1
  26. package/dist/xai/edge/index.d.ts +77 -73
  27. package/dist/xai/edge/index.d.ts.map +1 -0
  28. package/dist/xai/edge/index.js +203 -235
  29. package/dist/xai/edge/index.js.map +1 -1
  30. package/dist/xai/index.d.ts +62 -59
  31. package/dist/xai/index.d.ts.map +1 -0
  32. package/dist/xai/index.js +138 -141
  33. package/dist/xai/index.js.map +1 -1
  34. package/docs/16-google-vertex.mdx +3 -3
  35. package/package.json +11 -11
  36. package/src/edge/google-vertex-auth-edge.ts +1 -1
  37. package/src/google-vertex-provider-base.ts +1 -1
@@ -1,64 +1,66 @@
1
- import { GoogleAuthOptions } from 'google-auth-library';
2
- import { ProviderV4, LanguageModelV4 } from '@ai-sdk/provider';
3
- import { Resolvable, FetchFunction } from '@ai-sdk/provider-utils';
4
-
1
+ import { FetchFunction, Resolvable } from "@ai-sdk/provider-utils";
2
+ import { GoogleAuthOptions } from "google-auth-library";
3
+ import { LanguageModelV4, ProviderV4 } from "@ai-sdk/provider";
4
+ //#region src/xai/google-vertex-xai-options.d.ts
5
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
-
6
+ //#endregion
7
+ //#region src/xai/google-vertex-xai-provider.d.ts
7
8
  interface GoogleVertexXaiProvider extends ProviderV4 {
8
- /**
9
- * Creates a model for text generation.
10
- */
11
- (modelId: GoogleVertexXaiModelId): LanguageModelV4;
12
- /**
13
- * Creates a model for text generation.
14
- */
15
- languageModel(modelId: GoogleVertexXaiModelId): LanguageModelV4;
16
- /**
17
- * Creates a chat model for text generation.
18
- */
19
- chatModel(modelId: GoogleVertexXaiModelId): LanguageModelV4;
20
- /**
21
- * @deprecated Use `embeddingModel` instead.
22
- */
23
- textEmbeddingModel(modelId: string): never;
9
+ /**
10
+ * Creates a model for text generation.
11
+ */
12
+ (modelId: GoogleVertexXaiModelId): LanguageModelV4;
13
+ /**
14
+ * Creates a model for text generation.
15
+ */
16
+ languageModel(modelId: GoogleVertexXaiModelId): LanguageModelV4;
17
+ /**
18
+ * Creates a chat model for text generation.
19
+ */
20
+ chatModel(modelId: GoogleVertexXaiModelId): LanguageModelV4;
21
+ /**
22
+ * @deprecated Use `embeddingModel` instead.
23
+ */
24
+ textEmbeddingModel(modelId: string): never;
24
25
  }
25
26
  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;
27
+ /**
28
+ * Google Cloud project ID. Defaults to the value of the `GOOGLE_VERTEX_PROJECT` environment variable.
29
+ */
30
+ project?: string;
31
+ /**
32
+ * Google Cloud location/region. Defaults to the value of the `GOOGLE_VERTEX_LOCATION` environment variable.
33
+ * Use 'global' for the global endpoint.
34
+ */
35
+ location?: string;
36
+ /**
37
+ * Base URL for the API calls. If not provided, will be constructed from project and location.
38
+ */
39
+ baseURL?: string;
40
+ /**
41
+ * Headers to use for requests. Can be:
42
+ * - A headers object
43
+ * - A Promise that resolves to a headers object
44
+ * - A function that returns a headers object
45
+ * - A function that returns a Promise of a headers object
46
+ */
47
+ headers?: Resolvable<Record<string, string | undefined>>;
48
+ /**
49
+ * Custom fetch implementation. You can use it as a middleware to intercept requests,
50
+ * or to provide a custom fetch implementation for e.g. testing.
51
+ */
52
+ fetch?: FetchFunction;
52
53
  }
53
-
54
+ //#endregion
55
+ //#region src/xai/google-vertex-xai-provider-node.d.ts
54
56
  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;
57
+ /**
58
+ * Optional. The Authentication options provided by google-auth-library.
59
+ * Complete list of authentication options is documented in the
60
+ * GoogleAuthOptions interface:
61
+ * https://github.com/googleapis/google-auth-library-nodejs/blob/main/src/auth/googleauth.ts.
62
+ */
63
+ googleAuthOptions?: GoogleAuthOptions;
62
64
  }
63
65
  /**
64
66
  * Create a Google Vertex AI xAI provider instance for Node.js.
@@ -67,10 +69,11 @@ interface GoogleVertexXaiProviderSettings extends GoogleVertexXaiProviderSetting
67
69
  *
68
70
  * @see https://cloud.google.com/vertex-ai/generative-ai/docs/partner-models/grok
69
71
  */
70
- declare function createGoogleVertexXai(options?: GoogleVertexXaiProviderSettings): GoogleVertexXaiProvider;
72
+ export declare function createGoogleVertexXai(options?: GoogleVertexXaiProviderSettings): GoogleVertexXaiProvider;
71
73
  /**
72
74
  * Default Google Vertex AI xAI provider instance for Node.js.
73
75
  */
74
- declare const googleVertexXai: GoogleVertexXaiProvider;
75
-
76
- export { type GoogleVertexXaiModelId, type GoogleVertexXaiProvider, type GoogleVertexXaiProviderSettings, createGoogleVertexXai, googleVertexXai };
76
+ export declare const googleVertexXai: GoogleVertexXaiProvider;
77
+ //#endregion
78
+ export type { GoogleVertexXaiModelId, GoogleVertexXaiProvider, GoogleVertexXaiProviderSettings };
79
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","names":["GoogleVertexXaiProviderSettings","GoogleVertexXaiProviderSettingsOriginal"],"sources":["../../src/xai/google-vertex-xai-options.ts","../../src/xai/google-vertex-xai-provider.ts","../../src/xai/google-vertex-xai-provider-node.ts"],"mappings":";;;;KACY;;;UCkBK,gCAAgC;;;;GAI9C,SAAS,yBAAyB;;;;EAKnC,cAAc,SAAS,yBAAyB;;;;EAKhD,UAAU,SAAS,yBAAyB;;;;EAK5C,mBAAmB;;UAGJA;;;;EAIf;;;;;EAMA;;;;EAKA;;;;;;;;EASA,UAAU,WAAW;;;;;EAMrB,QAAQ;;;;UC7DO,wCAAwCC;;;;;;;EAOvD,oBAAoB;;;;;;;;;wBAUN,sBACd,UAAS,kCACR;;;;qBAgCU,iBAAe"}
package/dist/xai/index.js CHANGED
@@ -1,152 +1,149 @@
1
- // src/xai/google-vertex-xai-provider-node.ts
2
- import { resolve } from "@ai-sdk/provider-utils";
3
-
4
- // src/google-vertex-auth-google-auth-library.ts
1
+ import { loadOptionalSetting, loadSetting, resolve, withoutTrailingSlash } from "@ai-sdk/provider-utils";
5
2
  import { GoogleAuth } from "google-auth-library";
3
+ import { NoSuchModelError } from "@ai-sdk/provider";
4
+ import { createOpenAICompatible } from "@ai-sdk/openai-compatible";
5
+ //#region src/google-vertex-auth-google-auth-library.ts
6
6
  function createAuthTokenGenerator(options) {
7
- const auth = new GoogleAuth({
8
- scopes: ["https://www.googleapis.com/auth/cloud-platform"],
9
- ...options
10
- });
11
- return async function generateAuthToken() {
12
- const client = await auth.getClient();
13
- const token = await client.getAccessToken();
14
- return token?.token ?? null;
15
- };
7
+ const auth = new GoogleAuth({
8
+ scopes: ["https://www.googleapis.com/auth/cloud-platform"],
9
+ ...options
10
+ });
11
+ return async function generateAuthToken() {
12
+ return (await (await auth.getClient()).getAccessToken())?.token ?? null;
13
+ };
16
14
  }
17
-
18
- // src/xai/google-vertex-xai-provider.ts
19
- import {
20
- NoSuchModelError
21
- } from "@ai-sdk/provider";
22
- import {
23
- createOpenAICompatible
24
- } from "@ai-sdk/openai-compatible";
25
- import {
26
- loadOptionalSetting,
27
- loadSetting,
28
- withoutTrailingSlash
29
- } from "@ai-sdk/provider-utils";
15
+ //#endregion
16
+ //#region src/xai/google-vertex-xai-provider.ts
30
17
  function convertGoogleVertexXaiUsage(usage) {
31
- if (usage == null) {
32
- return {
33
- inputTokens: {
34
- total: void 0,
35
- noCache: void 0,
36
- cacheRead: void 0,
37
- cacheWrite: void 0
38
- },
39
- outputTokens: {
40
- total: void 0,
41
- text: void 0,
42
- reasoning: void 0
43
- },
44
- raw: void 0
45
- };
46
- }
47
- const promptTokens = usage.prompt_tokens ?? 0;
48
- const completionTokens = usage.completion_tokens ?? 0;
49
- const cacheReadTokens = usage.prompt_tokens_details?.cached_tokens ?? 0;
50
- const reasoningTokens = usage.completion_tokens_details?.reasoning_tokens ?? 0;
51
- return {
52
- inputTokens: {
53
- total: promptTokens,
54
- noCache: promptTokens - cacheReadTokens,
55
- cacheRead: cacheReadTokens,
56
- cacheWrite: void 0
57
- },
58
- outputTokens: {
59
- total: completionTokens + reasoningTokens,
60
- text: completionTokens,
61
- reasoning: reasoningTokens
62
- },
63
- raw: usage
64
- };
18
+ if (usage == null) return {
19
+ inputTokens: {
20
+ total: void 0,
21
+ noCache: void 0,
22
+ cacheRead: void 0,
23
+ cacheWrite: void 0
24
+ },
25
+ outputTokens: {
26
+ total: void 0,
27
+ text: void 0,
28
+ reasoning: void 0
29
+ },
30
+ raw: void 0
31
+ };
32
+ const promptTokens = usage.prompt_tokens ?? 0;
33
+ const completionTokens = usage.completion_tokens ?? 0;
34
+ const cacheReadTokens = usage.prompt_tokens_details?.cached_tokens ?? 0;
35
+ const reasoningTokens = usage.completion_tokens_details?.reasoning_tokens ?? 0;
36
+ return {
37
+ inputTokens: {
38
+ total: promptTokens,
39
+ noCache: promptTokens - cacheReadTokens,
40
+ cacheRead: cacheReadTokens,
41
+ cacheWrite: void 0
42
+ },
43
+ outputTokens: {
44
+ total: completionTokens + reasoningTokens,
45
+ text: completionTokens,
46
+ reasoning: reasoningTokens
47
+ },
48
+ raw: usage
49
+ };
65
50
  }
66
51
  function transformGoogleVertexXaiRequestBody(args) {
67
- const { reasoning_effort: _reasoningEffort, ...rest } = args;
68
- return rest;
52
+ const { reasoning_effort: _reasoningEffort, ...rest } = args;
53
+ return rest;
69
54
  }
55
+ /**
56
+ * Create a Google Vertex AI xAI provider instance.
57
+ * Uses the OpenAI-compatible Chat Completions API for Grok partner models.
58
+ *
59
+ * @see https://cloud.google.com/vertex-ai/generative-ai/docs/partner-models/grok
60
+ */
61
+ function createGoogleVertexXai$1(options = {}) {
62
+ const loadLocation = () => loadOptionalSetting({
63
+ settingValue: options.location,
64
+ environmentVariableName: "GOOGLE_VERTEX_LOCATION"
65
+ });
66
+ const loadProject = () => loadSetting({
67
+ settingValue: options.project,
68
+ settingName: "project",
69
+ environmentVariableName: "GOOGLE_VERTEX_PROJECT",
70
+ description: "Google Vertex project"
71
+ });
72
+ const constructBaseURL = () => {
73
+ return `https://aiplatform.googleapis.com/v1/projects/${loadProject()}/locations/${loadLocation() ?? "global"}/endpoints/openapi`;
74
+ };
75
+ const loadBaseURL = () => withoutTrailingSlash(options.baseURL ?? "") || constructBaseURL();
76
+ let cachedProvider;
77
+ const getProvider = () => cachedProvider ??= createOpenAICompatible({
78
+ name: "googleVertex.xai",
79
+ baseURL: loadBaseURL(),
80
+ fetch: options.fetch,
81
+ includeUsage: true,
82
+ supportsStructuredOutputs: true,
83
+ supportedUrls: () => ({ "image/*": [/^https?:\/\/.*$/] }),
84
+ transformRequestBody: transformGoogleVertexXaiRequestBody,
85
+ convertUsage: convertGoogleVertexXaiUsage
86
+ });
87
+ const createChatModel = (modelId) => getProvider().languageModel(modelId);
88
+ const provider = function(modelId) {
89
+ if (new.target) throw new Error("The Google Vertex xAI model function cannot be called with the new keyword.");
90
+ return createChatModel(modelId);
91
+ };
92
+ provider.specificationVersion = "v4";
93
+ provider.languageModel = createChatModel;
94
+ provider.chatModel = (modelId) => getProvider().chatModel(modelId);
95
+ provider.embeddingModel = (modelId) => {
96
+ throw new NoSuchModelError({
97
+ modelId,
98
+ modelType: "embeddingModel"
99
+ });
100
+ };
101
+ provider.textEmbeddingModel = provider.embeddingModel;
102
+ provider.imageModel = (modelId) => {
103
+ throw new NoSuchModelError({
104
+ modelId,
105
+ modelType: "imageModel"
106
+ });
107
+ };
108
+ return provider;
109
+ }
110
+ //#endregion
111
+ //#region src/xai/google-vertex-xai-provider-node.ts
112
+ /**
113
+ * Create a Google Vertex AI xAI provider instance for Node.js.
114
+ * Uses the OpenAI-compatible Chat Completions API for Grok partner models.
115
+ * Automatically handles Google Cloud authentication.
116
+ *
117
+ * @see https://cloud.google.com/vertex-ai/generative-ai/docs/partner-models/grok
118
+ */
70
119
  function createGoogleVertexXai(options = {}) {
71
- const loadLocation = () => loadOptionalSetting({
72
- settingValue: options.location,
73
- environmentVariableName: "GOOGLE_VERTEX_LOCATION"
74
- });
75
- const loadProject = () => loadSetting({
76
- settingValue: options.project,
77
- settingName: "project",
78
- environmentVariableName: "GOOGLE_VERTEX_PROJECT",
79
- description: "Google Vertex project"
80
- });
81
- const constructBaseURL = () => {
82
- const projectId = loadProject();
83
- const location = loadLocation() ?? "global";
84
- return `https://aiplatform.googleapis.com/v1/projects/${projectId}/locations/${location}/endpoints/openapi`;
85
- };
86
- const loadBaseURL = () => withoutTrailingSlash(options.baseURL ?? "") || constructBaseURL();
87
- let cachedProvider;
88
- const getProvider = () => cachedProvider ??= createOpenAICompatible({
89
- name: "googleVertex.xai",
90
- baseURL: loadBaseURL(),
91
- fetch: options.fetch,
92
- includeUsage: true,
93
- supportsStructuredOutputs: true,
94
- supportedUrls: () => ({
95
- "image/*": [/^https?:\/\/.*$/]
96
- }),
97
- transformRequestBody: transformGoogleVertexXaiRequestBody,
98
- convertUsage: convertGoogleVertexXaiUsage
99
- });
100
- const createChatModel = (modelId) => getProvider().languageModel(modelId);
101
- const provider = function(modelId) {
102
- if (new.target) {
103
- throw new Error(
104
- "The Google Vertex xAI model function cannot be called with the new keyword."
105
- );
106
- }
107
- return createChatModel(modelId);
108
- };
109
- provider.specificationVersion = "v4";
110
- provider.languageModel = createChatModel;
111
- provider.chatModel = (modelId) => getProvider().chatModel(modelId);
112
- provider.embeddingModel = (modelId) => {
113
- throw new NoSuchModelError({ modelId, modelType: "embeddingModel" });
114
- };
115
- provider.textEmbeddingModel = provider.embeddingModel;
116
- provider.imageModel = (modelId) => {
117
- throw new NoSuchModelError({ modelId, modelType: "imageModel" });
118
- };
119
- return provider;
120
+ const generateAuthToken = createAuthTokenGenerator(options.googleAuthOptions);
121
+ const customFetch = async (url, init) => {
122
+ const token = await generateAuthToken();
123
+ const authHeaders = {
124
+ ...await resolve(options.headers),
125
+ Authorization: `Bearer ${token}`
126
+ };
127
+ const fetchInit = {
128
+ ...init,
129
+ headers: {
130
+ ...init?.headers,
131
+ ...authHeaders
132
+ }
133
+ };
134
+ return (options.fetch ?? fetch)(url, fetchInit);
135
+ };
136
+ return createGoogleVertexXai$1({
137
+ ...options,
138
+ fetch: customFetch,
139
+ headers: void 0
140
+ });
120
141
  }
142
+ /**
143
+ * Default Google Vertex AI xAI provider instance for Node.js.
144
+ */
145
+ const googleVertexXai = createGoogleVertexXai();
146
+ //#endregion
147
+ export { createGoogleVertexXai, googleVertexXai };
121
148
 
122
- // src/xai/google-vertex-xai-provider-node.ts
123
- function createGoogleVertexXai2(options = {}) {
124
- const generateAuthToken = createAuthTokenGenerator(options.googleAuthOptions);
125
- const customFetch = async (url, init) => {
126
- const token = await generateAuthToken();
127
- const resolvedHeaders = await resolve(options.headers);
128
- const authHeaders = {
129
- ...resolvedHeaders,
130
- Authorization: `Bearer ${token}`
131
- };
132
- const fetchInit = {
133
- ...init,
134
- headers: {
135
- ...init?.headers,
136
- ...authHeaders
137
- }
138
- };
139
- return (options.fetch ?? fetch)(url, fetchInit);
140
- };
141
- return createGoogleVertexXai({
142
- ...options,
143
- fetch: customFetch,
144
- headers: void 0
145
- });
146
- }
147
- var googleVertexXai = createGoogleVertexXai2();
148
- export {
149
- createGoogleVertexXai2 as createGoogleVertexXai,
150
- googleVertexXai
151
- };
152
149
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/xai/google-vertex-xai-provider-node.ts","../../src/google-vertex-auth-google-auth-library.ts","../../src/xai/google-vertex-xai-provider.ts"],"sourcesContent":["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 LanguageModelV4,\n type LanguageModelV4Usage,\n type ProviderV4,\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 ProviderV4 {\n /**\n * Creates a model for text generation.\n */\n (modelId: GoogleVertexXaiModelId): LanguageModelV4;\n\n /**\n * Creates a model for text generation.\n */\n languageModel(modelId: GoogleVertexXaiModelId): LanguageModelV4;\n\n /**\n * Creates a chat model for text generation.\n */\n chatModel(modelId: GoogleVertexXaiModelId): LanguageModelV4;\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): LanguageModelV4Usage {\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 = 'v4' 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,SAAS,eAAmC;;;ACA5C,SAAS,kBAA0C;AAE5C,SAAS,yBAAyB,SAA6B;AACpE,QAAM,OAAO,IAAI,WAAW;AAAA,IAC1B,QAAQ,CAAC,gDAAgD;AAAA,IACzD,GAAG;AAAA,EACL,CAAC;AAED,SAAO,eAAe,oBAAoB;AACxC,UAAM,SAAS,MAAM,KAAK,UAAU;AACpC,UAAM,QAAQ,MAAM,OAAO,eAAe;AAC1C,WAAO,OAAO,SAAS;AAAA,EACzB;AACF;;;ACbA;AAAA,EACE;AAAA,OAIK;AACP;AAAA,EACE;AAAA,OAEK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAGK;AAwEP,SAAS,4BACP,OACsB;AACtB,MAAI,SAAS,MAAM;AACjB,WAAO;AAAA,MACL,aAAa;AAAA,QACX,OAAO;AAAA,QACP,SAAS;AAAA,QACT,WAA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H;AAKO,IAAM,kBAAkBA,uBAAsB;","names":["createGoogleVertexXai"]}
1
+ {"version":3,"file":"index.js","names":["createGoogleVertexXai","createGoogleVertexXaiOriginal"],"sources":["../../src/google-vertex-auth-google-auth-library.ts","../../src/xai/google-vertex-xai-provider.ts","../../src/xai/google-vertex-xai-provider-node.ts"],"sourcesContent":["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 LanguageModelV4,\n type LanguageModelV4Usage,\n type ProviderV4,\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 ProviderV4 {\n /**\n * Creates a model for text generation.\n */\n (modelId: GoogleVertexXaiModelId): LanguageModelV4;\n\n /**\n * Creates a model for text generation.\n */\n languageModel(modelId: GoogleVertexXaiModelId): LanguageModelV4;\n\n /**\n * Creates a chat model for text generation.\n */\n chatModel(modelId: GoogleVertexXaiModelId): LanguageModelV4;\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): LanguageModelV4Usage {\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 = 'v4' 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","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"],"mappings":";;;;;AAEA,SAAgB,yBAAyB,SAA6B;CACpE,MAAM,OAAO,IAAI,WAAW;EAC1B,QAAQ,CAAC,gDAAgD;EACzD,GAAG;CACL,CAAC;CAED,OAAO,eAAe,oBAAoB;EAGxC,QAAO,OADa,MADC,KAAK,UAAU,EAAA,CACT,eAAe,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,CAAC;CAEH,MAAM,mBAAmB,YACvB,YAAY,CAAC,CAAC,cAAc,OAAO;CAErC,MAAM,WAAW,SAAU,SAAiC;EAC1D,IAAI,YACF,MAAM,IAAI,MACR,6EACF;EAGF,OAAO,gBAAgB,OAAO;CAChC;CAEA,SAAS,uBAAuB;CAChC,SAAS,gBAAgB;CACzB,SAAS,aAAa,YACpB,YAAY,CAAC,CAAC,UAAU,OAAO;CACjC,SAAS,kBAAkB,YAA2B;EACpD,MAAM,IAAI,iBAAiB;GAAE;GAAS,WAAW;EAAiB,CAAC;CACrE;CACA,SAAS,qBAAqB,SAAS;CACvC,SAAS,cAAc,YAA2B;EAChD,MAAM,IAAI,iBAAiB;GAAE;GAAS,WAAW;EAAa,CAAC;CACjE;CAEA,OAAO;AACT;;;;;;;;;;ACxLA,SAAgB,sBACd,UAA2C,CAAC,GACnB;CACzB,MAAM,oBAAoB,yBAAyB,QAAQ,iBAAiB;CAE5E,MAAM,cAA6B,OAAO,KAAK,SAAS;EACtD,MAAM,QAAQ,MAAM,kBAAkB;EAEtC,MAAM,cAAc;GAClB,GAAG,MAFyB,QAAQ,QAAQ,OAAO;GAGnD,eAAe,UAAU;EAC3B;EAEA,MAAM,YAAY;GAChB,GAAG;GACH,SAAS;IACP,GAAG,MAAM;IACT,GAAG;GACL;EACF;EAEA,QAAQ,QAAQ,SAAS,MAAA,CAAO,KAAK,SAAS;CAChD;CAEA,OAAOC,wBAA8B;EACnC,GAAG;EACH,OAAO;EACP,SAAS,KAAA;CACX,CAAC;AACH;;;;AAKA,MAAa,kBAAkB,sBAAsB"}
@@ -488,7 +488,7 @@ The response will contain `tool-call` and `tool-result` parts for the executed c
488
488
 
489
489
  #### URL Context
490
490
 
491
- URL Context allows Gemini models to retrieve and analyze content from URLs. Supported models: Gemini 2.5 Flash-Lite, 2.5 Pro, 2.5 Flash, 2.0 Flash.
491
+ URL Context allows Gemini models to retrieve and analyze content from URLs. Supported models: Gemini 2.0 and newer.
492
492
 
493
493
  ```ts
494
494
  import { googleVertex } from '@ai-sdk/google-vertex';
@@ -503,7 +503,7 @@ const result = await generateText({
503
503
 
504
504
  #### Google Search
505
505
 
506
- Google Search enables Gemini models to access real-time web information. Supported models: Gemini 2.5 Flash-Lite, 2.5 Flash, 2.0 Flash, 2.5 Pro.
506
+ Google Search enables Gemini models to access real-time web information. Supported models: Gemini 2.0 and newer.
507
507
 
508
508
  ```ts
509
509
  import { googleVertex } from '@ai-sdk/google-vertex';
@@ -535,7 +535,7 @@ const result = await generateText({
535
535
 
536
536
  #### Google Maps
537
537
 
538
- Google Maps grounding enables Gemini models to access Google Maps data for location-aware responses. Supported models: Gemini 2.5 Flash-Lite, 2.5 Flash, 2.0 Flash, 2.5 Pro, 3.0 Pro.
538
+ Google Maps grounding enables Gemini models to access Google Maps data for location-aware responses. Supported models: Gemini 2.0 and newer.
539
539
 
540
540
  ```ts
541
541
  import { googleVertex } from '@ai-sdk/google-vertex';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-sdk/google-vertex",
3
- "version": "5.0.97",
3
+ "version": "5.0.99",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "sideEffects": false,
@@ -71,18 +71,18 @@
71
71
  }
72
72
  },
73
73
  "dependencies": {
74
- "@ai-sdk/anthropic": "4.0.67",
75
- "@ai-sdk/google": "4.0.84",
76
- "@ai-sdk/openai-compatible": "3.0.58",
77
- "@ai-sdk/provider": "4.0.19",
78
- "@ai-sdk/provider-utils": "5.0.50",
74
+ "@ai-sdk/anthropic": "4.0.69",
75
+ "@ai-sdk/google": "4.0.86",
76
+ "@ai-sdk/openai-compatible": "3.0.60",
77
+ "@ai-sdk/provider": "4.0.20",
78
+ "@ai-sdk/provider-utils": "5.0.52",
79
79
  "google-auth-library": "^10.6.2"
80
80
  },
81
81
  "devDependencies": {
82
- "@ai-sdk/test-server": "2.0.2",
82
+ "@ai-sdk/test-server": "2.0.3",
83
83
  "@types/node": "22.19.19",
84
84
  "@vercel/ai-tsconfig": "0.0.0",
85
- "tsup": "^8.5.1",
85
+ "tsdown": "^0.23.0",
86
86
  "typescript": "5.8.3",
87
87
  "zod": "3.25.76"
88
88
  },
@@ -109,9 +109,9 @@
109
109
  "ai"
110
110
  ],
111
111
  "scripts": {
112
- "build": "pnpm clean && tsup --tsconfig tsconfig.build.json",
113
- "build:watch": "pnpm clean && tsup --watch",
114
- "clean": "del-cli dist docs *.tsbuildinfo",
112
+ "build": "pnpm clean && tsdown",
113
+ "build:watch": "pnpm clean && tsdown --watch",
114
+ "clean": "del-cli docs *.tsbuildinfo",
115
115
  "type-check": "tsc --build",
116
116
  "test": "pnpm test:node && pnpm test:edge",
117
117
  "test:update": "pnpm test:node -u",
@@ -139,7 +139,7 @@ export async function generateAuthToken(credentials?: GoogleCredentials) {
139
139
  method: 'POST',
140
140
  headers: withUserAgentSuffix(
141
141
  { 'Content-Type': 'application/x-www-form-urlencoded' },
142
- `ai-sdk/google-vertex/${VERSION}`,
142
+ `ai-sdk-google-vertex/${VERSION}`,
143
143
  getRuntimeEnvironmentUserAgent(),
144
144
  ),
145
145
  body: new URLSearchParams({
@@ -271,7 +271,7 @@ export function createGoogleVertex(
271
271
  const originalHeaders = await resolve(options.headers ?? {});
272
272
  return withUserAgentSuffix(
273
273
  originalHeaders,
274
- `ai-sdk/google-vertex/${VERSION}`,
274
+ `ai-sdk-google-vertex/${VERSION}`,
275
275
  );
276
276
  };
277
277