@ai-sdk/google-vertex 5.0.132 → 5.0.133

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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":["GoogleVertexMaasProviderSettings","GoogleVertexMaasProviderSettingsOriginal"],"sources":["../../../src/edge/google-vertex-auth-edge.ts","../../../src/maas/google-vertex-maas-options.ts","../../../src/maas/google-vertex-maas-provider.ts","../../../src/maas/edge/google-vertex-maas-provider-edge.ts"],"mappings":";;;UAQiB;;;;;EAKf;;;;;EAMA;;;;;EAMA;;;;KCxBU;;;UC2BK,iCAAiC,yBAChD;UAMeA;;;;EAIf;;;;;EAMA;;;;EAKA;;;;;;;;EASA,UAAU,WAAW;;;;;EAMrB,QAAQ;;;;UCrDO,yCAAyCC;;;;;;EAMxD,oBAAoB;;;;;;;;;wBAUN,uBACd,UAAS,mCACR;;;;qBAiCU,kBAAgB"}
1
+ {"version":3,"file":"index.d.ts","names":["GoogleVertexMaasProviderSettings","GoogleVertexMaasProviderSettingsOriginal"],"sources":["../../../src/edge/google-vertex-auth-edge.ts","../../../src/maas/google-vertex-maas-options.ts","../../../src/maas/google-vertex-maas-provider.ts","../../../src/maas/edge/google-vertex-maas-provider-edge.ts"],"mappings":";;;UAQiB;;;;;EAKf;;;;;EAMA;;;;;EAMA;;;;KCxBU;;;UCwBK,iCAAiC,yBAChD;UAMeA;;;;EAIf;;;;;EAMA;;;;EAKA;;;;;;;;EASA,UAAU,WAAW;;;;;EAMrB,QAAQ;;;;UClDO,yCAAyCC;;;;;;EAMxD,oBAAoB;;;;;;;;;wBAUN,uBACd,UAAS,mCACR;;;;qBAiCU,kBAAgB"}
@@ -2,7 +2,7 @@ import { getRuntimeEnvironmentUserAgent, isValidHostnamePart, loadOptionalSettin
2
2
  import { InvalidArgumentError } from "@ai-sdk/provider";
3
3
  import { createOpenAICompatible } from "@ai-sdk/openai-compatible";
4
4
  //#region src/version.ts
5
- const VERSION = "5.0.132";
5
+ const VERSION = "5.0.133";
6
6
  //#endregion
7
7
  //#region src/edge/google-vertex-auth-edge.ts
8
8
  const loadCredentials = async () => {
@@ -82,13 +82,33 @@ async function generateAuthToken(credentials) {
82
82
  return (await response.json()).access_token;
83
83
  }
84
84
  //#endregion
85
+ //#region src/google-vertex-model-catalog-config.ts
86
+ function requestConfig(modelId) {
87
+ const embedContent = modelId === "gemini-embedding-2" || modelId === "gemini-embedding-2-preview";
88
+ return {
89
+ language: {
90
+ endpoint: modelId.startsWith("endpoints/"),
91
+ maxOutputTokens: modelId === "meta/llama-4-maverick-17b-128e-instruct-maas" || modelId === "meta/llama-4-scout-17b-16e-instruct-maas" ? 8192 : void 0
92
+ },
93
+ image: { gemini: modelId.startsWith("gemini-") },
94
+ embedding: {
95
+ endpoint: embedContent ? "embedContent" : "predict",
96
+ maxEmbeddingsPerCall: embedContent ? 1 : 250
97
+ },
98
+ speech: { api: modelId.startsWith("chirp") ? "cloud-tts" : "gemini" },
99
+ transcription: {
100
+ api: modelId.startsWith("gemini") ? "gemini" : "cloud-speech",
101
+ live: modelId.includes("-live")
102
+ }
103
+ };
104
+ }
105
+ function getGoogleVertexRequestConfig(modelId) {
106
+ return requestConfig(modelId);
107
+ }
108
+ //#endregion
85
109
  //#region src/maas/google-vertex-maas-provider.ts
86
- const maxOutputTokensByModel = {
87
- "meta/llama-4-maverick-17b-128e-instruct-maas": 8192,
88
- "meta/llama-4-scout-17b-16e-instruct-maas": 8192
89
- };
90
110
  function transformGoogleVertexMaasRequestBody(args) {
91
- const maxOutputTokens = maxOutputTokensByModel[args.model];
111
+ const maxOutputTokens = getGoogleVertexRequestConfig(args.model).language?.maxOutputTokens;
92
112
  return maxOutputTokens != null && args.max_tokens === void 0 ? {
93
113
  ...args,
94
114
  max_tokens: maxOutputTokens
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["createGoogleVertexMaas","createVertexMaasOriginal"],"sources":["../../../src/version.ts","../../../src/edge/google-vertex-auth-edge.ts","../../../src/maas/google-vertex-maas-provider.ts","../../../src/maas/edge/google-vertex-maas-provider-edge.ts"],"sourcesContent":["// 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 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 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}\n","import { InvalidArgumentError } from '@ai-sdk/provider';\nimport {\n createOpenAICompatible,\n type OpenAICompatibleProvider,\n} from '@ai-sdk/openai-compatible';\nimport {\n isValidHostnamePart,\n loadOptionalSetting,\n loadSetting,\n withoutTrailingSlash,\n type FetchFunction,\n type Resolvable,\n} from '@ai-sdk/provider-utils';\nimport type { GoogleVertexMaasModelId } from './google-vertex-maas-options';\n\nconst maxOutputTokensByModel: Record<string, number | undefined> = {\n 'meta/llama-4-maverick-17b-128e-instruct-maas': 8192,\n 'meta/llama-4-scout-17b-16e-instruct-maas': 8192,\n};\n\nfunction transformGoogleVertexMaasRequestBody(args: Record<string, any>) {\n const maxOutputTokens = maxOutputTokensByModel[args.model];\n\n return maxOutputTokens != null && args.max_tokens === undefined\n ? { ...args, max_tokens: maxOutputTokens }\n : args;\n}\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 createGoogleVertexMaas(\n options: GoogleVertexMaasProviderSettings = {},\n): GoogleVertexMaasProvider {\n // Lazy-load settings to support loading from environment variables at runtime\n const loadLocation = () => {\n const location =\n loadOptionalSetting({\n settingValue: options.location,\n environmentVariableName: 'GOOGLE_VERTEX_LOCATION',\n }) ?? 'global';\n if (!isValidHostnamePart(location)) {\n throw new InvalidArgumentError({\n argument: 'location',\n message:\n 'Invalid Google Vertex location. Expected a single DNS label (letters, digits, and hyphens). Use `baseURL` for custom endpoints.',\n });\n }\n return 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 getHost = (location: string) => {\n if (location === 'global') {\n return 'aiplatform.googleapis.com';\n } else if (location === 'eu' || location === 'us') {\n return `aiplatform.${location}.rep.googleapis.com`;\n } else {\n return `${location}-aiplatform.googleapis.com`;\n }\n };\n\n const constructBaseURL = () => {\n const projectId = loadProject();\n const location = loadLocation();\n\n return `https://${getHost(location)}/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 transformRequestBody: transformGoogleVertexMaasRequestBody,\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","import { resolve, type FetchFunction } from '@ai-sdk/provider-utils';\nimport {\n generateAuthToken,\n type GoogleCredentials,\n} from '../../edge/google-vertex-auth-edge';\nimport {\n createGoogleVertexMaas as createVertexMaasOriginal,\n type GoogleVertexMaasProvider,\n type GoogleVertexMaasProviderSettings as GoogleVertexMaasProviderSettingsOriginal,\n} from '../google-vertex-maas-provider';\nexport type { GoogleVertexMaasProvider };\n\nexport interface GoogleVertexMaasProviderSettings extends GoogleVertexMaasProviderSettingsOriginal {\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 MaaS (Model as a Service) provider instance for Edge runtimes.\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 createGoogleVertexMaas(\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.googleCredentials);\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 Edge runtimes.\n */\nexport const googleVertexMaas = createGoogleVertexMaas();\n"],"mappings":";;;;AAEA,MAAa,UAAA;;;AC0Bb,MAAM,kBAAkB,YAAwC;CAC9D,IAAI;EACF,OAAO;GACL,aAAa,YAAY;IACvB,cAAc,KAAA;IACd,aAAa;IACb,yBAAyB;IACzB,aAAa;GACf,CAAC;GACD,YAAY,YAAY;IACtB,cAAc,KAAA;IACd,aAAa;IACb,yBAAyB;IACzB,aAAa;GACf,CAAC;GACD,cAAc,oBAAoB;IAChC,cAAc,KAAA;IACd,yBAAyB;GAC3B,CAAC;EACH;CACF,SAAS,OAAY;EACnB,MAAM,IAAI,MAAM,sCAAsC,MAAM,SAAS;CACvE;AACF;AAGA,MAAM,aAAa,QAAgB;CACjC,OAAO,KAAK,GAAG,CAAC,CAAC,QAAQ,OAAO,GAAG,CAAC,CAAC,QAAQ,OAAO,GAAG,CAAC,CAAC,QAAQ,MAAM,EAAE;AAC3E;AACA,MAAM,mBAAmB,OAAO,WAAmB;CAKjD,MAAM,cAAc,OACjB,QAAQ,+BAAW,EAAE,CAAC,CACtB,QAAQ,6BAAW,EAAE,CAAC,CACtB,QAAQ,OAAO,EAAE;CAGpB,MAAM,eAAe,KAAK,WAAW;CAGrC,MAAM,aAAa,IAAI,WAAW,aAAa,MAAM;CACrD,KAAK,IAAI,IAAI,GAAG,IAAI,aAAa,QAAQ,KACvC,WAAW,KAAK,aAAa,WAAW,CAAC;CAG3C,OAAO,MAAM,OAAO,OAAO,UACzB,SACA,YACA;EAAE,MAAM;EAAqB,MAAM;CAAU,GAC7C,MACA,CAAC,MAAM,CACT;AACF;AAEA,MAAM,WAAW,OAAO,gBAAmC;CACzD,MAAM,MAAM,KAAK,MAAM,KAAK,IAAI,IAAI,GAAI;CAGxC,MAAM,SAAqD;EACzD,KAAK;EACL,KAAK;CACP;CAEA,IAAI,YAAY,cACd,OAAO,MAAM,YAAY;C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nB;CAE1B,MAAM,cAA6B,OAAO,KAAK,SAAS;EACtD,MAAM,QAAQ,MAAM,kBAAkB,QAAQ,iBAAiB;EAE/D,MAAM,cAAc;GAClB,GAAG,MAFyB,QAAQ,QAAQ,OAAO;GAGnD,eAAe,UAAU;EAC3B;EAGA,MAAM,YAAY;GAChB,GAAG;GACH,SAAS;IACP,GAAG,MAAM;IACT,GAAG;GACL;EACF;EAGA,QAAQ,QAAQ,SAAS,MAAA,CAAO,KAAK,SAAS;CAChD;CAEA,OAAOC,yBAAyB;EAC9B,GAAG;EACH,OAAO;EACP,SAAS,KAAA;CACX,CAAC;AACH;;;;AAKA,MAAa,mBAAmB,uBAAuB"}
1
+ {"version":3,"file":"index.js","names":["createGoogleVertexMaas","createVertexMaasOriginal"],"sources":["../../../src/version.ts","../../../src/edge/google-vertex-auth-edge.ts","../../../src/google-vertex-model-catalog-config.ts","../../../src/maas/google-vertex-maas-provider.ts","../../../src/maas/edge/google-vertex-maas-provider-edge.ts"],"sourcesContent":["// 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 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 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}\n","export type VertexRequestConfig = {\n language?: { endpoint: boolean; maxOutputTokens?: number };\n image?: { gemini: boolean };\n embedding?: {\n endpoint: 'embedContent' | 'predict';\n maxEmbeddingsPerCall: number;\n };\n speech?: { api: 'cloud-tts' | 'gemini' };\n transcription?: { api: 'gemini' | 'cloud-speech'; live: boolean };\n};\n\nfunction requestConfig(modelId: string): VertexRequestConfig {\n const embedContent =\n modelId === 'gemini-embedding-2' ||\n modelId === 'gemini-embedding-2-preview';\n return {\n language: {\n endpoint: modelId.startsWith('endpoints/'),\n maxOutputTokens:\n modelId === 'meta/llama-4-maverick-17b-128e-instruct-maas' ||\n modelId === 'meta/llama-4-scout-17b-16e-instruct-maas'\n ? 8192\n : undefined,\n },\n image: { gemini: modelId.startsWith('gemini-') },\n embedding: {\n endpoint: embedContent ? 'embedContent' : 'predict',\n maxEmbeddingsPerCall: embedContent ? 1 : 250,\n },\n speech: { api: modelId.startsWith('chirp') ? 'cloud-tts' : 'gemini' },\n transcription: {\n api: modelId.startsWith('gemini') ? 'gemini' : 'cloud-speech',\n live: modelId.includes('-live'),\n },\n };\n}\n\nexport function getGoogleVertexRequestConfig(\n modelId: string,\n): VertexRequestConfig {\n return requestConfig(modelId);\n}\n","import { getGoogleVertexRequestConfig } from '../google-vertex-model-catalog-config';\nimport { InvalidArgumentError } from '@ai-sdk/provider';\nimport {\n createOpenAICompatible,\n type OpenAICompatibleProvider,\n} from '@ai-sdk/openai-compatible';\nimport {\n isValidHostnamePart,\n loadOptionalSetting,\n loadSetting,\n withoutTrailingSlash,\n type FetchFunction,\n type Resolvable,\n} from '@ai-sdk/provider-utils';\nimport type { GoogleVertexMaasModelId } from './google-vertex-maas-options';\n\nfunction transformGoogleVertexMaasRequestBody(args: Record<string, any>) {\n const maxOutputTokens = getGoogleVertexRequestConfig(args.model).language\n ?.maxOutputTokens;\n\n return maxOutputTokens != null && args.max_tokens === undefined\n ? { ...args, max_tokens: maxOutputTokens }\n : args;\n}\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 createGoogleVertexMaas(\n options: GoogleVertexMaasProviderSettings = {},\n): GoogleVertexMaasProvider {\n // Lazy-load settings to support loading from environment variables at runtime\n const loadLocation = () => {\n const location =\n loadOptionalSetting({\n settingValue: options.location,\n environmentVariableName: 'GOOGLE_VERTEX_LOCATION',\n }) ?? 'global';\n if (!isValidHostnamePart(location)) {\n throw new InvalidArgumentError({\n argument: 'location',\n message:\n 'Invalid Google Vertex location. Expected a single DNS label (letters, digits, and hyphens). Use `baseURL` for custom endpoints.',\n });\n }\n return 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 getHost = (location: string) => {\n if (location === 'global') {\n return 'aiplatform.googleapis.com';\n } else if (location === 'eu' || location === 'us') {\n return `aiplatform.${location}.rep.googleapis.com`;\n } else {\n return `${location}-aiplatform.googleapis.com`;\n }\n };\n\n const constructBaseURL = () => {\n const projectId = loadProject();\n const location = loadLocation();\n\n return `https://${getHost(location)}/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 transformRequestBody: transformGoogleVertexMaasRequestBody,\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","import { resolve, type FetchFunction } from '@ai-sdk/provider-utils';\nimport {\n generateAuthToken,\n type GoogleCredentials,\n} from '../../edge/google-vertex-auth-edge';\nimport {\n createGoogleVertexMaas as createVertexMaasOriginal,\n type GoogleVertexMaasProvider,\n type GoogleVertexMaasProviderSettings as GoogleVertexMaasProviderSettingsOriginal,\n} from '../google-vertex-maas-provider';\nexport type { GoogleVertexMaasProvider };\n\nexport interface GoogleVertexMaasProviderSettings extends GoogleVertexMaasProviderSettingsOriginal {\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 MaaS (Model as a Service) provider instance for Edge runtimes.\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 createGoogleVertexMaas(\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.googleCredentials);\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 Edge runtimes.\n */\nexport const googleVertexMaas = createGoogleVertexMaas();\n"],"mappings":";;;;AAEA,MAAa,UAAA;;;AC0Bb,MAAM,kBAAkB,YAAwC;CAC9D,IAAI;EACF,OAAO;GACL,aAAa,YAAY;IACvB,cAAc,KAAA;IACd,aAAa;IACb,yBAAyB;IACzB,aAAa;GACf,CAAC;GACD,YAAY,YAAY;IACtB,cAAc,KAAA;IACd,aAAa;IACb,yBAAyB;IACzB,aAAa;GACf,CAAC;GACD,cAAc,oBAAoB;IAChC,cAAc,KAAA;IACd,yBAAyB;GAC3B,CAAC;EACH;CACF,SAAS,OAAY;EACnB,MAAM,IAAI,MAAM,sCAAsC,MAAM,SAAS;CACvE;AACF;AAGA,MAAM,aAAa,QAAgB;CACjC,OAAO,KAAK,GAAG,CAAC,CAAC,QAAQ,OAAO,GAAG,CAAC,CAAC,QAAQ,OAAO,GAAG,CAAC,CAAC,QAAQ,MAAM,EAAE;AAC3E;AACA,MAAM,mBAAmB,OAAO,WAAmB;CAKjD,MAAM,cAAc,OACjB,QAAQ,+BAAW,EAAE,CAAC,CACtB,QAAQ,6BAAW,EAAE,CAAC,CACtB,QAAQ,OAAO,EAAE;CAGpB,MAAM,eAAe,KAAK,WAAW;CAGrC,MAAM,aAAa,IAAI,WAAW,aAAa,MAAM;CACrD,KAAK,IAAI,IAAI,GAAG,IAAI,aAAa,QAAQ,KACvC,WAAW,KAAK,aAAa,WAAW,CAAC;CAG3C,OAAO,MAAM,OAAO,OAAO,UACzB,SACA,YACA;EAAE,MAAM;EAAqB,MAAM;CAAU,GAC7C,MACA,CAAC,MAAM,CACT;AACF;AAEA,MAAM,WAAW,OAAO,gBAAmC;CACzD,MAAM,MAAM,KAAK,MAAM,KAAK,IAAI,IAAI,GAAI;CAGxC,MAAM,SAAqD;EACzD,KAAK;EACL,KAAK;CACP;CAEA,IAAI,YAAY,cACd,OAAO,MAAM,Y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ACxB,CAAC;CAEH,MAAM,YAAY,YAAqC,YAAY,CAAC,CAAC,OAAO;CAE5E,SAAS,uBAAuB;CAChC,SAAS,iBAAiB,YACxB,YAAY,CAAC,CAAC,cAAc,OAAO;CACrC,SAAS,aAAa,YACpB,YAAY,CAAC,CAAC,UAAU,OAAO;CACjC,SAAS,mBAAmB,YAC1B,YAAY,CAAC,CAAC,gBAAgB,OAAO;CACvC,SAAS,kBAAkB,YACzB,YAAY,CAAC,CAAC,eAAe,OAAO;CACtC,SAAS,sBAAsB,YAC7B,YAAY,CAAC,CAAC,mBAAmB,OAAO;CAC1C,SAAS,cAAc,YAAoB,YAAY,CAAC,CAAC,WAAW,OAAO;CAE3E,OAAO;AACT;;;;;;;;;;ACpHA,SAAgB,uBACd,UAA4C,CAAC,GACnB;CAE1B,MAAM,cAA6B,OAAO,KAAK,SAAS;EACtD,MAAM,QAAQ,MAAM,kBAAkB,QAAQ,iBAAiB;EAE/D,MAAM,cAAc;GAClB,GAAG,MAFyB,QAAQ,QAAQ,OAAO;GAGnD,eAAe,UAAU;EAC3B;EAGA,MAAM,YAAY;GAChB,GAAG;GACH,SAAS;IACP,GAAG,MAAM;IACT,GAAG;GACL;EACF;EAGA,QAAQ,QAAQ,SAAS,MAAA,CAAO,KAAK,SAAS;CAChD;CAEA,OAAOC,yBAAyB;EAC9B,GAAG;EACH,OAAO;EACP,SAAS,KAAA;CACX,CAAC;AACH;;;;AAKA,MAAa,mBAAmB,uBAAuB"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":["GoogleVertexMaasProviderSettings","GoogleVertexMaasProviderSettingsOriginal"],"sources":["../../src/maas/google-vertex-maas-options.ts","../../src/maas/google-vertex-maas-provider.ts","../../src/maas/google-vertex-maas-provider-node.ts"],"mappings":";;;;KACY;;;UC2BK,iCAAiC,yBAChD;UAMeA;;;;EAIf;;;;;EAMA;;;;EAKA;;;;;;;;EASA,UAAU,WAAW;;;;;EAMrB,QAAQ;;;;UCvDO,yCAAyCC;;;;;;;EAOxD,oBAAoB;;;;;;;;;wBAUN,uBACd,UAAS,mCACR;;;;qBAmCU,kBAAgB"}
1
+ {"version":3,"file":"index.d.ts","names":["GoogleVertexMaasProviderSettings","GoogleVertexMaasProviderSettingsOriginal"],"sources":["../../src/maas/google-vertex-maas-options.ts","../../src/maas/google-vertex-maas-provider.ts","../../src/maas/google-vertex-maas-provider-node.ts"],"mappings":";;;;KACY;;;UCwBK,iCAAiC,yBAChD;UAMeA;;;;EAIf;;;;;EAMA;;;;EAKA;;;;;;;;EASA,UAAU,WAAW;;;;;EAMrB,QAAQ;;;;UCpDO,yCAAyCC;;;;;;;EAOxD,oBAAoB;;;;;;;;;wBAUN,uBACd,UAAS,mCACR;;;;qBAmCU,kBAAgB"}
@@ -13,13 +13,33 @@ function createAuthTokenGenerator(options) {
13
13
  };
14
14
  }
15
15
  //#endregion
16
+ //#region src/google-vertex-model-catalog-config.ts
17
+ function requestConfig(modelId) {
18
+ const embedContent = modelId === "gemini-embedding-2" || modelId === "gemini-embedding-2-preview";
19
+ return {
20
+ language: {
21
+ endpoint: modelId.startsWith("endpoints/"),
22
+ maxOutputTokens: modelId === "meta/llama-4-maverick-17b-128e-instruct-maas" || modelId === "meta/llama-4-scout-17b-16e-instruct-maas" ? 8192 : void 0
23
+ },
24
+ image: { gemini: modelId.startsWith("gemini-") },
25
+ embedding: {
26
+ endpoint: embedContent ? "embedContent" : "predict",
27
+ maxEmbeddingsPerCall: embedContent ? 1 : 250
28
+ },
29
+ speech: { api: modelId.startsWith("chirp") ? "cloud-tts" : "gemini" },
30
+ transcription: {
31
+ api: modelId.startsWith("gemini") ? "gemini" : "cloud-speech",
32
+ live: modelId.includes("-live")
33
+ }
34
+ };
35
+ }
36
+ function getGoogleVertexRequestConfig(modelId) {
37
+ return requestConfig(modelId);
38
+ }
39
+ //#endregion
16
40
  //#region src/maas/google-vertex-maas-provider.ts
17
- const maxOutputTokensByModel = {
18
- "meta/llama-4-maverick-17b-128e-instruct-maas": 8192,
19
- "meta/llama-4-scout-17b-16e-instruct-maas": 8192
20
- };
21
41
  function transformGoogleVertexMaasRequestBody(args) {
22
- const maxOutputTokens = maxOutputTokensByModel[args.model];
42
+ const maxOutputTokens = getGoogleVertexRequestConfig(args.model).language?.maxOutputTokens;
23
43
  return maxOutputTokens != null && args.max_tokens === void 0 ? {
24
44
  ...args,
25
45
  max_tokens: maxOutputTokens
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["createGoogleVertexMaas","createVertexMaasOriginal"],"sources":["../../src/google-vertex-auth-google-auth-library.ts","../../src/maas/google-vertex-maas-provider.ts","../../src/maas/google-vertex-maas-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 { InvalidArgumentError } from '@ai-sdk/provider';\nimport {\n createOpenAICompatible,\n type OpenAICompatibleProvider,\n} from '@ai-sdk/openai-compatible';\nimport {\n isValidHostnamePart,\n loadOptionalSetting,\n loadSetting,\n withoutTrailingSlash,\n type FetchFunction,\n type Resolvable,\n} from '@ai-sdk/provider-utils';\nimport type { GoogleVertexMaasModelId } from './google-vertex-maas-options';\n\nconst maxOutputTokensByModel: Record<string, number | undefined> = {\n 'meta/llama-4-maverick-17b-128e-instruct-maas': 8192,\n 'meta/llama-4-scout-17b-16e-instruct-maas': 8192,\n};\n\nfunction transformGoogleVertexMaasRequestBody(args: Record<string, any>) {\n const maxOutputTokens = maxOutputTokensByModel[args.model];\n\n return maxOutputTokens != null && args.max_tokens === undefined\n ? { ...args, max_tokens: maxOutputTokens }\n : args;\n}\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 createGoogleVertexMaas(\n options: GoogleVertexMaasProviderSettings = {},\n): GoogleVertexMaasProvider {\n // Lazy-load settings to support loading from environment variables at runtime\n const loadLocation = () => {\n const location =\n loadOptionalSetting({\n settingValue: options.location,\n environmentVariableName: 'GOOGLE_VERTEX_LOCATION',\n }) ?? 'global';\n if (!isValidHostnamePart(location)) {\n throw new InvalidArgumentError({\n argument: 'location',\n message:\n 'Invalid Google Vertex location. Expected a single DNS label (letters, digits, and hyphens). Use `baseURL` for custom endpoints.',\n });\n }\n return 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 getHost = (location: string) => {\n if (location === 'global') {\n return 'aiplatform.googleapis.com';\n } else if (location === 'eu' || location === 'us') {\n return `aiplatform.${location}.rep.googleapis.com`;\n } else {\n return `${location}-aiplatform.googleapis.com`;\n }\n };\n\n const constructBaseURL = () => {\n const projectId = loadProject();\n const location = loadLocation();\n\n return `https://${getHost(location)}/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 transformRequestBody: transformGoogleVertexMaasRequestBody,\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","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 createGoogleVertexMaas as createVertexMaasOriginal,\n type GoogleVertexMaasProvider,\n type GoogleVertexMaasProviderSettings as GoogleVertexMaasProviderSettingsOriginal,\n} from './google-vertex-maas-provider';\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 createGoogleVertexMaas(\n options: GoogleVertexMaasProviderSettings = {},\n): GoogleVertexMaasProvider {\n const generateAuthToken = createAuthTokenGenerator(options.googleAuthOptions);\n\n // Create a custom fetch wrapper that adds auth headers\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 // 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 googleVertexMaas = createGoogleVertexMaas();\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,EAAA,EAC5B,SAAS;CACzB;AACF;;;ACEA,MAAM,yBAA6D;CACjE,gDAAgD;CAChD,4CAA4C;AAC9C;AAEA,SAAS,qCAAqC,MAA2B;CACvE,MAAM,kBAAkB,uBAAuB,KAAK;CAEpD,OAAO,mBAAmB,QAAQ,KAAK,eAAe,KAAA,IAClD;EAAE,GAAG;EAAM,YAAY;CAAgB,IACvC;AACN;;;;;;;AAgDA,SAAgBA,yBACd,UAA4C,CAAC,GACnB;CAE1B,MAAM,qBAAqB;EACzB,MAAM,WACJ,oBAAoB;GAClB,cA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,iBAAiB;CAG5E,MAAM,cAA6B,OAAO,KAAK,SAAS;EACtD,MAAM,QAAQ,MAAM,kBAAkB;EAEtC,MAAM,cAAc;GAClB,GAAG,MAFyB,QAAQ,QAAQ,OAAO;GAGnD,eAAe,UAAU;EAC3B;EAGA,MAAM,YAAY;GAChB,GAAG;GACH,SAAS;IACP,GAAG,MAAM;IACT,GAAG;GACL;EACF;EAGA,QAAQ,QAAQ,SAAS,MAAA,CAAO,KAAK,SAAS;CAChD;CAEA,OAAOC,yBAAyB;EAC9B,GAAG;EACH,OAAO;EACP,SAAS,KAAA;CACX,CAAC;AACH;;;;AAKA,MAAa,mBAAmB,uBAAuB"}
1
+ {"version":3,"file":"index.js","names":["createGoogleVertexMaas","createVertexMaasOriginal"],"sources":["../../src/google-vertex-auth-google-auth-library.ts","../../src/google-vertex-model-catalog-config.ts","../../src/maas/google-vertex-maas-provider.ts","../../src/maas/google-vertex-maas-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","export type VertexRequestConfig = {\n language?: { endpoint: boolean; maxOutputTokens?: number };\n image?: { gemini: boolean };\n embedding?: {\n endpoint: 'embedContent' | 'predict';\n maxEmbeddingsPerCall: number;\n };\n speech?: { api: 'cloud-tts' | 'gemini' };\n transcription?: { api: 'gemini' | 'cloud-speech'; live: boolean };\n};\n\nfunction requestConfig(modelId: string): VertexRequestConfig {\n const embedContent =\n modelId === 'gemini-embedding-2' ||\n modelId === 'gemini-embedding-2-preview';\n return {\n language: {\n endpoint: modelId.startsWith('endpoints/'),\n maxOutputTokens:\n modelId === 'meta/llama-4-maverick-17b-128e-instruct-maas' ||\n modelId === 'meta/llama-4-scout-17b-16e-instruct-maas'\n ? 8192\n : undefined,\n },\n image: { gemini: modelId.startsWith('gemini-') },\n embedding: {\n endpoint: embedContent ? 'embedContent' : 'predict',\n maxEmbeddingsPerCall: embedContent ? 1 : 250,\n },\n speech: { api: modelId.startsWith('chirp') ? 'cloud-tts' : 'gemini' },\n transcription: {\n api: modelId.startsWith('gemini') ? 'gemini' : 'cloud-speech',\n live: modelId.includes('-live'),\n },\n };\n}\n\nexport function getGoogleVertexRequestConfig(\n modelId: string,\n): VertexRequestConfig {\n return requestConfig(modelId);\n}\n","import { getGoogleVertexRequestConfig } from '../google-vertex-model-catalog-config';\nimport { InvalidArgumentError } from '@ai-sdk/provider';\nimport {\n createOpenAICompatible,\n type OpenAICompatibleProvider,\n} from '@ai-sdk/openai-compatible';\nimport {\n isValidHostnamePart,\n loadOptionalSetting,\n loadSetting,\n withoutTrailingSlash,\n type FetchFunction,\n type Resolvable,\n} from '@ai-sdk/provider-utils';\nimport type { GoogleVertexMaasModelId } from './google-vertex-maas-options';\n\nfunction transformGoogleVertexMaasRequestBody(args: Record<string, any>) {\n const maxOutputTokens = getGoogleVertexRequestConfig(args.model).language\n ?.maxOutputTokens;\n\n return maxOutputTokens != null && args.max_tokens === undefined\n ? { ...args, max_tokens: maxOutputTokens }\n : args;\n}\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 createGoogleVertexMaas(\n options: GoogleVertexMaasProviderSettings = {},\n): GoogleVertexMaasProvider {\n // Lazy-load settings to support loading from environment variables at runtime\n const loadLocation = () => {\n const location =\n loadOptionalSetting({\n settingValue: options.location,\n environmentVariableName: 'GOOGLE_VERTEX_LOCATION',\n }) ?? 'global';\n if (!isValidHostnamePart(location)) {\n throw new InvalidArgumentError({\n argument: 'location',\n message:\n 'Invalid Google Vertex location. Expected a single DNS label (letters, digits, and hyphens). Use `baseURL` for custom endpoints.',\n });\n }\n return 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 getHost = (location: string) => {\n if (location === 'global') {\n return 'aiplatform.googleapis.com';\n } else if (location === 'eu' || location === 'us') {\n return `aiplatform.${location}.rep.googleapis.com`;\n } else {\n return `${location}-aiplatform.googleapis.com`;\n }\n };\n\n const constructBaseURL = () => {\n const projectId = loadProject();\n const location = loadLocation();\n\n return `https://${getHost(location)}/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 transformRequestBody: transformGoogleVertexMaasRequestBody,\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","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 createGoogleVertexMaas as createVertexMaasOriginal,\n type GoogleVertexMaasProvider,\n type GoogleVertexMaasProviderSettings as GoogleVertexMaasProviderSettingsOriginal,\n} from './google-vertex-maas-provider';\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 createGoogleVertexMaas(\n options: GoogleVertexMaasProviderSettings = {},\n): GoogleVertexMaasProvider {\n const generateAuthToken = createAuthTokenGenerator(options.googleAuthOptions);\n\n // Create a custom fetch wrapper that adds auth headers\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 // 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 googleVertexMaas = createGoogleVertexMaas();\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,EAAA,EAC5B,SAAS;CACzB;AACF;;;ACFA,SAAS,cAAc,SAAsC;CAC3D,MAAM,eACJ,YAAY,wBACZ,YAAY;CACd,OAAO;EACL,UAAU;GACR,UAAU,QAAQ,WAAW,YAAY;GACzC,iBACE,YAAY,kDACZ,YAAY,6CACR,OACA,KAAA;EACR;EACA,OAAO,EAAE,QAAQ,QAAQ,WAAW,SAAS,EAAE;EAC/C,WAAW;GACT,UAAU,eAAe,iBAAiB;GAC1C,sBAAsB,eAAe,IAAI;EAC3C;EACA,QAAQ,EAAE,KAAK,QAAQ,WAAW,OAAO,IAAI,cAAc,SAAS;EACpE,eAAe;GACb,KAAK,QAAQ,WAAW,QAAQ,IAAI,WAAW;GAC/C,MAAM,QAAQ,SAAS,OAAO;EAChC;CACF;AACF;AAEA,SAAgB,6BACd,SACqB;CACrB,OAAO,cAAc,OAAO;AAC9B;;;ACzBA,SAAS,qCAAqC,MAA2B;CACvE,MAAM,kBAAkB,6BAA6B,KAAK,KAAK,CAAC,CAAC,UAC7D;CAEJ,OAAO,mBAAmB,QAAQ,KAAK,eAAe,KAAA,IAClD;EAAE,GAAG;EAAM,YA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AC,CAAC,WAAW,OAAO;CAE3E,OAAO;AACT;;;;;;;;;;ACrHA,SAAgB,uBACd,UAA4C,CAAC,GACnB;CAC1B,MAAM,oBAAoB,yBAAyB,QAAQ,iBAAiB;CAG5E,MAAM,cAA6B,OAAO,KAAK,SAAS;EACtD,MAAM,QAAQ,MAAM,kBAAkB;EAEtC,MAAM,cAAc;GAClB,GAAG,MAFyB,QAAQ,QAAQ,OAAO;GAGnD,eAAe,UAAU;EAC3B;EAGA,MAAM,YAAY;GAChB,GAAG;GACH,SAAS;IACP,GAAG,MAAM;IACT,GAAG;GACL;EACF;EAGA,QAAQ,QAAQ,SAAS,MAAA,CAAO,KAAK,SAAS;CAChD;CAEA,OAAOC,yBAAyB;EAC9B,GAAG;EACH,OAAO;EACP,SAAS,KAAA;CACX,CAAC;AACH;;;;AAKA,MAAa,mBAAmB,uBAAuB"}
@@ -2,7 +2,7 @@ import { getRuntimeEnvironmentUserAgent, loadOptionalSetting, loadSetting, resol
2
2
  import { NoSuchModelError } from "@ai-sdk/provider";
3
3
  import { createOpenAICompatible } from "@ai-sdk/openai-compatible";
4
4
  //#region src/version.ts
5
- const VERSION = "5.0.132";
5
+ const VERSION = "5.0.133";
6
6
  //#endregion
7
7
  //#region src/edge/google-vertex-auth-edge.ts
8
8
  const loadCredentials = async () => {
@@ -1045,19 +1045,29 @@ The following Zod features are known to not work with Google Vertex:
1045
1045
 
1046
1046
  ### Model Capabilities
1047
1047
 
1048
- | Model | Image Input | Object Generation | Tool Usage | Tool Streaming |
1049
- | ------------------------ | ----------- | ----------------- | ---------- | -------------- |
1050
- | `gemini-nano-banana-2.1` | <Check /> | <Cross /> | <Cross /> | <Cross /> |
1051
- | `gemini-4-argon` | <Check /> | <Check /> | <Check /> | <Check /> |
1052
- | `gemini-3.8-flash` | <Check /> | <Check /> | <Check /> | <Check /> |
1053
- | `gemini-3.7-flash` | <Check /> | <Check /> | <Check /> | <Check /> |
1054
- | `gemini-3.6-flash` | <Check /> | <Check /> | <Check /> | <Check /> |
1055
- | `gemini-3.5-flash` | <Check /> | <Check /> | <Check /> | <Check /> |
1056
- | `gemini-3.5-flash-lite` | <Check /> | <Check /> | <Check /> | <Check /> |
1057
- | `gemini-3-pro-preview` | <Check /> | <Check /> | <Check /> | <Check /> |
1058
- | `gemini-2.5-pro` | <Check /> | <Check /> | <Check /> | <Check /> |
1059
- | `gemini-2.5-flash` | <Check /> | <Check /> | <Check /> | <Check /> |
1060
- | `gemini-2.0-flash-001` | <Check /> | <Check /> | <Check /> | <Check /> |
1048
+ {/* model-capabilities:google-vertex-language:start */}
1049
+
1050
+ | Model | Image Input | Object Generation | Tool Usage | Tool Streaming |
1051
+ | -------------------------------- | ----------- | ----------------- | ---------- | -------------- |
1052
+ | `gemini-nano-banana-2.1` | <Check /> | <Cross /> | <Cross /> | <Cross /> |
1053
+ | `gemini-4-argon` | <Check /> | <Check /> | <Check /> | <Check /> |
1054
+ | `gemini-3.8-flash` | <Check /> | <Check /> | <Check /> | <Check /> |
1055
+ | `gemini-3.7-flash` | <Check /> | <Check /> | <Check /> | <Check /> |
1056
+ | `gemini-3.6-flash` | <Check /> | <Check /> | <Check /> | <Check /> |
1057
+ | `gemini-3.5-flash` | <Check /> | <Check /> | <Check /> | <Check /> |
1058
+ | `gemini-3.5-flash-lite` | <Check /> | <Check /> | <Check /> | <Check /> |
1059
+ | `gemini-2.5-pro` | <Check /> | <Check /> | <Check /> | <Check /> |
1060
+ | `gemini-2.5-flash` | <Check /> | <Check /> | <Check /> | <Check /> |
1061
+ | `gemini-2.5-flash-lite` | <Check /> | <Check /> | <Check /> | <Check /> |
1062
+ | `gemini-2.0-flash` | <Check /> | <Check /> | <Check /> | <Check /> |
1063
+ | `gemini-3-pro-preview` | <Check /> | <Check /> | <Check /> | <Check /> |
1064
+ | `gemini-3-pro-image-preview` | <Check /> | <Check /> | <Check /> | <Check /> |
1065
+ | `gemini-3-flash-preview` | <Check /> | <Check /> | <Check /> | <Check /> |
1066
+ | `gemini-3.1-pro-preview` | <Check /> | <Check /> | <Check /> | <Check /> |
1067
+ | `gemini-3.1-flash-image-preview` | <Check /> | <Check /> | <Check /> | <Check /> |
1068
+ | `gemini-3.1-flash-lite-preview` | <Check /> | <Check /> | <Check /> | <Check /> |
1069
+
1070
+ {/* model-capabilities:google-vertex-language:end */}
1061
1071
 
1062
1072
  <Note>
1063
1073
  The table above lists popular models. Please see the [Google Vertex AI
@@ -1126,11 +1136,23 @@ The following optional provider options are available for Google Vertex AI embed
1126
1136
 
1127
1137
  #### Model Capabilities
1128
1138
 
1129
- | Model | Max Values Per Call | Parallel Calls | Multimodal |
1130
- | ---------------------------- | ------------------- | -------------- | ---------- |
1131
- | `text-embedding-005` | 2048 | <Check /> | <Cross /> |
1132
- | `gemini-embedding-2` | 2048 | <Check /> | <Check /> |
1133
- | `gemini-embedding-2-preview` | 2048 | <Check /> | <Check /> |
1139
+ {/* model-capabilities:google-vertex-embedding:start */}
1140
+
1141
+ | Model | Max Values Per Call | Parallel Calls | Multimodal |
1142
+ | -------------------------------------- | ------------------- | -------------- | ---------- |
1143
+ | `textembedding-gecko` | 250 | <Check /> | <Cross /> |
1144
+ | `textembedding-gecko@001` | 250 | <Check /> | <Cross /> |
1145
+ | `textembedding-gecko@003` | 250 | <Check /> | <Cross /> |
1146
+ | `textembedding-gecko-multilingual` | 250 | <Check /> | <Cross /> |
1147
+ | `textembedding-gecko-multilingual@001` | 250 | <Check /> | <Cross /> |
1148
+ | `text-multilingual-embedding-002` | 250 | <Check /> | <Cross /> |
1149
+ | `text-embedding-004` | 250 | <Check /> | <Cross /> |
1150
+ | `text-embedding-005` | 250 | <Check /> | <Cross /> |
1151
+ | `gemini-embedding-001` | 250 | <Check /> | <Cross /> |
1152
+ | `gemini-embedding-2` | 1 | <Check /> | <Check /> |
1153
+ | `gemini-embedding-2-preview` | 1 | <Check /> | <Check /> |
1154
+
1155
+ {/* model-capabilities:google-vertex-embedding:end */}
1134
1156
 
1135
1157
  <Note>
1136
1158
  The table above lists popular models. You can also pass any available provider
@@ -1197,13 +1219,17 @@ const { image } = await generateImage({
1197
1219
 
1198
1220
  ##### Gemini Image Model Capabilities
1199
1221
 
1222
+ {/* model-capabilities:google-vertex-image:start */}
1223
+
1200
1224
  | Model | Image Generation | Image Editing | Aspect Ratios |
1201
1225
  | -------------------------------- | ---------------- | ------------- | ----------------------------------------------------------------------- |
1202
1226
  | `gemini-nano-banana-2.1` | <Check /> | <Check /> | 1:1, 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, 21:9, 1:8, 8:1, 1:4, 4:1 |
1203
- | `gemini-3.1-flash-image-preview` | <Check /> | <Check /> | 1:1, 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, 21:9 |
1204
1227
  | `gemini-3-pro-image-preview` | <Check /> | <Check /> | 1:1, 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, 21:9 |
1228
+ | `gemini-3.1-flash-image-preview` | <Check /> | <Check /> | 1:1, 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, 21:9 |
1205
1229
  | `gemini-2.5-flash-image` | <Check /> | <Check /> | 1:1, 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, 21:9 |
1206
1230
 
1231
+ {/* model-capabilities:google-vertex-image:end */}
1232
+
1207
1233
  <Note>
1208
1234
  `gemini-3-pro-image-preview` supports additional features including up to 14
1209
1235
  reference images for editing (6 objects, 5 humans), resolution options (1K,
@@ -1350,13 +1376,23 @@ The following provider options are available:
1350
1376
 
1351
1377
  #### Model Capabilities
1352
1378
 
1353
- | Model | Audio Support |
1354
- | --------------------------- | ------------- |
1355
- | `veo-3.1-generate-001` | Yes |
1356
- | `veo-3.1-fast-generate-001` | Yes |
1357
- | `veo-3.0-generate-001` | Yes |
1358
- | `veo-3.0-fast-generate-001` | Yes |
1359
- | `veo-2.0-generate-001` | No |
1379
+ {/* model-capabilities:google-vertex-video:start */}
1380
+
1381
+ | Model | Audio Support |
1382
+ | ------------------------------- | ------------- |
1383
+ | `veo-2.0-generate-preview` | <Cross /> |
1384
+ | `veo-2.0-generate-exp` | <Cross /> |
1385
+ | `veo-2.0-generate-001` | <Cross /> |
1386
+ | `veo-3.0-generate-001` | <Check /> |
1387
+ | `veo-3.0-fast-generate-001` | <Check /> |
1388
+ | `veo-3.0-generate-preview` | <Check /> |
1389
+ | `veo-3.0-fast-generate-preview` | <Check /> |
1390
+ | `veo-3.1-generate-001` | <Check /> |
1391
+ | `veo-3.1-fast-generate-001` | <Check /> |
1392
+ | `veo-3.1-generate-preview` | <Check /> |
1393
+ | `veo-3.1-fast-generate-preview` | <Check /> |
1394
+
1395
+ {/* model-capabilities:google-vertex-video:end */}
1360
1396
 
1361
1397
  <Note>
1362
1398
  The table above lists popular models. You can also pass any available provider
@@ -1394,12 +1430,17 @@ rate is reported in `result.providerMetadata.google.sampleRate`.
1394
1430
 
1395
1431
  #### Speech Model Capabilities
1396
1432
 
1433
+ {/* model-capabilities:google-vertex-speech:start */}
1434
+
1397
1435
  | Model | Multi-speaker | Style via instructions |
1398
1436
  | ----------------------------------- | ------------- | ---------------------- |
1399
1437
  | `gemini-2.5-flash-tts` | <Check /> | <Check /> |
1400
1438
  | `gemini-2.5-pro-tts` | <Check /> | <Check /> |
1401
1439
  | `gemini-2.5-flash-lite-preview-tts` | <Check /> | <Check /> |
1402
1440
  | `gemini-3.1-flash-tts-preview` | <Check /> | <Check /> |
1441
+ | `chirp-3-hd` | <Cross /> | <Cross /> |
1442
+
1443
+ {/* model-capabilities:google-vertex-speech:end */}
1403
1444
 
1404
1445
  ### Transcription Models
1405
1446
 
@@ -1490,12 +1531,16 @@ The following provider options are available:
1490
1531
 
1491
1532
  #### Transcription Model Capabilities
1492
1533
 
1534
+ {/* model-capabilities:google-vertex-transcription:start */}
1535
+
1493
1536
  | Model | Word timestamps | Language detection |
1494
1537
  | ----------- | --------------------------------------------------------- | ------------------------------------------------------------------------------ |
1495
1538
  | `chirp_2` | Available with a potential quality and speed tradeoff | Auto detection with `['auto']` |
1496
1539
  | `chirp_3` | Available with a potential transcription quality tradeoff | Auto detection with `['auto']` |
1497
1540
  | `telephony` | Available | Explicit supported language codes, with alternative language detection support |
1498
1541
 
1542
+ {/* model-capabilities:google-vertex-transcription:end */}
1543
+
1499
1544
  ## Google Vertex Anthropic Provider Usage
1500
1545
 
1501
1546
  The Google Vertex Anthropic provider for the [AI SDK](/docs) offers support for Anthropic's Claude models through the Google Vertex AI APIs. This section provides details on how to set up and use the Google Vertex Anthropic provider.
@@ -2083,6 +2128,8 @@ These tools can be used in conjunction with supported Claude models to enable mo
2083
2128
  The latest Anthropic model list on Vertex AI is available [here](https://cloud.google.com/vertex-ai/generative-ai/docs/partner-models/use-claude#model-list).
2084
2129
  See also [Anthropic Model Comparison](https://docs.anthropic.com/en/docs/about-claude/models#model-comparison).
2085
2130
 
2131
+ {/* model-capabilities:google-vertex-anthropic:start */}
2132
+
2086
2133
  | Model | Image Input | Object Generation | Tool Usage | Tool Streaming | Computer Use |
2087
2134
  | ------------------------------- | ----------- | ----------------- | ---------- | -------------- | ------------ |
2088
2135
  | `claude-fable-5-1` | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> |
@@ -2094,6 +2141,8 @@ See also [Anthropic Model Comparison](https://docs.anthropic.com/en/docs/about-c
2094
2141
  | `claude-3-haiku@20240307` | <Check /> | <Check /> | <Check /> | <Check /> | <Cross /> |
2095
2142
  | `claude-3-opus@20240229` | <Check /> | <Check /> | <Check /> | <Check /> | <Cross /> |
2096
2143
 
2144
+ {/* model-capabilities:google-vertex-anthropic:end */}
2145
+
2097
2146
  <Note>
2098
2147
  The table above lists popular models. You can also pass any available provider
2099
2148
  model ID as a string if needed.
@@ -2266,12 +2315,16 @@ const result = await generateText({
2266
2315
 
2267
2316
  The following models are available through the Google Vertex xAI provider. You can also pass any valid model ID as a string.
2268
2317
 
2269
- | Model ID | Reasoning |
2318
+ {/* model-capabilities:google-vertex-xai:start */}
2319
+
2320
+ | Model | Reasoning |
2270
2321
  | --------------------------------- | --------- |
2271
- | `xai/grok-4.20-reasoning` | Yes |
2272
- | `xai/grok-4.20-non-reasoning` | No |
2273
- | `xai/grok-4.1-fast-reasoning` | Yes |
2274
- | `xai/grok-4.1-fast-non-reasoning` | No |
2322
+ | `xai/grok-4.20-reasoning` | <Check /> |
2323
+ | `xai/grok-4.20-non-reasoning` | <Cross /> |
2324
+ | `xai/grok-4.1-fast-reasoning` | <Check /> |
2325
+ | `xai/grok-4.1-fast-non-reasoning` | <Cross /> |
2326
+
2327
+ {/* model-capabilities:google-vertex-xai:end */}
2275
2328
 
2276
2329
  <Note>
2277
2330
  Grok reasoning models on Vertex report reasoning token counts in usage
@@ -2401,7 +2454,9 @@ for await (const textPart of result.textStream) {
2401
2454
 
2402
2455
  The following models are available through the MaaS provider. You can also pass any valid model ID as a string.
2403
2456
 
2404
- | Model ID | Provider |
2457
+ {/* model-capabilities:google-vertex-maas:start */}
2458
+
2459
+ | Model | Provider |
2405
2460
  | ---------------------------------------------- | -------- |
2406
2461
  | `deepseek-ai/deepseek-r1-0528-maas` | DeepSeek |
2407
2462
  | `deepseek-ai/deepseek-v3.1-maas` | DeepSeek |
@@ -2416,6 +2471,8 @@ The following models are available through the MaaS provider. You can also pass
2416
2471
  | `qwen/qwen3-next-80b-a3b-thinking-maas` | Qwen |
2417
2472
  | `moonshotai/kimi-k2-thinking-maas` | Moonshot |
2418
2473
 
2474
+ {/* model-capabilities:google-vertex-maas:end */}
2475
+
2419
2476
  <Note>
2420
2477
  Llama 4 MaaS models default to their 8,192-token output limit when
2421
2478
  `maxOutputTokens` is not specified. An explicit `maxOutputTokens` value takes
@@ -2428,3 +2485,81 @@ The following models are available through the MaaS provider. You can also pass
2428
2485
  Garden](https://console.cloud.google.com/vertex-ai/model-garden) for the
2429
2486
  latest available models.
2430
2487
  </Note>
2488
+
2489
+ ### Transcription Capability Reference
2490
+
2491
+ {/* model-capabilities:google-vertex-transcription-all:start */}
2492
+
2493
+ | Model | Transcription | Streaming | Duration | Segments | Language |
2494
+ | ---------------------------- | ------------- | --------- | --------- | -------------------------------------- | --------- |
2495
+ | `chirp_2` | <Check /> | <Cross /> | <Check /> | Conditional: Requires word timestamps. | <Check /> |
2496
+ | `chirp_3` | <Check /> | <Cross /> | <Check /> | Conditional: Requires word timestamps. | <Check /> |
2497
+ | `telephony` | <Check /> | <Cross /> | <Check /> | Conditional: Requires word timestamps. | <Check /> |
2498
+ | `gemini-3.5-transcribe` | <Check /> | <Cross /> | <Cross /> | Conditional: Requires word timestamps. | <Check /> |
2499
+ | `gemini-3.5-transcribe-live` | <Cross /> | <Check /> | <Cross /> | <Cross /> | <Check /> |
2500
+
2501
+ {/* model-capabilities:google-vertex-transcription-all:end */}
2502
+
2503
+ ## Provider Option Reference
2504
+
2505
+ The following option definitions are generated from the provider catalog.
2506
+
2507
+ {/* model-capabilities:google-vertex-provider-options:start */}
2508
+
2509
+ | Operation | Option | Description |
2510
+ | ------------- | ----------------------------- | ----------------------------------------------------- |
2511
+ | language | `responseModalities` | Response modalities to generate. |
2512
+ | language | `thinkingConfig` | Thinking budget, level, and thought output. |
2513
+ | language | `cachedContent` | Cached content to use as request context. |
2514
+ | language | `structuredOutputs` | Whether to send the JSON response schema. |
2515
+ | language | `safetySettings` | Safety settings for the request. |
2516
+ | language | `threshold` | Default threshold for configurable safety categories. |
2517
+ | language | `audioTimestamp` | Enable timestamp understanding for audio. |
2518
+ | language | `labels` | Billing labels. Vertex AI only. |
2519
+ | language | `mediaResolution` | Resolution used to process media inputs. |
2520
+ | language | `imageConfig` | Image generation configuration. |
2521
+ | language | `retrievalConfig` | Retrieval configuration for tools. |
2522
+ | language | `streamFunctionCallArguments` | Stream function arguments. Vertex AI only. |
2523
+ | language | `serviceTier` | Service tier. Gemini API only. |
2524
+ | language | `continuationToken` | Resume a response using its continuation token. |
2525
+ | language | `sharedRequestType` | Shared PayGo tier. Vertex AI only. |
2526
+ | language | `requestType` | Request routing type. Vertex AI only. |
2527
+ | image | `thinkingConfig` | Thinking budget, level, and thought output. |
2528
+ | image | `cachedContent` | Cached content to use as request context. |
2529
+ | image | `structuredOutputs` | Whether to send the JSON response schema. |
2530
+ | image | `safetySettings` | Safety settings for the request. |
2531
+ | image | `threshold` | Default threshold for configurable safety categories. |
2532
+ | image | `audioTimestamp` | Enable timestamp understanding for audio. |
2533
+ | image | `labels` | Billing labels. Vertex AI only. |
2534
+ | image | `mediaResolution` | Resolution used to process media inputs. |
2535
+ | image | `imageConfig` | Image generation configuration. |
2536
+ | image | `retrievalConfig` | Retrieval configuration for tools. |
2537
+ | image | `streamFunctionCallArguments` | Stream function arguments. Vertex AI only. |
2538
+ | image | `serviceTier` | Service tier. Gemini API only. |
2539
+ | image | `continuationToken` | Resume a response using its continuation token. |
2540
+ | image | `sharedRequestType` | Shared PayGo tier. Vertex AI only. |
2541
+ | image | `requestType` | Request routing type. Vertex AI only. |
2542
+ | embedding | `outputDimensionality` | Reduced output dimensions. |
2543
+ | embedding | `taskType` | Task for which embeddings are optimized. |
2544
+ | embedding | `title` | Document title; requires RETRIEVAL_DOCUMENT. |
2545
+ | embedding | `autoTruncate` | Truncate inputs exceeding the model context. |
2546
+ | speech | `speechMetadata` | Directions for Gemini 3.8 speech. |
2547
+ | speech | `turns` | Structured transcript for Gemini 3.8 speech. |
2548
+ | speech | `multiSpeakerVoiceConfig` | Voice configuration for dialogue speakers. |
2549
+ | transcription | `languageCodes` | Language hints or automatic language detection. |
2550
+ | transcription | `enableAutomaticPunctuation` | Include punctuation in Cloud Speech transcripts. |
2551
+ | transcription | `enableWordTimeOffsets` | Include Cloud Speech word timestamps. |
2552
+ | transcription | `region` | Cloud Speech region. |
2553
+ | transcription | `customVocabulary` | Vocabulary hints for Gemini transcription. |
2554
+ | transcription | `wordTimestamp` | Include Gemini word timestamps. |
2555
+ | transcription | `diarization` | Enable Gemini speaker diarization. |
2556
+ | transcription | `mode` | Verbatim or smart Gemini transcription formatting. |
2557
+ | video | `pollIntervalMs` | Polling interval. |
2558
+ | video | `pollTimeoutMs` | Polling timeout. |
2559
+ | video | `personGeneration` | Policy for generating people. |
2560
+ | video | `negativePrompt` | Content to avoid. |
2561
+ | video | `generateAudio` | Generate synchronized audio. |
2562
+ | video | `gcsOutputDirectory` | Cloud Storage output directory. |
2563
+ | video | `referenceImages` | Reference images for video generation. |
2564
+
2565
+ {/* model-capabilities:google-vertex-provider-options:end */}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-sdk/google-vertex",
3
- "version": "5.0.132",
3
+ "version": "5.0.133",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "sideEffects": false,
@@ -71,9 +71,9 @@
71
71
  }
72
72
  },
73
73
  "dependencies": {
74
- "@ai-sdk/anthropic": "4.0.97",
75
- "@ai-sdk/google": "4.0.112",
76
- "@ai-sdk/openai-compatible": "3.0.85",
74
+ "@ai-sdk/anthropic": "4.0.98",
75
+ "@ai-sdk/google": "4.0.113",
76
+ "@ai-sdk/openai-compatible": "3.0.86",
77
77
  "@ai-sdk/provider": "4.0.36",
78
78
  "@ai-sdk/provider-utils": "5.0.75",
79
79
  "google-auth-library": "^11.3.1"
@@ -1,3 +1,4 @@
1
+ import { getGoogleVertexRequestConfig } from '../google-vertex-model-catalog-config';
1
2
  import {
2
3
  InvalidArgumentError,
3
4
  type Experimental_TranscriptionModelV4StreamOptions as TranscriptionModelV4StreamOptions,
@@ -47,7 +48,7 @@ const defaultFinishGraceMs = 3000;
47
48
 
48
49
  /** Live transcription is only supported by `*-live` model variants. */
49
50
  function isLiveTranscriptionModelId(modelId: string): boolean {
50
- return modelId.includes('-live');
51
+ return getGoogleVertexRequestConfig(modelId).transcription?.live === true;
51
52
  }
52
53
 
53
54
  /** Regional Vertex hostname (mirrors the provider's base-URL host rules). */
@@ -1,3 +1,4 @@
1
+ import { getGoogleVertexRequestConfig } from './google-vertex-model-catalog-config';
1
2
  import {
2
3
  TooManyEmbeddingValuesForCallError,
3
4
  type EmbeddingModelV4,
@@ -226,6 +227,6 @@ const googleVertexEmbedContentResponseSchema = lazySchema(() =>
226
227
 
227
228
  function usesEmbedContentEndpoint(modelId: GoogleVertexEmbeddingModelId) {
228
229
  return (
229
- modelId === 'gemini-embedding-2' || modelId === 'gemini-embedding-2-preview'
230
+ getGoogleVertexRequestConfig(modelId).embedding?.endpoint === 'embedContent'
230
231
  );
231
232
  }