@ai-sdk/google-vertex 5.0.0-beta.11 → 5.0.0-beta.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.
Files changed (80) hide show
  1. package/CHANGELOG.md +954 -8
  2. package/README.md +65 -2
  3. package/dist/anthropic/edge/index.d.ts +18 -151
  4. package/dist/anthropic/edge/index.js +88 -70
  5. package/dist/anthropic/edge/index.js.map +1 -1
  6. package/dist/anthropic/index.d.ts +18 -151
  7. package/dist/anthropic/index.js +88 -81
  8. package/dist/anthropic/index.js.map +1 -1
  9. package/dist/edge/index.d.ts +49 -20
  10. package/dist/edge/index.js +629 -278
  11. package/dist/edge/index.js.map +1 -1
  12. package/dist/index.d.ts +61 -23
  13. package/dist/index.js +638 -296
  14. package/dist/index.js.map +1 -1
  15. package/dist/maas/edge/index.d.ts +76 -0
  16. package/dist/maas/edge/index.js +209 -0
  17. package/dist/maas/edge/index.js.map +1 -0
  18. package/dist/maas/index.d.ts +60 -0
  19. package/dist/maas/index.js +109 -0
  20. package/dist/maas/index.js.map +1 -0
  21. package/dist/xai/edge/index.d.ts +92 -0
  22. package/dist/xai/edge/index.js +259 -0
  23. package/dist/xai/edge/index.js.map +1 -0
  24. package/dist/xai/index.d.ts +76 -0
  25. package/dist/xai/index.js +159 -0
  26. package/dist/xai/index.js.map +1 -0
  27. package/docs/16-google-vertex.mdx +640 -102
  28. package/maas/edge.d.ts +1 -0
  29. package/maas/index.d.ts +1 -0
  30. package/package.json +49 -24
  31. package/src/anthropic/edge/google-vertex-anthropic-provider-edge.ts +17 -13
  32. package/src/anthropic/edge/index.ts +6 -2
  33. package/src/anthropic/{google-vertex-anthropic-messages-options.ts → google-vertex-anthropic-options.ts} +4 -1
  34. package/src/anthropic/google-vertex-anthropic-provider-node.ts +18 -13
  35. package/src/anthropic/google-vertex-anthropic-provider.ts +68 -19
  36. package/src/anthropic/index.ts +6 -2
  37. package/src/edge/google-vertex-provider-edge.ts +10 -12
  38. package/src/edge/index.ts +8 -1
  39. package/src/google-vertex-auth-google-auth-library.ts +13 -26
  40. package/src/google-vertex-config.ts +2 -2
  41. package/src/{google-vertex-embedding-options.ts → google-vertex-embedding-model-options.ts} +1 -0
  42. package/src/google-vertex-embedding-model.ts +90 -7
  43. package/src/google-vertex-image-model-options.ts +74 -0
  44. package/src/google-vertex-image-model.ts +89 -116
  45. package/src/google-vertex-options.ts +1 -1
  46. package/src/google-vertex-provider-base.ts +311 -0
  47. package/src/google-vertex-provider.ts +43 -233
  48. package/src/google-vertex-speech-model-options.ts +11 -0
  49. package/src/google-vertex-transcription-model-options.ts +46 -0
  50. package/src/google-vertex-transcription-model.ts +231 -0
  51. package/src/google-vertex-video-model-options.ts +49 -0
  52. package/src/google-vertex-video-model.ts +38 -71
  53. package/src/index.ts +20 -5
  54. package/src/maas/edge/google-vertex-maas-provider-edge.ts +64 -0
  55. package/src/maas/edge/index.ts +13 -0
  56. package/src/maas/google-vertex-maas-options.ts +15 -0
  57. package/src/maas/google-vertex-maas-provider-node.ts +65 -0
  58. package/src/maas/google-vertex-maas-provider.ts +122 -0
  59. package/src/maas/index.ts +13 -0
  60. package/src/xai/edge/google-vertex-xai-provider-edge.ts +61 -0
  61. package/src/xai/edge/index.ts +9 -0
  62. package/src/xai/google-vertex-xai-options.ts +7 -0
  63. package/src/xai/google-vertex-xai-provider-node.ts +62 -0
  64. package/src/xai/google-vertex-xai-provider.ts +212 -0
  65. package/src/xai/index.ts +9 -0
  66. package/xai/edge.d.ts +1 -0
  67. package/xai/index.d.ts +1 -0
  68. package/dist/anthropic/edge/index.d.mts +0 -231
  69. package/dist/anthropic/edge/index.mjs +0 -259
  70. package/dist/anthropic/edge/index.mjs.map +0 -1
  71. package/dist/anthropic/index.d.mts +0 -215
  72. package/dist/anthropic/index.mjs +0 -164
  73. package/dist/anthropic/index.mjs.map +0 -1
  74. package/dist/edge/index.d.mts +0 -160
  75. package/dist/edge/index.mjs +0 -1049
  76. package/dist/edge/index.mjs.map +0 -1
  77. package/dist/index.d.mts +0 -219
  78. package/dist/index.mjs +0 -960
  79. package/dist/index.mjs.map +0 -1
  80. package/src/google-vertex-provider-node.ts +0 -49
package/dist/index.js CHANGED
@@ -1,92 +1,80 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/index.ts
21
- var src_exports = {};
22
- __export(src_exports, {
23
- VERSION: () => VERSION,
24
- createVertex: () => createVertex2,
25
- vertex: () => vertex
26
- });
27
- module.exports = __toCommonJS(src_exports);
28
-
29
- // src/google-vertex-provider-node.ts
30
- var import_provider_utils6 = require("@ai-sdk/provider-utils");
1
+ // src/google-vertex-provider.ts
2
+ import { loadOptionalSetting as loadOptionalSetting2, resolve as resolve6 } from "@ai-sdk/provider-utils";
31
3
 
32
4
  // src/google-vertex-auth-google-auth-library.ts
