@ai-sdk/google-vertex 5.0.0-beta.10 → 5.0.0-beta.109

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 +937 -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 +58 -29
  10. package/dist/edge/index.js +581 -278
  11. package/dist/edge/index.js.map +1 -1
  12. package/dist/index.d.ts +70 -32
  13. package/dist/index.js +590 -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 +35 -10
  43. package/src/google-vertex-image-model-options.ts +74 -0
  44. package/src/google-vertex-image-model.ts +106 -133
  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 +39 -75
  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.10" : "0.0.0-test";
35
+ var VERSION = true ? "5.0.0-beta.109" : "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,23 +102,32 @@ 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
- this.specificationVersion = "v3";
116
+ this.specificationVersion = "v4";
129
117
  this.maxEmbeddingsPerCall = 2048;
130
118
  this.supportsParallelCalls = true;
131
119
  this.modelId = modelId;
132
120
  this.config = config;
133
121
  }
122
+ static [WORKFLOW_SERIALIZE](model) {
123
+ return serializeModelOptions({
124
+ modelId: model.modelId,
125
+ config: model.config
126
+ });
127
+ }
128
+ static [WORKFLOW_DESERIALIZE](options) {
129
+ return new _GoogleVertexEmbeddingModel(options.modelId, options.config);
130
+ }
134
131
  get provider() {
135
132
  return this.config.provider;
136
133
  }
