@ai-sdk/google-vertex 5.0.0-beta.6 → 5.0.0-beta.60

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 (55) hide show
  1. package/CHANGELOG.md +516 -8
  2. package/README.md +65 -2
  3. package/dist/anthropic/edge/index.d.ts +69 -24
  4. package/dist/anthropic/edge/index.js +67 -60
  5. package/dist/anthropic/edge/index.js.map +1 -1
  6. package/dist/anthropic/index.d.ts +69 -24
  7. package/dist/anthropic/index.js +57 -55
  8. package/dist/anthropic/index.js.map +1 -1
  9. package/dist/edge/index.d.ts +35 -26
  10. package/dist/edge/index.js +217 -176
  11. package/dist/edge/index.js.map +1 -1
  12. package/dist/index.d.ts +35 -26
  13. package/dist/index.js +208 -173
  14. package/dist/index.js.map +1 -1
  15. package/dist/maas/edge/index.d.ts +76 -0
  16. package/dist/maas/edge/index.js +196 -0
  17. package/dist/maas/edge/index.js.map +1 -0
  18. package/dist/maas/index.d.ts +60 -0
  19. package/dist/maas/index.js +101 -0
  20. package/dist/maas/index.js.map +1 -0
  21. package/docs/16-google-vertex.mdx +236 -14
  22. package/maas/edge.d.ts +1 -0
  23. package/maas/index.d.ts +1 -0
  24. package/package.json +33 -20
  25. package/src/anthropic/edge/google-vertex-anthropic-provider-edge.ts +1 -2
  26. package/src/anthropic/{google-vertex-anthropic-messages-options.ts → google-vertex-anthropic-options.ts} +2 -1
  27. package/src/anthropic/google-vertex-anthropic-provider-node.ts +1 -2
  28. package/src/anthropic/google-vertex-anthropic-provider.ts +38 -13
  29. package/src/edge/google-vertex-provider-edge.ts +1 -2
  30. package/src/google-vertex-config.ts +1 -1
  31. package/src/google-vertex-embedding-model.ts +23 -6
  32. package/src/google-vertex-embedding-options.ts +2 -0
  33. package/src/google-vertex-image-model.ts +40 -20
  34. package/src/google-vertex-options.ts +0 -1
  35. package/src/google-vertex-provider-node.ts +1 -2
  36. package/src/google-vertex-provider.ts +14 -14
  37. package/src/google-vertex-video-model.ts +7 -7
  38. package/src/maas/edge/google-vertex-maas-provider-edge.ts +65 -0
  39. package/src/maas/edge/index.ts +9 -0
  40. package/src/maas/google-vertex-maas-options.ts +15 -0
  41. package/src/maas/google-vertex-maas-provider-node.ts +64 -0
  42. package/src/maas/google-vertex-maas-provider.ts +111 -0
  43. package/src/maas/index.ts +9 -0
  44. package/dist/anthropic/edge/index.d.mts +0 -231
  45. package/dist/anthropic/edge/index.mjs +0 -259
  46. package/dist/anthropic/edge/index.mjs.map +0 -1
  47. package/dist/anthropic/index.d.mts +0 -215
  48. package/dist/anthropic/index.mjs +0 -164
  49. package/dist/anthropic/index.mjs.map +0 -1
  50. package/dist/edge/index.d.mts +0 -160
  51. package/dist/edge/index.mjs +0 -1049
  52. package/dist/edge/index.mjs.map +0 -1
  53. package/dist/index.d.mts +0 -219
  54. package/dist/index.mjs +0 -960
  55. package/dist/index.mjs.map +0 -1
