@ai-sdk/google-vertex 5.0.110 → 5.0.112

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,26 @@
1
1
  # @ai-sdk/google-vertex
2
2
 
3
+ ## 5.0.112
4
+
5
+ ### Patch Changes
6
+
7
+ - 40d0aec: feat(vertex-anthropic): forward 'providerOptions.vertex.labels' as a header
8
+ - Updated dependencies [2e89fa4]
9
+ - Updated dependencies [40d0aec]
10
+ - Updated dependencies [40a4ce1]
11
+ - @ai-sdk/provider-utils@5.0.60
12
+ - @ai-sdk/anthropic@4.0.80
13
+ - @ai-sdk/google@4.0.96
14
+ - @ai-sdk/openai-compatible@3.0.69
15
+
16
+ ## 5.0.111
17
+
18
+ ### Patch Changes
19
+
20
+ - bdbeba3: feat(google): add `gemini-4-argon` model id and long decode support for `generateContent`: requests that reach the per-request cap (`CONTINUATION`) are continued automatically with usage summed across requests and the first request's prompt token count exposed as `providerMetadata.google.initialPromptTokenCount`, and the `continuationToken` provider option / provider metadata resume responses that used up their `maxOutputTokens` budget. `generateText` with the Interactions API now polls `background: true` model calls until they finish.
21
+ - Updated dependencies [bdbeba3]
22
+ - @ai-sdk/google@4.0.95
23
+
3
24
  ## 5.0.110
4
25
 
5
26
  ### Patch Changes
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":["GoogleVertexAnthropicProviderSettings","GoogleVertexAnthropicProviderSettingsOriginal"],"sources":["../../../src/edge/google-vertex-auth-edge.ts","../../../src/anthropic/google-vertex-anthropic-options.ts","../../../src/anthropic/google-vertex-anthropic-provider.ts","../../../src/anthropic/edge/google-vertex-anthropic-provider-edge.ts"],"mappings":";;;;UAQiB;;;;;EAKf;;;;;EAMA;;;;;EAMA;;;;KCxBU;;;KCkBP,6BAA6B,YACzB;;;;;cAiBI,4BAA4B;UAkFxB,sCAAsC;;;;GAIpD,SAAS,+BAA+B;;;;EAKzC,cAAc,SAAS,+BAA+B;;;;;;;;;EAUtD,cAAc;;;;EAKd,mBAAmB;;UAGJA;;;;EAIf;;;;EAKA;;;;;EAMA;;;;EAKA,UAAU,WAAW;;;;;EAMrB,QAAQ;;;;UChKO,8CAA8CC;;;;;;EAM7D,oBAAoB;;;;;EAKpB,0BAA0B;;wBAGZ,4BACd,UAAS,wCACR;;;;qBAgBU,uBAAqB"}
1
+ {"version":3,"file":"index.d.ts","names":["GoogleVertexAnthropicProviderSettings","GoogleVertexAnthropicProviderSettingsOriginal"],"sources":["../../../src/edge/google-vertex-auth-edge.ts","../../../src/anthropic/google-vertex-anthropic-options.ts","../../../src/anthropic/google-vertex-anthropic-provider.ts","../../../src/anthropic/edge/google-vertex-anthropic-provider-edge.ts"],"mappings":";;;;UAQiB;;;;;EAKf;;;;;EAMA;;;;;EAMA;;;;KCbU;;;KCYP,6BAA6B,YACzB;;;;;cAiBI,4BAA4B;UAkFxB,sCAAsC;;;;GAIpD,SAAS,+BAA+B;;;;EAKzC,cAAc,SAAS,+BAA+B;;;;;;;;;EAUtD,cAAc;;;;EAKd,mBAAmB;;UAGJA;;;;EAIf;;;;EAKA;;;;;EAMA;;;;EAKA,UAAU,WAAW;;;;;EAMrB,QAAQ;;;;UCrKO,8CAA8CC;;;;;;EAM7D,oBAAoB;;;;;EAKpB,0BAA0B;;wBAGZ,4BACd,UAAS,wCACR;;;;qBAgBU,uBAAqB"}
@@ -1,8 +1,9 @@
1
- import { getRuntimeEnvironmentUserAgent, isValidHostnamePart, loadOptionalSetting, loadSetting, resolve, withUserAgentSuffix, withoutTrailingSlash } from "@ai-sdk/provider-utils";
1
+ import { convertUint8ArrayToBase64, getRuntimeEnvironmentUserAgent, isValidHostnamePart, lazySchema, loadOptionalSetting, loadSetting, parseProviderOptions, resolve, withUserAgentSuffix, withoutTrailingSlash, zodSchema } from "@ai-sdk/provider-utils";
2
2
  import { InvalidArgumentError, NoSuchModelError } from "@ai-sdk/provider";
3
3
  import { AnthropicLanguageModel, anthropicTools } from "@ai-sdk/anthropic/internal";
4
+ import { z } from "zod/v4";
4
5
  //#region src/version.ts
5
- const VERSION = "5.0.110";
6
+ const VERSION = "5.0.112";
6
7
  //#endregion
7
8
  //#region src/edge/google-vertex-auth-edge.ts