33
- var import_google_auth_library = require("google-auth-library");
34
- var authInstance = null;
35
- var authOptions = null;
36
- function getAuth(options) {
37
- if (!authInstance || options !== authOptions) {
38
- authInstance = new import_google_auth_library.GoogleAuth({
39
- scopes: ["https://www.googleapis.com/auth/cloud-platform"],
40
- ...options
41
- });
42
- authOptions = options;
43
- }
44
- return authInstance;
45
- }
46
- async function generateAuthToken(options) {
47
- const auth = getAuth(options || {});
48
- const client = await auth.getClient();
49
- const token = await client.getAccessToken();
50
- return (token == null ? void 0 : token.token) || null;
5
+ import { GoogleAuth } from "google-auth-library";
6
+ function createAuthTokenGenerator(options) {
7
+ const auth = new GoogleAuth({
8
+ scopes: ["https://www.googleapis.com/auth/cloud-platform"],
9
+ ...options
10
+ });
11
+ return async function generateAuthToken() {
12
+ var _a;
13
+ const client = await auth.getClient();
14
+ const token = await client.getAccessToken();
15
+ return (_a = token == null ? void 0 : token.token) != null ? _a : null;
16
+ };
51
17
  }
52
18
 
53
- // src/google-vertex-provider.ts
54
- var import_internal3 = require("@ai-sdk/google/internal");
55
- var import_provider_utils5 = require("@ai-sdk/provider-utils");
19
+ // src/google-vertex-provider-base.ts
20
+ import {
21
+ GoogleLanguageModel as GoogleLanguageModel2,
22
+ GoogleSpeechModel
23
+ } from "@ai-sdk/google/internal";
24
+ import {
25
+ generateId,
26
+ loadOptionalSetting,
27
+ loadSetting,
28
+ normalizeHeaders,
29
+ resolve as resolve5,
30
+ withoutTrailingSlash,
31
+ withUserAgentSuffix
32
+ } from "@ai-sdk/provider-utils";
56
33
 
57
34
  // src/version.ts
58
- var VERSION = true ? "5.0.0-beta.11" : "0.0.0-test";
35
+ var VERSION = true ? "5.0.0-beta.112" : "0.0.0-test";
59
36
 
60
37
  // src/google-vertex-embedding-model.ts
61
- var import_provider = require("@ai-sdk/provider");
62
- var import_provider_utils2 = require("@ai-sdk/provider-utils");
63
- var import_v43 = require("zod/v4");
38
+ import {
39
+ TooManyEmbeddingValuesForCallError
40
+ } from "@ai-sdk/provider";
41
+ import {
42
+ combineHeaders,
43
+ createJsonResponseHandler,
44
+ postJsonToApi,
45
+ resolve,
46
+ parseProviderOptions,
47
+ serializeModelOptions,
48
+ WORKFLOW_SERIALIZE,
49
+ WORKFLOW_DESERIALIZE
50
+ } from "@ai-sdk/provider-utils";
51
+ import { z as z3 } from "zod/v4";
64
52
 
65
53
  // src/google-vertex-error.ts
66
- var import_provider_utils = require("@ai-sdk/provider-utils");
67
- var import_v4 = require("zod/v4");
68
- var googleVertexErrorDataSchema = import_v4.z.object({
69
- error: import_v4.z.object({
70
- code: import_v4.z.number().nullable(),
71
- message: import_v4.z.string(),
72
- status: import_v4.z.string()
54
+ import { createJsonErrorResponseHandler } from "@ai-sdk/provider-utils";
55
+ import { z } from "zod/v4";
56
+ var googleVertexErrorDataSchema = z.object({
57
+ error: z.object({
58
+ code: z.number().nullable(),
59
+ message: z.string(),
60
+ status: z.string()
73
61
  })
74
62
  });
75
- var googleVertexFailedResponseHandler = (0, import_provider_utils.createJsonErrorResponseHandler)(
63
+ var googleVertexFailedResponseHandler = createJsonErrorResponseHandler(
76
64
  {
77
65
  errorSchema: googleVertexErrorDataSchema,
78
66
  errorToMessage: (data) => data.error.message
79
67
  }
80
68
  );
81
69
 
82
- // src/google-vertex-embedding-options.ts
83
- var import_v42 = require("zod/v4");
84
- var googleVertexEmbeddingModelOptions = import_v42.z.object({
70
+ // src/google-vertex-embedding-model-options.ts
71
+ import { z as z2 } from "zod/v4";
72
+ var googleVertexEmbeddingModelOptions = z2.object({
85
73
  /**
86
74
  * Optional. Optional reduced dimension for the output embedding.
87
75
  * If set, excessive values in the output embedding are truncated from the end.
88
76
  */
89
- outputDimensionality: import_v42.z.number().optional(),
77
+ outputDimensionality: z2.number().optional(),
90
78
  /**
91
79
  * Optional. Specifies the task type for generating embeddings.
92
80
  * Supported task types:
@@ -99,7 +87,7 @@ var googleVertexEmbeddingModelOptions = import_v42.z.object({
99
87
  * - FACT_VERIFICATION: Optimized for verifying factual information.
100
88
  * - CODE_RETRIEVAL_QUERY: Optimized for retrieving code blocks based on natural language queries.
101
89
  */
102
- taskType: import_v42.z.enum([
90
+ taskType: z2.enum([
103
91
  "SEMANTIC_SIMILARITY",
104
92
  "CLASSIFICATION",
105
93
  "CLUSTERING",
@@ -114,39 +102,60 @@ var googleVertexEmbeddingModelOptions = import_v42.z.object({
114
102
  * Only valid when task_type is set to 'RETRIEVAL_DOCUMENT'.
115
103
  * Helps the model produce better embeddings by providing additional context.
116
104
  */
117
- title: import_v42.z.string().optional(),
105
+ title: z2.string().optional(),
118
106
  /**
119
107
  * Optional. When set to true, input text will be truncated. When set to false,
120
108
  * an error is returned if the input text is longer than the maximum length supported by the model. Defaults to true.
121
109
  */
122
- autoTruncate: import_v42.z.boolean().optional()
110
+ autoTruncate: z2.boolean().optional()
123
111
  });
124
112
 
125
113
  // src/google-vertex-embedding-model.ts
126
- var GoogleVertexEmbeddingModel = class {
114
+ var GoogleVertexEmbeddingModel = class _GoogleVertexEmbeddingModel {
127
115
  constructor(modelId, config) {
128
116
  this.specificationVersion = "v4";
129
- this.maxEmbeddingsPerCall = 2048;
130
117
  this.supportsParallelCalls = true;
131
118
  this.modelId = modelId;
132
119
  this.config = config;
133
120
  }
121
+ static [WORKFLOW_SERIALIZE](model) {
122
+ return serializeModelOptions({
123
+ modelId: model.modelId,
124
+ config: model.config
125
+ });
126
+ }
127
+ static [WORKFLOW_DESERIALIZE](options) {
128
+ return new _GoogleVertexEmbeddingModel(options.modelId, options.config);
129
+ }
134
130
  get provider() {
135
131
  return this.config.provider;
136
132
  }
133
+ // gemini-embedding-2 models only support :embedContent (one value per call),
134
+ // not the :predict batch endpoint. https://github.com/vercel/ai/issues/15853
135
+ get maxEmbeddingsPerCall() {
136
+ return usesEmbedContentEndpoint(this.modelId) ? 1 : 2048;
137
+ }
137
138
  async doEmbed({
138
139
  values,
139
140
  headers,
140
141
  abortSignal,
141
142
  providerOptions
142
143
  }) {
143
- let googleOptions = await (0, import_provider_utils2.parseProviderOptions)({
144
- provider: "vertex",
144
+ var _a;
145
+ let googleOptions = await parseProviderOptions({
146
+ provider: "googleVertex",
145
147
  providerOptions,
146
148
  schema: googleVertexEmbeddingModelOptions
147
149
  });
148
150
  if (googleOptions == null) {
149
- googleOptions = await (0, import_provider_utils2.parseProviderOptions)({
151
+ googleOptions = await parseProviderOptions({
152
+ provider: "vertex",
153
+ providerOptions,
154
+ schema: googleVertexEmbeddingModelOptions
155
+ });
156
+ }
157
+ if (googleOptions == null) {
158
+ googleOptions = await parseProviderOptions({
150
159
  provider: "google",
151
160
  providerOptions,
152
161
  schema: googleVertexEmbeddingModelOptions
@@ -154,23 +163,54 @@ var GoogleVertexEmbeddingModel = class {
154
163
  }
155
164
  googleOptions = googleOptions != null ? googleOptions : {};
156
165
  if (values.length > this.maxEmbeddingsPerCall) {
157
- throw new import_provider.TooManyEmbeddingValuesForCallError({
166
+ throw new TooManyEmbeddingValuesForCallError({
158
167
  provider: this.provider,
159
168
  modelId: this.modelId,
160
169
  maxEmbeddingsPerCall: this.maxEmbeddingsPerCall,
161
170
  values
162
171
  });
163
172
  }
164
- const mergedHeaders = (0, import_provider_utils2.combineHeaders)(
165
- await (0, import_provider_utils2.resolve)(this.config.headers),
173
+ const mergedHeaders = combineHeaders(
174
+ this.config.headers ? await resolve(this.config.headers) : void 0,
166
175
  headers
167
176
  );
177
+ if (usesEmbedContentEndpoint(this.modelId)) {
178
+ const {
179
+ responseHeaders: responseHeaders2,
180
+ value: response2,
181
+ rawValue: rawValue2
182
+ } = await postJsonToApi({
183
+ url: `${this.config.baseURL}/models/${this.modelId}:embedContent`,
184
+ headers: mergedHeaders,
185
+ body: {
186
+ content: { parts: [{ text: values[0] }] },
187
+ embedContentConfig: {
188
+ outputDimensionality: googleOptions.outputDimensionality,
189
+ taskType: googleOptions.taskType,
190
+ title: googleOptions.title,
191
+ autoTruncate: googleOptions.autoTruncate
192
+ }
193
+ },
194
+ failedResponseHandler: googleVertexFailedResponseHandler,
195
+ successfulResponseHandler: createJsonResponseHandler(
196
+ googleVertexEmbedContentResponseSchema
197
+ ),
198
+ abortSignal,
199
+ fetch: this.config.fetch
200
+ });
201
+ return {
202
+ warnings: [],
203
+ embeddings: [response2.embedding.values],
204
+ usage: ((_a = response2.usageMetadata) == null ? void 0 : _a.promptTokenCount) == null ? void 0 : { tokens: response2.usageMetadata.promptTokenCount },
205
+ response: { headers: responseHeaders2, body: rawValue2 }
206
+ };
207
+ }
168
208
  const url = `${this.config.baseURL}/models/${this.modelId}:predict`;
169
209
  const {
170
210
  responseHeaders,
171
211
  value: response,
172
212
  rawValue
173
- } = await (0, import_provider_utils2.postJsonToApi)({
213
+ } = await postJsonToApi({
174
214
  url,
175
215
  headers: mergedHeaders,
176
216
  body: {
@@ -185,7 +225,7 @@ var GoogleVertexEmbeddingModel = class {
185
225
  }
186
226
  },
187
227
  failedResponseHandler: googleVertexFailedResponseHandler,
188
- successfulResponseHandler: (0, import_provider_utils2.createJsonResponseHandler)(
228
+ successfulResponseHandler: createJsonResponseHandler(
189
229
  googleVertexTextEmbeddingResponseSchema
190
230
  ),
191
231
  abortSignal,
@@ -206,29 +246,122 @@ var GoogleVertexEmbeddingModel = class {
206
246
  };
207
247
  }
208
248
  };
209
- var googleVertexTextEmbeddingResponseSchema = import_v43.z.object({
210
- predictions: import_v43.z.array(
211
- import_v43.z.object({
212
- embeddings: import_v43.z.object({
213
- values: import_v43.z.array(import_v43.z.number()),
214
- statistics: import_v43.z.object({
215
- token_count: import_v43.z.number()
249
+ var googleVertexTextEmbeddingResponseSchema = z3.object({
250
+ predictions: z3.array(
251
+ z3.object({
252
+ embeddings: z3.object({
253
+ values: z3.array(z3.number()),
254
+ statistics: z3.object({
255
+ token_count: z3.number()
216
256
  })
217
257
  })
218
258
  })
219
259
  )
220
260
  });
261
+ var googleVertexEmbedContentResponseSchema = z3.object({
262
+ embedding: z3.object({
263
+ values: z3.array(z3.number())
264
+ }),
265
+ usageMetadata: z3.object({
266
+ promptTokenCount: z3.number().nullish()
267
+ }).nullish()
268
+ });
269
+ function usesEmbedContentEndpoint(modelId) {
270
+ return modelId === "gemini-embedding-2" || modelId === "gemini-embedding-2-preview";
271
+ }
272
+
273
+ // src/google-vertex-image-model.ts
274
+ import { GoogleLanguageModel } from "@ai-sdk/google/internal";
275
+ import {
276
+ combineHeaders as combineHeaders2,
277
+ convertToBase64,
278
+ convertUint8ArrayToBase64,
279
+ createJsonResponseHandler as createJsonResponseHandler2,
280
+ generateId as defaultGenerateId,
281
+ parseProviderOptions as parseProviderOptions2,
282
+ postJsonToApi as postJsonToApi2,
283
+ resolve as resolve2,
284
+ serializeModelOptions as serializeModelOptions2,
285
+ WORKFLOW_SERIALIZE as WORKFLOW_SERIALIZE2,
286
+ WORKFLOW_DESERIALIZE as WORKFLOW_DESERIALIZE2
287
+ } from "@ai-sdk/provider-utils";
288
+ import { z as z5 } from "zod/v4";
289
+
290
+ // src/google-vertex-image-model-options.ts
291
+ import { z as z4 } from "zod/v4";
292
+ var googleVertexImageModelOptionsSchema = z4.object({
293
+ negativePrompt: z4.string().nullish(),
294
+ personGeneration: z4.enum(["dont_allow", "allow_adult", "allow_all"]).nullish(),
295
+ safetySetting: z4.enum([
296
+ "block_low_and_above",
297
+ "block_medium_and_above",
298
+ "block_only_high",
299
+ "block_none"
300
+ ]).nullish(),
301
+ addWatermark: z4.boolean().nullish(),
302
+ storageUri: z4.string().nullish(),
303
+ sampleImageSize: z4.enum(["1K", "2K"]).nullish(),
304
+ /**
305
+ * Configuration for image editing operations
306
+ */
307
+ edit: z4.object({
308
+ /**
309
+ * An integer that represents the number of sampling steps.
310
+ * A higher value offers better image quality, a lower value offers better latency.
311
+ * Try 35 steps to start. If the quality doesn't meet your requirements,
312
+ * increase the value towards an upper limit of 75.
313
+ */
314
+ baseSteps: z4.number().nullish(),
315
+ // Edit mode options
316
+ // https://cloud.google.com/vertex-ai/generative-ai/docs/image/edit-insert-objects
317
+ mode: z4.enum([
318
+ "EDIT_MODE_INPAINT_INSERTION",
319
+ "EDIT_MODE_INPAINT_REMOVAL",
320
+ "EDIT_MODE_OUTPAINT",
321
+ "EDIT_MODE_CONTROLLED_EDITING",
322
+ "EDIT_MODE_PRODUCT_IMAGE",
323
+ "EDIT_MODE_BGSWAP"
324
+ ]).nullish(),
325
+ /**
326
+ * The mask mode to use.
327
+ * - `MASK_MODE_DEFAULT` - Default value for mask mode.
328
+ * - `MASK_MODE_USER_PROVIDED` - User provided mask. No segmentation needed.
329
+ * - `MASK_MODE_DETECTION_BOX` - Mask from detected bounding boxes.
330
+ * - `MASK_MODE_CLOTHING_AREA` - Masks from segmenting the clothing area with open-vocab segmentation.
331
+ * - `MASK_MODE_PARSED_PERSON` - Masks from segmenting the person body and clothing using the person-parsing model.
332
+ */
333
+ maskMode: z4.enum([
334
+ "MASK_MODE_DEFAULT",
335
+ "MASK_MODE_USER_PROVIDED",
336
+ "MASK_MODE_DETECTION_BOX",
337
+ "MASK_MODE_CLOTHING_AREA",
338
+ "MASK_MODE_PARSED_PERSON"
339
+ ]).nullish(),
340
+ /**
341
+ * Optional. A float value between 0 and 1, inclusive, that represents the
342
+ * percentage of the image width to grow the mask by. Using dilation helps
343
+ * compensate for imprecise masks. We recommend a value of 0.01.
344
+ */
345
+ maskDilation: z4.number().nullish()
346
+ }).nullish()
347
+ });
221
348
 
222
349
  // src/google-vertex-image-model.ts
223
- var import_internal = require("@ai-sdk/google/internal");
224
- var import_provider_utils3 = require("@ai-sdk/provider-utils");
225
- var import_v44 = require("zod/v4");
226
- var GoogleVertexImageModel = class {
350
+ var GoogleVertexImageModel = class _GoogleVertexImageModel {
227
351
  constructor(modelId, config) {
228
352
  this.modelId = modelId;
229
353
  this.config = config;
230
354
  this.specificationVersion = "v4";
231
355
  }
356
+ static [WORKFLOW_SERIALIZE2](model) {
357
+ return serializeModelOptions2({
358
+ modelId: model.modelId,
359
+ config: model.config
360
+ });
361
+ }
362
+ static [WORKFLOW_DESERIALIZE2](options) {
363
+ return new _GoogleVertexImageModel(options.modelId, options.config);
364
+ }
232
365
  get maxImagesPerCall() {
233
366
  if (isGeminiModel(this.modelId)) {
234
367
  return 10;
@@ -256,7 +389,7 @@ var GoogleVertexImageModel = class {
256
389
  files,
257
390
  mask
258
391
  }) {
259
- var _a, _b, _c, _d, _e, _f, _g;
392
+ var _a, _b, _c, _d, _e, _f;
260
393
  const warnings = [];
261
394
  if (size != null) {
262
395
  warnings.push({
@@ -265,12 +398,16 @@ var GoogleVertexImageModel = class {
265
398
  details: "This model does not support the `size` option. Use `aspectRatio` instead."
266
399
  });
267
400
  }
268
- const vertexImageOptions = await (0, import_provider_utils3.parseProviderOptions)({
401
+ const googleVertexImageOptions = (_a = await parseProviderOptions2({
402
+ provider: "googleVertex",
403
+ providerOptions,
404
+ schema: googleVertexImageModelOptionsSchema
405
+ })) != null ? _a : await parseProviderOptions2({
269
406
  provider: "vertex",
270
407
  providerOptions,
271
408
  schema: googleVertexImageModelOptionsSchema
272
409
  });
273
- const { edit, ...otherOptions } = vertexImageOptions != null ? vertexImageOptions : {};
410
+ const { edit, ...otherOptions } = googleVertexImageOptions != null ? googleVertexImageOptions : {};
274
411
  const { mode: editMode, baseSteps, maskMode, maskDilation } = edit != null ? edit : {};
275
412
  const isEditMode = files != null && files.length > 0;
276
413
  let body;
@@ -326,39 +463,44 @@ var GoogleVertexImageModel = class {
326
463
  }
327
464
  };
328
465
  }
329
- const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
330
- const { value: response, responseHeaders } = await (0, import_provider_utils3.postJsonToApi)({
466
+ const currentDate = (_d = (_c = (_b = this.config._internal) == null ? void 0 : _b.currentDate) == null ? void 0 : _c.call(_b)) != null ? _d : /* @__PURE__ */ new Date();
467
+ const { value: response, responseHeaders } = await postJsonToApi2({
331
468
  url: `${this.config.baseURL}/models/${this.modelId}:predict`,
332
- headers: (0, import_provider_utils3.combineHeaders)(await (0, import_provider_utils3.resolve)(this.config.headers), headers),
469
+ headers: combineHeaders2(
470
+ this.config.headers ? await resolve2(this.config.headers) : void 0,
471
+ headers
472
+ ),
333
473
  body,
334
474
  failedResponseHandler: googleVertexFailedResponseHandler,
335
- successfulResponseHandler: (0, import_provider_utils3.createJsonResponseHandler)(
336
- vertexImageResponseSchema
475
+ successfulResponseHandler: createJsonResponseHandler2(
476
+ googleVertexImageResponseSchema
337
477
  ),
338
478
  abortSignal,
339
479
  fetch: this.config.fetch
340
480
  });
341
481
  return {
342
- images: (_e = (_d = response.predictions) == null ? void 0 : _d.map(
482
+ images: (_f = (_e = response.predictions) == null ? void 0 : _e.map(
343
483
  ({ bytesBase64Encoded }) => bytesBase64Encoded
344
- )) != null ? _e : [],
484
+ )) != null ? _f : [],
345
485
  warnings,
346
486
  response: {
347
487
  timestamp: currentDate,
348
488
  modelId: this.modelId,
349
489
  headers: responseHeaders
350
490
  },
351
- providerMetadata: {
352
- vertex: {
353
- images: (_g = (_f = response.predictions) == null ? void 0 : _f.map((prediction) => {
491
+ providerMetadata: (() => {
492
+ var _a2, _b2;
493
+ const payload = {
494
+ images: (_b2 = (_a2 = response.predictions) == null ? void 0 : _a2.map((prediction) => {
354
495
  const {
355
496
  // normalize revised prompt property
356
497
  prompt: revisedPrompt
357
498
  } = prediction;
358
499
  return { ...revisedPrompt != null && { revisedPrompt } };
359
- })) != null ? _g : []
360
- }
361
- }
500
+ })) != null ? _b2 : []
501
+ };
502
+ return { googleVertex: payload, vertex: payload };
503
+ })()
362
504
  };
363
505
  }
364
506
  async doGenerateGemini({
@@ -401,13 +543,16 @@ var GoogleVertexImageModel = class {
401
543
  if (file.type === "url") {
402
544
  userContent.push({
403
545
  type: "file",
404
- data: new URL(file.url),
546
+ data: { type: "url", url: new URL(file.url) },
405
547
  mediaType: "image/*"
406
548
  });
407
549
  } else {
408
550
  userContent.push({
409
551
  type: "file",
410
- data: typeof file.data === "string" ? file.data : new Uint8Array(file.data),
552
+ data: {
553
+ type: "data",
554
+ data: typeof file.data === "string" ? file.data : new Uint8Array(file.data)
555
+ },
411
556
  mediaType: file.mediaType
412
557
  });
413
558
  }
@@ -416,27 +561,30 @@ var GoogleVertexImageModel = class {
416
561
  const languageModelPrompt = [
417
562
  { role: "user", content: userContent }
418
563
  ];
419
- const languageModel = new import_internal.GoogleGenerativeAILanguageModel(this.modelId, {
564
+ const languageModel = new GoogleLanguageModel(this.modelId, {
420
565
  provider: this.config.provider,
421
566
  baseURL: this.config.baseURL,
422
567
  headers: (_a = this.config.headers) != null ? _a : {},
423
568
  fetch: this.config.fetch,
424
- generateId: (_b = this.config.generateId) != null ? _b : import_provider_utils3.generateId,
569
+ generateId: (_b = this.config.generateId) != null ? _b : defaultGenerateId,
425
570
  supportedUrls: () => ({
426
571
  "*": [/^https?:\/\/.*$/, /^gs:\/\/.*$/]
427
572
  })
428
573
  });
574
+ const userVertexOptions = (_c = providerOptions == null ? void 0 : providerOptions.googleVertex) != null ? _c : providerOptions == null ? void 0 : providerOptions.vertex;
575
+ const innerVertexOptions = {
576
+ responseModalities: ["IMAGE"],
577
+ imageConfig: aspectRatio ? {
578
+ aspectRatio
579
+ } : void 0,
580
+ ...userVertexOptions != null ? userVertexOptions : {}
581
+ };
429
582
  const result = await languageModel.doGenerate({
430
583
  prompt: languageModelPrompt,
431
584
  seed,
432
585
  providerOptions: {
433
- vertex: {
434
- responseModalities: ["IMAGE"],
435
- imageConfig: aspectRatio ? {
436
- aspectRatio
437
- } : void 0,
438
- ...(_c = providerOptions == null ? void 0 : providerOptions.vertex) != null ? _c : {}
439
- }
586
+ googleVertex: innerVertexOptions,
587
+ vertex: innerVertexOptions
440
588
  },
441
589
  headers,
442
590
  abortSignal
@@ -444,17 +592,19 @@ var GoogleVertexImageModel = class {
444
592
  const currentDate = (_f = (_e = (_d = this.config._internal) == null ? void 0 : _d.currentDate) == null ? void 0 : _e.call(_d)) != null ? _f : /* @__PURE__ */ new Date();
445
593
  const images = [];
446
594
  for (const part of result.content) {
447
- if (part.type === "file" && part.mediaType.startsWith("image/")) {
448
- images.push((0, import_provider_utils3.convertToBase64)(part.data));
595
+ if (part.type === "file" && part.mediaType.startsWith("image/") && part.data.type === "data") {
596
+ images.push(convertToBase64(part.data.data));
449
597
  }
450
598
  }
599
+ const geminiPayload = {
600
+ images: images.map(() => ({}))
601
+ };
451
602
  return {
452
603
  images,
453
604
  warnings,
454
605
  providerMetadata: {
455
- vertex: {
456
- images: images.map(() => ({}))
457
- }
606
+ googleVertex: geminiPayload,
607
+ vertex: geminiPayload
458
608
  },
459
609
  response: {
460
610
  timestamp: currentDate,
@@ -472,71 +622,15 @@ var GoogleVertexImageModel = class {
472
622
  function isGeminiModel(modelId) {
473
623
  return modelId.startsWith("gemini-");
474
624
  }
475
- var vertexImageResponseSchema = import_v44.z.object({
476
- predictions: import_v44.z.array(
477
- import_v44.z.object({
478
- bytesBase64Encoded: import_v44.z.string(),
479
- mimeType: import_v44.z.string(),
480
- prompt: import_v44.z.string().nullish()
625
+ var googleVertexImageResponseSchema = z5.object({
626
+ predictions: z5.array(
627
+ z5.object({
628
+ bytesBase64Encoded: z5.string(),
629
+ mimeType: z5.string(),
630
+ prompt: z5.string().nullish()
481
631
  })
482
632
  ).nullish()
483
633
  });
484
- var googleVertexImageModelOptionsSchema = import_v44.z.object({
485
- negativePrompt: import_v44.z.string().nullish(),
486
- personGeneration: import_v44.z.enum(["dont_allow", "allow_adult", "allow_all"]).nullish(),
487
- safetySetting: import_v44.z.enum([
488
- "block_low_and_above",
489
- "block_medium_and_above",
490
- "block_only_high",
491
- "block_none"
492
- ]).nullish(),
493
- addWatermark: import_v44.z.boolean().nullish(),
494
- storageUri: import_v44.z.string().nullish(),
495
- sampleImageSize: import_v44.z.enum(["1K", "2K"]).nullish(),
496
- /**
497
- * Configuration for image editing operations
498
- */
499
- edit: import_v44.z.object({
500
- /**
501
- * An integer that represents the number of sampling steps.
502
- * A higher value offers better image quality, a lower value offers better latency.
503
- * Try 35 steps to start. If the quality doesn't meet your requirements,
504
- * increase the value towards an upper limit of 75.
505
- */
506
- baseSteps: import_v44.z.number().nullish(),
507
- // Edit mode options
508
- // https://cloud.google.com/vertex-ai/generative-ai/docs/image/edit-insert-objects
509
- mode: import_v44.z.enum([
510
- "EDIT_MODE_INPAINT_INSERTION",
511
- "EDIT_MODE_INPAINT_REMOVAL",
512
- "EDIT_MODE_OUTPAINT",
513
- "EDIT_MODE_CONTROLLED_EDITING",
514
- "EDIT_MODE_PRODUCT_IMAGE",
515
- "EDIT_MODE_BGSWAP"
516
- ]).nullish(),
517
- /**
518
- * The mask mode to use.
519
- * - `MASK_MODE_DEFAULT` - Default value for mask mode.
520
- * - `MASK_MODE_USER_PROVIDED` - User provided mask. No segmentation needed.
521
- * - `MASK_MODE_DETECTION_BOX` - Mask from detected bounding boxes.
522
- * - `MASK_MODE_CLOTHING_AREA` - Masks from segmenting the clothing area with open-vocab segmentation.
523
- * - `MASK_MODE_PARSED_PERSON` - Masks from segmenting the person body and clothing using the person-parsing model.
524
- */
525
- maskMode: import_v44.z.enum([
526
- "MASK_MODE_DEFAULT",
527
- "MASK_MODE_USER_PROVIDED",
528
- "MASK_MODE_DETECTION_BOX",
529
- "MASK_MODE_CLOTHING_AREA",
530
- "MASK_MODE_PARSED_PERSON"
531
- ]).nullish(),
532
- /**
533
- * Optional. A float value between 0 and 1, inclusive, that represents the
534
- * percentage of the image width to grow the mask by. Using dilation helps
535
- * compensate for imprecise masks. We recommend a value of 0.01.
536
- */
537
- maskDilation: import_v44.z.number().nullish()
538
- }).nullish()
539
- });
540
634
  function getBase64Data(file) {
541
635
  if (file.type === "url") {
542
636
  throw new Error(
@@ -546,25 +640,250 @@ function getBase64Data(file) {
546
640
  if (typeof file.data === "string") {
547
641
  return file.data;
548
642
  }
549
- return (0, import_provider_utils3.convertUint8ArrayToBase64)(file.data);
643
+ return convertUint8ArrayToBase64(file.data);
550
644
  }
551
645
 
552
646
  // src/google-vertex-tools.ts
553
- var import_internal2 = require("@ai-sdk/google/internal");
647
+ import { googleTools } from "@ai-sdk/google/internal";
554
648
  var googleVertexTools = {
555
- googleSearch: import_internal2.googleTools.googleSearch,
556
- enterpriseWebSearch: import_internal2.googleTools.enterpriseWebSearch,
557
- googleMaps: import_internal2.googleTools.googleMaps,
558
- urlContext: import_internal2.googleTools.urlContext,
559
- fileSearch: import_internal2.googleTools.fileSearch,
560
- codeExecution: import_internal2.googleTools.codeExecution,
561
- vertexRagStore: import_internal2.googleTools.vertexRagStore
649
+ googleSearch: googleTools.googleSearch,
650
+ enterpriseWebSearch: googleTools.enterpriseWebSearch,
651
+ googleMaps: googleTools.googleMaps,
652
+ urlContext: googleTools.urlContext,
653
+ fileSearch: googleTools.fileSearch,
654
+ codeExecution: googleTools.codeExecution,
655
+ vertexRagStore: googleTools.vertexRagStore
656
+ };
657
+
658
+ // src/google-vertex-transcription-model.ts
659
+ import {
660
+ combineHeaders as combineHeaders3,
661
+ convertUint8ArrayToBase64 as convertUint8ArrayToBase642,
662
+ createJsonResponseHandler as createJsonResponseHandler3,
663
+ parseProviderOptions as parseProviderOptions3,
664
+ postJsonToApi as postJsonToApi3,
665
+ resolve as resolve3,
666
+ serializeModelOptions as serializeModelOptions3,
667
+ WORKFLOW_DESERIALIZE as WORKFLOW_DESERIALIZE3,
668
+ WORKFLOW_SERIALIZE as WORKFLOW_SERIALIZE3
669
+ } from "@ai-sdk/provider-utils";
670
+ import { z as z7 } from "zod/v4";
671
+
672
+ // src/google-vertex-transcription-model-options.ts
673
+ import { z as z6 } from "zod/v4";
674
+ var googleVertexTranscriptionProviderOptionsSchema = z6.object({
675
+ /**
676
+ * BCP-47 language codes to recognize (e.g. `['en-US']`), or `['auto']` to let
677
+ * Chirp auto-detect the spoken language. Defaults to `['auto']`. For
678
+ * `telephony`, pass a supported explicit language code.
679
+ */
680
+ languageCodes: z6.array(z6.string()).optional(),
681
+ /**
682
+ * Whether to add punctuation to the transcript. Defaults to `true`.
683
+ */
684
+ enableAutomaticPunctuation: z6.boolean().optional(),
685
+ /**
686
+ * Whether to include word-level timestamps. Defaults to `true` so the
687
+ * transcription result can include segments.
688
+ *
689
+ * Enabling word-level timestamps can reduce transcription quality and speed
690
+ * for Chirp models.
691
+ */
692
+ enableWordTimeOffsets: z6.boolean().optional(),
693
+ /**
694
+ * The Cloud Speech-to-Text region for the request (e.g. `'us'`, `'eu'`,
695
+ * `'us-central1'`). Defaults to the provider `location`.
696
+ *
697
+ * Note: Speech-to-Text regions differ from Vertex AI regions. Chirp is only
698
+ * available in specific Speech-to-Text regions and is not available in the
699
+ * `global` location.
700
+ */
701
+ region: z6.string().optional()
702
+ });
703
+
704
+ // src/google-vertex-transcription-model.ts
705
+ function parseDurationSeconds(value) {
706
+ if (value == null) {
707
+ return void 0;
708
+ }
709
+ const seconds = Number.parseFloat(value);
710
+ return Number.isFinite(seconds) ? seconds : void 0;
711
+ }
712
+ function convertBcp47ToIso6391(value) {
713
+ if (value == null) {
714
+ return void 0;
715
+ }
716
+ try {
717
+ const language = new Intl.Locale(value).language;
718
+ return language.length === 2 ? language : void 0;
719
+ } catch (e) {
720
+ return void 0;
721
+ }
722
+ }
723
+ var GoogleVertexTranscriptionModel = class _GoogleVertexTranscriptionModel {
724
+ constructor(modelId, config) {
725
+ this.modelId = modelId;
726
+ this.config = config;
727
+ this.specificationVersion = "v4";
728
+ }
729
+ static [WORKFLOW_SERIALIZE3](model) {
730
+ return serializeModelOptions3({
731
+ modelId: model.modelId,
732
+ config: model.config
733
+ });
734
+ }
735
+ static [WORKFLOW_DESERIALIZE3](options) {
736
+ return new _GoogleVertexTranscriptionModel(options.modelId, options.config);
737
+ }
738
+ get provider() {
739
+ return this.config.provider;
740
+ }
741
+ async doGenerate(options) {
742
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
743
+ const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
744
+ const warnings = [];
745
+ let googleOptions;
746
+ for (const provider of ["googleVertex", "vertex", "google"]) {
747
+ googleOptions = await parseProviderOptions3({
748
+ provider,
749
+ providerOptions: options.providerOptions,
750
+ schema: googleVertexTranscriptionProviderOptionsSchema
751
+ });
752
+ if (googleOptions != null) {
753
+ break;
754
+ }
755
+ }
756
+ const region = (_d = googleOptions == null ? void 0 : googleOptions.region) != null ? _d : this.config.location;
757
+ const languageCodes = (_e = googleOptions == null ? void 0 : googleOptions.languageCodes) != null ? _e : ["auto"];
758
+ const content = typeof options.audio === "string" ? options.audio : convertUint8ArrayToBase642(options.audio);
759
+ const requestBody = {
760
+ config: {
761
+ model: this.modelId,
762
+ languageCodes,
763
+ // Let Speech-to-Text auto-detect the audio encoding (wav/mp3/flac/…).
764
+ autoDecodingConfig: {},
765
+ features: {
766
+ // Word timing populates `segments`.
767
+ enableWordTimeOffsets: (_f = googleOptions == null ? void 0 : googleOptions.enableWordTimeOffsets) != null ? _f : true,
768
+ enableAutomaticPunctuation: (_g = googleOptions == null ? void 0 : googleOptions.enableAutomaticPunctuation) != null ? _g : true
769
+ }
770
+ },
771
+ content
772
+ };
773
+ const host = region === "global" ? "speech.googleapis.com" : `${region}-speech.googleapis.com`;
774
+ const url = `https://${host}/v2/projects/${this.config.project}/locations/${region}/recognizers/_:recognize`;
775
+ const {
776
+ value: response,
777
+ responseHeaders,
778
+ rawValue: rawResponse
779
+ } = await postJsonToApi3({
780
+ url,
781
+ headers: combineHeaders3(
782
+ this.config.headers ? await resolve3(this.config.headers) : void 0,
783
+ options.headers
784
+ ),
785
+ body: requestBody,
786
+ failedResponseHandler: googleVertexFailedResponseHandler,
787
+ successfulResponseHandler: createJsonResponseHandler3(
788
+ googleVertexTranscriptionResponseSchema
789
+ ),
790
+ abortSignal: options.abortSignal,
791
+ fetch: this.config.fetch
792
+ });
793
+ const results = (_h = response.results) != null ? _h : [];
794
+ const text = results.map((result) => {
795
+ var _a2, _b2, _c2;
796
+ return (_c2 = (_b2 = (_a2 = result.alternatives) == null ? void 0 : _a2[0]) == null ? void 0 : _b2.transcript) != null ? _c2 : "";
797
+ }).join(" ").trim();
798
+ const segments = results.flatMap(
799
+ (result) => {
800
+ var _a2, _b2, _c2, _d2;
801
+ return (_d2 = (_c2 = (_b2 = (_a2 = result.alternatives) == null ? void 0 : _a2[0]) == null ? void 0 : _b2.words) == null ? void 0 : _c2.flatMap((word) => {
802
+ const startSecond = parseDurationSeconds(word.startOffset);
803
+ const endSecond = parseDurationSeconds(word.endOffset);
804
+ return word.word == null || startSecond == null || endSecond == null ? [] : [{ text: word.word, startSecond, endSecond }];
805
+ })) != null ? _d2 : [];
806
+ }
807
+ );
808
+ const language = convertBcp47ToIso6391((_i = results[0]) == null ? void 0 : _i.languageCode);
809
+ return {
810
+ text,
811
+ segments,
812
+ language,
813
+ durationInSeconds: parseDurationSeconds(
814
+ (_j = response.metadata) == null ? void 0 : _j.totalBilledDuration
815
+ ),
816
+ warnings,
817
+ response: {
818
+ timestamp: currentDate,
819
+ modelId: this.modelId,
820
+ headers: responseHeaders,
821
+ body: rawResponse
822
+ }
823
+ };
824
+ }
562
825
  };
826
+ var googleVertexTranscriptionResponseSchema = z7.object({
827
+ results: z7.array(
828
+ z7.object({
829
+ alternatives: z7.array(
830
+ z7.object({
831
+ transcript: z7.string().nullish(),
832
+ words: z7.array(
833
+ z7.object({
834
+ word: z7.string().nullish(),
835
+ startOffset: z7.string().nullish(),
836
+ endOffset: z7.string().nullish()
837
+ })
838
+ ).nullish()
839
+ })
840
+ ).nullish(),
841
+ languageCode: z7.string().nullish()
842
+ })
843
+ ).nullish(),
844
+ metadata: z7.object({
845
+ totalBilledDuration: z7.string().nullish()
846
+ }).nullish()
847
+ });
848
+
849
+ // src/google-vertex-video-model.ts
850
+ import {
851
+ AISDKError
852
+ } from "@ai-sdk/provider";
853
+ import {
854
+ combineHeaders as combineHeaders4,
855
+ convertUint8ArrayToBase64 as convertUint8ArrayToBase643,
856
+ createJsonResponseHandler as createJsonResponseHandler4,
857
+ delay,
858
+ parseProviderOptions as parseProviderOptions4,
859
+ postJsonToApi as postJsonToApi4,
860
+ resolve as resolve4
861
+ } from "@ai-sdk/provider-utils";
862
+ import { z as z9 } from "zod/v4";
863
+
864
+ // src/google-vertex-video-model-options.ts
865
+ import { lazySchema, zodSchema } from "@ai-sdk/provider-utils";
866
+ import { z as z8 } from "zod/v4";
867
+ var googleVertexVideoModelOptionsSchema = lazySchema(
868
+ () => zodSchema(
869
+ z8.object({
870
+ pollIntervalMs: z8.number().positive().nullish(),
871
+ pollTimeoutMs: z8.number().positive().nullish(),
872
+ personGeneration: z8.enum(["dont_allow", "allow_adult", "allow_all"]).nullish(),
873
+ negativePrompt: z8.string().nullish(),
874
+ generateAudio: z8.boolean().nullish(),
875
+ gcsOutputDirectory: z8.string().nullish(),
876
+ referenceImages: z8.array(
877
+ z8.object({
878
+ bytesBase64Encoded: z8.string().nullish(),
879
+ gcsUri: z8.string().nullish()
880
+ })
881
+ ).nullish()
882
+ }).passthrough()
883
+ )
884
+ );
563
885
 
564
886
  // src/google-vertex-video-model.ts
565
- var import_provider2 = require("@ai-sdk/provider");
566
- var import_provider_utils4 = require("@ai-sdk/provider-utils");
567
- var import_v45 = require("zod/v4");
568
887
  var GoogleVertexVideoModel = class {
569
888
  constructor(modelId, config) {
570
889
  this.modelId = modelId;
@@ -578,10 +897,14 @@ var GoogleVertexVideoModel = class {
578
897
  return 4;
579
898
  }
580
899
  async doGenerate(options) {
581
- var _a, _b, _c, _d, _e, _f;
900
+ var _a, _b, _c, _d, _e, _f, _g, _h;
582
901
  const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
583
902
  const warnings = [];
584
- const vertexOptions = await (0, import_provider_utils4.parseProviderOptions)({
903
+ const googleVertexOptions = (_d = await parseProviderOptions4({
904
+ provider: "googleVertex",
905
+ providerOptions: options.providerOptions,
906
+ schema: googleVertexVideoModelOptionsSchema
907
+ })) != null ? _d : await parseProviderOptions4({
585
908
  provider: "vertex",
586
909
  providerOptions: options.providerOptions,
587
910
  schema: googleVertexVideoModelOptionsSchema
@@ -599,15 +922,15 @@ var GoogleVertexVideoModel = class {
599
922
  details: "Vertex AI video models require base64-encoded images or GCS URIs. URL will be ignored."
600
923
  });
601
924
  } else {
602
- const base64Data = typeof options.image.data === "string" ? options.image.data : (0, import_provider_utils4.convertUint8ArrayToBase64)(options.image.data);
925
+ const base64Data = typeof options.image.data === "string" ? options.image.data : convertUint8ArrayToBase643(options.image.data);
603
926
  instance.image = {
604
927
  bytesBase64Encoded: base64Data,
605
928
  mimeType: options.image.mediaType
606
929
  };
607
930
  }
608
931
  }
609
- if ((vertexOptions == null ? void 0 : vertexOptions.referenceImages) != null) {
610
- instance.referenceImages = vertexOptions.referenceImages;
932
+ if ((googleVertexOptions == null ? void 0 : googleVertexOptions.referenceImages) != null) {
933
+ instance.referenceImages = googleVertexOptions.referenceImages;
611
934
  }
612
935
  const parameters = {
613
936
  sampleCount: options.n
@@ -629,17 +952,18 @@ var GoogleVertexVideoModel = class {
629
952
  if (options.seed) {
630
953
  parameters.seed = options.seed;
631
954
  }
632
- if (vertexOptions != null) {
633
- const opts = vertexOptions;
955
+ const generateAudio = (_e = options.generateAudio) != null ? _e : googleVertexOptions == null ? void 0 : googleVertexOptions.generateAudio;
956
+ if (generateAudio != null) {
957
+ parameters.generateAudio = generateAudio;
958
+ }
959
+ if (googleVertexOptions != null) {
960
+ const opts = googleVertexOptions;
634
961
  if (opts.personGeneration !== void 0 && opts.personGeneration !== null) {
635
962
  parameters.personGeneration = opts.personGeneration;
636
963
  }
637
964
  if (opts.negativePrompt !== void 0 && opts.negativePrompt !== null) {
638
965
  parameters.negativePrompt = opts.negativePrompt;
639
966
  }
640
- if (opts.generateAudio !== void 0 && opts.generateAudio !== null) {
641
- parameters.generateAudio = opts.generateAudio;
642
- }
643
967
  if (opts.gcsOutputDirectory !== void 0 && opts.gcsOutputDirectory !== null) {
644
968
  parameters.gcsOutputDirectory = opts.gcsOutputDirectory;
645
969
  }
@@ -657,18 +981,18 @@ var GoogleVertexVideoModel = class {
657
981
  }
658
982
  }
659
983
  }
660
- const { value: operation } = await (0, import_provider_utils4.postJsonToApi)({
984
+ const { value: operation } = await postJsonToApi4({
661
985
  url: `${this.config.baseURL}/models/${this.modelId}:predictLongRunning`,
662
- headers: (0, import_provider_utils4.combineHeaders)(
663
- await (0, import_provider_utils4.resolve)(this.config.headers),
986
+ headers: combineHeaders4(
987
+ await resolve4(this.config.headers),
664
988
  options.headers
665
989
  ),
666
990
  body: {
667
991
  instances,
668
992
  parameters
669
993
  },
670
- successfulResponseHandler: (0, import_provider_utils4.createJsonResponseHandler)(
671
- vertexOperationSchema
994
+ successfulResponseHandler: createJsonResponseHandler4(
995
+ googleVertexOperationSchema
672
996
  ),
673
997
  failedResponseHandler: googleVertexFailedResponseHandler,
674
998
  abortSignal: options.abortSignal,
@@ -676,41 +1000,41 @@ var GoogleVertexVideoModel = class {
676
1000
  });
677
1001
  const operationName = operation.name;
678
1002
  if (!operationName) {
679
- throw new import_provider2.AISDKError({
1003
+ throw new AISDKError({
680
1004
  name: "VERTEX_VIDEO_GENERATION_ERROR",
681
1005
  message: "No operation name returned from API"
682
1006
  });
683
1007
  }
684
- const pollIntervalMs = (_d = vertexOptions == null ? void 0 : vertexOptions.pollIntervalMs) != null ? _d : 1e4;
685
- const pollTimeoutMs = (_e = vertexOptions == null ? void 0 : vertexOptions.pollTimeoutMs) != null ? _e : 6e5;
1008
+ const pollIntervalMs = (_f = googleVertexOptions == null ? void 0 : googleVertexOptions.pollIntervalMs) != null ? _f : 1e4;
1009
+ const pollTimeoutMs = (_g = googleVertexOptions == null ? void 0 : googleVertexOptions.pollTimeoutMs) != null ? _g : 6e5;
686
1010
  const startTime = Date.now();
687
1011
  let finalOperation = operation;
688
1012
  let responseHeaders;
689
1013
  while (!finalOperation.done) {
690
1014
  if (Date.now() - startTime > pollTimeoutMs) {
691
- throw new import_provider2.AISDKError({
1015
+ throw new AISDKError({
692
1016
  name: "VERTEX_VIDEO_GENERATION_TIMEOUT",
693
1017
  message: `Video generation timed out after ${pollTimeoutMs}ms`
694
1018
  });
695
1019
  }
696
- await (0, import_provider_utils4.delay)(pollIntervalMs);
697
- if ((_f = options.abortSignal) == null ? void 0 : _f.aborted) {
698
- throw new import_provider2.AISDKError({
1020
+ await delay(pollIntervalMs);
1021
+ if ((_h = options.abortSignal) == null ? void 0 : _h.aborted) {
1022
+ throw new AISDKError({
699
1023
  name: "VERTEX_VIDEO_GENERATION_ABORTED",
700
1024
  message: "Video generation request was aborted"
701
1025
  });
702
1026
  }
703
- const { value: statusOperation, responseHeaders: pollHeaders } = await (0, import_provider_utils4.postJsonToApi)({
1027
+ const { value: statusOperation, responseHeaders: pollHeaders } = await postJsonToApi4({
704
1028
  url: `${this.config.baseURL}/models/${this.modelId}:fetchPredictOperation`,
705
- headers: (0, import_provider_utils4.combineHeaders)(
706
- await (0, import_provider_utils4.resolve)(this.config.headers),
1029
+ headers: combineHeaders4(
1030
+ await resolve4(this.config.headers),
707
1031
  options.headers
708
1032
  ),
709
1033
  body: {
710
1034
  operationName
711
1035
  },
712
- successfulResponseHandler: (0, import_provider_utils4.createJsonResponseHandler)(
713
- vertexOperationSchema
1036
+ successfulResponseHandler: createJsonResponseHandler4(
1037
+ googleVertexOperationSchema
714
1038
  ),
715
1039
  failedResponseHandler: googleVertexFailedResponseHandler,
716
1040
  abortSignal: options.abortSignal,
@@ -720,14 +1044,14 @@ var GoogleVertexVideoModel = class {
720
1044
  responseHeaders = pollHeaders;
721
1045
  }
722
1046
  if (finalOperation.error) {
723
- throw new import_provider2.AISDKError({
1047
+ throw new AISDKError({
724
1048
  name: "VERTEX_VIDEO_GENERATION_FAILED",
725
1049
  message: `Video generation failed: ${finalOperation.error.message}`
726
1050
  });
727
1051
  }
728
1052
  const response = finalOperation.response;
729
1053
  if (!(response == null ? void 0 : response.videos) || response.videos.length === 0) {
730
- throw new import_provider2.AISDKError({
1054
+ throw new AISDKError({
731
1055
  name: "VERTEX_VIDEO_GENERATION_ERROR",
732
1056
  message: `No videos in response. Response: ${JSON.stringify(finalOperation)}`
733
1057
  });
@@ -757,7 +1081,7 @@ var GoogleVertexVideoModel = class {
757
1081
  }
758
1082
  }
759
1083
  if (videos.length === 0) {
760
- throw new import_provider2.AISDKError({
1084
+ throw new AISDKError({
761
1085
  name: "VERTEX_VIDEO_GENERATION_ERROR",
762
1086
  message: "No valid videos in response"
763
1087
  });
@@ -770,78 +1094,64 @@ var GoogleVertexVideoModel = class {
770
1094
  modelId: this.modelId,
771
1095
  headers: responseHeaders
772
1096
  },
773
- providerMetadata: {
774
- "google-vertex": {
775
- videos: videoMetadata
776
- }
777
- }
1097
+ providerMetadata: /* @__PURE__ */ (() => {
1098
+ const payload = { videos: videoMetadata };
1099
+ return {
1100
+ googleVertex: payload,
1101
+ // Legacy keys preserved for backward compatibility.
1102
+ "google-vertex": payload,
1103
+ vertex: payload
1104
+ };
1105
+ })()
778
1106
  };
779
1107
  }
780
1108
  };
781
- var vertexOperationSchema = import_v45.z.object({
782
- name: import_v45.z.string().nullish(),
783
- done: import_v45.z.boolean().nullish(),
784
- error: import_v45.z.object({
785
- code: import_v45.z.number().nullish(),
786
- message: import_v45.z.string(),
787
- status: import_v45.z.string().nullish()
1109
+ var googleVertexOperationSchema = z9.object({
1110
+ name: z9.string().nullish(),
1111
+ done: z9.boolean().nullish(),
1112
+ error: z9.object({
1113
+ code: z9.number().nullish(),
1114
+ message: z9.string(),
1115
+ status: z9.string().nullish()
788
1116
  }).nullish(),
789
- response: import_v45.z.object({
790
- videos: import_v45.z.array(
791
- import_v45.z.object({
792
- bytesBase64Encoded: import_v45.z.string().nullish(),
793
- gcsUri: import_v45.z.string().nullish(),
794
- mimeType: import_v45.z.string().nullish()
1117
+ response: z9.object({
1118
+ videos: z9.array(
1119
+ z9.object({
1120
+ bytesBase64Encoded: z9.string().nullish(),
1121
+ gcsUri: z9.string().nullish(),
1122
+ mimeType: z9.string().nullish()
795
1123
  })
796
1124
  ).nullish(),
797
- raiMediaFilteredCount: import_v45.z.number().nullish()
1125
+ raiMediaFilteredCount: z9.number().nullish()
798
1126
  }).nullish()
799
1127
  });
800
- var googleVertexVideoModelOptionsSchema = (0, import_provider_utils4.lazySchema)(
801
- () => (0, import_provider_utils4.zodSchema)(
802
- import_v45.z.object({
803
- pollIntervalMs: import_v45.z.number().positive().nullish(),
804
- pollTimeoutMs: import_v45.z.number().positive().nullish(),
805
- personGeneration: import_v45.z.enum(["dont_allow", "allow_adult", "allow_all"]).nullish(),
806
- negativePrompt: import_v45.z.string().nullish(),
807
- generateAudio: import_v45.z.boolean().nullish(),
808
- gcsOutputDirectory: import_v45.z.string().nullish(),
809
- referenceImages: import_v45.z.array(
810
- import_v45.z.object({
811
- bytesBase64Encoded: import_v45.z.string().nullish(),
812
- gcsUri: import_v45.z.string().nullish()
813
- })
814
- ).nullish()
815
- }).passthrough()
816
- )
817
- );
818
1128
 
819
- // src/google-vertex-provider.ts
1129
+ // src/google-vertex-provider-base.ts
820
1130
  var EXPRESS_MODE_BASE_URL = "https://aiplatform.googleapis.com/v1/publishers/google";
821
1131
  function createExpressModeFetch(apiKey, customFetch) {
822
1132
  return async (url, init) => {
823
1133
  const modifiedInit = {
824
1134
  ...init,
825
1135
  headers: {
826
- ...(init == null ? void 0 : init.headers) ? (0, import_provider_utils5.normalizeHeaders)(init.headers) : {},
1136
+ ...(init == null ? void 0 : init.headers) ? normalizeHeaders(init.headers) : {},
827
1137
  "x-goog-api-key": apiKey
828
1138
  }
829
1139
  };
830
1140
  return (customFetch != null ? customFetch : fetch)(url.toString(), modifiedInit);
831
1141
  };
832
1142
  }
833
- function createVertex(options = {}) {
834
- const apiKey = (0, import_provider_utils5.loadOptionalSetting)({
1143
+ function createGoogleVertex(options = {}) {
1144
+ const apiKey = loadOptionalSetting({
835
1145
  settingValue: options.apiKey,
836
1146
  environmentVariableName: "GOOGLE_VERTEX_API_KEY"
837
1147
  });
838
- const loadVertexProject = () => (0, import_provider_utils5.loadSetting)({
1148
+ const loadGoogleVertexProject = () => loadSetting({
839
1149
  settingValue: options.project,
840
1150
  settingName: "project",
841
1151
  environmentVariableName: "GOOGLE_VERTEX_PROJECT",
842
1152
  description: "Google Vertex project"
843
1153
  });
844
- const loadVertexLocation = () => (0, import_provider_utils5.loadSetting)({
1154
+ const loadGoogleVertexLocation = () => loadSetting({
845
1155
  settingValue: options.location,
846
1156
  settingName: "location",
847
1157
  environmentVariableName: "GOOGLE_VERTEX_LOCATION",
@@ -850,18 +1160,26 @@ function createVertex(options = {}) {
850
1160
  const loadBaseURL = () => {
851
1161
  var _a, _b;
852
1162
  if (apiKey) {
853
- return (_a = (0, import_provider_utils5.withoutTrailingSlash)(options.baseURL)) != null ? _a : EXPRESS_MODE_BASE_URL;
1163
+ return (_a = withoutTrailingSlash(options.baseURL)) != null ? _a : EXPRESS_MODE_BASE_URL;
854
1164
  }
855
- const region = loadVertexLocation();
856
- const project = loadVertexProject();
857
- const baseHost = `${region === "global" ? "" : region + "-"}aiplatform.googleapis.com`;
858
- return (_b = (0, import_provider_utils5.withoutTrailingSlash)(options.baseURL)) != null ? _b : `https://${baseHost}/v1beta1/projects/${project}/locations/${region}/publishers/google`;
1165
+ const region = loadGoogleVertexLocation();
1166
+ const project = loadGoogleVertexProject();
1167
+ const getHost = () => {
1168
+ if (region === "global") {
1169
+ return "aiplatform.googleapis.com";
1170
+ } else if (region === "eu" || region === "us") {
1171
+ return `aiplatform.${region}.rep.googleapis.com`;
1172
+ } else {
1173
+ return `${region}-aiplatform.googleapis.com`;
1174
+ }
1175
+ };
1176
+ return (_b = withoutTrailingSlash(options.baseURL)) != null ? _b : `https://${getHost()}/v1beta1/projects/${project}/locations/${region}/publishers/google`;
859
1177
  };
860
1178
  const createConfig = (name) => {
861
1179
  const getHeaders = async () => {
862
1180
  var _a;
863
- const originalHeaders = await (0, import_provider_utils5.resolve)((_a = options.headers) != null ? _a : {});
864
- return (0, import_provider_utils5.withUserAgentSuffix)(
1181
+ const originalHeaders = await resolve5((_a = options.headers) != null ? _a : {});
1182
+ return withUserAgentSuffix(
865
1183
  originalHeaders,
866
1184
  `ai-sdk/google-vertex/${VERSION}`
867
1185
  );
@@ -875,9 +1193,9 @@ function createVertex(options = {}) {
875
1193
  };
876
1194
  const createChatModel = (modelId) => {
877
1195
  var _a;
878
- return new import_internal3.GoogleGenerativeAILanguageModel(modelId, {
1196
+ return new GoogleLanguageModel2(modelId, {
879
1197
  ...createConfig("chat"),
880
- generateId: (_a = options.generateId) != null ? _a : import_provider_utils5.generateId,
1198
+ generateId: (_a = options.generateId) != null ? _a : generateId,
881
1199
  supportedUrls: () => ({
882
1200
  "*": [
883
1201
  // HTTP URLs:
@@ -893,14 +1211,30 @@ function createVertex(options = {}) {
893
1211
  var _a;
894
1212
  return new GoogleVertexImageModel(modelId, {
895
1213
  ...createConfig("image"),
896
- generateId: (_a = options.generateId) != null ? _a : import_provider_utils5.generateId
1214
+ generateId: (_a = options.generateId) != null ? _a : generateId
897
1215
  });
898
1216
  };
899
1217
  const createVideoModel = (modelId) => {
900
1218
  var _a;
901
1219
  return new GoogleVertexVideoModel(modelId, {
902
1220
  ...createConfig("video"),
903
- generateId: (_a = options.generateId) != null ? _a : import_provider_utils5.generateId
1221
+ generateId: (_a = options.generateId) != null ? _a : generateId
1222
+ });
1223
+ };
1224
+ const createSpeechModel = (modelId) => new GoogleSpeechModel(modelId, createConfig("speech"));
1225
+ const createTranscriptionModel = (modelId) => {
1226
+ if (apiKey) {
1227
+ throw new Error(
1228
+ "Google Vertex transcription models do not support Express Mode API keys. Use standard Google Cloud credentials instead."
1229
+ );
1230
+ }
1231
+ const config = createConfig("transcription");
1232
+ return new GoogleVertexTranscriptionModel(modelId, {
1233
+ provider: config.provider,
1234
+ headers: config.headers,
1235
+ fetch: config.fetch,
1236
+ project: loadGoogleVertexProject(),
1237
+ location: loadGoogleVertexLocation()
904
1238
  });
905
1239
  };
906
1240
  const provider = function(modelId) {
@@ -919,34 +1253,42 @@ function createVertex(options = {}) {
919
1253
  provider.imageModel = createImageModel;
920
1254
  provider.video = createVideoModel;
921
1255
  provider.videoModel = createVideoModel;
1256
+ provider.speech = createSpeechModel;
1257
+ provider.speechModel = createSpeechModel;
1258
+ provider.transcription = createTranscriptionModel;
1259
+ provider.transcriptionModel = createTranscriptionModel;
922
1260
  provider.tools = googleVertexTools;
923
1261
  return provider;
924
1262
  }
925
1263
 
926
- // src/google-vertex-provider-node.ts
927
- function createVertex2(options = {}) {
928
- const apiKey = (0, import_provider_utils6.loadOptionalSetting)({
1264
+ // src/google-vertex-provider.ts
1265
+ function createGoogleVertex2(options = {}) {
1266
+ const apiKey = loadOptionalSetting2({
929
1267
  settingValue: options.apiKey,
930
1268
  environmentVariableName: "GOOGLE_VERTEX_API_KEY"
931
1269
  });
932
1270
  if (apiKey) {
933
- return createVertex(options);
1271
+ return createGoogleVertex(options);
934
1272
  }
935
- return createVertex({
1273
+ const googleAuthOptions = options.project == null ? options.googleAuthOptions : {
1274
+ projectId: options.project,
1275
+ ...options.googleAuthOptions
1276
+ };
1277
+ const generateAuthToken = createAuthTokenGenerator(googleAuthOptions);
1278
+ return createGoogleVertex({
936
1279
  ...options,
937
1280
  headers: async () => ({
938
- Authorization: `Bearer ${await generateAuthToken(
939
- options.googleAuthOptions
940
- )}`,
941
- ...await (0, import_provider_utils6.resolve)(options.headers)
1281
+ Authorization: `Bearer ${await generateAuthToken()}`,
1282
+ ...await resolve6(options.headers)
942
1283
  })
943
1284
  });
944
1285
  }
945
- var vertex = createVertex2();
946
- // Annotate the CommonJS export names for ESM import in node:
947
- 0 && (module.exports = {
1286
+ var googleVertex = createGoogleVertex2();
1287
+ export {
948
1288
  VERSION,
949
- createVertex,
950
- vertex
951
- });
1289
+ createGoogleVertex2 as createGoogleVertex,
1290
+ createGoogleVertex2 as createVertex,
1291
+ googleVertex,
1292
+ googleVertex as vertex
1293
+ };
952
1294
  //# sourceMappingURL=index.js.map