@@ -0,0 +1,60 @@
1
+ import { GoogleAuthOptions } from 'google-auth-library';
2
+ import { OpenAICompatibleProvider } from '@ai-sdk/openai-compatible';
3
+ import { Resolvable, FetchFunction } from '@ai-sdk/provider-utils';
4
+
5
+ type GoogleVertexMaasModelId = 'deepseek-ai/deepseek-r1-0528-maas' | 'deepseek-ai/deepseek-v3.1-maas' | 'deepseek-ai/deepseek-v3.2-maas' | 'openai/gpt-oss-120b-maas' | 'openai/gpt-oss-20b-maas' | 'meta/llama-4-maverick-17b-128e-instruct-maas' | 'meta/llama-4-scout-17b-16e-instruct-maas' | 'minimax/minimax-m2-maas' | 'qwen/qwen3-coder-480b-a35b-instruct-maas' | 'qwen/qwen3-next-80b-a3b-instruct-maas' | 'qwen/qwen3-next-80b-a3b-thinking-maas' | 'moonshotai/kimi-k2-thinking-maas' | (string & {});
6
+
7
+ interface GoogleVertexMaasProvider extends OpenAICompatibleProvider<GoogleVertexMaasModelId, string, string, string> {
8
+ }
9
+ interface GoogleVertexMaasProviderSettings$1 {
10
+ /**
11
+ * Google Cloud project ID. Defaults to the value of the `GOOGLE_VERTEX_PROJECT` environment variable.
12
+ */
13
+ project?: string;
14
+ /**
15
+ * Google Cloud location/region. Defaults to the value of the `GOOGLE_VERTEX_LOCATION` environment variable.
16
+ * Use 'global' for the global endpoint.
17
+ */
18
+ location?: string;
19
+ /**
20
+ * Base URL for the API calls. If not provided, will be constructed from project and location.
21
+ */
22
+ baseURL?: string;
23
+ /**
24
+ * Headers to use for requests. Can be:
25
+ * - A headers object
26
+ * - A Promise that resolves to a headers object
27
+ * - A function that returns a headers object
28
+ * - A function that returns a Promise of a headers object
29
+ */
30
+ headers?: Resolvable<Record<string, string | undefined>>;
31
+ /**
32
+ * Custom fetch implementation. You can use it as a middleware to intercept requests,
33
+ * or to provide a custom fetch implementation for e.g. testing.
34
+ */
35
+ fetch?: FetchFunction;
36
+ }
37
+
38
+ interface GoogleVertexMaasProviderSettings extends GoogleVertexMaasProviderSettings$1 {
39
+ /**
40
+ * Optional. The Authentication options provided by google-auth-library.
41
+ * Complete list of authentication options is documented in the
42
+ * GoogleAuthOptions interface:
43
+ * https://github.com/googleapis/google-auth-library-nodejs/blob/main/src/auth/googleauth.ts.
44
+ */
45
+ googleAuthOptions?: GoogleAuthOptions;
46
+ }
47
+ /**
48
+ * Create a Google Vertex AI MaaS (Model as a Service) provider instance for Node.js.
49
+ * Uses the OpenAI-compatible Chat Completions API for partner and open models.
50
+ * Automatically handles Google Cloud authentication.
51
+ *
52
+ * @see https://cloud.google.com/vertex-ai/generative-ai/docs/maas/use-open-models
53
+ */
54
+ declare function createVertexMaas(options?: GoogleVertexMaasProviderSettings): GoogleVertexMaasProvider;
55
+ /**
56
+ * Default Google Vertex AI MaaS provider instance for Node.js.
57
+ */
58
+ declare const vertexMaas: GoogleVertexMaasProvider;
59
+
60
+ export { type GoogleVertexMaasModelId, type GoogleVertexMaasProvider, type GoogleVertexMaasProviderSettings, createVertexMaas, vertexMaas };
@@ -0,0 +1,101 @@
1
+ // src/maas/google-vertex-maas-provider-node.ts
2
+ import { resolve } from "@ai-sdk/provider-utils";
3
+
4
+ // src/google-vertex-auth-google-auth-library.ts
5
+ import { GoogleAuth } from "google-auth-library";
6
+ var authInstance = null;
7
+ var authOptions = null;
8
+ function getAuth(options) {
9
+ if (!authInstance || options !== authOptions) {
10
+ authInstance = new GoogleAuth({
11
+ scopes: ["https://www.googleapis.com/auth/cloud-platform"],
12
+ ...options
13
+ });
14
+ authOptions = options;
15
+ }
16
+ return authInstance;
17
+ }
18
+ async function generateAuthToken(options) {
19
+ const auth = getAuth(options || {});
20
+ const client = await auth.getClient();
21
+ const token = await client.getAccessToken();
22
+ return (token == null ? void 0 : token.token) || null;
23
+ }
24
+
25
+ // src/maas/google-vertex-maas-provider.ts
26
+ import { createOpenAICompatible } from "@ai-sdk/openai-compatible";
27
+ import {
28
+ loadOptionalSetting,
29
+ loadSetting,
30
+ withoutTrailingSlash
31
+ } from "@ai-sdk/provider-utils";
32
+ function createVertexMaas(options = {}) {
33
+ const loadLocation = () => loadOptionalSetting({
34
+ settingValue: options.location,
35
+ environmentVariableName: "GOOGLE_VERTEX_LOCATION"
36
+ });
37
+ const loadProject = () => loadSetting({
38
+ settingValue: options.project,
39
+ settingName: "project",
40
+ environmentVariableName: "GOOGLE_VERTEX_PROJECT",
41
+ description: "Google Vertex project"
42
+ });
43
+ const constructBaseURL = () => {
44
+ var _a;
45
+ const projectId = loadProject();
46
+ const location = (_a = loadLocation()) != null ? _a : "global";
47
+ return `https://aiplatform.googleapis.com/v1/projects/${projectId}/locations/${location}/endpoints/openapi`;
48
+ };
49
+ const loadBaseURL = () => {
50
+ var _a;
51
+ return withoutTrailingSlash((_a = options.baseURL) != null ? _a : "") || constructBaseURL();
52
+ };
53
+ let cachedProvider;
54
+ const getProvider = () => cachedProvider != null ? cachedProvider : cachedProvider = createOpenAICompatible({
55
+ name: "vertex.maas",
56
+ baseURL: loadBaseURL(),
57
+ fetch: options.fetch
58
+ });
59
+ const provider = (modelId) => getProvider()(modelId);
60
+ provider.specificationVersion = "v4";
61
+ provider.languageModel = (modelId) => getProvider().languageModel(modelId);
62
+ provider.chatModel = (modelId) => getProvider().chatModel(modelId);
63
+ provider.completionModel = (modelId) => getProvider().completionModel(modelId);
64
+ provider.embeddingModel = (modelId) => getProvider().embeddingModel(modelId);
65
+ provider.textEmbeddingModel = (modelId) => getProvider().textEmbeddingModel(modelId);
66
+ provider.imageModel = (modelId) => getProvider().imageModel(modelId);
67
+ return provider;
68
+ }
69
+
70
+ // src/maas/google-vertex-maas-provider-node.ts
71
+ function createVertexMaas2(options = {}) {
72
+ const customFetch = async (url, init) => {
73
+ var _a;
74
+ const token = await generateAuthToken(options.googleAuthOptions);
75
+ const resolvedHeaders = await resolve(options.headers);
76
+ const authHeaders = {
77
+ ...resolvedHeaders,
78
+ Authorization: `Bearer ${token}`
79
+ };
80
+ const fetchInit = {
81
+ ...init,
82
+ headers: {
83
+ ...init == null ? void 0 : init.headers,
84
+ ...authHeaders
85
+ }
86
+ };
87
+ return ((_a = options.fetch) != null ? _a : fetch)(url, fetchInit);
88
+ };
89
+ return createVertexMaas({
90
+ ...options,
91
+ fetch: customFetch,
92
+ headers: void 0
93
+ // Don't pass headers, we handle them in fetch
94
+ });
95
+ }
96
+ var vertexMaas = createVertexMaas2();
97
+ export {
98
+ createVertexMaas2 as createVertexMaas,
99
+ vertexMaas
100
+ };
101
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/maas/google-vertex-maas-provider-node.ts","../../src/google-vertex-auth-google-auth-library.ts","../../src/maas/google-vertex-maas-provider.ts"],"sourcesContent":["import { FetchFunction, resolve } from '@ai-sdk/provider-utils';\nimport { GoogleAuthOptions } from 'google-auth-library';\nimport { generateAuthToken } from '../google-vertex-auth-google-auth-library';\nimport {\n createVertexMaas as createVertexMaasOriginal,\n GoogleVertexMaasProvider,\n GoogleVertexMaasProviderSettings as GoogleVertexMaasProviderSettingsOriginal,\n} from './google-vertex-maas-provider';\n\nexport type { GoogleVertexMaasProvider };\n\nexport interface GoogleVertexMaasProviderSettings extends GoogleVertexMaasProviderSettingsOriginal {\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 MaaS (Model as a Service) provider instance for Node.js.\n * Uses the OpenAI-compatible Chat Completions API for partner and open models.\n * Automatically handles Google Cloud authentication.\n *\n * @see https://cloud.google.com/vertex-ai/generative-ai/docs/maas/use-open-models\n */\nexport function createVertexMaas(\n options: GoogleVertexMaasProviderSettings = {},\n): GoogleVertexMaasProvider {\n // Create a custom fetch wrapper that adds auth headers\n const customFetch: FetchFunction = async (url, init) => {\n const token = await generateAuthToken(options.googleAuthOptions);\n const resolvedHeaders = await resolve(options.headers);\n const authHeaders = {\n ...resolvedHeaders,\n Authorization: `Bearer ${token}`,\n };\n\n // Merge auth headers with existing headers from init\n const fetchInit = {\n ...init,\n headers: {\n ...init?.headers,\n ...authHeaders,\n },\n };\n\n // Call the original fetch or user's custom fetch\n return (options.fetch ?? fetch)(url, fetchInit);\n };\n\n return createVertexMaasOriginal({\n ...options,\n fetch: customFetch,\n headers: undefined, // Don't pass headers, we handle them in fetch\n });\n}\n\n/**\n * Default Google Vertex AI MaaS provider instance for Node.js.\n */\nexport const vertexMaas = createVertexMaas();\n","import { GoogleAuth, GoogleAuthOptions } from 'google-auth-library';\n\nlet authInstance: GoogleAuth | null = null;\nlet authOptions: GoogleAuthOptions | null = null;\n\nfunction getAuth(options: GoogleAuthOptions) {\n if (!authInstance || options !== authOptions) {\n authInstance = new GoogleAuth({\n scopes: ['https://www.googleapis.com/auth/cloud-platform'],\n ...options,\n });\n authOptions = options;\n }\n return authInstance;\n}\n\nexport async function generateAuthToken(options?: GoogleAuthOptions) {\n const auth = getAuth(options || {});\n const client = await auth.getClient();\n const token = await client.getAccessToken();\n return token?.token || null;\n}\n\n// For testing purposes only\nexport function _resetAuthInstance() {\n authInstance = null;\n}\n","import { createOpenAICompatible } from '@ai-sdk/openai-compatible';\nimport type { OpenAICompatibleProvider } from '@ai-sdk/openai-compatible';\nimport {\n FetchFunction,\n loadOptionalSetting,\n loadSetting,\n Resolvable,\n withoutTrailingSlash,\n} from '@ai-sdk/provider-utils';\nimport type { GoogleVertexMaasModelId } from './google-vertex-maas-options';\n\nexport interface GoogleVertexMaasProvider extends OpenAICompatibleProvider<\n GoogleVertexMaasModelId,\n string,\n string,\n string\n> {}\n\nexport interface GoogleVertexMaasProviderSettings {\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\n/**\n * Create a Google Vertex AI MaaS (Model as a Service) provider instance.\n * Uses the OpenAI-compatible Chat Completions API for partner and open models.\n *\n * @see https://cloud.google.com/vertex-ai/generative-ai/docs/maas/use-open-models\n */\nexport function createVertexMaas(\n options: GoogleVertexMaasProviderSettings = {},\n): GoogleVertexMaasProvider {\n // Lazy-load settings to support loading from environment variables at runtime\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 // Construct base URL: https://aiplatform.googleapis.com/v1/projects/{project}/locations/{location}/endpoints/openapi\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: GoogleVertexMaasProvider | undefined;\n const getProvider = () =>\n (cachedProvider ??= createOpenAICompatible({\n name: 'vertex.maas',\n baseURL: loadBaseURL(),\n fetch: options.fetch,\n }));\n\n const provider = (modelId: GoogleVertexMaasModelId) => getProvider()(modelId);\n\n provider.specificationVersion = 'v4' as const;\n provider.languageModel = (modelId: GoogleVertexMaasModelId) =>\n getProvider().languageModel(modelId);\n provider.chatModel = (modelId: GoogleVertexMaasModelId) =>\n getProvider().chatModel(modelId);\n provider.completionModel = (modelId: string) =>\n getProvider().completionModel(modelId);\n provider.embeddingModel = (modelId: string) =>\n getProvider().embeddingModel(modelId);\n provider.textEmbeddingModel = (modelId: string) =>\n getProvider().textEmbeddingModel(modelId);\n provider.imageModel = (modelId: string) => getProvider().imageModel(modelId);\n\n return provider as GoogleVertexMaasProvider;\n}\n"],"mappings":";AAAA,SAAwB,eAAe;;;ACAvC,SAAS,kBAAqC;AAE9C,IAAI,eAAkC;AACtC,IAAI,cAAwC;AAE5C,SAAS,QAAQ,SAA4B;AAC3C,MAAI,CAAC,gBAAgB,YAAY,aAAa;AAC5C,mBAAe,IAAI,WAAW;AAAA,MAC5B,QAAQ,CAAC,gDAAgD;AAAA,MACzD,GAAG;AAAA,IACL,CAAC;AACD,kBAAc;AAAA,EAChB;AACA,SAAO;AACT;AAEA,eAAsB,kBAAkB,SAA6B;AACnE,QAAM,OAAO,QAAQ,WAAW,CAAC,CAAC;AAClC,QAAM,SAAS,MAAM,KAAK,UAAU;AACpC,QAAM,QAAQ,MAAM,OAAO,eAAe;AAC1C,UAAO,+BAAO,UAAS;AACzB;;;ACrBA,SAAS,8BAA8B;AAEvC;AAAA,EAEE;AAAA,EACA;AAAA,EAEA;AAAA,OACK;AAiDA,SAAS,iBACd,UAA4C,CAAC,GACnB;AAE1B,QAAM,eAAe,MACnB,oBAAoB;AAAA,IAClB,cAAc,QAAQ;AAAA,IACtB,yBAAyB;AAAA,EAC3B,CAAC;AAEH,QAAM,cAAc,MAClB,YAAY;AAAA,IACV,cAAc,QAAQ;AAAA,IACtB,aAAa;AAAA,IACb,yBAAyB;AAAA,IACzB,aAAa;AAAA,EACf,CAAC;AAGH,QAAM,mBAAmB,MAAM;AA5EjC;AA6EI,UAAM,YAAY,YAAY;AAC9B,UAAM,YAAW,kBAAa,MAAb,YAAkB;AAEnC,WAAO,iDAAiD,SAAS,cAAc,QAAQ;AAAA,EACzF;AAEA,QAAM,cAAc,MAAG;AAnFzB;AAoFI,iCAAqB,aAAQ,YAAR,YAAmB,EAAE,KAAK,iBAAiB;AAAA;AAElE,MAAI;AACJ,QAAM,cAAc,MACjB,2DAAmB,uBAAuB;AAAA,IACzC,MAAM;AAAA,IACN,SAAS,YAAY;AAAA,IACrB,OAAO,QAAQ;AAAA,EACjB,CAAC;AAEH,QAAM,WAAW,CAAC,YAAqC,YAAY,EAAE,OAAO;AAE5E,WAAS,uBAAuB;AAChC,WAAS,gBAAgB,CAAC,YACxB,YAAY,EAAE,cAAc,OAAO;AACrC,WAAS,YAAY,CAAC,YACpB,YAAY,EAAE,UAAU,OAAO;AACjC,WAAS,kBAAkB,CAAC,YAC1B,YAAY,EAAE,gBAAgB,OAAO;AACvC,WAAS,iBAAiB,CAAC,YACzB,YAAY,EAAE,eAAe,OAAO;AACtC,WAAS,qBAAqB,CAAC,YAC7B,YAAY,EAAE,mBAAmB,OAAO;AAC1C,WAAS,aAAa,CAAC,YAAoB,YAAY,EAAE,WAAW,OAAO;AAE3E,SAAO;AACT;;;AFlFO,SAASA,kBACd,UAA4C,CAAC,GACnB;AAE1B,QAAM,cAA6B,OAAO,KAAK,SAAS;AAhC1D;AAiCI,UAAM,QAAQ,MAAM,kBAAkB,QAAQ,iBAAiB;AAC/D,UAAM,kBAAkB,MAAM,QAAQ,QAAQ,OAAO;AACrD,UAAM,cAAc;AAAA,MAClB,GAAG;AAAA,MACH,eAAe,UAAU,KAAK;AAAA,IAChC;AAGA,UAAM,YAAY;AAAA,MAChB,GAAG;AAAA,MACH,SAAS;AAAA,QACP,GAAG,6BAAM;AAAA,QACT,GAAG;AAAA,MACL;AAAA,IACF;AAGA,aAAQ,aAAQ,UAAR,YAAiB,OAAO,KAAK,SAAS;AAAA,EAChD;AAEA,SAAO,iBAAyB;AAAA,IAC9B,GAAG;AAAA,IACH,OAAO;AAAA,IACP,SAAS;AAAA;AAAA,EACX,CAAC;AACH;AAKO,IAAM,aAAaA,kBAAiB;","names":["createVertexMaas"]}
@@ -5,14 +5,15 @@ description: Learn how to use the Google Vertex AI provider.
5
5
 
6
6
  # Google Vertex Provider
7
7
 
8
- The Google Vertex provider for the [AI SDK](/docs) contains language model support for the [Google Vertex AI](https://cloud.google.com/vertex-ai) APIs. This includes support for [Google's Gemini models](https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models) and [Anthropic's Claude partner models](https://cloud.google.com/vertex-ai/generative-ai/docs/partner-models/use-claude).
8
+ The Google Vertex provider for the [AI SDK](/docs) contains language model support for the [Google Vertex AI](https://cloud.google.com/vertex-ai) APIs. This includes support for [Google's Gemini models](https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models), [Anthropic's Claude partner models](https://cloud.google.com/vertex-ai/generative-ai/docs/partner-models/use-claude), and [MaaS (Model as a Service) open models](https://cloud.google.com/vertex-ai/generative-ai/docs/maas/use-open-models).
9
9
 
10
10
  <Note>
11
11
  The Google Vertex provider is compatible with both Node.js and Edge runtimes.
12
12
  The Edge runtime is supported through the `@ai-sdk/google-vertex/edge`
13
13
  sub-module. More details can be found in the [Google Vertex Edge
14
- Runtime](#google-vertex-edge-runtime) and [Google Vertex Anthropic Edge
15
- Runtime](#google-vertex-anthropic-edge-runtime) sections below.
14
+ Runtime](#google-vertex-edge-runtime), [Google Vertex Anthropic Edge
15
+ Runtime](#google-vertex-anthropic-edge-runtime), and [Google Vertex MaaS Edge
16
+ Runtime](#google-vertex-maas-edge-runtime) sections below.
16
17
  </Note>
17
18
 
18
19
  ## Setup
@@ -344,6 +345,15 @@ The following optional provider options are available for Google Vertex models:
344
345
 
345
346
  Consult [Google's Documentation](https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/add-labels-to-api-calls) for usage details.
346
347
 
348
+ - **streamFunctionCallArguments** _boolean_
349
+
350
+ Optional. When set to true, function call arguments will be streamed
351
+ incrementally in streaming responses. This enables `tool-input-delta` events
352
+ to arrive as the model generates function call arguments, reducing perceived
353
+ latency for tool calls. Defaults to `false`. Only supported on the Vertex AI API (not the Gemini API) with Gemini 3+ models.
354
+
355
+ Consult [Google's Documentation](https://docs.cloud.google.com/vertex-ai/generative-ai/docs/multimodal/function-calling#streaming-fc) for details.
356
+
347
357
  You can use Google Vertex language models to generate text with the `generateText` function:
348
358
 
349
359
  ```ts highlight="1,4"
@@ -453,6 +463,59 @@ const result = await generateText({
453
463
 
454
464
  The optional `retrievalConfig.latLng` provider option provides location context for queries about nearby places. This configuration applies to any grounding tools that support location context.
455
465
 
466
+ #### Streaming Function Call Arguments
467
+
468
+ For Gemini 3 Pro and later models on Vertex AI, you can stream function call
469
+ arguments as they are generated by setting `streamFunctionCallArguments` to
470
+ `true`. This reduces perceived latency when functions need to be called, as
471
+ `tool-input-delta` events arrive incrementally instead of waiting for the
472
+ complete arguments. This option defaults to `false`.
473
+
474
+ ```ts
475
+ import { vertex } from '@ai-sdk/google-vertex';
476
+ import { type GoogleLanguageModelOptions } from '@ai-sdk/google';
477
+ import { streamText } from 'ai';
478
+ import { z } from 'zod';
479
+
480
+ const result = streamText({
481
+ model: vertex('gemini-3.1-pro-preview'),
482
+ prompt: 'What is the weather in Boston and San Francisco?',
483
+ tools: {
484
+ getWeather: {
485
+ description: 'Get the current weather in a given location',
486
+ inputSchema: z.object({
487
+ location: z.string().describe('City name'),
488
+ }),
489
+ },
490
+ },
491
+ providerOptions: {
492
+ vertex: {
493
+ streamFunctionCallArguments: true,
494
+ } satisfies GoogleLanguageModelOptions,
495
+ },
496
+ });
497
+
498
+ for await (const part of result.fullStream) {
499
+ switch (part.type) {
500
+ case 'tool-input-start':
501
+ console.log(`Tool call started: ${part.toolName}`);
502
+ break;
503
+ case 'tool-input-delta':
504
+ process.stdout.write(part.delta);
505
+ break;
506
+ case 'tool-call':
507
+ console.log(`Tool call complete: ${part.toolName}`, part.input);
508
+ break;
509
+ }
510
+ }
511
+ ```
512
+
513
+ <Note>
514
+ This feature is only available on the Vertex AI API. It is not supported on
515
+ the Gemini API. When used with the Google provider, a warning
516
+ will be emitted and the option will be ignored.
517
+ </Note>
518
+
456
519
  #### Reasoning (Thinking Tokens)
457
520
 
458
521
  Google Vertex AI, through its support for Gemini models, can also emit "thinking" tokens, representing the model's reasoning process. The AI SDK exposes these as reasoning information.
@@ -829,9 +892,10 @@ The following optional provider options are available for Google Vertex AI embed
829
892
 
830
893
  #### Model Capabilities
831
894
 
832
- | Model | Max Values Per Call | Parallel Calls |
833
- | -------------------- | ------------------- | ------------------- |
834
- | `text-embedding-005` | 2048 | <Check size={18} /> |
895
+ | Model | Max Values Per Call | Parallel Calls | Multimodal |
896
+ | ---------------------------- | ------------------- | ------------------- | ------------------- |
897
+ | `text-embedding-005` | 2048 | <Check size={18} /> | <Cross size={18} /> |
898
+ | `gemini-embedding-2-preview` | 2048 | <Check size={18} /> | <Check size={18} /> |
835
899
 
836
900
  <Note>
837
901
  The table above lists popular models. You can also pass any available provider
@@ -1428,6 +1492,12 @@ The following optional provider options are available for Anthropic models:
1428
1492
 
1429
1493
  Optional. See [Reasoning section](#reasoning) for more details.
1430
1494
 
1495
+ - `metadata` _object_
1496
+
1497
+ Optional. Metadata to include with the request. See the [Anthropic API documentation](https://platform.claude.com/docs/en/api/messages/create) for details.
1498
+
1499
+ - `userId` _string_ - An external identifier for the end-user.
1500
+
1431
1501
  ### Reasoning
1432
1502
 
1433
1503
  Anthropic has reasoning support for the `claude-3-7-sonnet@20250219` model.
@@ -1468,13 +1538,12 @@ on how to integrate reasoning into your chatbot.
1468
1538
  In the messages and message parts, you can use the `providerOptions` property to set cache control breakpoints.
1469
1539
  You need to set the `anthropic` property in the `providerOptions` object to `{ cacheControl: { type: 'ephemeral' } }` to set a cache control breakpoint.
1470
1540
 
1471
- The cache creation input tokens are then returned in the `providerMetadata` object
1472
- for `generateText`, again under the `anthropic` property.
1473
- When you use `streamText`, the response contains a promise
1474
- that resolves to the metadata. Alternatively you can receive it in the
1475
- `onFinish` callback.
1541
+ Cache read and cache write (creation) token counts are returned on the standard
1542
+ `usage` object for both `generateText` and `streamText`. You can access them at
1543
+ `result.usage.inputTokenDetails.cacheReadTokens` and
1544
+ `result.usage.inputTokenDetails.cacheWriteTokens`.
1476
1545
 
1477
- ```ts highlight="8,18-20,29-30"
1546
+ ```ts highlight="8,18-20,29-32"
1478
1547
  import { vertexAnthropic } from '@ai-sdk/google-vertex/anthropic';
1479
1548
  import { generateText } from 'ai';
1480
1549
 
@@ -1501,8 +1570,11 @@ const result = await generateText({
1501
1570
  });
1502
1571
 
1503
1572
  console.log(result.text);
1504
- console.log(result.providerMetadata?.anthropic);
1505
- // e.g. { cacheCreationInputTokens: 2118, cacheReadInputTokens: 0 }
1573
+ console.log('Cache read tokens:', result.usage.inputTokenDetails.cacheReadTokens);
1574
+ console.log(
1575
+ 'Cache write tokens:',
1576
+ result.usage.inputTokenDetails.cacheWriteTokens,
1577
+ );
1506
1578
  ```
1507
1579
 
1508
1580
  You can also use cache control on system messages by providing multiple system messages at the head of your messages array:
@@ -1547,6 +1619,12 @@ Google Vertex Anthropic supports a subset of Anthropic's built-in tools. The fol
1547
1619
  `@ai-sdk/anthropic` provider if you need access to all Anthropic tools.
1548
1620
  </Note>
1549
1621
 
1622
+ <Note>
1623
+ Google Vertex Anthropic does not support strict mode on tool definitions.
1624
+ Setting `strict: true` on a tool will be ignored and a warning will be
1625
+ emitted.
1626
+ </Note>
1627
+
1550
1628
  For more background on Anthropic tools, see [Anthropic's documentation](https://platform.claude.com/docs/en/agents-and-tools/tool-use/overview).
1551
1629
 
1552
1630
  #### Bash Tool
@@ -1703,3 +1781,147 @@ See also [Anthropic Model Comparison](https://docs.anthropic.com/en/docs/about-c
1703
1781
  The table above lists popular models. You can also pass any available provider
1704
1782
  model ID as a string if needed.
1705
1783
  </Note>
1784
+
1785
+ ## Google Vertex MaaS Provider Usage
1786
+
1787
+ The Google Vertex MaaS (Model as a Service) provider offers access to partner and open models hosted on Vertex AI through an OpenAI-compatible Chat Completions API. This includes models from DeepSeek, Qwen, Meta, MiniMax, Moonshot, and OpenAI.
1788
+
1789
+ For more information, see the [Vertex AI MaaS documentation](https://cloud.google.com/vertex-ai/generative-ai/docs/maas/use-open-models).
1790
+
1791
+ ### Provider Instance
1792
+
1793
+ You can import the default provider instance `vertexMaas` from `@ai-sdk/google-vertex/maas`:
1794
+
1795
+ ```typescript
1796
+ import { vertexMaas } from '@ai-sdk/google-vertex/maas';
1797
+ ```
1798
+
1799
+ If you need a customized setup, you can import `createVertexMaas` from `@ai-sdk/google-vertex/maas` and create a provider instance with your settings:
1800
+
1801
+ ```typescript
1802
+ import { createVertexMaas } from '@ai-sdk/google-vertex/maas';
1803
+
1804
+ const vertexMaas = createVertexMaas({
1805
+ project: 'my-project', // optional
1806
+ location: 'us-east5', // optional, defaults to 'global'
1807
+ });
1808
+ ```
1809
+
1810
+ #### Node.js Runtime
1811
+
1812
+ For Node.js environments, the Google Vertex MaaS provider supports all standard Google Cloud authentication options through the `google-auth-library`:
1813
+
1814
+ ```typescript
1815
+ import { createVertexMaas } from '@ai-sdk/google-vertex/maas';
1816
+
1817
+ const vertexMaas = createVertexMaas({
1818
+ googleAuthOptions: {
1819
+ credentials: {
1820
+ client_email: 'my-email',
1821
+ private_key: 'my-private-key',
1822
+ },
1823
+ },
1824
+ });
1825
+ ```
1826
+
1827
+ ##### Optional Provider Settings
1828
+
1829
+ - **project** _string_
1830
+
1831
+ The Google Cloud project ID. Defaults to the `GOOGLE_VERTEX_PROJECT` environment variable.
1832
+
1833
+ - **location** _string_
1834
+
1835
+ The Google Cloud location, e.g. `us-east5` or `global`. Defaults to the `GOOGLE_VERTEX_LOCATION` environment variable. If not set, defaults to `global`.
1836
+
1837
+ - **googleAuthOptions** _object_
1838
+
1839
+ Optional. The Authentication options used by the [Google Auth Library](https://github.com/googleapis/google-auth-library-nodejs/).
1840
+
1841
+ - **headers** _Resolvable&lt;Record&lt;string, string | undefined&gt;&gt;_
1842
+
1843
+ Headers to include in requests.
1844
+
1845
+ - **fetch** _(input: RequestInfo, init?: RequestInit) => Promise&lt;Response&gt;_
1846
+
1847
+ Custom [fetch](https://developer.mozilla.org/en-US/docs/Web/API/fetch) implementation.
1848
+
1849
+ <a id="google-vertex-maas-edge-runtime"></a>
1850
+
1851
+ #### Edge Runtime
1852
+
1853
+ For Edge runtimes, import from `@ai-sdk/google-vertex/maas/edge`:
1854
+
1855
+ ```typescript
1856
+ import { vertexMaas } from '@ai-sdk/google-vertex/maas/edge';
1857
+ ```
1858
+
1859
+ ```typescript
1860
+ import { createVertexMaas } from '@ai-sdk/google-vertex/maas/edge';
1861
+
1862
+ const vertexMaas = createVertexMaas({
1863
+ project: 'my-project',
1864
+ location: 'us-east5',
1865
+ });
1866
+ ```
1867
+
1868
+ For Edge runtime authentication, set these environment variables:
1869
+
1870
+ - `GOOGLE_CLIENT_EMAIL`
1871
+ - `GOOGLE_PRIVATE_KEY`
1872
+ - `GOOGLE_PRIVATE_KEY_ID` (optional)
1873
+
1874
+ ### Language Models
1875
+
1876
+ You can create models using the provider instance. The first argument is the model ID:
1877
+
1878
+ ```ts
1879
+ import { vertexMaas } from '@ai-sdk/google-vertex/maas';
1880
+ import { generateText } from 'ai';
1881
+
1882
+ const { text } = await generateText({
1883
+ model: vertexMaas('deepseek-ai/deepseek-v3.2-maas'),
1884
+ prompt: 'Invent a new holiday and describe its traditions.',
1885
+ });
1886
+ ```
1887
+
1888
+ Streaming is also supported:
1889
+
1890
+ ```ts
1891
+ import { vertexMaas } from '@ai-sdk/google-vertex/maas';
1892
+ import { streamText } from 'ai';
1893
+
1894
+ const result = streamText({
1895
+ model: vertexMaas('deepseek-ai/deepseek-v3.2-maas'),
1896
+ prompt: 'Invent a new holiday and describe its traditions.',
1897
+ });
1898
+
1899
+ for await (const textPart of result.textStream) {
1900
+ process.stdout.write(textPart);
1901
+ }
1902
+ ```
1903
+
1904
+ ### Available Models
1905
+
1906
+ The following models are available through the MaaS provider. You can also pass any valid model ID as a string.
1907
+
1908
+ | Model ID | Provider |
1909
+ | ---------------------------------------------- | -------- |
1910
+ | `deepseek-ai/deepseek-r1-0528-maas` | DeepSeek |
1911
+ | `deepseek-ai/deepseek-v3.1-maas` | DeepSeek |
1912
+ | `deepseek-ai/deepseek-v3.2-maas` | DeepSeek |
1913
+ | `openai/gpt-oss-120b-maas` | OpenAI |
1914
+ | `openai/gpt-oss-20b-maas` | OpenAI |
1915
+ | `meta/llama-4-maverick-17b-128e-instruct-maas` | Meta |
1916
+ | `meta/llama-4-scout-17b-16e-instruct-maas` | Meta |
1917
+ | `minimax/minimax-m2-maas` | MiniMax |
1918
+ | `qwen/qwen3-coder-480b-a35b-instruct-maas` | Qwen |
1919
+ | `qwen/qwen3-next-80b-a3b-instruct-maas` | Qwen |
1920
+ | `qwen/qwen3-next-80b-a3b-thinking-maas` | Qwen |
1921
+ | `moonshotai/kimi-k2-thinking-maas` | Moonshot |
1922
+
1923
+ <Note>
1924
+ Model availability depends on your Google Cloud project and region. Check the
1925
+ [Vertex AI Model Garden](https://console.cloud.google.com/vertex-ai/model-garden)
1926
+ for the latest available models.
1927
+ </Note>
package/maas/edge.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from '../dist/maas/edge/index';
@@ -0,0 +1 @@
1
+ export * from '../dist/maas/index';
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@ai-sdk/google-vertex",
3
- "version": "5.0.0-beta.6",
3
+ "version": "5.0.0-beta.60",
4
+ "type": "module",
4
5
  "license": "Apache-2.0",
5
6
  "sideEffects": false,
6
7
  "main": "./dist/index.js",
7
- "module": "./dist/index.mjs",
8
8
  "types": "./dist/index.d.ts",
9
9
  "files": [
10
10
  "dist/**/*",
@@ -18,7 +18,9 @@
18
18
  "README.md",
19
19
  "edge.d.ts",
20
20
  "anthropic/edge.d.ts",
21
- "anthropic/index.d.ts"
21
+ "anthropic/index.d.ts",
22
+ "maas/edge.d.ts",
23
+ "maas/index.d.ts"
22
24
  ],
23
25
  "directories": {
24
26
  "doc": "./docs"
@@ -27,38 +29,49 @@
27
29
  "./package.json": "./package.json",
28
30
  ".": {
29
31
  "types": "./dist/index.d.ts",
30
- "import": "./dist/index.mjs",
31
- "require": "./dist/index.js"
32
+ "import": "./dist/index.js",
33
+ "default": "./dist/index.js"
32
34
  },
33
35
  "./edge": {
34
36
  "types": "./dist/edge/index.d.ts",
35
- "import": "./dist/edge/index.mjs",
36
- "require": "./dist/edge/index.js"
37
+ "import": "./dist/edge/index.js",
38
+ "default": "./dist/edge/index.js"
37
39
  },
38
40
  "./anthropic": {
39
41
  "types": "./dist/anthropic/index.d.ts",
40
- "import": "./dist/anthropic/index.mjs",
41
- "require": "./dist/anthropic/index.js"
42
+ "import": "./dist/anthropic/index.js",
43
+ "default": "./dist/anthropic/index.js"
42
44
  },
43
45
  "./anthropic/edge": {
44
46
  "types": "./dist/anthropic/edge/index.d.ts",
45
- "import": "./dist/anthropic/edge/index.mjs",
46
- "require": "./dist/anthropic/edge/index.js"
47
+ "import": "./dist/anthropic/edge/index.js",
48
+ "default": "./dist/anthropic/edge/index.js"
49
+ },
50
+ "./maas": {
51
+ "types": "./dist/maas/index.d.ts",
52
+ "import": "./dist/maas/index.js",
53
+ "default": "./dist/maas/index.js"
54
+ },
55
+ "./maas/edge": {
56
+ "types": "./dist/maas/edge/index.d.ts",
57
+ "import": "./dist/maas/edge/index.js",
58
+ "default": "./dist/maas/edge/index.js"
47
59
  }
48
60
  },
49
61
  "dependencies": {
50
62
  "google-auth-library": "^10.5.0",
51
- "@ai-sdk/anthropic": "4.0.0-beta.2",
52
- "@ai-sdk/google": "4.0.0-beta.5",
53
- "@ai-sdk/provider-utils": "5.0.0-beta.1",
54
- "@ai-sdk/provider": "4.0.0-beta.0"
63
+ "@ai-sdk/anthropic": "4.0.0-beta.39",
64
+ "@ai-sdk/google": "4.0.0-beta.47",
65
+ "@ai-sdk/openai-compatible": "3.0.0-beta.33",
66
+ "@ai-sdk/provider": "4.0.0-beta.13",
67
+ "@ai-sdk/provider-utils": "5.0.0-beta.28"
55
68
  },
56
69
  "devDependencies": {
57
70
  "@types/node": "20.17.24",
58
71
  "tsup": "^8",
59
72
  "typescript": "5.8.3",
60
73
  "zod": "3.25.76",
61
- "@ai-sdk/test-server": "2.0.0-beta.0",
74
+ "@ai-sdk/test-server": "2.0.0-beta.2",
62
75
  "@vercel/ai-tsconfig": "0.0.0"
63
76
  },
64
77
  "peerDependencies": {
@@ -68,12 +81,14 @@
68
81
  "node": ">=18"
69
82
  },
70
83
  "publishConfig": {
71
- "access": "public"
84
+ "access": "public",
85
+ "provenance": true
72
86
  },
73
87
  "homepage": "https://ai-sdk.dev/docs",
74
88
  "repository": {
75
89
  "type": "git",
76
- "url": "git+https://github.com/vercel/ai.git"
90
+ "url": "https://github.com/vercel/ai",
91
+ "directory": "packages/google-vertex"
77
92
  },
78
93
  "bugs": {
79
94
  "url": "https://github.com/vercel/ai/issues"
@@ -85,9 +100,7 @@
85
100
  "build": "pnpm clean && tsup --tsconfig tsconfig.build.json",
86
101
  "build:watch": "pnpm clean && tsup --watch",
87
102
  "clean": "del-cli dist docs *.tsbuildinfo",
88
- "lint": "eslint \"./**/*.ts*\"",
89
103
  "type-check": "tsc --build",
90
- "prettier-check": "prettier --check \"./**/*.ts*\"",
91
104
  "test": "pnpm test:node && pnpm test:edge",
92
105
  "test:update": "pnpm test:node -u",
93
106
  "test:watch": "vitest --config vitest.node.config.js",
@@ -11,8 +11,7 @@ import {
11
11
 
12
12
  export type { GoogleVertexAnthropicProvider };
13
13
 
14
- export interface GoogleVertexAnthropicProviderSettings
15
- extends GoogleVertexAnthropicProviderSettingsOriginal {
14
+ export interface GoogleVertexAnthropicProviderSettings extends GoogleVertexAnthropicProviderSettingsOriginal {
16
15
  /**
17
16
  * Optional. The Google credentials for the Google Cloud service account. If
18
17
  * not provided, the Google Vertex provider will use environment variables to
@@ -1,5 +1,6 @@
1
1
  // https://cloud.google.com/vertex-ai/generative-ai/docs/partner-models/claude
2
- export type GoogleVertexAnthropicMessagesModelId =
2
+ export type GoogleVertexAnthropicModelId =
3
+ | 'claude-opus-4-7'
3
4
  | 'claude-opus-4-6'
4
5
  | 'claude-sonnet-4-6'
5
6
  | 'claude-opus-4-5@20251101'
@@ -9,8 +9,7 @@ import {
9
9
 
10
10
  export type { GoogleVertexAnthropicProvider };
11
11
 
12
- export interface GoogleVertexAnthropicProviderSettings
13
- extends GoogleVertexAnthropicProviderSettingsOriginal {
12
+ export interface GoogleVertexAnthropicProviderSettings extends GoogleVertexAnthropicProviderSettingsOriginal {
14
13
  /**
15
14
  * Optional. The Authentication options provided by google-auth-library.
16
15
  * Complete list of authentication options is documented in the