@@ -140,13 +137,20 @@ var GoogleVertexEmbeddingModel = class {
140
137
  abortSignal,
141
138
  providerOptions
142
139
  }) {
143
- let googleOptions = await (0, import_provider_utils2.parseProviderOptions)({
144
- provider: "vertex",
140
+ let googleOptions = await parseProviderOptions({
141
+ provider: "googleVertex",
145
142
  providerOptions,
146
143
  schema: googleVertexEmbeddingModelOptions
147
144
  });
148
145
  if (googleOptions == null) {
149
- googleOptions = await (0, import_provider_utils2.parseProviderOptions)({
146
+ googleOptions = await parseProviderOptions({
147
+ provider: "vertex",
148
+ providerOptions,
149
+ schema: googleVertexEmbeddingModelOptions
150
+ });
151
+ }
152
+ if (googleOptions == null) {
153
+ googleOptions = await parseProviderOptions({
150
154
  provider: "google",
151
155
  providerOptions,
152
156
  schema: googleVertexEmbeddingModelOptions
@@ -154,15 +158,15 @@ var GoogleVertexEmbeddingModel = class {
154
158
  }
155
159
  googleOptions = googleOptions != null ? googleOptions : {};
156
160
  if (values.length > this.maxEmbeddingsPerCall) {
157
- throw new import_provider.TooManyEmbeddingValuesForCallError({
161
+ throw new TooManyEmbeddingValuesForCallError({
158
162
  provider: this.provider,
159
163
  modelId: this.modelId,
160
164
  maxEmbeddingsPerCall: this.maxEmbeddingsPerCall,
161
165
  values
162
166
  });
163
167
  }
164
- const mergedHeaders = (0, import_provider_utils2.combineHeaders)(
165
- await (0, import_provider_utils2.resolve)(this.config.headers),
168
+ const mergedHeaders = combineHeaders(
169
+ this.config.headers ? await resolve(this.config.headers) : void 0,
166
170
  headers
167
171
  );
168
172
  const url = `${this.config.baseURL}/models/${this.modelId}:predict`;
@@ -170,7 +174,7 @@ var GoogleVertexEmbeddingModel = class {
170
174
  responseHeaders,
171
175
  value: response,
172
176
  rawValue
173
- } = await (0, import_provider_utils2.postJsonToApi)({
177
+ } = await postJsonToApi({
174
178
  url,
175
179
  headers: mergedHeaders,
176
180
  body: {
@@ -185,7 +189,7 @@ var GoogleVertexEmbeddingModel = class {
185
189
  }
186
190
  },
187
191
  failedResponseHandler: googleVertexFailedResponseHandler,
188
- successfulResponseHandler: (0, import_provider_utils2.createJsonResponseHandler)(
192
+ successfulResponseHandler: createJsonResponseHandler(
189
193
  googleVertexTextEmbeddingResponseSchema
190
194
  ),
191
195
  abortSignal,
@@ -206,13 +210,13 @@ var GoogleVertexEmbeddingModel = class {
206
210
  };
207
211
  }
208
212
  };
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()
213
+ var googleVertexTextEmbeddingResponseSchema = z3.object({
214
+ predictions: z3.array(
215
+ z3.object({
216
+ embeddings: z3.object({
217
+ values: z3.array(z3.number()),
218
+ statistics: z3.object({
219
+ token_count: z3.number()
216
220
  })
217
221
  })
218
222
  })
@@ -220,14 +224,96 @@ var googleVertexTextEmbeddingResponseSchema = import_v43.z.object({
220
224
  });
221
225
 
222
226
  // 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 {
227
+ import { GoogleLanguageModel } from "@ai-sdk/google/internal";
228
+ import {
229
+ combineHeaders as combineHeaders2,
230
+ convertToBase64,
231
+ convertUint8ArrayToBase64,
232
+ createJsonResponseHandler as createJsonResponseHandler2,
233
+ generateId as defaultGenerateId,
234
+ parseProviderOptions as parseProviderOptions2,
235
+ postJsonToApi as postJsonToApi2,
236
+ resolve as resolve2,
237
+ serializeModelOptions as serializeModelOptions2,
238
+ WORKFLOW_SERIALIZE as WORKFLOW_SERIALIZE2,
239
+ WORKFLOW_DESERIALIZE as WORKFLOW_DESERIALIZE2
240
+ } from "@ai-sdk/provider-utils";
241
+ import { z as z5 } from "zod/v4";
242
+
243
+ // src/google-vertex-image-model-options.ts
244
+ import { z as z4 } from "zod/v4";
245
+ var googleVertexImageModelOptionsSchema = z4.object({
246
+ negativePrompt: z4.string().nullish(),
247
+ personGeneration: z4.enum(["dont_allow", "allow_adult", "allow_all"]).nullish(),
248
+ safetySetting: z4.enum([
249
+ "block_low_and_above",
250
+ "block_medium_and_above",
251
+ "block_only_high",
252
+ "block_none"
253
+ ]).nullish(),
254
+ addWatermark: z4.boolean().nullish(),
255
+ storageUri: z4.string().nullish(),
256
+ sampleImageSize: z4.enum(["1K", "2K"]).nullish(),
257
+ /**
258
+ * Configuration for image editing operations
259
+ */
260
+ edit: z4.object({
261
+ /**
262
+ * An integer that represents the number of sampling steps.
263
+ * A higher value offers better image quality, a lower value offers better latency.
264
+ * Try 35 steps to start. If the quality doesn't meet your requirements,
265
+ * increase the value towards an upper limit of 75.
266
+ */
267
+ baseSteps: z4.number().nullish(),
268
+ // Edit mode options
269
+ // https://cloud.google.com/vertex-ai/generative-ai/docs/image/edit-insert-objects
270
+ mode: z4.enum([
271
+ "EDIT_MODE_INPAINT_INSERTION",
272
+ "EDIT_MODE_INPAINT_REMOVAL",
273
+ "EDIT_MODE_OUTPAINT",
274
+ "EDIT_MODE_CONTROLLED_EDITING",
275
+ "EDIT_MODE_PRODUCT_IMAGE",
276
+ "EDIT_MODE_BGSWAP"
277
+ ]).nullish(),
278
+ /**
279
+ * The mask mode to use.
280
+ * - `MASK_MODE_DEFAULT` - Default value for mask mode.
281
+ * - `MASK_MODE_USER_PROVIDED` - User provided mask. No segmentation needed.
282
+ * - `MASK_MODE_DETECTION_BOX` - Mask from detected bounding boxes.
283
+ * - `MASK_MODE_CLOTHING_AREA` - Masks from segmenting the clothing area with open-vocab segmentation.
284
+ * - `MASK_MODE_PARSED_PERSON` - Masks from segmenting the person body and clothing using the person-parsing model.
285
+ */
286
+ maskMode: z4.enum([
287
+ "MASK_MODE_DEFAULT",
288
+ "MASK_MODE_USER_PROVIDED",
289
+ "MASK_MODE_DETECTION_BOX",
290
+ "MASK_MODE_CLOTHING_AREA",
291
+ "MASK_MODE_PARSED_PERSON"
292
+ ]).nullish(),
293
+ /**
294
+ * Optional. A float value between 0 and 1, inclusive, that represents the
295
+ * percentage of the image width to grow the mask by. Using dilation helps
296
+ * compensate for imprecise masks. We recommend a value of 0.01.
297
+ */
298
+ maskDilation: z4.number().nullish()
299
+ }).nullish()
300
+ });
301
+
302
+ // src/google-vertex-image-model.ts
303
+ var GoogleVertexImageModel = class _GoogleVertexImageModel {
227
304
  constructor(modelId, config) {
228
305
  this.modelId = modelId;
229
306
  this.config = config;
230
- this.specificationVersion = "v3";
307
+ this.specificationVersion = "v4";
308
+ }
309
+ static [WORKFLOW_SERIALIZE2](model) {
310
+ return serializeModelOptions2({
311
+ modelId: model.modelId,
312
+ config: model.config
313
+ });
314
+ }
315
+ static [WORKFLOW_DESERIALIZE2](options) {
316
+ return new _GoogleVertexImageModel(options.modelId, options.config);
231
317
  }
232
318
  get maxImagesPerCall() {
233
319
  if (isGeminiModel(this.modelId)) {
@@ -256,7 +342,7 @@ var GoogleVertexImageModel = class {
256
342
  files,
257
343
  mask
258
344
  }) {
259
- var _a, _b, _c, _d, _e, _f, _g;
345
+ var _a, _b, _c, _d, _e, _f;
260
346
  const warnings = [];
261
347
  if (size != null) {
262
348
  warnings.push({
@@ -265,12 +351,16 @@ var GoogleVertexImageModel = class {
265
351
  details: "This model does not support the `size` option. Use `aspectRatio` instead."
266
352
  });
267
353
  }
268
- const vertexImageOptions = await (0, import_provider_utils3.parseProviderOptions)({
354
+ const googleVertexImageOptions = (_a = await parseProviderOptions2({
355
+ provider: "googleVertex",
356
+ providerOptions,
357
+ schema: googleVertexImageModelOptionsSchema
358
+ })) != null ? _a : await parseProviderOptions2({
269
359
  provider: "vertex",
270
360
  providerOptions,
271
361
  schema: googleVertexImageModelOptionsSchema
272
362
  });
273
- const { edit, ...otherOptions } = vertexImageOptions != null ? vertexImageOptions : {};
363
+ const { edit, ...otherOptions } = googleVertexImageOptions != null ? googleVertexImageOptions : {};
274
364
  const { mode: editMode, baseSteps, maskMode, maskDilation } = edit != null ? edit : {};
275
365
  const isEditMode = files != null && files.length > 0;
276
366
  let body;
@@ -326,39 +416,44 @@ var GoogleVertexImageModel = class {
326
416
  }
327
417
  };
328
418
  }
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)({
419
+ const currentDate = (_d = (_c = (_b = this.config._internal) == null ? void 0 : _b.currentDate) == null ? void 0 : _c.call(_b)) != null ? _d : /* @__PURE__ */ new Date();
420
+ const { value: response, responseHeaders } = await postJsonToApi2({
331
421
  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),
422
+ headers: combineHeaders2(
423
+ this.config.headers ? await resolve2(this.config.headers) : void 0,
424
+ headers
425
+ ),
333
426
  body,
334
427
  failedResponseHandler: googleVertexFailedResponseHandler,
335
- successfulResponseHandler: (0, import_provider_utils3.createJsonResponseHandler)(
336
- vertexImageResponseSchema
428
+ successfulResponseHandler: createJsonResponseHandler2(
429
+ googleVertexImageResponseSchema
337
430
  ),
338
431
  abortSignal,
339
432
  fetch: this.config.fetch
340
433
  });
341
434
  return {
342
- images: (_e = (_d = response.predictions) == null ? void 0 : _d.map(
435
+ images: (_f = (_e = response.predictions) == null ? void 0 : _e.map(
343
436
  ({ bytesBase64Encoded }) => bytesBase64Encoded
344
- )) != null ? _e : [],
437
+ )) != null ? _f : [],
345
438
  warnings,
346
439
  response: {
347
440
  timestamp: currentDate,
348
441
  modelId: this.modelId,
349
442
  headers: responseHeaders
350
443
  },
351
- providerMetadata: {
352
- vertex: {
353
- images: (_g = (_f = response.predictions) == null ? void 0 : _f.map((prediction) => {
444
+ providerMetadata: (() => {
445
+ var _a2, _b2;
446
+ const payload = {
447
+ images: (_b2 = (_a2 = response.predictions) == null ? void 0 : _a2.map((prediction) => {
354
448
  const {
355
449
  // normalize revised prompt property
356
450
  prompt: revisedPrompt
357
451
  } = prediction;
358
452
  return { ...revisedPrompt != null && { revisedPrompt } };
359
- })) != null ? _g : []
360
- }
361
- }
453
+ })) != null ? _b2 : []
454
+ };
455
+ return { googleVertex: payload, vertex: payload };
456
+ })()
362
457
  };
363
458
  }
364
459
  async doGenerateGemini({
@@ -401,13 +496,16 @@ var GoogleVertexImageModel = class {
401
496
  if (file.type === "url") {
402
497
  userContent.push({
403
498
  type: "file",
404
- data: new URL(file.url),
499
+ data: { type: "url", url: new URL(file.url) },
405
500
  mediaType: "image/*"
406
501
  });
407
502
  } else {
408
503
  userContent.push({
409
504
  type: "file",
410
- data: typeof file.data === "string" ? file.data : new Uint8Array(file.data),
505
+ data: {
506
+ type: "data",
507
+ data: typeof file.data === "string" ? file.data : new Uint8Array(file.data)
508
+ },
411
509
  mediaType: file.mediaType
412
510
  });
413
511
  }
@@ -416,27 +514,30 @@ var GoogleVertexImageModel = class {
416
514
  const languageModelPrompt = [
417
515
  { role: "user", content: userContent }
418
516
  ];
419
- const languageModel = new import_internal.GoogleGenerativeAILanguageModel(this.modelId, {
517
+ const languageModel = new GoogleLanguageModel(this.modelId, {
420
518
  provider: this.config.provider,
421
519
  baseURL: this.config.baseURL,
422
520
  headers: (_a = this.config.headers) != null ? _a : {},
423
521
  fetch: this.config.fetch,
424
- generateId: (_b = this.config.generateId) != null ? _b : import_provider_utils3.generateId,
522
+ generateId: (_b = this.config.generateId) != null ? _b : defaultGenerateId,
425
523
  supportedUrls: () => ({
426
524
  "*": [/^https?:\/\/.*$/, /^gs:\/\/.*$/]
427
525
  })
428
526
  });
527
+ const userVertexOptions = (_c = providerOptions == null ? void 0 : providerOptions.googleVertex) != null ? _c : providerOptions == null ? void 0 : providerOptions.vertex;
528
+ const innerVertexOptions = {
529
+ responseModalities: ["IMAGE"],
530
+ imageConfig: aspectRatio ? {
531
+ aspectRatio
532
+ } : void 0,
533
+ ...userVertexOptions != null ? userVertexOptions : {}
534
+ };
429
535
  const result = await languageModel.doGenerate({
430
536
  prompt: languageModelPrompt,
431
537
  seed,
432
538
  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
- }
539
+ googleVertex: innerVertexOptions,
540
+ vertex: innerVertexOptions
440
541
  },
441
542
  headers,
442
543
  abortSignal
@@ -444,17 +545,19 @@ var GoogleVertexImageModel = class {
444
545
  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
546
  const images = [];
446
547
  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));
548
+ if (part.type === "file" && part.mediaType.startsWith("image/") && part.data.type === "data") {
549
+ images.push(convertToBase64(part.data.data));
449
550
  }
450
551
  }
552
+ const geminiPayload = {
553
+ images: images.map(() => ({}))
554
+ };
451
555
  return {
452
556
  images,
453
557
  warnings,
454
558
  providerMetadata: {
455
- vertex: {
456
- images: images.map(() => ({}))
457
- }
559
+ googleVertex: geminiPayload,
560
+ vertex: geminiPayload
458
561
  },
459
562
  response: {
460
563
  timestamp: currentDate,
@@ -472,71 +575,15 @@ var GoogleVertexImageModel = class {
472
575
  function isGeminiModel(modelId) {
473
576
  return modelId.startsWith("gemini-");
474
577
  }
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()
578
+ var googleVertexImageResponseSchema = z5.object({
579
+ predictions: z5.array(
580
+ z5.object({
581
+ bytesBase64Encoded: z5.string(),
582
+ mimeType: z5.string(),
583
+ prompt: z5.string().nullish()
481
584
  })
482
585
  ).nullish()
483
586
  });
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
587
  function getBase64Data(file) {
541
588
  if (file.type === "url") {
542
589
  throw new Error(
@@ -546,30 +593,255 @@ function getBase64Data(file) {
546
593
  if (typeof file.data === "string") {
547
594
  return file.data;
548
595
  }
549
- return (0, import_provider_utils3.convertUint8ArrayToBase64)(file.data);
596
+ return convertUint8ArrayToBase64(file.data);
550
597
  }
551
598
 
552
599
  // src/google-vertex-tools.ts
553
- var import_internal2 = require("@ai-sdk/google/internal");
600
+ import { googleTools } from "@ai-sdk/google/internal";
554
601
  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
602
+ googleSearch: googleTools.googleSearch,
603
+ enterpriseWebSearch: googleTools.enterpriseWebSearch,
604
+ googleMaps: googleTools.googleMaps,
605
+ urlContext: googleTools.urlContext,
606
+ fileSearch: googleTools.fileSearch,
607
+ codeExecution: googleTools.codeExecution,
608
+ vertexRagStore: googleTools.vertexRagStore
609
+ };
610
+
611
+ // src/google-vertex-transcription-model.ts
612
+ import {
613
+ combineHeaders as combineHeaders3,
614
+ convertUint8ArrayToBase64 as convertUint8ArrayToBase642,
615
+ createJsonResponseHandler as createJsonResponseHandler3,
616
+ parseProviderOptions as parseProviderOptions3,
617
+ postJsonToApi as postJsonToApi3,
618
+ resolve as resolve3,
619
+ serializeModelOptions as serializeModelOptions3,
620
+ WORKFLOW_DESERIALIZE as WORKFLOW_DESERIALIZE3,
621
+ WORKFLOW_SERIALIZE as WORKFLOW_SERIALIZE3
622
+ } from "@ai-sdk/provider-utils";
623
+ import { z as z7 } from "zod/v4";
624
+
625
+ // src/google-vertex-transcription-model-options.ts
626
+ import { z as z6 } from "zod/v4";
627
+ var googleVertexTranscriptionProviderOptionsSchema = z6.object({
628
+ /**
629
+ * BCP-47 language codes to recognize (e.g. `['en-US']`), or `['auto']` to let
630
+ * Chirp auto-detect the spoken language. Defaults to `['auto']`. For
631
+ * `telephony`, pass a supported explicit language code.
632
+ */
633
+ languageCodes: z6.array(z6.string()).optional(),
634
+ /**
635
+ * Whether to add punctuation to the transcript. Defaults to `true`.
636
+ */
637
+ enableAutomaticPunctuation: z6.boolean().optional(),
638
+ /**
639
+ * Whether to include word-level timestamps. Defaults to `true` so the
640
+ * transcription result can include segments.
641
+ *
642
+ * Enabling word-level timestamps can reduce transcription quality and speed
643
+ * for Chirp models.
644
+ */
645
+ enableWordTimeOffsets: z6.boolean().optional(),
646
+ /**
647
+ * The Cloud Speech-to-Text region for the request (e.g. `'us'`, `'eu'`,
648
+ * `'us-central1'`). Defaults to the provider `location`.
649
+ *
650
+ * Note: Speech-to-Text regions differ from Vertex AI regions. Chirp is only
651
+ * available in specific Speech-to-Text regions and is not available in the
652
+ * `global` location.
653
+ */
654
+ region: z6.string().optional()
655
+ });
656
+
657
+ // src/google-vertex-transcription-model.ts
658
+ function parseDurationSeconds(value) {
659
+ if (value == null) {
660
+ return void 0;
661
+ }
662
+ const seconds = Number.parseFloat(value);
663
+ return Number.isFinite(seconds) ? seconds : void 0;
664
+ }
665
+ function convertBcp47ToIso6391(value) {
666
+ if (value == null) {
667
+ return void 0;
668
+ }
669
+ try {
670
+ const language = new Intl.Locale(value).language;
671
+ return language.length === 2 ? language : void 0;
672
+ } catch (e) {
673
+ return void 0;
674
+ }
675
+ }
676
+ var GoogleVertexTranscriptionModel = class _GoogleVertexTranscriptionModel {
677
+ constructor(modelId, config) {
678
+ this.modelId = modelId;
679
+ this.config = config;
680
+ this.specificationVersion = "v4";
681
+ }
682
+ static [WORKFLOW_SERIALIZE3](model) {
683
+ return serializeModelOptions3({
684
+ modelId: model.modelId,
685
+ config: model.config
686
+ });
687
+ }
688
+ static [WORKFLOW_DESERIALIZE3](options) {
689
+ return new _GoogleVertexTranscriptionModel(options.modelId, options.config);
690
+ }
691
+ get provider() {
692
+ return this.config.provider;
693
+ }
694
+ async doGenerate(options) {
695
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
696
+ const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
697
+ const warnings = [];
698
+ let googleOptions;
699
+ for (const provider of ["googleVertex", "vertex", "google"]) {
700
+ googleOptions = await parseProviderOptions3({
701
+ provider,
702
+ providerOptions: options.providerOptions,
703
+ schema: googleVertexTranscriptionProviderOptionsSchema
704
+ });
705
+ if (googleOptions != null) {
706
+ break;
707
+ }
708
+ }
709
+ const region = (_d = googleOptions == null ? void 0 : googleOptions.region) != null ? _d : this.config.location;
710
+ const languageCodes = (_e = googleOptions == null ? void 0 : googleOptions.languageCodes) != null ? _e : ["auto"];
711
+ const content = typeof options.audio === "string" ? options.audio : convertUint8ArrayToBase642(options.audio);
712
+ const requestBody = {
713
+ config: {
714
+ model: this.modelId,
715
+ languageCodes,
716
+ // Let Speech-to-Text auto-detect the audio encoding (wav/mp3/flac/…).
717
+ autoDecodingConfig: {},
718
+ features: {
719
+ // Word timing populates `segments`.
720
+ enableWordTimeOffsets: (_f = googleOptions == null ? void 0 : googleOptions.enableWordTimeOffsets) != null ? _f : true,
721
+ enableAutomaticPunctuation: (_g = googleOptions == null ? void 0 : googleOptions.enableAutomaticPunctuation) != null ? _g : true
722
+ }
723
+ },
724
+ content
725
+ };
726
+ const host = region === "global" ? "speech.googleapis.com" : `${region}-speech.googleapis.com`;
727
+ const url = `https://${host}/v2/projects/${this.config.project}/locations/${region}/recognizers/_:recognize`;
728
+ const {
729
+ value: response,
730
+ responseHeaders,
731
+ rawValue: rawResponse
732
+ } = await postJsonToApi3({
733
+ url,
734
+ headers: combineHeaders3(
735
+ this.config.headers ? await resolve3(this.config.headers) : void 0,
736
+ options.headers
737
+ ),
738
+ body: requestBody,
739
+ failedResponseHandler: googleVertexFailedResponseHandler,
740
+ successfulResponseHandler: createJsonResponseHandler3(
741
+ googleVertexTranscriptionResponseSchema
742
+ ),
743
+ abortSignal: options.abortSignal,
744
+ fetch: this.config.fetch
745
+ });
746
+ const results = (_h = response.results) != null ? _h : [];
747
+ const text = results.map((result) => {
748
+ var _a2, _b2, _c2;
749
+ return (_c2 = (_b2 = (_a2 = result.alternatives) == null ? void 0 : _a2[0]) == null ? void 0 : _b2.transcript) != null ? _c2 : "";
750
+ }).join(" ").trim();
751
+ const segments = results.flatMap(
752
+ (result) => {
753
+ var _a2, _b2, _c2, _d2;
754
+ return (_d2 = (_c2 = (_b2 = (_a2 = result.alternatives) == null ? void 0 : _a2[0]) == null ? void 0 : _b2.words) == null ? void 0 : _c2.flatMap((word) => {
755
+ const startSecond = parseDurationSeconds(word.startOffset);
756
+ const endSecond = parseDurationSeconds(word.endOffset);
757
+ return word.word == null || startSecond == null || endSecond == null ? [] : [{ text: word.word, startSecond, endSecond }];
758
+ })) != null ? _d2 : [];
759
+ }
760
+ );
761
+ const language = convertBcp47ToIso6391((_i = results[0]) == null ? void 0 : _i.languageCode);
762
+ return {
763
+ text,
764
+ segments,
765
+ language,
766
+ durationInSeconds: parseDurationSeconds(
767
+ (_j = response.metadata) == null ? void 0 : _j.totalBilledDuration
768
+ ),
769
+ warnings,
770
+ response: {
771
+ timestamp: currentDate,
772
+ modelId: this.modelId,
773
+ headers: responseHeaders,
774
+ body: rawResponse
775
+ }
776
+ };
777
+ }
562
778
  };
779
+ var googleVertexTranscriptionResponseSchema = z7.object({
780
+ results: z7.array(
781
+ z7.object({
782
+ alternatives: z7.array(
783
+ z7.object({
784
+ transcript: z7.string().nullish(),
785
+ words: z7.array(
786
+ z7.object({
787
+ word: z7.string().nullish(),
788
+ startOffset: z7.string().nullish(),
789
+ endOffset: z7.string().nullish()
790
+ })
791
+ ).nullish()
792
+ })
793
+ ).nullish(),
794
+ languageCode: z7.string().nullish()
795
+ })
796
+ ).nullish(),
797
+ metadata: z7.object({
798
+ totalBilledDuration: z7.string().nullish()
799
+ }).nullish()
800
+ });
801
+
802
+ // src/google-vertex-video-model.ts
803
+ import {
804
+ AISDKError
805
+ } from "@ai-sdk/provider";
806
+ import {
807
+ combineHeaders as combineHeaders4,
808
+ convertUint8ArrayToBase64 as convertUint8ArrayToBase643,
809
+ createJsonResponseHandler as createJsonResponseHandler4,
810
+ delay,
811
+ parseProviderOptions as parseProviderOptions4,
812
+ postJsonToApi as postJsonToApi4,
813
+ resolve as resolve4
814
+ } from "@ai-sdk/provider-utils";
815
+ import { z as z9 } from "zod/v4";
816
+
817
+ // src/google-vertex-video-model-options.ts
818
+ import { lazySchema, zodSchema } from "@ai-sdk/provider-utils";
819
+ import { z as z8 } from "zod/v4";
820
+ var googleVertexVideoModelOptionsSchema = lazySchema(
821
+ () => zodSchema(
822
+ z8.object({
823
+ pollIntervalMs: z8.number().positive().nullish(),
824
+ pollTimeoutMs: z8.number().positive().nullish(),
825
+ personGeneration: z8.enum(["dont_allow", "allow_adult", "allow_all"]).nullish(),
826
+ negativePrompt: z8.string().nullish(),
827
+ generateAudio: z8.boolean().nullish(),
828
+ gcsOutputDirectory: z8.string().nullish(),
829
+ referenceImages: z8.array(
830
+ z8.object({
831
+ bytesBase64Encoded: z8.string().nullish(),
832
+ gcsUri: z8.string().nullish()
833
+ })
834
+ ).nullish()
835
+ }).passthrough()
836
+ )
837
+ );
563
838
 
564
839
  // 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
840
  var GoogleVertexVideoModel = class {
569
841
  constructor(modelId, config) {
570
842
  this.modelId = modelId;
571
843
  this.config = config;
572
- this.specificationVersion = "v3";
844
+ this.specificationVersion = "v4";
573
845
  }
574
846
  get provider() {
575
847
  return this.config.provider;
@@ -578,10 +850,14 @@ var GoogleVertexVideoModel = class {
578
850
  return 4;
579
851
  }
580
852
  async doGenerate(options) {
581
- var _a, _b, _c, _d, _e, _f;
853
+ var _a, _b, _c, _d, _e, _f, _g;
582
854
  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
855
  const warnings = [];
584
- const vertexOptions = await (0, import_provider_utils4.parseProviderOptions)({
856
+ const googleVertexOptions = (_d = await parseProviderOptions4({
857
+ provider: "googleVertex",
858
+ providerOptions: options.providerOptions,
859
+ schema: googleVertexVideoModelOptionsSchema
860
+ })) != null ? _d : await parseProviderOptions4({
585
861
  provider: "vertex",
586
862
  providerOptions: options.providerOptions,
587
863
  schema: googleVertexVideoModelOptionsSchema
@@ -599,15 +875,15 @@ var GoogleVertexVideoModel = class {
599
875
  details: "Vertex AI video models require base64-encoded images or GCS URIs. URL will be ignored."
600
876
  });
601
877
  } else {
602
- const base64Data = typeof options.image.data === "string" ? options.image.data : (0, import_provider_utils4.convertUint8ArrayToBase64)(options.image.data);
878
+ const base64Data = typeof options.image.data === "string" ? options.image.data : convertUint8ArrayToBase643(options.image.data);
603
879
  instance.image = {
604
880
  bytesBase64Encoded: base64Data,
605
881
  mimeType: options.image.mediaType
606
882
  };
607
883
  }
608
884
  }
609
- if ((vertexOptions == null ? void 0 : vertexOptions.referenceImages) != null) {
610
- instance.referenceImages = vertexOptions.referenceImages;
885
+ if ((googleVertexOptions == null ? void 0 : googleVertexOptions.referenceImages) != null) {
886
+ instance.referenceImages = googleVertexOptions.referenceImages;
611
887
  }
612
888
  const parameters = {
613
889
  sampleCount: options.n
@@ -629,8 +905,8 @@ var GoogleVertexVideoModel = class {
629
905
  if (options.seed) {
630
906
  parameters.seed = options.seed;
631
907
  }
632
- if (vertexOptions != null) {
633
- const opts = vertexOptions;
908
+ if (googleVertexOptions != null) {
909
+ const opts = googleVertexOptions;
634
910
  if (opts.personGeneration !== void 0 && opts.personGeneration !== null) {
635
911
  parameters.personGeneration = opts.personGeneration;
636
912
  }
@@ -657,18 +933,18 @@ var GoogleVertexVideoModel = class {
657
933
  }
658
934
  }
659
935
  }
660
- const { value: operation } = await (0, import_provider_utils4.postJsonToApi)({
936
+ const { value: operation } = await postJsonToApi4({
661
937
  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),
938
+ headers: combineHeaders4(
939
+ await resolve4(this.config.headers),
664
940
  options.headers
665
941
  ),
666
942
  body: {
667
943
  instances,
668
944
  parameters
669
945
  },
670
- successfulResponseHandler: (0, import_provider_utils4.createJsonResponseHandler)(
671
- vertexOperationSchema
946
+ successfulResponseHandler: createJsonResponseHandler4(
947
+ googleVertexOperationSchema
672
948
  ),
673
949
  failedResponseHandler: googleVertexFailedResponseHandler,
674
950
  abortSignal: options.abortSignal,
@@ -676,41 +952,41 @@ var GoogleVertexVideoModel = class {
676
952
  });
677
953
  const operationName = operation.name;
678
954
  if (!operationName) {
679
- throw new import_provider2.AISDKError({
955
+ throw new AISDKError({
680
956
  name: "VERTEX_VIDEO_GENERATION_ERROR",
681
957
  message: "No operation name returned from API"
682
958
  });
683
959
  }
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;
960
+ const pollIntervalMs = (_e = googleVertexOptions == null ? void 0 : googleVertexOptions.pollIntervalMs) != null ? _e : 1e4;
961
+ const pollTimeoutMs = (_f = googleVertexOptions == null ? void 0 : googleVertexOptions.pollTimeoutMs) != null ? _f : 6e5;
686
962
  const startTime = Date.now();
687
963
  let finalOperation = operation;
688
964
  let responseHeaders;
689
965
  while (!finalOperation.done) {
690
966
  if (Date.now() - startTime > pollTimeoutMs) {
691
- throw new import_provider2.AISDKError({
967
+ throw new AISDKError({
692
968
  name: "VERTEX_VIDEO_GENERATION_TIMEOUT",
693
969
  message: `Video generation timed out after ${pollTimeoutMs}ms`
694
970
  });
695
971
  }
696
- await (0, import_provider_utils4.delay)(pollIntervalMs);
697
- if ((_f = options.abortSignal) == null ? void 0 : _f.aborted) {
698
- throw new import_provider2.AISDKError({
972
+ await delay(pollIntervalMs);
973
+ if ((_g = options.abortSignal) == null ? void 0 : _g.aborted) {
974
+ throw new AISDKError({
699
975
  name: "VERTEX_VIDEO_GENERATION_ABORTED",
700
976
  message: "Video generation request was aborted"
701
977
  });
702
978
  }
703
- const { value: statusOperation, responseHeaders: pollHeaders } = await (0, import_provider_utils4.postJsonToApi)({
979
+ const { value: statusOperation, responseHeaders: pollHeaders } = await postJsonToApi4({
704
980
  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),
981
+ headers: combineHeaders4(
982
+ await resolve4(this.config.headers),
707
983
  options.headers
708
984
  ),
709
985
  body: {
710
986
  operationName
711
987
  },
712
- successfulResponseHandler: (0, import_provider_utils4.createJsonResponseHandler)(
713
- vertexOperationSchema
988
+ successfulResponseHandler: createJsonResponseHandler4(
989
+ googleVertexOperationSchema
714
990
  ),
715
991
  failedResponseHandler: googleVertexFailedResponseHandler,
716
992
  abortSignal: options.abortSignal,
@@ -720,14 +996,14 @@ var GoogleVertexVideoModel = class {
720
996
  responseHeaders = pollHeaders;
721
997
  }
722
998
  if (finalOperation.error) {
723
- throw new import_provider2.AISDKError({
999
+ throw new AISDKError({
724
1000
  name: "VERTEX_VIDEO_GENERATION_FAILED",
725
1001
  message: `Video generation failed: ${finalOperation.error.message}`
726
1002
  });
727
1003
  }
728
1004
  const response = finalOperation.response;
729
1005
  if (!(response == null ? void 0 : response.videos) || response.videos.length === 0) {
730
- throw new import_provider2.AISDKError({
1006
+ throw new AISDKError({
731
1007
  name: "VERTEX_VIDEO_GENERATION_ERROR",
732
1008
  message: `No videos in response. Response: ${JSON.stringify(finalOperation)}`
733
1009
  });
@@ -757,7 +1033,7 @@ var GoogleVertexVideoModel = class {
757
1033
  }
758
1034
  }
759
1035
  if (videos.length === 0) {
760
- throw new import_provider2.AISDKError({
1036
+ throw new AISDKError({
761
1037
  name: "VERTEX_VIDEO_GENERATION_ERROR",
762
1038
  message: "No valid videos in response"
763
1039
  });
@@ -770,78 +1046,64 @@ var GoogleVertexVideoModel = class {
770
1046
  modelId: this.modelId,
771
1047
  headers: responseHeaders
772
1048
  },
773
- providerMetadata: {
774
- "google-vertex": {
775
- videos: videoMetadata
776
- }
777
- }
1049
+ providerMetadata: /* @__PURE__ */ (() => {
1050
+ const payload = { videos: videoMetadata };
1051
+ return {
1052
+ googleVertex: payload,
1053
+ // Legacy keys preserved for backward compatibility.
1054
+ "google-vertex": payload,
1055
+ vertex: payload
1056
+ };
1057
+ })()
778
1058
  };
779
1059
  }
780
1060
  };
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()
1061
+ var googleVertexOperationSchema = z9.object({
1062
+ name: z9.string().nullish(),
1063
+ done: z9.boolean().nullish(),
1064
+ error: z9.object({
1065
+ code: z9.number().nullish(),
1066
+ message: z9.string(),
1067
+ status: z9.string().nullish()
788
1068
  }).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()
1069
+ response: z9.object({
1070
+ videos: z9.array(
1071
+ z9.object({
1072
+ bytesBase64Encoded: z9.string().nullish(),
1073
+ gcsUri: z9.string().nullish(),
1074
+ mimeType: z9.string().nullish()
795
1075
  })
796
1076
  ).nullish(),
797
- raiMediaFilteredCount: import_v45.z.number().nullish()
1077
+ raiMediaFilteredCount: z9.number().nullish()
798
1078
  }).nullish()
799
1079
  });
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
1080
 
819
- // src/google-vertex-provider.ts
1081
+ // src/google-vertex-provider-base.ts
820
1082
  var EXPRESS_MODE_BASE_URL = "https://aiplatform.googleapis.com/v1/publishers/google";
821
1083
  function createExpressModeFetch(apiKey, customFetch) {
822
1084
  return async (url, init) => {
823
1085
  const modifiedInit = {
824
1086
  ...init,
825
1087
  headers: {
826
- ...(init == null ? void 0 : init.headers) ? (0, import_provider_utils5.normalizeHeaders)(init.headers) : {},
1088
+ ...(init == null ? void 0 : init.headers) ? normalizeHeaders(init.headers) : {},
827
1089
  "x-goog-api-key": apiKey
828
1090
  }
829
1091
  };
830
1092
  return (customFetch != null ? customFetch : fetch)(url.toString(), modifiedInit);
831
1093
  };
832
1094
  }
833
- function createVertex(options = {}) {
834
- const apiKey = (0, import_provider_utils5.loadOptionalSetting)({
1095
+ function createGoogleVertex(options = {}) {
1096
+ const apiKey = loadOptionalSetting({
835
1097
  settingValue: options.apiKey,
836
1098
  environmentVariableName: "GOOGLE_VERTEX_API_KEY"
837
1099
  });
838
- const loadVertexProject = () => (0, import_provider_utils5.loadSetting)({
1100
+ const loadGoogleVertexProject = () => loadSetting({
839
1101
  settingValue: options.project,
840
1102
  settingName: "project",
841
1103
  environmentVariableName: "GOOGLE_VERTEX_PROJECT",
842
1104
  description: "Google Vertex project"
843
1105
  });
844
- const loadVertexLocation = () => (0, import_provider_utils5.loadSetting)({
1106
+ const loadGoogleVertexLocation = () => loadSetting({
845
1107
  settingValue: options.location,
846
1108
  settingName: "location",
847
1109
  environmentVariableName: "GOOGLE_VERTEX_LOCATION",
@@ -850,18 +1112,26 @@ function createVertex(options = {}) {
850
1112
  const loadBaseURL = () => {
851
1113
  var _a, _b;
852
1114
  if (apiKey) {
853
- return (_a = (0, import_provider_utils5.withoutTrailingSlash)(options.baseURL)) != null ? _a : EXPRESS_MODE_BASE_URL;
1115
+ return (_a = withoutTrailingSlash(options.baseURL)) != null ? _a : EXPRESS_MODE_BASE_URL;
854
1116
  }
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`;
1117
+ const region = loadGoogleVertexLocation();
1118
+ const project = loadGoogleVertexProject();
1119
+ const getHost = () => {
1120
+ if (region === "global") {
1121
+ return "aiplatform.googleapis.com";
1122
+ } else if (region === "eu" || region === "us") {
1123
+ return `aiplatform.${region}.rep.googleapis.com`;
1124
+ } else {
1125
+ return `${region}-aiplatform.googleapis.com`;
1126
+ }
1127
+ };
1128
+ return (_b = withoutTrailingSlash(options.baseURL)) != null ? _b : `https://${getHost()}/v1beta1/projects/${project}/locations/${region}/publishers/google`;
859
1129
  };
860
1130
  const createConfig = (name) => {
861
1131
  const getHeaders = async () => {
862
1132
  var _a;
863
- const originalHeaders = await (0, import_provider_utils5.resolve)((_a = options.headers) != null ? _a : {});
864
- return (0, import_provider_utils5.withUserAgentSuffix)(
1133
+ const originalHeaders = await resolve5((_a = options.headers) != null ? _a : {});
1134
+ return withUserAgentSuffix(
865
1135
  originalHeaders,
866
1136
  `ai-sdk/google-vertex/${VERSION}`
867
1137
  );
@@ -875,9 +1145,9 @@ function createVertex(options = {}) {
875
1145
  };
876
1146
  const createChatModel = (modelId) => {
877
1147
  var _a;
878
- return new import_internal3.GoogleGenerativeAILanguageModel(modelId, {
1148
+ return new GoogleLanguageModel2(modelId, {
879
1149
  ...createConfig("chat"),
880
- generateId: (_a = options.generateId) != null ? _a : import_provider_utils5.generateId,
1150
+ generateId: (_a = options.generateId) != null ? _a : generateId,
881
1151
  supportedUrls: () => ({
882
1152
  "*": [
883
1153
  // HTTP URLs:
@@ -893,14 +1163,30 @@ function createVertex(options = {}) {
893
1163
  var _a;
894
1164
  return new GoogleVertexImageModel(modelId, {
895
1165
  ...createConfig("image"),
896
- generateId: (_a = options.generateId) != null ? _a : import_provider_utils5.generateId
1166
+ generateId: (_a = options.generateId) != null ? _a : generateId
897
1167
  });
898
1168
  };
899
1169
  const createVideoModel = (modelId) => {
900
1170
  var _a;
901
1171
  return new GoogleVertexVideoModel(modelId, {
902
1172
  ...createConfig("video"),
903
- generateId: (_a = options.generateId) != null ? _a : import_provider_utils5.generateId
1173
+ generateId: (_a = options.generateId) != null ? _a : generateId
1174
+ });
1175
+ };
1176
+ const createSpeechModel = (modelId) => new GoogleSpeechModel(modelId, createConfig("speech"));
1177
+ const createTranscriptionModel = (modelId) => {
1178
+ if (apiKey) {
1179
+ throw new Error(
1180
+ "Google Vertex transcription models do not support Express Mode API keys. Use standard Google Cloud credentials instead."
1181
+ );
1182
+ }
1183
+ const config = createConfig("transcription");
1184
+ return new GoogleVertexTranscriptionModel(modelId, {
1185
+ provider: config.provider,
1186
+ headers: config.headers,
1187
+ fetch: config.fetch,
1188
+ project: loadGoogleVertexProject(),
1189
+ location: loadGoogleVertexLocation()
904
1190
  });
905
1191
  };
906
1192
  const provider = function(modelId) {
@@ -911,7 +1197,7 @@ function createVertex(options = {}) {
911
1197
  }
912
1198
  return createChatModel(modelId);
913
1199
  };
914
- provider.specificationVersion = "v3";
1200
+ provider.specificationVersion = "v4";
915
1201
  provider.languageModel = createChatModel;
916
1202
  provider.embeddingModel = createEmbeddingModel;
917
1203
  provider.textEmbeddingModel = createEmbeddingModel;
@@ -919,34 +1205,42 @@ function createVertex(options = {}) {
919
1205
  provider.imageModel = createImageModel;
920
1206
  provider.video = createVideoModel;
921
1207
  provider.videoModel = createVideoModel;
1208
+ provider.speech = createSpeechModel;
1209
+ provider.speechModel = createSpeechModel;
1210
+ provider.transcription = createTranscriptionModel;
1211
+ provider.transcriptionModel = createTranscriptionModel;
922
1212
  provider.tools = googleVertexTools;
923
1213
  return provider;
924
1214
  }
925
1215
 
926
- // src/google-vertex-provider-node.ts
927
- function createVertex2(options = {}) {
928
- const apiKey = (0, import_provider_utils6.loadOptionalSetting)({
1216
+ // src/google-vertex-provider.ts
1217
+ function createGoogleVertex2(options = {}) {
1218
+ const apiKey = loadOptionalSetting2({
929
1219
  settingValue: options.apiKey,
930
1220
  environmentVariableName: "GOOGLE_VERTEX_API_KEY"
931
1221
  });
932
1222
  if (apiKey) {
933
- return createVertex(options);
1223
+ return createGoogleVertex(options);
934
1224
  }
935
- return createVertex({
1225
+ const googleAuthOptions = options.project == null ? options.googleAuthOptions : {
1226
+ projectId: options.project,
1227
+ ...options.googleAuthOptions
1228
+ };
1229
+ const generateAuthToken = createAuthTokenGenerator(googleAuthOptions);
1230
+ return createGoogleVertex({
936
1231
  ...options,
937
1232
  headers: async () => ({
938
- Authorization: `Bearer ${await generateAuthToken(
939
- options.googleAuthOptions
940
- )}`,
941
- ...await (0, import_provider_utils6.resolve)(options.headers)
1233
+ Authorization: `Bearer ${await generateAuthToken()}`,
1234
+ ...await resolve6(options.headers)
942
1235
  })
943
1236
  });
944
1237
  }
945
- var vertex = createVertex2();
946
- // Annotate the CommonJS export names for ESM import in node:
947
- 0 && (module.exports = {
1238
+ var googleVertex = createGoogleVertex2();
1239
+ export {
948
1240
  VERSION,
949
- createVertex,
950
- vertex
951
- });
1241
+ createGoogleVertex2 as createGoogleVertex,
1242
+ createGoogleVertex2 as createVertex,
1243
+ googleVertex,
1244
+ googleVertex as vertex
1245
+ };
952
1246
  //# sourceMappingURL=index.js.map