8
9
  const loadCredentials = async () => {
@@ -82,6 +83,9 @@ async function generateAuthToken(credentials) {
82
83
  return (await response.json()).access_token;
83
84
  }
84
85
  //#endregion
86
+ //#region src/anthropic/google-vertex-anthropic-options.ts
87
+ const googleVertexAnthropicProviderOptions = lazySchema(() => zodSchema(z.object({ labels: z.record(z.string(), z.string()).optional() })));
88
+ //#endregion
85
89
  //#region src/anthropic/google-vertex-anthropic-provider.ts
86
90
  /**
87
91
  * Tools supported by Google Vertex Anthropic.
@@ -199,6 +203,18 @@ function createGoogleVertexAnthropic$1(options = {}) {
199
203
  anthropic_version: "vertex-2023-10-16"
200
204
  };
201
205
  },
206
+ transformRequestHeaders: async (headers, providerOptions) => {
207
+ const vertexOptions = await parseProviderOptions({
208
+ provider: "vertex",
209
+ providerOptions,
210
+ schema: googleVertexAnthropicProviderOptions
211
+ });
212
+ if (vertexOptions?.labels == null || Object.keys(headers).some((name) => name.toLowerCase() === "x-vertex-ai-labels" && headers[name] != null)) return headers;
213
+ return {
214
+ ...headers,
215
+ "x-vertex-ai-labels": convertUint8ArrayToBase64(new TextEncoder().encode(JSON.stringify(vertexOptions.labels)))
216
+ };
217
+ },
202
218
  supportedUrls: () => ({}),
203
219
  supportsNativeStructuredOutput: false,
204
220
  supportsStrictTools: false
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["createGoogleVertexAnthropic","generateAuthToken","defaultGenerateAuthToken","createVertexAnthropicOriginal"],"sources":["../../../src/version.ts","../../../src/edge/google-vertex-auth-edge.ts","../../../src/anthropic/google-vertex-anthropic-provider.ts","../../../src/anthropic/edge/google-vertex-anthropic-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 {\n InvalidArgumentError,\n NoSuchModelError,\n type LanguageModelV4,\n type ProviderV4,\n} from '@ai-sdk/provider';\nimport {\n isValidHostnamePart,\n loadOptionalSetting,\n withoutTrailingSlash,\n type FetchFunction,\n type Resolvable,\n} from '@ai-sdk/provider-utils';\nimport {\n anthropicTools,\n AnthropicLanguageModel,\n} from '@ai-sdk/anthropic/internal';\nimport type { GoogleVertexAnthropicModelId } from './google-vertex-anthropic-options';\n\ntype GoogleVertexAnthropicTools = Pick<\n typeof anthropicTools,\n | 'bash_20241022'\n | 'bash_20250124'\n | 'textEditor_20241022'\n | 'textEditor_20250124'\n | 'textEditor_20250429'\n | 'textEditor_20250728'\n | 'computer_20241022'\n | 'webSearch_20250305'\n | 'toolSearchRegex_20251119'\n | 'toolSearchBm25_20251119'\n>;\n\n/**\n * Tools supported by Google Vertex Anthropic.\n * This is a subset of the full Anthropic tools - only these are recognized by the Vertex API.\n */\nexport const googleVertexAnthropicTools: GoogleVertexAnthropicTools = {\n /**\n * The bash tool enables Claude to execute shell commands in a persistent bash session,\n * allowing system operations, script execution, and command-line automation.\n *\n * Image results are supported.\n */\n bash_20241022: anthropicTools.bash_20241022,\n\n /**\n * The bash tool enables Claude to execute shell commands in a persistent bash session,\n * allowing system operations, script execution, and command-line automation.\n *\n * Image results are supported.\n */\n bash_20250124: anthropicTools.bash_20250124,\n\n /**\n * Claude can use an Anthropic-defined text editor tool to view and modify text files,\n * helping you debug, fix, and improve your code or other text documents.\n *\n * Supported models: Claude Sonnet 3.5\n */\n textEditor_20241022: anthropicTools.textEditor_20241022,\n\n /**\n * Claude can use an Anthropic-defined text editor tool to view and modify text files,\n * helping you debug, fix, and improve your code or other text documents.\n *\n * Supported models: Claude Sonnet 3.7\n */\n textEditor_20250124: anthropicTools.textEditor_20250124,\n\n /**\n * Claude can use an Anthropic-defined text editor tool to view and modify text files.\n * Note: This version does not support the \"undo_edit\" command.\n * @deprecated Use textEditor_20250728 instead\n */\n textEditor_20250429: anthropicTools.textEditor_20250429,\n\n /**\n * Claude can use an Anthropic-defined text editor tool to view and modify text files.\n * Note: This version does not support the \"undo_edit\" command and adds optional max_characters parameter.\n * Supported models: Claude Sonnet 4, Opus 4, and Opus 4.1\n */\n textEditor_20250728: anthropicTools.textEditor_20250728,\n\n /**\n * Claude can interact with computer environments through the computer use tool, which\n * provides screenshot capabilities and mouse/keyboard control for autonomous desktop interaction.\n *\n * Image results are supported.\n */\n computer_20241022: anthropicTools.computer_20241022,\n\n /**\n * Creates a web search tool that gives Claude direct access to real-time web content.\n */\n webSearch_20250305: anthropicTools.webSearch_20250305,\n\n /**\n * Creates a tool search tool that uses regex patterns to find tools.\n *\n * The tool search tool enables Claude to work with hundreds or thousands of tools\n * by dynamically discovering and loading them on-demand.\n *\n * Use `providerOptions: { anthropic: { deferLoading: true } }` on other tools\n * to mark them for deferred loading.\n */\n toolSearchRegex_20251119: anthropicTools.toolSearchRegex_20251119,\n\n /**\n * Creates a tool search tool that uses BM25 (natural language) to find tools.\n *\n * The tool search tool enables Claude to work with hundreds or thousands of tools\n * by dynamically discovering and loading them on-demand.\n *\n * Use `providerOptions: { anthropic: { deferLoading: true } }` on other tools\n * to mark them for deferred loading.\n */\n toolSearchBm25_20251119: anthropicTools.toolSearchBm25_20251119,\n};\nexport interface GoogleVertexAnthropicProvider extends ProviderV4 {\n /**\n * Creates a model for text generation.\n */\n (modelId: GoogleVertexAnthropicModelId): LanguageModelV4;\n\n /**\n * Creates a model for text generation.\n */\n languageModel(modelId: GoogleVertexAnthropicModelId): LanguageModelV4;\n\n /**\n * Anthropic tools supported by Google Vertex.\n * Note: Only a subset of Anthropic tools are available on Vertex.\n * Supported tools: bash_20241022, bash_20250124, textEditor_20241022,\n * textEditor_20250124, textEditor_20250429, textEditor_20250728,\n * computer_20241022, webSearch_20250305, toolSearchRegex_20251119,\n * toolSearchBm25_20251119\n */\n tools: typeof googleVertexAnthropicTools;\n\n /**\n * @deprecated Use `embeddingModel` instead.\n */\n textEmbeddingModel(modelId: string): never;\n}\n\nexport interface GoogleVertexAnthropicProviderSettings {\n /**\n * Google Cloud project ID. Defaults to the value of the `GOOGLE_VERTEX_PROJECT` environment variable.\n */\n project?: string;\n\n /**\n * Google Cloud region. Defaults to the value of the `GOOGLE_VERTEX_LOCATION` environment variable.\n */\n location?: string;\n\n /**\n * Use a different URL prefix for API calls, e.g. to use proxy servers.\n * The default prefix is `https://api.anthropic.com/v1`.\n */\n baseURL?: string;\n\n /**\n * Custom headers to include in the requests.\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 Anthropic provider instance.\n */\nexport function createGoogleVertexAnthropic(\n options: GoogleVertexAnthropicProviderSettings = {},\n): GoogleVertexAnthropicProvider {\n const getBaseURL = () => {\n const baseURL = withoutTrailingSlash(options.baseURL);\n if (baseURL != null) {\n return baseURL;\n }\n const location = loadOptionalSetting({\n settingValue: options.location,\n environmentVariableName: 'GOOGLE_VERTEX_LOCATION',\n });\n if (location != null && !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 const project = loadOptionalSetting({\n settingValue: options.project,\n environmentVariableName: 'GOOGLE_VERTEX_PROJECT',\n });\n\n const getHost = () => {\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 return `https://${getHost()}/v1/projects/${project}/locations/${location}/publishers/anthropic/models`;\n };\n\n const createChatModel = (modelId: GoogleVertexAnthropicModelId) =>\n new AnthropicLanguageModel(modelId, {\n provider: 'googleVertex.anthropic.messages',\n baseURL: getBaseURL(),\n headers: options.headers ?? {},\n fetch: options.fetch,\n\n buildRequestUrl: (baseURL, isStreaming) =>\n `${baseURL}/${modelId}:${\n isStreaming ? 'streamRawPredict' : 'rawPredict'\n }`,\n transformRequestBody: args => {\n // Remove model from args and add anthropic version\n const { model: _model, ...rest } = args;\n return {\n ...rest,\n anthropic_version: 'vertex-2023-10-16',\n };\n },\n // Google Vertex Anthropic doesn't support URL sources, force download and base64 conversion\n supportedUrls: () => ({}),\n // force the use of JSON tool fallback for structured outputs since beta header isn't supported\n supportsNativeStructuredOutput: false,\n // Vertex Anthropic doesn't support strict mode on tool definitions.\n supportsStrictTools: false,\n });\n\n const provider = function (modelId: GoogleVertexAnthropicModelId) {\n if (new.target) {\n throw new Error(\n 'The Anthropic model function cannot be called with the new keyword.',\n );\n }\n\n return createChatModel(modelId);\n };\n\n provider.specificationVersion = 'v4' as const;\n provider.languageModel = createChatModel;\n provider.chat = createChatModel;\n provider.messages = createChatModel;\n\n provider.embeddingModel = (modelId: string) => {\n throw new NoSuchModelError({ modelId, modelType: 'embeddingModel' });\n };\n provider.textEmbeddingModel = provider.embeddingModel;\n provider.imageModel = (modelId: string) => {\n throw new NoSuchModelError({ modelId, modelType: 'imageModel' });\n };\n\n provider.tools = googleVertexAnthropicTools;\n\n return provider;\n}\n","import { resolve } from '@ai-sdk/provider-utils';\nimport {\n generateAuthToken as defaultGenerateAuthToken,\n type GoogleCredentials,\n} from '../../edge/google-vertex-auth-edge';\nimport {\n createGoogleVertexAnthropic as createVertexAnthropicOriginal,\n type GoogleVertexAnthropicProvider,\n type GoogleVertexAnthropicProviderSettings as GoogleVertexAnthropicProviderSettingsOriginal,\n} from '../google-vertex-anthropic-provider';\nexport type { GoogleVertexAnthropicProvider };\n\nexport interface GoogleVertexAnthropicProviderSettings extends GoogleVertexAnthropicProviderSettingsOriginal {\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 * Optional. Override the Bearer token generator. Defaults to OAuth exchange\n * with `googleCredentials`.\n */\n generateAuthToken?: () => Promise<string>;\n}\n\nexport function createGoogleVertexAnthropic(\n options: GoogleVertexAnthropicProviderSettings = {},\n): GoogleVertexAnthropicProvider {\n const generateAuthToken =\n options.generateAuthToken ??\n (() => defaultGenerateAuthToken(options.googleCredentials));\n return createVertexAnthropicOriginal({\n ...options,\n headers: async () => ({\n Authorization: `Bearer ${await generateAuthToken()}`,\n ...(await resolve(options.headers)),\n }),\n });\n}\n\n/**\n * Default Google Vertex AI Anthropic provider instance.\n */\nexport const googleVertexAnthropic = createGoogleVertexAnthropic();\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,KA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ACH,mBAAmB;GACrB;EACF;EAEA,sBAAsB,CAAC;EAEvB,gCAAgC;EAEhC,qBAAqB;CACvB,CAAC;CAEH,MAAM,WAAW,SAAU,SAAuC;EAChE,IAAI,YACF,MAAM,IAAI,MACR,qEACF;EAGF,OAAO,gBAAgB,OAAO;CAChC;CAEA,SAAS,uBAAuB;CAChC,SAAS,gBAAgB;CACzB,SAAS,OAAO;CAChB,SAAS,WAAW;CAEpB,SAAS,kBAAkB,YAAoB;EAC7C,MAAM,IAAI,iBAAiB;GAAE;GAAS,WAAW;EAAiB,CAAC;CACrE;CACA,SAAS,qBAAqB,SAAS;CACvC,SAAS,cAAc,YAAoB;EACzC,MAAM,IAAI,iBAAiB;GAAE;GAAS,WAAW;EAAa,CAAC;CACjE;CAEA,SAAS,QAAQ;CAEjB,OAAO;AACT;;;AClPA,SAAgB,4BACd,UAAiD,CAAC,GACnB;CAC/B,MAAMC,sBACJ,QAAQ,4BACDC,kBAAyB,QAAQ,iBAAiB;CAC3D,OAAOC,8BAA8B;EACnC,GAAG;EACH,SAAS,aAAa;GACpB,eAAe,UAAU,MAAMF,oBAAkB;GACjD,GAAI,MAAM,QAAQ,QAAQ,OAAO;EACnC;CACF,CAAC;AACH;;;;AAKA,MAAa,wBAAwB,4BAA4B"}
1
+ {"version":3,"file":"index.js","names":["createGoogleVertexAnthropic","generateAuthToken","defaultGenerateAuthToken","createVertexAnthropicOriginal"],"sources":["../../../src/version.ts","../../../src/edge/google-vertex-auth-edge.ts","../../../src/anthropic/google-vertex-anthropic-options.ts","../../../src/anthropic/google-vertex-anthropic-provider.ts","../../../src/anthropic/edge/google-vertex-anthropic-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 { lazySchema, zodSchema } from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\n\nexport const googleVertexAnthropicProviderOptions = lazySchema(() =>\n zodSchema(\n z.object({\n labels: z.record(z.string(), z.string()).optional(),\n }),\n ),\n);\n\n// https://cloud.google.com/vertex-ai/generative-ai/docs/partner-models/claude\nexport type GoogleVertexAnthropicModelId =\n | 'claude-sonnet-5'\n | 'claude-sonnet-5-5'\n | 'claude-haiku-5-5'\n | 'claude-fable-5'\n | 'claude-fable-5-1'\n | 'claude-opus-5'\n | 'claude-opus-5-5'\n | 'claude-opus-4-8'\n | 'claude-opus-4-7'\n | 'claude-opus-4-6'\n | 'claude-sonnet-4-6'\n | 'claude-opus-4-5@20251101'\n | 'claude-sonnet-4-5@20250929'\n | 'claude-opus-4-1@20250805'\n | 'claude-opus-4@20250514'\n | 'claude-sonnet-4@20250514'\n | 'claude-3-7-sonnet@20250219'\n | 'claude-3-5-sonnet-v2@20241022'\n | 'claude-3-5-haiku@20241022'\n | 'claude-3-5-sonnet@20240620'\n | 'claude-3-haiku@20240307'\n | 'claude-3-sonnet@20240229'\n | 'claude-3-opus@20240229'\n | (string & {});\n","import {\n InvalidArgumentError,\n NoSuchModelError,\n type LanguageModelV4,\n type ProviderV4,\n} from '@ai-sdk/provider';\nimport {\n convertUint8ArrayToBase64,\n isValidHostnamePart,\n loadOptionalSetting,\n parseProviderOptions,\n withoutTrailingSlash,\n type FetchFunction,\n type Resolvable,\n} from '@ai-sdk/provider-utils';\nimport {\n anthropicTools,\n AnthropicLanguageModel,\n} from '@ai-sdk/anthropic/internal';\nimport {\n googleVertexAnthropicProviderOptions,\n type GoogleVertexAnthropicModelId,\n} from './google-vertex-anthropic-options';\n\ntype GoogleVertexAnthropicTools = Pick<\n typeof anthropicTools,\n | 'bash_20241022'\n | 'bash_20250124'\n | 'textEditor_20241022'\n | 'textEditor_20250124'\n | 'textEditor_20250429'\n | 'textEditor_20250728'\n | 'computer_20241022'\n | 'webSearch_20250305'\n | 'toolSearchRegex_20251119'\n | 'toolSearchBm25_20251119'\n>;\n\n/**\n * Tools supported by Google Vertex Anthropic.\n * This is a subset of the full Anthropic tools - only these are recognized by the Vertex API.\n */\nexport const googleVertexAnthropicTools: GoogleVertexAnthropicTools = {\n /**\n * The bash tool enables Claude to execute shell commands in a persistent bash session,\n * allowing system operations, script execution, and command-line automation.\n *\n * Image results are supported.\n */\n bash_20241022: anthropicTools.bash_20241022,\n\n /**\n * The bash tool enables Claude to execute shell commands in a persistent bash session,\n * allowing system operations, script execution, and command-line automation.\n *\n * Image results are supported.\n */\n bash_20250124: anthropicTools.bash_20250124,\n\n /**\n * Claude can use an Anthropic-defined text editor tool to view and modify text files,\n * helping you debug, fix, and improve your code or other text documents.\n *\n * Supported models: Claude Sonnet 3.5\n */\n textEditor_20241022: anthropicTools.textEditor_20241022,\n\n /**\n * Claude can use an Anthropic-defined text editor tool to view and modify text files,\n * helping you debug, fix, and improve your code or other text documents.\n *\n * Supported models: Claude Sonnet 3.7\n */\n textEditor_20250124: anthropicTools.textEditor_20250124,\n\n /**\n * Claude can use an Anthropic-defined text editor tool to view and modify text files.\n * Note: This version does not support the \"undo_edit\" command.\n * @deprecated Use textEditor_20250728 instead\n */\n textEditor_20250429: anthropicTools.textEditor_20250429,\n\n /**\n * Claude can use an Anthropic-defined text editor tool to view and modify text files.\n * Note: This version does not support the \"undo_edit\" command and adds optional max_characters parameter.\n * Supported models: Claude Sonnet 4, Opus 4, and Opus 4.1\n */\n textEditor_20250728: anthropicTools.textEditor_20250728,\n\n /**\n * Claude can interact with computer environments through the computer use tool, which\n * provides screenshot capabilities and mouse/keyboard control for autonomous desktop interaction.\n *\n * Image results are supported.\n */\n computer_20241022: anthropicTools.computer_20241022,\n\n /**\n * Creates a web search tool that gives Claude direct access to real-time web content.\n */\n webSearch_20250305: anthropicTools.webSearch_20250305,\n\n /**\n * Creates a tool search tool that uses regex patterns to find tools.\n *\n * The tool search tool enables Claude to work with hundreds or thousands of tools\n * by dynamically discovering and loading them on-demand.\n *\n * Use `providerOptions: { anthropic: { deferLoading: true } }` on other tools\n * to mark them for deferred loading.\n */\n toolSearchRegex_20251119: anthropicTools.toolSearchRegex_20251119,\n\n /**\n * Creates a tool search tool that uses BM25 (natural language) to find tools.\n *\n * The tool search tool enables Claude to work with hundreds or thousands of tools\n * by dynamically discovering and loading them on-demand.\n *\n * Use `providerOptions: { anthropic: { deferLoading: true } }` on other tools\n * to mark them for deferred loading.\n */\n toolSearchBm25_20251119: anthropicTools.toolSearchBm25_20251119,\n};\nexport interface GoogleVertexAnthropicProvider extends ProviderV4 {\n /**\n * Creates a model for text generation.\n */\n (modelId: GoogleVertexAnthropicModelId): LanguageModelV4;\n\n /**\n * Creates a model for text generation.\n */\n languageModel(modelId: GoogleVertexAnthropicModelId): LanguageModelV4;\n\n /**\n * Anthropic tools supported by Google Vertex.\n * Note: Only a subset of Anthropic tools are available on Vertex.\n * Supported tools: bash_20241022, bash_20250124, textEditor_20241022,\n * textEditor_20250124, textEditor_20250429, textEditor_20250728,\n * computer_20241022, webSearch_20250305, toolSearchRegex_20251119,\n * toolSearchBm25_20251119\n */\n tools: typeof googleVertexAnthropicTools;\n\n /**\n * @deprecated Use `embeddingModel` instead.\n */\n textEmbeddingModel(modelId: string): never;\n}\n\nexport interface GoogleVertexAnthropicProviderSettings {\n /**\n * Google Cloud project ID. Defaults to the value of the `GOOGLE_VERTEX_PROJECT` environment variable.\n */\n project?: string;\n\n /**\n * Google Cloud region. Defaults to the value of the `GOOGLE_VERTEX_LOCATION` environment variable.\n */\n location?: string;\n\n /**\n * Use a different URL prefix for API calls, e.g. to use proxy servers.\n * The default prefix is `https://api.anthropic.com/v1`.\n */\n baseURL?: string;\n\n /**\n * Custom headers to include in the requests.\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 Anthropic provider instance.\n */\nexport function createGoogleVertexAnthropic(\n options: GoogleVertexAnthropicProviderSettings = {},\n): GoogleVertexAnthropicProvider {\n const getBaseURL = () => {\n const baseURL = withoutTrailingSlash(options.baseURL);\n if (baseURL != null) {\n return baseURL;\n }\n const location = loadOptionalSetting({\n settingValue: options.location,\n environmentVariableName: 'GOOGLE_VERTEX_LOCATION',\n });\n if (location != null && !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 const project = loadOptionalSetting({\n settingValue: options.project,\n environmentVariableName: 'GOOGLE_VERTEX_PROJECT',\n });\n\n const getHost = () => {\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 return `https://${getHost()}/v1/projects/${project}/locations/${location}/publishers/anthropic/models`;\n };\n\n const createChatModel = (modelId: GoogleVertexAnthropicModelId) =>\n new AnthropicLanguageModel(modelId, {\n provider: 'googleVertex.anthropic.messages',\n baseURL: getBaseURL(),\n headers: options.headers ?? {},\n fetch: options.fetch,\n\n buildRequestUrl: (baseURL, isStreaming) =>\n `${baseURL}/${modelId}:${\n isStreaming ? 'streamRawPredict' : 'rawPredict'\n }`,\n transformRequestBody: args => {\n // Remove model from args and add anthropic version\n const { model: _model, ...rest } = args;\n return {\n ...rest,\n anthropic_version: 'vertex-2023-10-16',\n };\n },\n transformRequestHeaders: async (headers, providerOptions) => {\n const vertexOptions = await parseProviderOptions({\n provider: 'vertex',\n providerOptions,\n schema: googleVertexAnthropicProviderOptions,\n });\n\n // Explicit headers take precedence, regardless of their casing.\n if (\n vertexOptions?.labels == null ||\n Object.keys(headers).some(\n name =>\n name.toLowerCase() === 'x-vertex-ai-labels' &&\n headers[name] != null,\n )\n ) {\n return headers;\n }\n\n return {\n ...headers,\n 'x-vertex-ai-labels': convertUint8ArrayToBase64(\n new TextEncoder().encode(JSON.stringify(vertexOptions.labels)),\n ),\n };\n },\n // Google Vertex Anthropic doesn't support URL sources, force download and base64 conversion\n supportedUrls: () => ({}),\n // force the use of JSON tool fallback for structured outputs since beta header isn't supported\n supportsNativeStructuredOutput: false,\n // Vertex Anthropic doesn't support strict mode on tool definitions.\n supportsStrictTools: false,\n });\n\n const provider = function (modelId: GoogleVertexAnthropicModelId) {\n if (new.target) {\n throw new Error(\n 'The Anthropic model function cannot be called with the new keyword.',\n );\n }\n\n return createChatModel(modelId);\n };\n\n provider.specificationVersion = 'v4' as const;\n provider.languageModel = createChatModel;\n provider.chat = createChatModel;\n provider.messages = createChatModel;\n\n provider.embeddingModel = (modelId: string) => {\n throw new NoSuchModelError({ modelId, modelType: 'embeddingModel' });\n };\n provider.textEmbeddingModel = provider.embeddingModel;\n provider.imageModel = (modelId: string) => {\n throw new NoSuchModelError({ modelId, modelType: 'imageModel' });\n };\n\n provider.tools = googleVertexAnthropicTools;\n\n return provider;\n}\n","import { resolve } from '@ai-sdk/provider-utils';\nimport {\n generateAuthToken as defaultGenerateAuthToken,\n type GoogleCredentials,\n} from '../../edge/google-vertex-auth-edge';\nimport {\n createGoogleVertexAnthropic as createVertexAnthropicOriginal,\n type GoogleVertexAnthropicProvider,\n type GoogleVertexAnthropicProviderSettings as GoogleVertexAnthropicProviderSettingsOriginal,\n} from '../google-vertex-anthropic-provider';\nexport type { GoogleVertexAnthropicProvider };\n\nexport interface GoogleVertexAnthropicProviderSettings extends GoogleVertexAnthropicProviderSettingsOriginal {\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 * Optional. Override the Bearer token generator. Defaults to OAuth exchange\n * with `googleCredentials`.\n */\n generateAuthToken?: () => Promise<string>;\n}\n\nexport function createGoogleVertexAnthropic(\n options: GoogleVertexAnthropicProviderSettings = {},\n): GoogleVertexAnthropicProvider {\n const generateAuthToken =\n options.generateAuthToken ??\n (() => defaultGenerateAuthToken(options.googleCredentials));\n return createVertexAnthropicOriginal({\n ...options,\n headers: async () => ({\n Authorization: `Bearer ${await generateAuthToken()}`,\n ...(await resolve(options.headers)),\n }),\n });\n}\n\n/**\n * Default Google Vertex AI Anthropic provider instance.\n */\nexport const googleVertexAnthropic = createGoogleVertexAnthropic();\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;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IAC/C,UAAU;IACV;IACA,QAAQ;GACV,CAAC;GAGD,IACE,eAAe,UAAU,QACzB,OAAO,KAAK,OAAO,CAAC,CAAC,MACnB,SACE,KAAK,YAAY,MAAM,wBACvB,QAAQ,SAAS,IACrB,GAEA,OAAO;GAGT,OAAO;IACL,GAAG;IACH,sBAAsB,0BACpB,IAAI,YAAY,CAAC,CAAC,OAAO,KAAK,UAAU,cAAc,MAAM,CAAC,CAC/D;GACF;EACF;EAEA,sBAAsB,CAAC;EAEvB,gCAAgC;EAEhC,qBAAqB;CACvB,CAAC;CAEH,MAAM,WAAW,SAAU,SAAuC;EAChE,IAAI,YACF,MAAM,IAAI,MACR,qEACF;EAGF,OAAO,gBAAgB,OAAO;CAChC;CAEA,SAAS,uBAAuB;CAChC,SAAS,gBAAgB;CACzB,SAAS,OAAO;CAChB,SAAS,WAAW;CAEpB,SAAS,kBAAkB,YAAoB;EAC7C,MAAM,IAAI,iBAAiB;GAAE;GAAS,WAAW;EAAiB,CAAC;CACrE;CACA,SAAS,qBAAqB,SAAS;CACvC,SAAS,cAAc,YAAoB;EACzC,MAAM,IAAI,iBAAiB;GAAE;GAAS,WAAW;EAAa,CAAC;CACjE;CAEA,SAAS,QAAQ;CAEjB,OAAO;AACT;;;ACjRA,SAAgB,4BACd,UAAiD,CAAC,GACnB;CAC/B,MAAMC,sBACJ,QAAQ,4BACDC,kBAAyB,QAAQ,iBAAiB;CAC3D,OAAOC,8BAA8B;EACnC,GAAG;EACH,SAAS,aAAa;GACpB,eAAe,UAAU,MAAMF,oBAAkB;GACjD,GAAI,MAAM,QAAQ,QAAQ,OAAO;EACnC;CACF,CAAC;AACH;;;;AAKA,MAAa,wBAAwB,4BAA4B"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":["GoogleVertexAnthropicProviderSettings","GoogleVertexAnthropicProviderSettingsOriginal"],"sources":["../../src/anthropic/google-vertex-anthropic-options.ts","../../src/anthropic/google-vertex-anthropic-provider.ts","../../src/anthropic/google-vertex-anthropic-provider-node.ts"],"mappings":";;;;;KACY;;;KCkBP,6BAA6B,YACzB;;;;;cAiBI,4BAA4B;UAkFxB,sCAAsC;;;;GAIpD,SAAS,+BAA+B;;;;EAKzC,cAAc,SAAS,+BAA+B;;;;;;;;;EAUtD,cAAc;;;;EAKd,mBAAmB;;UAGJA;;;;EAIf;;;;EAKA;;;;;EAMA;;;;EAKA,UAAU,WAAW;;;;;EAMrB,QAAQ;;;;UClKO,8CAA8CC;;;;;;;EAO7D,oBAAoB;;;;;EAKpB,0BAA0B;;wBAGZ,4BACd,UAAS,wCACR;;;;qBAiBU,uBAAqB"}
1
+ {"version":3,"file":"index.d.ts","names":["GoogleVertexAnthropicProviderSettings","GoogleVertexAnthropicProviderSettingsOriginal"],"sources":["../../src/anthropic/google-vertex-anthropic-options.ts","../../src/anthropic/google-vertex-anthropic-provider.ts","../../src/anthropic/google-vertex-anthropic-provider-node.ts"],"mappings":";;;;;KAYY;;;KCYP,6BAA6B,YACzB;;;;;cAiBI,4BAA4B;UAkFxB,sCAAsC;;;;GAIpD,SAAS,+BAA+B;;;;EAKzC,cAAc,SAAS,+BAA+B;;;;;;;;;EAUtD,cAAc;;;;EAKd,mBAAmB;;UAGJA;;;;EAIf;;;;EAKA;;;;;EAMA;;;;EAKA,UAAU,WAAW;;;;;EAMrB,QAAQ;;;;UCvKO,8CAA8CC;;;;;;;EAO7D,oBAAoB;;;;;EAKpB,0BAA0B;;wBAGZ,4BACd,UAAS,wCACR;;;;qBAiBU,uBAAqB"}
@@ -1,7 +1,8 @@
1
- import { isValidHostnamePart, loadOptionalSetting, resolve, withoutTrailingSlash } from "@ai-sdk/provider-utils";
1
+ import { convertUint8ArrayToBase64, isValidHostnamePart, lazySchema, loadOptionalSetting, parseProviderOptions, resolve, withoutTrailingSlash, zodSchema } from "@ai-sdk/provider-utils";
2
2
  import { GoogleAuth } from "google-auth-library";
3
3
  import { InvalidArgumentError, NoSuchModelError } from "@ai-sdk/provider";
4
4
  import { AnthropicLanguageModel, anthropicTools } from "@ai-sdk/anthropic/internal";
5
+ import { z } from "zod/v4";
5
6
  //#region src/google-vertex-auth-google-auth-library.ts
6
7
  function createAuthTokenGenerator(options) {
7
8
  const auth = new GoogleAuth({
@@ -13,6 +14,9 @@ function createAuthTokenGenerator(options) {
13
14
  };
14
15
  }
15
16
  //#endregion
17
+ //#region src/anthropic/google-vertex-anthropic-options.ts
18
+ const googleVertexAnthropicProviderOptions = lazySchema(() => zodSchema(z.object({ labels: z.record(z.string(), z.string()).optional() })));
19
+ //#endregion
16
20
  //#region src/anthropic/google-vertex-anthropic-provider.ts
17
21
  /**
18
22
  * Tools supported by Google Vertex Anthropic.
@@ -130,6 +134,18 @@ function createGoogleVertexAnthropic$1(options = {}) {
130
134
  anthropic_version: "vertex-2023-10-16"
131
135
  };
132
136
  },
137
+ transformRequestHeaders: async (headers, providerOptions) => {
138
+ const vertexOptions = await parseProviderOptions({
139
+ provider: "vertex",
140
+ providerOptions,
141
+ schema: googleVertexAnthropicProviderOptions
142
+ });
143
+ if (vertexOptions?.labels == null || Object.keys(headers).some((name) => name.toLowerCase() === "x-vertex-ai-labels" && headers[name] != null)) return headers;
144
+ return {
145
+ ...headers,
146
+ "x-vertex-ai-labels": convertUint8ArrayToBase64(new TextEncoder().encode(JSON.stringify(vertexOptions.labels)))
147
+ };
148
+ },
133
149
  supportedUrls: () => ({}),
134
150
  supportsNativeStructuredOutput: false,
135
151
  supportsStrictTools: false
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["createGoogleVertexAnthropic","createVertexAnthropicOriginal"],"sources":["../../src/google-vertex-auth-google-auth-library.ts","../../src/anthropic/google-vertex-anthropic-provider.ts","../../src/anthropic/google-vertex-anthropic-provider-node.ts"],"sourcesContent":["import { GoogleAuth, type GoogleAuthOptions } from 'google-auth-library';\n\nexport function createAuthTokenGenerator(options?: GoogleAuthOptions) {\n const auth = new GoogleAuth({\n scopes: ['https://www.googleapis.com/auth/cloud-platform'],\n ...options,\n });\n\n return async function generateAuthToken() {\n const client = await auth.getClient();\n const token = await client.getAccessToken();\n return token?.token ?? null;\n };\n}\n","import {\n InvalidArgumentError,\n NoSuchModelError,\n type LanguageModelV4,\n type ProviderV4,\n} from '@ai-sdk/provider';\nimport {\n isValidHostnamePart,\n loadOptionalSetting,\n withoutTrailingSlash,\n type FetchFunction,\n type Resolvable,\n} from '@ai-sdk/provider-utils';\nimport {\n anthropicTools,\n AnthropicLanguageModel,\n} from '@ai-sdk/anthropic/internal';\nimport type { GoogleVertexAnthropicModelId } from './google-vertex-anthropic-options';\n\ntype GoogleVertexAnthropicTools = Pick<\n typeof anthropicTools,\n | 'bash_20241022'\n | 'bash_20250124'\n | 'textEditor_20241022'\n | 'textEditor_20250124'\n | 'textEditor_20250429'\n | 'textEditor_20250728'\n | 'computer_20241022'\n | 'webSearch_20250305'\n | 'toolSearchRegex_20251119'\n | 'toolSearchBm25_20251119'\n>;\n\n/**\n * Tools supported by Google Vertex Anthropic.\n * This is a subset of the full Anthropic tools - only these are recognized by the Vertex API.\n */\nexport const googleVertexAnthropicTools: GoogleVertexAnthropicTools = {\n /**\n * The bash tool enables Claude to execute shell commands in a persistent bash session,\n * allowing system operations, script execution, and command-line automation.\n *\n * Image results are supported.\n */\n bash_20241022: anthropicTools.bash_20241022,\n\n /**\n * The bash tool enables Claude to execute shell commands in a persistent bash session,\n * allowing system operations, script execution, and command-line automation.\n *\n * Image results are supported.\n */\n bash_20250124: anthropicTools.bash_20250124,\n\n /**\n * Claude can use an Anthropic-defined text editor tool to view and modify text files,\n * helping you debug, fix, and improve your code or other text documents.\n *\n * Supported models: Claude Sonnet 3.5\n */\n textEditor_20241022: anthropicTools.textEditor_20241022,\n\n /**\n * Claude can use an Anthropic-defined text editor tool to view and modify text files,\n * helping you debug, fix, and improve your code or other text documents.\n *\n * Supported models: Claude Sonnet 3.7\n */\n textEditor_20250124: anthropicTools.textEditor_20250124,\n\n /**\n * Claude can use an Anthropic-defined text editor tool to view and modify text files.\n * Note: This version does not support the \"undo_edit\" command.\n * @deprecated Use textEditor_20250728 instead\n */\n textEditor_20250429: anthropicTools.textEditor_20250429,\n\n /**\n * Claude can use an Anthropic-defined text editor tool to view and modify text files.\n * Note: This version does not support the \"undo_edit\" command and adds optional max_characters parameter.\n * Supported models: Claude Sonnet 4, Opus 4, and Opus 4.1\n */\n textEditor_20250728: anthropicTools.textEditor_20250728,\n\n /**\n * Claude can interact with computer environments through the computer use tool, which\n * provides screenshot capabilities and mouse/keyboard control for autonomous desktop interaction.\n *\n * Image results are supported.\n */\n computer_20241022: anthropicTools.computer_20241022,\n\n /**\n * Creates a web search tool that gives Claude direct access to real-time web content.\n */\n webSearch_20250305: anthropicTools.webSearch_20250305,\n\n /**\n * Creates a tool search tool that uses regex patterns to find tools.\n *\n * The tool search tool enables Claude to work with hundreds or thousands of tools\n * by dynamically discovering and loading them on-demand.\n *\n * Use `providerOptions: { anthropic: { deferLoading: true } }` on other tools\n * to mark them for deferred loading.\n */\n toolSearchRegex_20251119: anthropicTools.toolSearchRegex_20251119,\n\n /**\n * Creates a tool search tool that uses BM25 (natural language) to find tools.\n *\n * The tool search tool enables Claude to work with hundreds or thousands of tools\n * by dynamically discovering and loading them on-demand.\n *\n * Use `providerOptions: { anthropic: { deferLoading: true } }` on other tools\n * to mark them for deferred loading.\n */\n toolSearchBm25_20251119: anthropicTools.toolSearchBm25_20251119,\n};\nexport interface GoogleVertexAnthropicProvider extends ProviderV4 {\n /**\n * Creates a model for text generation.\n */\n (modelId: GoogleVertexAnthropicModelId): LanguageModelV4;\n\n /**\n * Creates a model for text generation.\n */\n languageModel(modelId: GoogleVertexAnthropicModelId): LanguageModelV4;\n\n /**\n * Anthropic tools supported by Google Vertex.\n * Note: Only a subset of Anthropic tools are available on Vertex.\n * Supported tools: bash_20241022, bash_20250124, textEditor_20241022,\n * textEditor_20250124, textEditor_20250429, textEditor_20250728,\n * computer_20241022, webSearch_20250305, toolSearchRegex_20251119,\n * toolSearchBm25_20251119\n */\n tools: typeof googleVertexAnthropicTools;\n\n /**\n * @deprecated Use `embeddingModel` instead.\n */\n textEmbeddingModel(modelId: string): never;\n}\n\nexport interface GoogleVertexAnthropicProviderSettings {\n /**\n * Google Cloud project ID. Defaults to the value of the `GOOGLE_VERTEX_PROJECT` environment variable.\n */\n project?: string;\n\n /**\n * Google Cloud region. Defaults to the value of the `GOOGLE_VERTEX_LOCATION` environment variable.\n */\n location?: string;\n\n /**\n * Use a different URL prefix for API calls, e.g. to use proxy servers.\n * The default prefix is `https://api.anthropic.com/v1`.\n */\n baseURL?: string;\n\n /**\n * Custom headers to include in the requests.\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 Anthropic provider instance.\n */\nexport function createGoogleVertexAnthropic(\n options: GoogleVertexAnthropicProviderSettings = {},\n): GoogleVertexAnthropicProvider {\n const getBaseURL = () => {\n const baseURL = withoutTrailingSlash(options.baseURL);\n if (baseURL != null) {\n return baseURL;\n }\n const location = loadOptionalSetting({\n settingValue: options.location,\n environmentVariableName: 'GOOGLE_VERTEX_LOCATION',\n });\n if (location != null && !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 const project = loadOptionalSetting({\n settingValue: options.project,\n environmentVariableName: 'GOOGLE_VERTEX_PROJECT',\n });\n\n const getHost = () => {\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 return `https://${getHost()}/v1/projects/${project}/locations/${location}/publishers/anthropic/models`;\n };\n\n const createChatModel = (modelId: GoogleVertexAnthropicModelId) =>\n new AnthropicLanguageModel(modelId, {\n provider: 'googleVertex.anthropic.messages',\n baseURL: getBaseURL(),\n headers: options.headers ?? {},\n fetch: options.fetch,\n\n buildRequestUrl: (baseURL, isStreaming) =>\n `${baseURL}/${modelId}:${\n isStreaming ? 'streamRawPredict' : 'rawPredict'\n }`,\n transformRequestBody: args => {\n // Remove model from args and add anthropic version\n const { model: _model, ...rest } = args;\n return {\n ...rest,\n anthropic_version: 'vertex-2023-10-16',\n };\n },\n // Google Vertex Anthropic doesn't support URL sources, force download and base64 conversion\n supportedUrls: () => ({}),\n // force the use of JSON tool fallback for structured outputs since beta header isn't supported\n supportsNativeStructuredOutput: false,\n // Vertex Anthropic doesn't support strict mode on tool definitions.\n supportsStrictTools: false,\n });\n\n const provider = function (modelId: GoogleVertexAnthropicModelId) {\n if (new.target) {\n throw new Error(\n 'The Anthropic model function cannot be called with the new keyword.',\n );\n }\n\n return createChatModel(modelId);\n };\n\n provider.specificationVersion = 'v4' as const;\n provider.languageModel = createChatModel;\n provider.chat = createChatModel;\n provider.messages = createChatModel;\n\n provider.embeddingModel = (modelId: string) => {\n throw new NoSuchModelError({ modelId, modelType: 'embeddingModel' });\n };\n provider.textEmbeddingModel = provider.embeddingModel;\n provider.imageModel = (modelId: string) => {\n throw new NoSuchModelError({ modelId, modelType: 'imageModel' });\n };\n\n provider.tools = googleVertexAnthropicTools;\n\n return provider;\n}\n","import { resolve } from '@ai-sdk/provider-utils';\nimport type { GoogleAuthOptions } from 'google-auth-library';\nimport { createAuthTokenGenerator } from '../google-vertex-auth-google-auth-library';\nimport {\n createGoogleVertexAnthropic as createVertexAnthropicOriginal,\n type GoogleVertexAnthropicProvider,\n type GoogleVertexAnthropicProviderSettings as GoogleVertexAnthropicProviderSettingsOriginal,\n} from './google-vertex-anthropic-provider';\nexport type { GoogleVertexAnthropicProvider };\n\nexport interface GoogleVertexAnthropicProviderSettings extends GoogleVertexAnthropicProviderSettingsOriginal {\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 * Optional. Override the Bearer token generator. Defaults to OAuth exchange\n * via `google-auth-library` with `googleAuthOptions`.\n */\n generateAuthToken?: () => Promise<string | null>;\n}\n\nexport function createGoogleVertexAnthropic(\n options: GoogleVertexAnthropicProviderSettings = {},\n): GoogleVertexAnthropicProvider {\n const generateAuthToken =\n options.generateAuthToken ??\n createAuthTokenGenerator(options.googleAuthOptions);\n\n return createVertexAnthropicOriginal({\n ...options,\n headers: async () => ({\n Authorization: `Bearer ${await generateAuthToken()}`,\n ...(await resolve(options.headers)),\n }),\n });\n}\n\n/**\n * Default Google Vertex Anthropic provider instance.\n */\nexport const googleVertexAnthropic = createGoogleVertexAnthropic();\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;;;;;;;ACwBA,MAAa,6BAAyD;;;;;;;CAOpE,eAAe,eAAe;;;;;;;CAQ9B,eAAe,eAAe;;;;;;;CAQ9B,qBAAqB,eAAe;;;;;;;CAQpC,qBAAqB,eAAe;;;;;;CAOpC,qBAAqB,eAAe;;;;;;CAOpC,qBAAqB,eAAe;;;;;;;CAQpC,mBAAmB,eAAe;;;;CAKlC,oBAAoB,eAAe;;;;;;;;;;CAWnC,0BAA0B,eAAe;;;;;;;;;;CAWzC,yBAAyB,eAAe;AAC1C;;;;AA4DA,SAAgBA,8BACd,UAAiD,CAAC,GACnB;CAC/B,MAAM,mBAAmB;EACvB,MAAM,UAAU,qBAAqB,QAAQ,OAAO;EACpD,IAAI,WAAW,MACb,OAAO;EA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AQ;CAEjB,OAAO;AACT;;;ACnPA,SAAgB,4BACd,UAAiD,CAAC,GACnB;CAC/B,MAAM,oBACJ,QAAQ,qBACR,yBAAyB,QAAQ,iBAAiB;CAEpD,OAAOC,8BAA8B;EACnC,GAAG;EACH,SAAS,aAAa;GACpB,eAAe,UAAU,MAAM,kBAAkB;GACjD,GAAI,MAAM,QAAQ,QAAQ,OAAO;EACnC;CACF,CAAC;AACH;;;;AAKA,MAAa,wBAAwB,4BAA4B"}
1
+ {"version":3,"file":"index.js","names":["createGoogleVertexAnthropic","createVertexAnthropicOriginal"],"sources":["../../src/google-vertex-auth-google-auth-library.ts","../../src/anthropic/google-vertex-anthropic-options.ts","../../src/anthropic/google-vertex-anthropic-provider.ts","../../src/anthropic/google-vertex-anthropic-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 { lazySchema, zodSchema } from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\n\nexport const googleVertexAnthropicProviderOptions = lazySchema(() =>\n zodSchema(\n z.object({\n labels: z.record(z.string(), z.string()).optional(),\n }),\n ),\n);\n\n// https://cloud.google.com/vertex-ai/generative-ai/docs/partner-models/claude\nexport type GoogleVertexAnthropicModelId =\n | 'claude-sonnet-5'\n | 'claude-sonnet-5-5'\n | 'claude-haiku-5-5'\n | 'claude-fable-5'\n | 'claude-fable-5-1'\n | 'claude-opus-5'\n | 'claude-opus-5-5'\n | 'claude-opus-4-8'\n | 'claude-opus-4-7'\n | 'claude-opus-4-6'\n | 'claude-sonnet-4-6'\n | 'claude-opus-4-5@20251101'\n | 'claude-sonnet-4-5@20250929'\n | 'claude-opus-4-1@20250805'\n | 'claude-opus-4@20250514'\n | 'claude-sonnet-4@20250514'\n | 'claude-3-7-sonnet@20250219'\n | 'claude-3-5-sonnet-v2@20241022'\n | 'claude-3-5-haiku@20241022'\n | 'claude-3-5-sonnet@20240620'\n | 'claude-3-haiku@20240307'\n | 'claude-3-sonnet@20240229'\n | 'claude-3-opus@20240229'\n | (string & {});\n","import {\n InvalidArgumentError,\n NoSuchModelError,\n type LanguageModelV4,\n type ProviderV4,\n} from '@ai-sdk/provider';\nimport {\n convertUint8ArrayToBase64,\n isValidHostnamePart,\n loadOptionalSetting,\n parseProviderOptions,\n withoutTrailingSlash,\n type FetchFunction,\n type Resolvable,\n} from '@ai-sdk/provider-utils';\nimport {\n anthropicTools,\n AnthropicLanguageModel,\n} from '@ai-sdk/anthropic/internal';\nimport {\n googleVertexAnthropicProviderOptions,\n type GoogleVertexAnthropicModelId,\n} from './google-vertex-anthropic-options';\n\ntype GoogleVertexAnthropicTools = Pick<\n typeof anthropicTools,\n | 'bash_20241022'\n | 'bash_20250124'\n | 'textEditor_20241022'\n | 'textEditor_20250124'\n | 'textEditor_20250429'\n | 'textEditor_20250728'\n | 'computer_20241022'\n | 'webSearch_20250305'\n | 'toolSearchRegex_20251119'\n | 'toolSearchBm25_20251119'\n>;\n\n/**\n * Tools supported by Google Vertex Anthropic.\n * This is a subset of the full Anthropic tools - only these are recognized by the Vertex API.\n */\nexport const googleVertexAnthropicTools: GoogleVertexAnthropicTools = {\n /**\n * The bash tool enables Claude to execute shell commands in a persistent bash session,\n * allowing system operations, script execution, and command-line automation.\n *\n * Image results are supported.\n */\n bash_20241022: anthropicTools.bash_20241022,\n\n /**\n * The bash tool enables Claude to execute shell commands in a persistent bash session,\n * allowing system operations, script execution, and command-line automation.\n *\n * Image results are supported.\n */\n bash_20250124: anthropicTools.bash_20250124,\n\n /**\n * Claude can use an Anthropic-defined text editor tool to view and modify text files,\n * helping you debug, fix, and improve your code or other text documents.\n *\n * Supported models: Claude Sonnet 3.5\n */\n textEditor_20241022: anthropicTools.textEditor_20241022,\n\n /**\n * Claude can use an Anthropic-defined text editor tool to view and modify text files,\n * helping you debug, fix, and improve your code or other text documents.\n *\n * Supported models: Claude Sonnet 3.7\n */\n textEditor_20250124: anthropicTools.textEditor_20250124,\n\n /**\n * Claude can use an Anthropic-defined text editor tool to view and modify text files.\n * Note: This version does not support the \"undo_edit\" command.\n * @deprecated Use textEditor_20250728 instead\n */\n textEditor_20250429: anthropicTools.textEditor_20250429,\n\n /**\n * Claude can use an Anthropic-defined text editor tool to view and modify text files.\n * Note: This version does not support the \"undo_edit\" command and adds optional max_characters parameter.\n * Supported models: Claude Sonnet 4, Opus 4, and Opus 4.1\n */\n textEditor_20250728: anthropicTools.textEditor_20250728,\n\n /**\n * Claude can interact with computer environments through the computer use tool, which\n * provides screenshot capabilities and mouse/keyboard control for autonomous desktop interaction.\n *\n * Image results are supported.\n */\n computer_20241022: anthropicTools.computer_20241022,\n\n /**\n * Creates a web search tool that gives Claude direct access to real-time web content.\n */\n webSearch_20250305: anthropicTools.webSearch_20250305,\n\n /**\n * Creates a tool search tool that uses regex patterns to find tools.\n *\n * The tool search tool enables Claude to work with hundreds or thousands of tools\n * by dynamically discovering and loading them on-demand.\n *\n * Use `providerOptions: { anthropic: { deferLoading: true } }` on other tools\n * to mark them for deferred loading.\n */\n toolSearchRegex_20251119: anthropicTools.toolSearchRegex_20251119,\n\n /**\n * Creates a tool search tool that uses BM25 (natural language) to find tools.\n *\n * The tool search tool enables Claude to work with hundreds or thousands of tools\n * by dynamically discovering and loading them on-demand.\n *\n * Use `providerOptions: { anthropic: { deferLoading: true } }` on other tools\n * to mark them for deferred loading.\n */\n toolSearchBm25_20251119: anthropicTools.toolSearchBm25_20251119,\n};\nexport interface GoogleVertexAnthropicProvider extends ProviderV4 {\n /**\n * Creates a model for text generation.\n */\n (modelId: GoogleVertexAnthropicModelId): LanguageModelV4;\n\n /**\n * Creates a model for text generation.\n */\n languageModel(modelId: GoogleVertexAnthropicModelId): LanguageModelV4;\n\n /**\n * Anthropic tools supported by Google Vertex.\n * Note: Only a subset of Anthropic tools are available on Vertex.\n * Supported tools: bash_20241022, bash_20250124, textEditor_20241022,\n * textEditor_20250124, textEditor_20250429, textEditor_20250728,\n * computer_20241022, webSearch_20250305, toolSearchRegex_20251119,\n * toolSearchBm25_20251119\n */\n tools: typeof googleVertexAnthropicTools;\n\n /**\n * @deprecated Use `embeddingModel` instead.\n */\n textEmbeddingModel(modelId: string): never;\n}\n\nexport interface GoogleVertexAnthropicProviderSettings {\n /**\n * Google Cloud project ID. Defaults to the value of the `GOOGLE_VERTEX_PROJECT` environment variable.\n */\n project?: string;\n\n /**\n * Google Cloud region. Defaults to the value of the `GOOGLE_VERTEX_LOCATION` environment variable.\n */\n location?: string;\n\n /**\n * Use a different URL prefix for API calls, e.g. to use proxy servers.\n * The default prefix is `https://api.anthropic.com/v1`.\n */\n baseURL?: string;\n\n /**\n * Custom headers to include in the requests.\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 Anthropic provider instance.\n */\nexport function createGoogleVertexAnthropic(\n options: GoogleVertexAnthropicProviderSettings = {},\n): GoogleVertexAnthropicProvider {\n const getBaseURL = () => {\n const baseURL = withoutTrailingSlash(options.baseURL);\n if (baseURL != null) {\n return baseURL;\n }\n const location = loadOptionalSetting({\n settingValue: options.location,\n environmentVariableName: 'GOOGLE_VERTEX_LOCATION',\n });\n if (location != null && !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 const project = loadOptionalSetting({\n settingValue: options.project,\n environmentVariableName: 'GOOGLE_VERTEX_PROJECT',\n });\n\n const getHost = () => {\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 return `https://${getHost()}/v1/projects/${project}/locations/${location}/publishers/anthropic/models`;\n };\n\n const createChatModel = (modelId: GoogleVertexAnthropicModelId) =>\n new AnthropicLanguageModel(modelId, {\n provider: 'googleVertex.anthropic.messages',\n baseURL: getBaseURL(),\n headers: options.headers ?? {},\n fetch: options.fetch,\n\n buildRequestUrl: (baseURL, isStreaming) =>\n `${baseURL}/${modelId}:${\n isStreaming ? 'streamRawPredict' : 'rawPredict'\n }`,\n transformRequestBody: args => {\n // Remove model from args and add anthropic version\n const { model: _model, ...rest } = args;\n return {\n ...rest,\n anthropic_version: 'vertex-2023-10-16',\n };\n },\n transformRequestHeaders: async (headers, providerOptions) => {\n const vertexOptions = await parseProviderOptions({\n provider: 'vertex',\n providerOptions,\n schema: googleVertexAnthropicProviderOptions,\n });\n\n // Explicit headers take precedence, regardless of their casing.\n if (\n vertexOptions?.labels == null ||\n Object.keys(headers).some(\n name =>\n name.toLowerCase() === 'x-vertex-ai-labels' &&\n headers[name] != null,\n )\n ) {\n return headers;\n }\n\n return {\n ...headers,\n 'x-vertex-ai-labels': convertUint8ArrayToBase64(\n new TextEncoder().encode(JSON.stringify(vertexOptions.labels)),\n ),\n };\n },\n // Google Vertex Anthropic doesn't support URL sources, force download and base64 conversion\n supportedUrls: () => ({}),\n // force the use of JSON tool fallback for structured outputs since beta header isn't supported\n supportsNativeStructuredOutput: false,\n // Vertex Anthropic doesn't support strict mode on tool definitions.\n supportsStrictTools: false,\n });\n\n const provider = function (modelId: GoogleVertexAnthropicModelId) {\n if (new.target) {\n throw new Error(\n 'The Anthropic model function cannot be called with the new keyword.',\n );\n }\n\n return createChatModel(modelId);\n };\n\n provider.specificationVersion = 'v4' as const;\n provider.languageModel = createChatModel;\n provider.chat = createChatModel;\n provider.messages = createChatModel;\n\n provider.embeddingModel = (modelId: string) => {\n throw new NoSuchModelError({ modelId, modelType: 'embeddingModel' });\n };\n provider.textEmbeddingModel = provider.embeddingModel;\n provider.imageModel = (modelId: string) => {\n throw new NoSuchModelError({ modelId, modelType: 'imageModel' });\n };\n\n provider.tools = googleVertexAnthropicTools;\n\n return provider;\n}\n","import { resolve } from '@ai-sdk/provider-utils';\nimport type { GoogleAuthOptions } from 'google-auth-library';\nimport { createAuthTokenGenerator } from '../google-vertex-auth-google-auth-library';\nimport {\n createGoogleVertexAnthropic as createVertexAnthropicOriginal,\n type GoogleVertexAnthropicProvider,\n type GoogleVertexAnthropicProviderSettings as GoogleVertexAnthropicProviderSettingsOriginal,\n} from './google-vertex-anthropic-provider';\nexport type { GoogleVertexAnthropicProvider };\n\nexport interface GoogleVertexAnthropicProviderSettings extends GoogleVertexAnthropicProviderSettingsOriginal {\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 * Optional. Override the Bearer token generator. Defaults to OAuth exchange\n * via `google-auth-library` with `googleAuthOptions`.\n */\n generateAuthToken?: () => Promise<string | null>;\n}\n\nexport function createGoogleVertexAnthropic(\n options: GoogleVertexAnthropicProviderSettings = {},\n): GoogleVertexAnthropicProvider {\n const generateAuthToken =\n options.generateAuthToken ??\n createAuthTokenGenerator(options.googleAuthOptions);\n\n return createVertexAnthropicOriginal({\n ...options,\n headers: async () => ({\n Authorization: `Bearer ${await generateAuthToken()}`,\n ...(await resolve(options.headers)),\n }),\n });\n}\n\n/**\n * Default Google Vertex Anthropic provider instance.\n */\nexport const googleVertexAnthropic = createGoogleVertexAnthropic();\n"],"mappings":";;;;;;AAEA,SAAgB,yBAAyB,SAA6B;CACpE,MAAM,OAAO,IAAI,WAAW;EAC1B,QAAQ,CAAC,gDAAgD;EACzD,GAAG;CACL,CAAC;CAED,OAAO,eAAe,oBAAoB;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UAAU,MAAM,kBAAkB;GACjD,GAAI,MAAM,QAAQ,QAAQ,OAAO;EACnC;CACF,CAAC;AACH;;;;AAKA,MAAa,wBAAwB,4BAA4B"}
@@ -38,7 +38,7 @@ declare class GoogleVertexEmbeddingModel implements EmbeddingModelV4 {
38
38
  type GoogleVertexImageModelId = 'gemini-2.5-flash-image' | 'gemini-3-pro-image-preview' | 'gemini-3.1-flash-image-preview' | 'gemini-nano-banana-2.1' | (string & {});
39
39
  //#endregion
40
40
  //#region src/google-vertex-options.d.ts
41
- type GoogleVertexModelId = 'gemini-nano-banana-2.1' | 'gemini-3.8-flash' | 'gemini-3.7-flash' | 'gemini-3.6-flash' | 'gemini-3.5-flash' | 'gemini-3.5-flash-lite' | 'gemini-2.5-pro' | 'gemini-2.5-flash' | 'gemini-2.5-flash-lite' | 'gemini-2.0-flash-lite' | 'gemini-2.0-flash' | 'gemini-2.0-flash-001' | 'gemini-1.5-flash' | 'gemini-1.5-flash-001' | 'gemini-1.5-flash-002' | 'gemini-1.5-pro' | 'gemini-1.5-pro-001' | 'gemini-1.5-pro-002' | 'gemini-1.0-pro-001' | 'gemini-1.0-pro-vision-001' | 'gemini-1.0-pro' | 'gemini-1.0-pro-002' | 'gemini-2.0-flash-lite-preview-02-05' | 'gemini-2.5-flash-preview-09-2025' | 'gemini-3-pro-preview' | 'gemini-3-pro-image-preview' | 'gemini-3-flash-preview' | 'gemini-3.1-pro-preview' | 'gemini-3.1-flash-image-preview' | 'gemini-3.1-flash-lite-preview' | 'gemini-2.0-pro-exp-02-05' | 'gemini-2.0-flash-exp' | (string & {});
41
+ type GoogleVertexModelId = 'gemini-nano-banana-2.1' | 'gemini-4-argon' | 'gemini-3.8-flash' | 'gemini-3.7-flash' | 'gemini-3.6-flash' | 'gemini-3.5-flash' | 'gemini-3.5-flash-lite' | 'gemini-2.5-pro' | 'gemini-2.5-flash' | 'gemini-2.5-flash-lite' | 'gemini-2.0-flash-lite' | 'gemini-2.0-flash' | 'gemini-2.0-flash-001' | 'gemini-1.5-flash' | 'gemini-1.5-flash-001' | 'gemini-1.5-flash-002' | 'gemini-1.5-pro' | 'gemini-1.5-pro-001' | 'gemini-1.5-pro-002' | 'gemini-1.0-pro-001' | 'gemini-1.0-pro-vision-001' | 'gemini-1.0-pro' | 'gemini-1.0-pro-002' | 'gemini-2.0-flash-lite-preview-02-05' | 'gemini-2.5-flash-preview-09-2025' | 'gemini-3-pro-preview' | 'gemini-3-pro-image-preview' | 'gemini-3-flash-preview' | 'gemini-3.1-pro-preview' | 'gemini-3.1-flash-image-preview' | 'gemini-3.1-flash-lite-preview' | 'gemini-2.0-pro-exp-02-05' | 'gemini-2.0-flash-exp' | (string & {});
42
42
  //#endregion
43
43
  //#region src/google-vertex-tools.d.ts
44
44
  declare const googleVertexTools: {
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":["GoogleVertexProviderSettings","GoogleVertexProviderSettingsOriginal"],"sources":["../../src/google-vertex-embedding-model-options.ts","../../src/google-vertex-config.ts","../../src/google-vertex-embedding-model.ts","../../src/google-vertex-image-settings.ts","../../src/google-vertex-options.ts","../../src/google-vertex-tools.ts","../../src/google-vertex-transcription-model-options.ts","../../src/google-vertex-video-settings.ts","../../src/google-vertex-speech-model-options.ts","../../src/google-vertex-provider-base.ts","../../src/edge/google-vertex-auth-edge.ts","../../src/edge/google-vertex-provider-edge.ts"],"mappings":";;;;;;KAGY;;;UCDK;EACf;EACA;EACA,UAAU,WAAW;EACrB,QAAQ;;;;cCgBG,sCAAsC;WACxC;WACA,SAAS;WACT;mBAEQ;UAET,oBAAoB,OAAO;;;;UAO3B,sBAAsB;IAC5B;IACA,QAAQ;MACT;MAIG;MAMA;EAKF,YAAA,SAAS,8BACT,QAAQ;EAMJ,UACJ,QACA,YACA,SACA,aACA,mBACC,WAAW,kCAAkC,QAC9C,QAAQ,WAAW;;;;KCpEX;;;KCGA;;;cCDC;;;;MASk+mB,YAAC;MAAsD,cAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KCP3hnB;;;KCJA;;;KCMA;;;UCqEK,6BAA6B;;;;GAI3C,SAAS,sBAAsB;EAEhC,gBAAgB,SAAS,wBAAwB;;;;;;;EAQjD,aACE,gBACI;IACE,OAAO;;IACP;MACL;;;;EAKH,MAAM,SAAS,2BAA2B;;;;EAK1C,WAAW,SAAS,2BAA2B;EAE/C,cAAc;;;;EAKd,mBACE,SAAS,+BACR;;;;EAKH,MAAM,SAAS,2BAA2B;;;;EAK1C,WAAW,SAAS,2BAA2B;;;;EAK/C,OAAO,SAAS,4BAA4B;;;;EAK5C,YAAY,SAAS,4BAA4B;;;;EAKjD,cACE,SAAS,mCACR;;;;EAKH,mBACE,SAAS,mCACR;;UAGYA;;;;;;EAMf;;;;EAKA;;;;EAKA;;;;;;;;EASA,UAAU,WAAW;;;;;EAMrB,QAAQ;EAGR;;;;EAKA;;;;;;EAOA,YAAY;;;;;EAMZ;;;;IAIE;;;;;UCtMa;;;;;EAKf;;;;;EAMA;;;;;EAMA;;;;UCbe,qCAAqCC;;;;;;EAMpD,oBAAoB;;wBAGN,mBACd,UAAS,+BACR;;;;qBAwBU,cAAY"}
1
+ {"version":3,"file":"index.d.ts","names":["GoogleVertexProviderSettings","GoogleVertexProviderSettingsOriginal"],"sources":["../../src/google-vertex-embedding-model-options.ts","../../src/google-vertex-config.ts","../../src/google-vertex-embedding-model.ts","../../src/google-vertex-image-settings.ts","../../src/google-vertex-options.ts","../../src/google-vertex-tools.ts","../../src/google-vertex-transcription-model-options.ts","../../src/google-vertex-video-settings.ts","../../src/google-vertex-speech-model-options.ts","../../src/google-vertex-provider-base.ts","../../src/edge/google-vertex-auth-edge.ts","../../src/edge/google-vertex-provider-edge.ts"],"mappings":";;;;;;KAGY;;;UCDK;EACf;EACA;EACA,UAAU,WAAW;EACrB,QAAQ;;;;cCgBG,sCAAsC;WACxC;WACA,SAAS;WACT;mBAEQ;UAET,oBAAoB,OAAO;;;;UAO3B,sBAAsB;IAC5B;IACA,QAAQ;MACT;MAIG;MAMA;EAKF,YAAA,SAAS,8BACT,QAAQ;EAMJ,UACJ,QACA,YACA,SACA,aACA,mBACC,WAAW,kCAAkC,QAC9C,QAAQ,WAAW;;;;KCpEX;;;KCGA;;;cCDC;;;;MAS4pnB,YAAC;MAAsD,cAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KCPrtnB;;;KCJA;;;KCMA;;;UCqEK,6BAA6B;;;;GAI3C,SAAS,sBAAsB;EAEhC,gBAAgB,SAAS,wBAAwB;;;;;;;EAQjD,aACE,gBACI;IACE,OAAO;;IACP;MACL;;;;EAKH,MAAM,SAAS,2BAA2B;;;;EAK1C,WAAW,SAAS,2BAA2B;EAE/C,cAAc;;;;EAKd,mBACE,SAAS,+BACR;;;;EAKH,MAAM,SAAS,2BAA2B;;;;EAK1C,WAAW,SAAS,2BAA2B;;;;EAK/C,OAAO,SAAS,4BAA4B;;;;EAK5C,YAAY,SAAS,4BAA4B;;;;EAKjD,cACE,SAAS,mCACR;;;;EAKH,mBACE,SAAS,mCACR;;UAGYA;;;;;;EAMf;;;;EAKA;;;;EAKA;;;;;;;;EASA,UAAU,WAAW;;;;;EAMrB,QAAQ;EAGR;;;;EAKA;;;;;;EAOA,YAAY;;;;;EAMZ;;;;IAIE;;;;;UCtMa;;;;;EAKf;;;;;EAMA;;;;;EAMA;;;;UCbe,qCAAqCC;;;;;;EAMpD,oBAAoB;;wBAGN,mBACd,UAAS,+BACR;;;;qBAwBU,cAAY"}
@@ -3,7 +3,7 @@ import { GoogleInteractionsLanguageModel, GoogleLanguageModel, GoogleSpeechModel
3
3
  import { AISDKError, InvalidArgumentError, TooManyEmbeddingValuesForCallError } from "@ai-sdk/provider";
4
4
  import { z } from "zod/v4";
5
5
  //#region src/version.ts
6
- const VERSION = "5.0.110";
6
+ const VERSION = "5.0.112";
7
7
  //#endregion
8
8
  //#region src/google-vertex-error.ts
9
9
  const googleVertexErrorDataSchema = z.object({ error: z.object({
package/dist/index.d.ts CHANGED
@@ -90,7 +90,7 @@ declare class GoogleVertexEmbeddingModel implements EmbeddingModelV4 {
90
90
  type GoogleVertexImageModelId = 'gemini-2.5-flash-image' | 'gemini-3-pro-image-preview' | 'gemini-3.1-flash-image-preview' | 'gemini-nano-banana-2.1' | (string & {});
91
91
  //#endregion
92
92
  //#region src/google-vertex-options.d.ts
93
- type GoogleVertexModelId = 'gemini-nano-banana-2.1' | 'gemini-3.8-flash' | 'gemini-3.7-flash' | 'gemini-3.6-flash' | 'gemini-3.5-flash' | 'gemini-3.5-flash-lite' | 'gemini-2.5-pro' | 'gemini-2.5-flash' | 'gemini-2.5-flash-lite' | 'gemini-2.0-flash-lite' | 'gemini-2.0-flash' | 'gemini-2.0-flash-001' | 'gemini-1.5-flash' | 'gemini-1.5-flash-001' | 'gemini-1.5-flash-002' | 'gemini-1.5-pro' | 'gemini-1.5-pro-001' | 'gemini-1.5-pro-002' | 'gemini-1.0-pro-001' | 'gemini-1.0-pro-vision-001' | 'gemini-1.0-pro' | 'gemini-1.0-pro-002' | 'gemini-2.0-flash-lite-preview-02-05' | 'gemini-2.5-flash-preview-09-2025' | 'gemini-3-pro-preview' | 'gemini-3-pro-image-preview' | 'gemini-3-flash-preview' | 'gemini-3.1-pro-preview' | 'gemini-3.1-flash-image-preview' | 'gemini-3.1-flash-lite-preview' | 'gemini-2.0-pro-exp-02-05' | 'gemini-2.0-flash-exp' | (string & {});
93
+ type GoogleVertexModelId = 'gemini-nano-banana-2.1' | 'gemini-4-argon' | 'gemini-3.8-flash' | 'gemini-3.7-flash' | 'gemini-3.6-flash' | 'gemini-3.5-flash' | 'gemini-3.5-flash-lite' | 'gemini-2.5-pro' | 'gemini-2.5-flash' | 'gemini-2.5-flash-lite' | 'gemini-2.0-flash-lite' | 'gemini-2.0-flash' | 'gemini-2.0-flash-001' | 'gemini-1.5-flash' | 'gemini-1.5-flash-001' | 'gemini-1.5-flash-002' | 'gemini-1.5-pro' | 'gemini-1.5-pro-001' | 'gemini-1.5-pro-002' | 'gemini-1.0-pro-001' | 'gemini-1.0-pro-vision-001' | 'gemini-1.0-pro' | 'gemini-1.0-pro-002' | 'gemini-2.0-flash-lite-preview-02-05' | 'gemini-2.5-flash-preview-09-2025' | 'gemini-3-pro-preview' | 'gemini-3-pro-image-preview' | 'gemini-3-flash-preview' | 'gemini-3.1-pro-preview' | 'gemini-3.1-flash-image-preview' | 'gemini-3.1-flash-lite-preview' | 'gemini-2.0-pro-exp-02-05' | 'gemini-2.0-flash-exp' | (string & {});
94
94
  //#endregion
95
95
  //#region src/google-vertex-tools.d.ts
96
96
  declare const googleVertexTools: {
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":["GoogleVertexProviderSettings","GoogleVertexProviderSettingsOriginal","TranscriptionModelV4StreamOptions"],"sources":["../src/google-vertex-embedding-model-options.ts","../src/google-vertex-transcription-model-options.ts","../src/google-vertex-image-model-options.ts","../src/google-vertex-video-model-options.ts","../src/google-vertex-video-settings.ts","../src/google-vertex-speech-model-options.ts","../src/google-vertex-config.ts","../src/google-vertex-embedding-model.ts","../src/google-vertex-image-settings.ts","../src/google-vertex-options.ts","../src/google-vertex-tools.ts","../src/google-vertex-provider-base.ts","../src/google-vertex-provider.ts","../src/gemini-transcription/google-vertex-gemini-transcription-model-options.ts","../src/gemini-transcription/google-vertex-gemini-transcription-model.ts","../src/version.ts"],"mappings":";;;;;;;KAGY;cAcC,mCAAiC,EAAA;;;;;;;;;;;;;;GA4C5C,EAAA,KAAA;KAEU,oCAAoC,EAAE,aACzC;;;KC5DG;cAMC,gDAA8C,EAAA;;;;;GAgCzD,EAAA,KAAA;KAEU,wCAAwC,EAAE,aAC7C;;;KC3CG,gCAAgC,KAC1C;;;KCAU;EAEV;EACA;EAGA;EACA;EACA;EAGA;EAGA,kBAAkB;IAChB;IACA;;GAGD;;;;KCtBS;;;KCMA;KAQA,iCAAiC;;;UCZ5B;EACf;EACA;EACA,UAAU,WAAW;EACrB,QAAQ;;;;cCgBG,sCAAsC;WACxC;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Q;MACT;MAOG;EAKO,YAAA,SAAS,wCACD,QAAQ;UAGb;EAeR,WACJ,SAAS,WAAW,yCACnB,QAAQ,QAAQ,WAAW;EAwGxB,SACJ,SAASC,iDACR,QACD,QAAQ,WAAW,YAAY;;;;qBCpQtB"}
1
+ {"version":3,"file":"index.d.ts","names":["GoogleVertexProviderSettings","GoogleVertexProviderSettingsOriginal","TranscriptionModelV4StreamOptions"],"sources":["../src/google-vertex-embedding-model-options.ts","../src/google-vertex-transcription-model-options.ts","../src/google-vertex-image-model-options.ts","../src/google-vertex-video-model-options.ts","../src/google-vertex-video-settings.ts","../src/google-vertex-speech-model-options.ts","../src/google-vertex-config.ts","../src/google-vertex-embedding-model.ts","../src/google-vertex-image-settings.ts","../src/google-vertex-options.ts","../src/google-vertex-tools.ts","../src/google-vertex-provider-base.ts","../src/google-vertex-provider.ts","../src/gemini-transcription/google-vertex-gemini-transcription-model-options.ts","../src/gemini-transcription/google-vertex-gemini-transcription-model.ts","../src/version.ts"],"mappings":";;;;;;;KAGY;cAcC,mCAAiC,EAAA;;;;;;;;;;;;;;GA4C5C,EAAA,KAAA;KAEU,oCAAoC,EAAE,aACzC;;;KC5DG;cAMC,gDAA8C,EAAA;;;;;GAgCzD,EAAA,KAAA;KAEU,wCAAwC,EAAE,aAC7C;;;KC3CG,gCAAgC,KAC1C;;;KCAU;EAEV;EACA;EAGA;EACA;EACA;EAGA;EAGA,kBAAkB;IAChB;IACA;;GAGD;;;;KCtBS;;;KCMA;KAQA,iCAAiC;;;UCZ5B;EACf;EACA;EACA,UAAU,WAAW;EACrB,QAAQ;;;;cCgBG,sCAAsC;WACxC;WACA,SAAS;WACT;mBAEQ;UAET,oBAAoB,OAAO;;;;UAO3B,sBAAsB;IAC5B;IACA,QAAQ;MACT;MAIG;MAMA;EAKF,YAAA,SAAS,8BACT,QAAQ;EAMJ,UACJ,QACA,YACA,SACA,aACA,mBACC,WAAW,kCAAkC,QAC9C,QAAQ,WAAW;;;;KCpEX;;;KC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enerator(options) {
15
15
  }
16
16
  //#endregion
17
17
  //#region src/version.ts
18
- const VERSION = "5.0.110";
18
+ const VERSION = "5.0.112";
19
19
  //#endregion
20
20
  //#region src/google-vertex-error.ts
21
21
  const googleVertexErrorDataSchema = z.object({ error: z.object({
@@ -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.110";
5
+ const VERSION = "5.0.112";
6
6
  //#endregion
7
7
  //#region src/edge/google-vertex-auth-edge.ts
8
8
  const loadCredentials = async () => {
@@ -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.110";
5
+ const VERSION = "5.0.112";
6
6
  //#endregion
7
7
  //#region src/edge/google-vertex-auth-edge.ts
8
8
  const loadCredentials = async () => {
@@ -713,6 +713,16 @@ const { text } = await generateText({
713
713
 
714
714
  See [File Parts](/docs/foundations/prompts#file-parts) for details on how to use files in prompts.
715
715
 
716
+ ### Long decode
717
+
718
+ Gemini 4 models such as `gemini-4-argon` support long decode on Vertex AI the
719
+ same way as on the Gemini API: set `maxOutputTokens` above the per-request cap
720
+ (up to 1M minus input) and the provider continues the response automatically.
721
+ See [Long decode](/providers/ai-sdk-providers/google#long-decode) for details
722
+ on budgets, usage across requests, and resuming with a continuation token.
723
+
724
+ The Vertex AI Interactions API (preview) does not support long decode.
725
+
716
726
  ### Tool Result Files
717
727
 
718
728
  For Gemini 3 and later models, tool results can include Google Cloud Storage
@@ -953,6 +963,7 @@ The following Zod features are known to not work with Google Vertex:
953
963
  | Model | Image Input | Object Generation | Tool Usage | Tool Streaming |
954
964
  | ------------------------ | ----------- | ----------------- | ---------- | -------------- |
955
965
  | `gemini-nano-banana-2.1` | <Check /> | <Cross /> | <Cross /> | <Cross /> |
966
+ | `gemini-4-argon` | <Check /> | <Check /> | <Check /> | <Check /> |
956
967
  | `gemini-3.8-flash` | <Check /> | <Check /> | <Check /> | <Check /> |
957
968
  | `gemini-3.7-flash` | <Check /> | <Check /> | <Check /> | <Check /> |
958
969
  | `gemini-3.6-flash` | <Check /> | <Check /> | <Check /> | <Check /> |
@@ -1598,6 +1609,34 @@ The following optional provider options are available for Anthropic models:
1598
1609
  Optional. Metadata to include with the request. See the [Anthropic API documentation](https://platform.claude.com/docs/en/api/messages/create) for details.
1599
1610
  - `userId` _string_ - An external identifier for the end-user.
1600
1611
 
1612
+ ### Billing Labels
1613
+
1614
+ Pass billing labels for Claude requests using `providerOptions.vertex.labels`.
1615
+ Labels are a map of string keys to string values and work with both
1616
+ `generateText` and `streamText`:
1617
+
1618
+ ```ts
1619
+ import { vertexAnthropic } from '@ai-sdk/google-vertex/anthropic';
1620
+ import { generateText } from 'ai';
1621
+
1622
+ const { text } = await generateText({
1623
+ model: vertexAnthropic('claude-sonnet-4-6@default'),
1624
+ prompt: 'Write a vegetarian lasagna recipe for 4 people.',
1625
+ providerOptions: {
1626
+ vertex: {
1627
+ labels: { team: 'data-platform', feature: 'my-app' },
1628
+ },
1629
+ },
1630
+ });
1631
+ ```
1632
+
1633
+ The provider sends the labels as base64-encoded UTF-8 JSON in the
1634
+ `X-Vertex-AI-Labels` header. An explicitly supplied labels header takes
1635
+ precedence over `providerOptions.vertex.labels`.
1636
+
1637
+ See [Google's billing labels documentation](https://docs.cloud.google.com/vertex-ai/generative-ai/docs/multimodal/add-labels-to-api-calls#add_a_label_to_a_partner_model_api_call)
1638
+ for label requirements and supported billing options.
1639
+
1601
1640
  ### Reasoning
1602
1641
 
1603
1642
  Anthropic has reasoning support for the `claude-3-7-sonnet@20250219` model.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-sdk/google-vertex",
3
- "version": "5.0.110",
3
+ "version": "5.0.112",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "sideEffects": false,
@@ -71,11 +71,11 @@
71
71
  }
72
72
  },
73
73
  "dependencies": {
74
- "@ai-sdk/anthropic": "4.0.79",
75
- "@ai-sdk/google": "4.0.94",
76
- "@ai-sdk/openai-compatible": "3.0.68",
74
+ "@ai-sdk/anthropic": "4.0.80",
75
+ "@ai-sdk/google": "4.0.96",
76
+ "@ai-sdk/openai-compatible": "3.0.69",
77
77
  "@ai-sdk/provider": "4.0.27",
78
- "@ai-sdk/provider-utils": "5.0.59",
78
+ "@ai-sdk/provider-utils": "5.0.60",
79
79
  "google-auth-library": "^10.6.2"
80
80
  },
81
81
  "devDependencies": {
@@ -1,3 +1,14 @@
1
+ import { lazySchema, zodSchema } from '@ai-sdk/provider-utils';
2
+ import { z } from 'zod/v4';
3
+
4
+ export const googleVertexAnthropicProviderOptions = lazySchema(() =>
5
+ zodSchema(
6
+ z.object({
7
+ labels: z.record(z.string(), z.string()).optional(),
8
+ }),
9
+ ),
10
+ );
11
+
1
12
  // https://cloud.google.com/vertex-ai/generative-ai/docs/partner-models/claude
2
13
  export type GoogleVertexAnthropicModelId =
3
14
  | 'claude-sonnet-5'
@@ -5,8 +5,10 @@ import {
5
5
  type ProviderV4,
6
6
  } from '@ai-sdk/provider';
7
7
  import {
8
+ convertUint8ArrayToBase64,
8
9
  isValidHostnamePart,
9
10
  loadOptionalSetting,
11
+ parseProviderOptions,
10
12
  withoutTrailingSlash,
11
13
  type FetchFunction,
12
14
  type Resolvable,
@@ -15,7 +17,10 @@ import {
15
17
  anthropicTools,
16
18
  AnthropicLanguageModel,
17
19
  } from '@ai-sdk/anthropic/internal';
18
- import type { GoogleVertexAnthropicModelId } from './google-vertex-anthropic-options';
20
+ import {
21
+ googleVertexAnthropicProviderOptions,
22
+ type GoogleVertexAnthropicModelId,
23
+ } from './google-vertex-anthropic-options';
19
24
 
20
25
  type GoogleVertexAnthropicTools = Pick<
21
26
  typeof anthropicTools,
@@ -232,6 +237,32 @@ export function createGoogleVertexAnthropic(
232
237
  anthropic_version: 'vertex-2023-10-16',
233
238
  };
234
239
  },
240
+ transformRequestHeaders: async (headers, providerOptions) => {
241
+ const vertexOptions = await parseProviderOptions({
242
+ provider: 'vertex',
243
+ providerOptions,
244
+ schema: googleVertexAnthropicProviderOptions,
245
+ });
246
+
247
+ // Explicit headers take precedence, regardless of their casing.
248
+ if (
249
+ vertexOptions?.labels == null ||
250
+ Object.keys(headers).some(
251
+ name =>
252
+ name.toLowerCase() === 'x-vertex-ai-labels' &&
253
+ headers[name] != null,
254
+ )
255
+ ) {
256
+ return headers;
257
+ }
258
+
259
+ return {
260
+ ...headers,
261
+ 'x-vertex-ai-labels': convertUint8ArrayToBase64(
262
+ new TextEncoder().encode(JSON.stringify(vertexOptions.labels)),
263
+ ),
264
+ };
265
+ },
235
266
  // Google Vertex Anthropic doesn't support URL sources, force download and base64 conversion
236
267
  supportedUrls: () => ({}),
237
268
  // force the use of JSON tool fallback for structured outputs since beta header isn't supported
@@ -4,6 +4,7 @@
4
4
  export type GoogleVertexModelId =
5
5
  // Stable models
6
6
  | 'gemini-nano-banana-2.1'
7
+ | 'gemini-4-argon'
7
8
  | 'gemini-3.8-flash'
8
9
  | 'gemini-3.7-flash'
9
10
  | 'gemini-3.6-flash'