@ai-sdk/google-vertex 5.0.0-beta.5 → 5.0.0-beta.52

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/CHANGELOG.md +430 -8
  2. package/README.md +65 -1
  3. package/dist/anthropic/edge/index.d.ts +61 -16
  4. package/dist/anthropic/edge/index.js +67 -60
  5. package/dist/anthropic/edge/index.js.map +1 -1
  6. package/dist/anthropic/index.d.ts +61 -16
  7. package/dist/anthropic/index.js +57 -55
  8. package/dist/anthropic/index.js.map +1 -1
  9. package/dist/edge/index.d.ts +31 -22
  10. package/dist/edge/index.js +217 -176
  11. package/dist/edge/index.js.map +1 -1
  12. package/dist/index.d.ts +31 -22
  13. package/dist/index.js +208 -173
  14. package/dist/index.js.map +1 -1
  15. package/dist/maas/edge/index.d.ts +76 -0
  16. package/dist/maas/edge/index.js +196 -0
  17. package/dist/maas/edge/index.js.map +1 -0
  18. package/dist/maas/index.d.ts +60 -0
  19. package/dist/maas/index.js +101 -0
  20. package/dist/maas/index.js.map +1 -0
  21. package/docs/16-google-vertex.mdx +226 -6
  22. package/maas/edge.d.ts +1 -0
  23. package/maas/index.d.ts +1 -0
  24. package/package.json +29 -18
  25. package/src/anthropic/edge/google-vertex-anthropic-provider-edge.ts +1 -2
  26. package/src/anthropic/google-vertex-anthropic-messages-options.ts +1 -0
  27. package/src/anthropic/google-vertex-anthropic-provider-node.ts +1 -2
  28. package/src/anthropic/google-vertex-anthropic-provider.ts +33 -8
  29. package/src/edge/google-vertex-provider-edge.ts +1 -2
  30. package/src/google-vertex-config.ts +1 -1
  31. package/src/google-vertex-embedding-model.ts +23 -6
  32. package/src/google-vertex-embedding-options.ts +2 -0
  33. package/src/google-vertex-image-model.ts +38 -18
  34. package/src/google-vertex-options.ts +0 -1
  35. package/src/google-vertex-provider-node.ts +1 -2
  36. package/src/google-vertex-provider.ts +12 -12
  37. package/src/google-vertex-video-model.ts +7 -7
  38. package/src/maas/edge/google-vertex-maas-provider-edge.ts +65 -0
  39. package/src/maas/edge/index.ts +9 -0
  40. package/src/maas/google-vertex-maas-options.ts +15 -0
  41. package/src/maas/google-vertex-maas-provider-node.ts +64 -0
  42. package/src/maas/google-vertex-maas-provider.ts +111 -0
  43. package/src/maas/index.ts +9 -0
  44. package/dist/anthropic/edge/index.d.mts +0 -231
  45. package/dist/anthropic/edge/index.mjs +0 -259
  46. package/dist/anthropic/edge/index.mjs.map +0 -1
  47. package/dist/anthropic/index.d.mts +0 -215
  48. package/dist/anthropic/index.mjs +0 -164
  49. package/dist/anthropic/index.mjs.map +0 -1
  50. package/dist/edge/index.d.mts +0 -160
  51. package/dist/edge/index.mjs +0 -1049
  52. package/dist/edge/index.mjs.map +0 -1
  53. package/dist/index.d.mts +0 -219
  54. package/dist/index.mjs +0 -960
  55. package/dist/index.mjs.map +0 -1
package/dist/index.js CHANGED
@@ -1,41 +1,13 @@
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
1
  // src/google-vertex-provider-node.ts
30
- var import_provider_utils6 = require("@ai-sdk/provider-utils");
2
+ import { loadOptionalSetting as loadOptionalSetting2, resolve as resolve5 } 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");
5
+ import { GoogleAuth } from "google-auth-library";
34
6
  var authInstance = null;
35
7
  var authOptions = null;
36
8
  function getAuth(options) {
37
9
  if (!authInstance || options !== authOptions) {
38
- authInstance = new import_google_auth_library.GoogleAuth({
10
+ authInstance = new GoogleAuth({
39
11
  scopes: ["https://www.googleapis.com/auth/cloud-platform"],
40
12
  ...options
41
13
  });
@@ -51,28 +23,47 @@ async function generateAuthToken(options) {
51
23
  }
52
24
 
53
25
  // src/google-vertex-provider.ts
54
- var import_internal3 = require("@ai-sdk/google/internal");
55
- var import_provider_utils5 = require("@ai-sdk/provider-utils");
26
+ import { GoogleGenerativeAILanguageModel as GoogleGenerativeAILanguageModel2 } from "@ai-sdk/google/internal";
27
+ import {
28
+ generateId,
29
+ loadOptionalSetting,
30
+ loadSetting,
31
+ normalizeHeaders,
32
+ resolve as resolve4,
33
+ withoutTrailingSlash,
34
+ withUserAgentSuffix
35
+ } from "@ai-sdk/provider-utils";
56
36
 
57
37
  // src/version.ts
58
- var VERSION = true ? "5.0.0-beta.5" : "0.0.0-test";
38
+ var VERSION = true ? "5.0.0-beta.52" : "0.0.0-test";
59
39
 
60
40
  // 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");
41
+ import {
42
+ TooManyEmbeddingValuesForCallError
43
+ } from "@ai-sdk/provider";
44
+ import {
45
+ combineHeaders,
46
+ createJsonResponseHandler,
47
+ postJsonToApi,
48
+ resolve,
49
+ parseProviderOptions,
50
+ serializeModelOptions,
51
+ WORKFLOW_SERIALIZE,
52
+ WORKFLOW_DESERIALIZE
53
+ } from "@ai-sdk/provider-utils";
54
+ import { z as z3 } from "zod/v4";
64
55
 
65
56
  // 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()
57
+ import { createJsonErrorResponseHandler } from "@ai-sdk/provider-utils";
58
+ import { z } from "zod/v4";
59
+ var googleVertexErrorDataSchema = z.object({
60
+ error: z.object({
61
+ code: z.number().nullable(),
62
+ message: z.string(),
63
+ status: z.string()
73
64
  })
74
65
  });
75
- var googleVertexFailedResponseHandler = (0, import_provider_utils.createJsonErrorResponseHandler)(
66
+ var googleVertexFailedResponseHandler = createJsonErrorResponseHandler(
76
67
  {
77
68
  errorSchema: googleVertexErrorDataSchema,
78
69
  errorToMessage: (data) => data.error.message
@@ -80,13 +71,13 @@ var googleVertexFailedResponseHandler = (0, import_provider_utils.createJsonErro
80
71
  );
81
72
 
82
73
  // src/google-vertex-embedding-options.ts
83
- var import_v42 = require("zod/v4");
84
- var googleVertexEmbeddingModelOptions = import_v42.z.object({
74
+ import { z as z2 } from "zod/v4";
75
+ var googleVertexEmbeddingModelOptions = z2.object({
85
76
  /**
86
77
  * Optional. Optional reduced dimension for the output embedding.
87
78
  * If set, excessive values in the output embedding are truncated from the end.
88
79
  */
89
- outputDimensionality: import_v42.z.number().optional(),
80
+ outputDimensionality: z2.number().optional(),
90
81
  /**
91
82
  * Optional. Specifies the task type for generating embeddings.
92
83
  * Supported task types:
@@ -99,7 +90,7 @@ var googleVertexEmbeddingModelOptions = import_v42.z.object({
99
90
  * - FACT_VERIFICATION: Optimized for verifying factual information.
100
91
  * - CODE_RETRIEVAL_QUERY: Optimized for retrieving code blocks based on natural language queries.
101
92
  */
102
- taskType: import_v42.z.enum([
93
+ taskType: z2.enum([
103
94
  "SEMANTIC_SIMILARITY",
104
95
  "CLASSIFICATION",
105
96
  "CLUSTERING",
@@ -114,23 +105,32 @@ var googleVertexEmbeddingModelOptions = import_v42.z.object({
114
105
  * Only valid when task_type is set to 'RETRIEVAL_DOCUMENT'.
115
106
  * Helps the model produce better embeddings by providing additional context.
116
107
  */
117
- title: import_v42.z.string().optional(),
108
+ title: z2.string().optional(),
118
109
  /**
119
110
  * Optional. When set to true, input text will be truncated. When set to false,
120
111
  * an error is returned if the input text is longer than the maximum length supported by the model. Defaults to true.
121
112
  */
122
- autoTruncate: import_v42.z.boolean().optional()
113
+ autoTruncate: z2.boolean().optional()
123
114
  });
124
115
 
125
116
  // src/google-vertex-embedding-model.ts
126
- var GoogleVertexEmbeddingModel = class {
117
+ var GoogleVertexEmbeddingModel = class _GoogleVertexEmbeddingModel {
127
118
  constructor(modelId, config) {
128
- this.specificationVersion = "v3";
119
+ this.specificationVersion = "v4";
129
120
  this.maxEmbeddingsPerCall = 2048;
130
121
  this.supportsParallelCalls = true;
131
122
  this.modelId = modelId;
132
123
  this.config = config;
133
124
  }
125
+ static [WORKFLOW_SERIALIZE](model) {
126
+ return serializeModelOptions({
127
+ modelId: model.modelId,
128
+ config: model.config
129
+ });
130
+ }
131
+ static [WORKFLOW_DESERIALIZE](options) {
132
+ return new _GoogleVertexEmbeddingModel(options.modelId, options.config);
133
+ }
134
134
  get provider() {
135
135
  return this.config.provider;
136
136
  }
@@ -140,13 +140,13 @@ var GoogleVertexEmbeddingModel = class {
140
140
  abortSignal,
141
141
  providerOptions
142
142
  }) {
143
- let googleOptions = await (0, import_provider_utils2.parseProviderOptions)({
143
+ let googleOptions = await parseProviderOptions({
144
144
  provider: "vertex",
145
145
  providerOptions,
146
146
  schema: googleVertexEmbeddingModelOptions
147
147
  });
148
148
  if (googleOptions == null) {
149
- googleOptions = await (0, import_provider_utils2.parseProviderOptions)({
149
+ googleOptions = await parseProviderOptions({
150
150
  provider: "google",
151
151
  providerOptions,
152
152
  schema: googleVertexEmbeddingModelOptions
@@ -154,15 +154,15 @@ var GoogleVertexEmbeddingModel = class {
154
154
  }
155
155
  googleOptions = googleOptions != null ? googleOptions : {};
156
156
  if (values.length > this.maxEmbeddingsPerCall) {
157
- throw new import_provider.TooManyEmbeddingValuesForCallError({
157
+ throw new TooManyEmbeddingValuesForCallError({
158
158
  provider: this.provider,
159
159
  modelId: this.modelId,
160
160
  maxEmbeddingsPerCall: this.maxEmbeddingsPerCall,
161
161
  values
162
162
  });
163
163
  }
164
- const mergedHeaders = (0, import_provider_utils2.combineHeaders)(
165
- await (0, import_provider_utils2.resolve)(this.config.headers),
164
+ const mergedHeaders = combineHeaders(
165
+ this.config.headers ? await resolve(this.config.headers) : void 0,
166
166
  headers
167
167
  );
168
168
  const url = `${this.config.baseURL}/models/${this.modelId}:predict`;
@@ -170,7 +170,7 @@ var GoogleVertexEmbeddingModel = class {
170
170
  responseHeaders,
171
171
  value: response,
172
172
  rawValue
173
- } = await (0, import_provider_utils2.postJsonToApi)({
173
+ } = await postJsonToApi({
174
174
  url,
175
175
  headers: mergedHeaders,
176
176
  body: {
@@ -185,7 +185,7 @@ var GoogleVertexEmbeddingModel = class {
185
185
  }
186
186
  },
187
187
  failedResponseHandler: googleVertexFailedResponseHandler,
188
- successfulResponseHandler: (0, import_provider_utils2.createJsonResponseHandler)(
188
+ successfulResponseHandler: createJsonResponseHandler(
189
189
  googleVertexTextEmbeddingResponseSchema
190
190
  ),
191
191
  abortSignal,
@@ -206,13 +206,13 @@ var GoogleVertexEmbeddingModel = class {
206
206
  };
207
207
  }
208
208
  };
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()
209
+ var googleVertexTextEmbeddingResponseSchema = z3.object({
210
+ predictions: z3.array(
211
+ z3.object({
212
+ embeddings: z3.object({
213
+ values: z3.array(z3.number()),
214
+ statistics: z3.object({
215
+ token_count: z3.number()
216
216
  })
217
217
  })
218
218
  })
@@ -220,14 +220,35 @@ var googleVertexTextEmbeddingResponseSchema = import_v43.z.object({
220
220
  });
221
221
 
222
222
  // 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 {
223
+ import { GoogleGenerativeAILanguageModel } from "@ai-sdk/google/internal";
224
+ import {
225
+ combineHeaders as combineHeaders2,
226
+ convertToBase64,
227
+ convertUint8ArrayToBase64,
228
+ createJsonResponseHandler as createJsonResponseHandler2,
229
+ generateId as defaultGenerateId,
230
+ parseProviderOptions as parseProviderOptions2,
231
+ postJsonToApi as postJsonToApi2,
232
+ resolve as resolve2,
233
+ serializeModelOptions as serializeModelOptions2,
234
+ WORKFLOW_SERIALIZE as WORKFLOW_SERIALIZE2,
235
+ WORKFLOW_DESERIALIZE as WORKFLOW_DESERIALIZE2
236
+ } from "@ai-sdk/provider-utils";
237
+ import { z as z4 } from "zod/v4";
238
+ var GoogleVertexImageModel = class _GoogleVertexImageModel {
227
239
  constructor(modelId, config) {
228
240
  this.modelId = modelId;
229
241
  this.config = config;
230
- this.specificationVersion = "v3";
242
+ this.specificationVersion = "v4";
243
+ }
244
+ static [WORKFLOW_SERIALIZE2](model) {
245
+ return serializeModelOptions2({
246
+ modelId: model.modelId,
247
+ config: model.config
248
+ });
249
+ }
250
+ static [WORKFLOW_DESERIALIZE2](options) {
251
+ return new _GoogleVertexImageModel(options.modelId, options.config);
231
252
  }
232
253
  get maxImagesPerCall() {
233
254
  if (isGeminiModel(this.modelId)) {
@@ -265,7 +286,7 @@ var GoogleVertexImageModel = class {
265
286
  details: "This model does not support the `size` option. Use `aspectRatio` instead."
266
287
  });
267
288
  }
268
- const vertexImageOptions = await (0, import_provider_utils3.parseProviderOptions)({
289
+ const vertexImageOptions = await parseProviderOptions2({
269
290
  provider: "vertex",
270
291
  providerOptions,
271
292
  schema: googleVertexImageModelOptionsSchema
@@ -327,12 +348,15 @@ var GoogleVertexImageModel = class {
327
348
  };
328
349
  }
329
350
  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)({
351
+ const { value: response, responseHeaders } = await postJsonToApi2({
331
352
  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),
353
+ headers: combineHeaders2(
354
+ this.config.headers ? await resolve2(this.config.headers) : void 0,
355
+ headers
356
+ ),
333
357
  body,
334
358
  failedResponseHandler: googleVertexFailedResponseHandler,
335
- successfulResponseHandler: (0, import_provider_utils3.createJsonResponseHandler)(
359
+ successfulResponseHandler: createJsonResponseHandler2(
336
360
  vertexImageResponseSchema
337
361
  ),
338
362
  abortSignal,
@@ -416,12 +440,12 @@ var GoogleVertexImageModel = class {
416
440
  const languageModelPrompt = [
417
441
  { role: "user", content: userContent }
418
442
  ];
419
- const languageModel = new import_internal.GoogleGenerativeAILanguageModel(this.modelId, {
443
+ const languageModel = new GoogleGenerativeAILanguageModel(this.modelId, {
420
444
  provider: this.config.provider,
421
445
  baseURL: this.config.baseURL,
422
446
  headers: (_a = this.config.headers) != null ? _a : {},
423
447
  fetch: this.config.fetch,
424
- generateId: (_b = this.config.generateId) != null ? _b : import_provider_utils3.generateId,
448
+ generateId: (_b = this.config.generateId) != null ? _b : defaultGenerateId,
425
449
  supportedUrls: () => ({
426
450
  "*": [/^https?:\/\/.*$/, /^gs:\/\/.*$/]
427
451
  })
@@ -445,7 +469,7 @@ var GoogleVertexImageModel = class {
445
469
  const images = [];
446
470
  for (const part of result.content) {
447
471
  if (part.type === "file" && part.mediaType.startsWith("image/")) {
448
- images.push((0, import_provider_utils3.convertToBase64)(part.data));
472
+ images.push(convertToBase64(part.data));
449
473
  }
450
474
  }
451
475
  return {
@@ -472,41 +496,41 @@ var GoogleVertexImageModel = class {
472
496
  function isGeminiModel(modelId) {
473
497
  return modelId.startsWith("gemini-");
474
498
  }
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()
499
+ var vertexImageResponseSchema = z4.object({
500
+ predictions: z4.array(
501
+ z4.object({
502
+ bytesBase64Encoded: z4.string(),
503
+ mimeType: z4.string(),
504
+ prompt: z4.string().nullish()
481
505
  })
482
506
  ).nullish()
483
507
  });
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([
508
+ var googleVertexImageModelOptionsSchema = z4.object({
509
+ negativePrompt: z4.string().nullish(),
510
+ personGeneration: z4.enum(["dont_allow", "allow_adult", "allow_all"]).nullish(),
511
+ safetySetting: z4.enum([
488
512
  "block_low_and_above",
489
513
  "block_medium_and_above",
490
514
  "block_only_high",
491
515
  "block_none"
492
516
  ]).nullish(),
493
- addWatermark: import_v44.z.boolean().nullish(),
494
- storageUri: import_v44.z.string().nullish(),
495
- sampleImageSize: import_v44.z.enum(["1K", "2K"]).nullish(),
517
+ addWatermark: z4.boolean().nullish(),
518
+ storageUri: z4.string().nullish(),
519
+ sampleImageSize: z4.enum(["1K", "2K"]).nullish(),
496
520
  /**
497
521
  * Configuration for image editing operations
498
522
  */
499
- edit: import_v44.z.object({
523
+ edit: z4.object({
500
524
  /**
501
525
  * An integer that represents the number of sampling steps.
502
526
  * A higher value offers better image quality, a lower value offers better latency.
503
527
  * Try 35 steps to start. If the quality doesn't meet your requirements,
504
528
  * increase the value towards an upper limit of 75.
505
529
  */
506
- baseSteps: import_v44.z.number().nullish(),
530
+ baseSteps: z4.number().nullish(),
507
531
  // Edit mode options
508
532
  // https://cloud.google.com/vertex-ai/generative-ai/docs/image/edit-insert-objects
509
- mode: import_v44.z.enum([
533
+ mode: z4.enum([
510
534
  "EDIT_MODE_INPAINT_INSERTION",
511
535
  "EDIT_MODE_INPAINT_REMOVAL",
512
536
  "EDIT_MODE_OUTPAINT",
@@ -522,7 +546,7 @@ var googleVertexImageModelOptionsSchema = import_v44.z.object({
522
546
  * - `MASK_MODE_CLOTHING_AREA` - Masks from segmenting the clothing area with open-vocab segmentation.
523
547
  * - `MASK_MODE_PARSED_PERSON` - Masks from segmenting the person body and clothing using the person-parsing model.
524
548
  */
525
- maskMode: import_v44.z.enum([
549
+ maskMode: z4.enum([
526
550
  "MASK_MODE_DEFAULT",
527
551
  "MASK_MODE_USER_PROVIDED",
528
552
  "MASK_MODE_DETECTION_BOX",
@@ -534,7 +558,7 @@ var googleVertexImageModelOptionsSchema = import_v44.z.object({
534
558
  * percentage of the image width to grow the mask by. Using dilation helps
535
559
  * compensate for imprecise masks. We recommend a value of 0.01.
536
560
  */
537
- maskDilation: import_v44.z.number().nullish()
561
+ maskDilation: z4.number().nullish()
538
562
  }).nullish()
539
563
  });
540
564
  function getBase64Data(file) {
@@ -546,30 +570,42 @@ function getBase64Data(file) {
546
570
  if (typeof file.data === "string") {
547
571
  return file.data;
548
572
  }
549
- return (0, import_provider_utils3.convertUint8ArrayToBase64)(file.data);
573
+ return convertUint8ArrayToBase64(file.data);
550
574
  }
551
575
 
552
576
  // src/google-vertex-tools.ts
553
- var import_internal2 = require("@ai-sdk/google/internal");
577
+ import { googleTools } from "@ai-sdk/google/internal";
554
578
  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
579
+ googleSearch: googleTools.googleSearch,
580
+ enterpriseWebSearch: googleTools.enterpriseWebSearch,
581
+ googleMaps: googleTools.googleMaps,
582
+ urlContext: googleTools.urlContext,
583
+ fileSearch: googleTools.fileSearch,
584
+ codeExecution: googleTools.codeExecution,
585
+ vertexRagStore: googleTools.vertexRagStore
562
586
  };
563
587
 
564
588
  // 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");
589
+ import {
590
+ AISDKError
591
+ } from "@ai-sdk/provider";
592
+ import {
593
+ combineHeaders as combineHeaders3,
594
+ convertUint8ArrayToBase64 as convertUint8ArrayToBase642,
595
+ createJsonResponseHandler as createJsonResponseHandler3,
596
+ delay,
597
+ lazySchema,
598
+ parseProviderOptions as parseProviderOptions3,
599
+ postJsonToApi as postJsonToApi3,
600
+ resolve as resolve3,
601
+ zodSchema
602
+ } from "@ai-sdk/provider-utils";
603
+ import { z as z5 } from "zod/v4";
568
604
  var GoogleVertexVideoModel = class {
569
605
  constructor(modelId, config) {
570
606
  this.modelId = modelId;
571
607
  this.config = config;
572
- this.specificationVersion = "v3";
608
+ this.specificationVersion = "v4";
573
609
  }
574
610
  get provider() {
575
611
  return this.config.provider;
@@ -581,7 +617,7 @@ var GoogleVertexVideoModel = class {
581
617
  var _a, _b, _c, _d, _e, _f;
582
618
  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
619
  const warnings = [];
584
- const vertexOptions = await (0, import_provider_utils4.parseProviderOptions)({
620
+ const vertexOptions = await parseProviderOptions3({
585
621
  provider: "vertex",
586
622
  providerOptions: options.providerOptions,
587
623
  schema: googleVertexVideoModelOptionsSchema
@@ -599,7 +635,7 @@ var GoogleVertexVideoModel = class {
599
635
  details: "Vertex AI video models require base64-encoded images or GCS URIs. URL will be ignored."
600
636
  });
601
637
  } else {
602
- const base64Data = typeof options.image.data === "string" ? options.image.data : (0, import_provider_utils4.convertUint8ArrayToBase64)(options.image.data);
638
+ const base64Data = typeof options.image.data === "string" ? options.image.data : convertUint8ArrayToBase642(options.image.data);
603
639
  instance.image = {
604
640
  bytesBase64Encoded: base64Data,
605
641
  mimeType: options.image.mediaType
@@ -657,17 +693,17 @@ var GoogleVertexVideoModel = class {
657
693
  }
658
694
  }
659
695
  }
660
- const { value: operation } = await (0, import_provider_utils4.postJsonToApi)({
696
+ const { value: operation } = await postJsonToApi3({
661
697
  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),
698
+ headers: combineHeaders3(
699
+ await resolve3(this.config.headers),
664
700
  options.headers
665
701
  ),
666
702
  body: {
667
703
  instances,
668
704
  parameters
669
705
  },
670
- successfulResponseHandler: (0, import_provider_utils4.createJsonResponseHandler)(
706
+ successfulResponseHandler: createJsonResponseHandler3(
671
707
  vertexOperationSchema
672
708
  ),
673
709
  failedResponseHandler: googleVertexFailedResponseHandler,
@@ -676,7 +712,7 @@ var GoogleVertexVideoModel = class {
676
712
  });
677
713
  const operationName = operation.name;
678
714
  if (!operationName) {
679
- throw new import_provider2.AISDKError({
715
+ throw new AISDKError({
680
716
  name: "VERTEX_VIDEO_GENERATION_ERROR",
681
717
  message: "No operation name returned from API"
682
718
  });
@@ -688,28 +724,28 @@ var GoogleVertexVideoModel = class {
688
724
  let responseHeaders;
689
725
  while (!finalOperation.done) {
690
726
  if (Date.now() - startTime > pollTimeoutMs) {
691
- throw new import_provider2.AISDKError({
727
+ throw new AISDKError({
692
728
  name: "VERTEX_VIDEO_GENERATION_TIMEOUT",
693
729
  message: `Video generation timed out after ${pollTimeoutMs}ms`
694
730
  });
695
731
  }
696
- await (0, import_provider_utils4.delay)(pollIntervalMs);
732
+ await delay(pollIntervalMs);
697
733
  if ((_f = options.abortSignal) == null ? void 0 : _f.aborted) {
698
- throw new import_provider2.AISDKError({
734
+ throw new AISDKError({
699
735
  name: "VERTEX_VIDEO_GENERATION_ABORTED",
700
736
  message: "Video generation request was aborted"
701
737
  });
702
738
  }
703
- const { value: statusOperation, responseHeaders: pollHeaders } = await (0, import_provider_utils4.postJsonToApi)({
739
+ const { value: statusOperation, responseHeaders: pollHeaders } = await postJsonToApi3({
704
740
  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),
741
+ headers: combineHeaders3(
742
+ await resolve3(this.config.headers),
707
743
  options.headers
708
744
  ),
709
745
  body: {
710
746
  operationName
711
747
  },
712
- successfulResponseHandler: (0, import_provider_utils4.createJsonResponseHandler)(
748
+ successfulResponseHandler: createJsonResponseHandler3(
713
749
  vertexOperationSchema
714
750
  ),
715
751
  failedResponseHandler: googleVertexFailedResponseHandler,
@@ -720,14 +756,14 @@ var GoogleVertexVideoModel = class {
720
756
  responseHeaders = pollHeaders;
721
757
  }
722
758
  if (finalOperation.error) {
723
- throw new import_provider2.AISDKError({
759
+ throw new AISDKError({
724
760
  name: "VERTEX_VIDEO_GENERATION_FAILED",
725
761
  message: `Video generation failed: ${finalOperation.error.message}`
726
762
  });
727
763
  }
728
764
  const response = finalOperation.response;
729
765
  if (!(response == null ? void 0 : response.videos) || response.videos.length === 0) {
730
- throw new import_provider2.AISDKError({
766
+ throw new AISDKError({
731
767
  name: "VERTEX_VIDEO_GENERATION_ERROR",
732
768
  message: `No videos in response. Response: ${JSON.stringify(finalOperation)}`
733
769
  });
@@ -757,7 +793,7 @@ var GoogleVertexVideoModel = class {
757
793
  }
758
794
  }
759
795
  if (videos.length === 0) {
760
- throw new import_provider2.AISDKError({
796
+ throw new AISDKError({
761
797
  name: "VERTEX_VIDEO_GENERATION_ERROR",
762
798
  message: "No valid videos in response"
763
799
  });
@@ -778,38 +814,38 @@ var GoogleVertexVideoModel = class {
778
814
  };
779
815
  }
780
816
  };
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()
817
+ var vertexOperationSchema = z5.object({
818
+ name: z5.string().nullish(),
819
+ done: z5.boolean().nullish(),
820
+ error: z5.object({
821
+ code: z5.number().nullish(),
822
+ message: z5.string(),
823
+ status: z5.string().nullish()
788
824
  }).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()
825
+ response: z5.object({
826
+ videos: z5.array(
827
+ z5.object({
828
+ bytesBase64Encoded: z5.string().nullish(),
829
+ gcsUri: z5.string().nullish(),
830
+ mimeType: z5.string().nullish()
795
831
  })
796
832
  ).nullish(),
797
- raiMediaFilteredCount: import_v45.z.number().nullish()
833
+ raiMediaFilteredCount: z5.number().nullish()
798
834
  }).nullish()
799
835
  });
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()
836
+ var googleVertexVideoModelOptionsSchema = lazySchema(
837
+ () => zodSchema(
838
+ z5.object({
839
+ pollIntervalMs: z5.number().positive().nullish(),
840
+ pollTimeoutMs: z5.number().positive().nullish(),
841
+ personGeneration: z5.enum(["dont_allow", "allow_adult", "allow_all"]).nullish(),
842
+ negativePrompt: z5.string().nullish(),
843
+ generateAudio: z5.boolean().nullish(),
844
+ gcsOutputDirectory: z5.string().nullish(),
845
+ referenceImages: z5.array(
846
+ z5.object({
847
+ bytesBase64Encoded: z5.string().nullish(),
848
+ gcsUri: z5.string().nullish()
813
849
  })
814
850
  ).nullish()
815
851
  }).passthrough()
@@ -823,7 +859,7 @@ function createExpressModeFetch(apiKey, customFetch) {
823
859
  const modifiedInit = {
824
860
  ...init,
825
861
  headers: {
826
- ...(init == null ? void 0 : init.headers) ? (0, import_provider_utils5.normalizeHeaders)(init.headers) : {},
862
+ ...(init == null ? void 0 : init.headers) ? normalizeHeaders(init.headers) : {},
827
863
  "x-goog-api-key": apiKey
828
864
  }
829
865
  };
@@ -831,17 +867,17 @@ function createExpressModeFetch(apiKey, customFetch) {
831
867
  };
832
868
  }
833
869
  function createVertex(options = {}) {
834
- const apiKey = (0, import_provider_utils5.loadOptionalSetting)({
870
+ const apiKey = loadOptionalSetting({
835
871
  settingValue: options.apiKey,
836
872
  environmentVariableName: "GOOGLE_VERTEX_API_KEY"
837
873
  });
838
- const loadVertexProject = () => (0, import_provider_utils5.loadSetting)({
874
+ const loadVertexProject = () => loadSetting({
839
875
  settingValue: options.project,
840
876
  settingName: "project",
841
877
  environmentVariableName: "GOOGLE_VERTEX_PROJECT",
842
878
  description: "Google Vertex project"
843
879
  });
844
- const loadVertexLocation = () => (0, import_provider_utils5.loadSetting)({
880
+ const loadVertexLocation = () => loadSetting({
845
881
  settingValue: options.location,
846
882
  settingName: "location",
847
883
  environmentVariableName: "GOOGLE_VERTEX_LOCATION",
@@ -850,18 +886,18 @@ function createVertex(options = {}) {
850
886
  const loadBaseURL = () => {
851
887
  var _a, _b;
852
888
  if (apiKey) {
853
- return (_a = (0, import_provider_utils5.withoutTrailingSlash)(options.baseURL)) != null ? _a : EXPRESS_MODE_BASE_URL;
889
+ return (_a = withoutTrailingSlash(options.baseURL)) != null ? _a : EXPRESS_MODE_BASE_URL;
854
890
  }
855
891
  const region = loadVertexLocation();
856
892
  const project = loadVertexProject();
857
893
  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`;
894
+ return (_b = withoutTrailingSlash(options.baseURL)) != null ? _b : `https://${baseHost}/v1beta1/projects/${project}/locations/${region}/publishers/google`;
859
895
  };
860
896
  const createConfig = (name) => {
861
897
  const getHeaders = async () => {
862
898
  var _a;
863
- const originalHeaders = await (0, import_provider_utils5.resolve)((_a = options.headers) != null ? _a : {});
864
- return (0, import_provider_utils5.withUserAgentSuffix)(
899
+ const originalHeaders = await resolve4((_a = options.headers) != null ? _a : {});
900
+ return withUserAgentSuffix(
865
901
  originalHeaders,
866
902
  `ai-sdk/google-vertex/${VERSION}`
867
903
  );
@@ -875,9 +911,9 @@ function createVertex(options = {}) {
875
911
  };
876
912
  const createChatModel = (modelId) => {
877
913
  var _a;
878
- return new import_internal3.GoogleGenerativeAILanguageModel(modelId, {
914
+ return new GoogleGenerativeAILanguageModel2(modelId, {
879
915
  ...createConfig("chat"),
880
- generateId: (_a = options.generateId) != null ? _a : import_provider_utils5.generateId,
916
+ generateId: (_a = options.generateId) != null ? _a : generateId,
881
917
  supportedUrls: () => ({
882
918
  "*": [
883
919
  // HTTP URLs:
@@ -893,14 +929,14 @@ function createVertex(options = {}) {
893
929
  var _a;
894
930
  return new GoogleVertexImageModel(modelId, {
895
931
  ...createConfig("image"),
896
- generateId: (_a = options.generateId) != null ? _a : import_provider_utils5.generateId
932
+ generateId: (_a = options.generateId) != null ? _a : generateId
897
933
  });
898
934
  };
899
935
  const createVideoModel = (modelId) => {
900
936
  var _a;
901
937
  return new GoogleVertexVideoModel(modelId, {
902
938
  ...createConfig("video"),
903
- generateId: (_a = options.generateId) != null ? _a : import_provider_utils5.generateId
939
+ generateId: (_a = options.generateId) != null ? _a : generateId
904
940
  });
905
941
  };
906
942
  const provider = function(modelId) {
@@ -911,7 +947,7 @@ function createVertex(options = {}) {
911
947
  }
912
948
  return createChatModel(modelId);
913
949
  };
914
- provider.specificationVersion = "v3";
950
+ provider.specificationVersion = "v4";
915
951
  provider.languageModel = createChatModel;
916
952
  provider.embeddingModel = createEmbeddingModel;
917
953
  provider.textEmbeddingModel = createEmbeddingModel;
@@ -925,7 +961,7 @@ function createVertex(options = {}) {
925
961
 
926
962
  // src/google-vertex-provider-node.ts
927
963
  function createVertex2(options = {}) {
928
- const apiKey = (0, import_provider_utils6.loadOptionalSetting)({
964
+ const apiKey = loadOptionalSetting2({
929
965
  settingValue: options.apiKey,
930
966
  environmentVariableName: "GOOGLE_VERTEX_API_KEY"
931
967
  });
@@ -938,15 +974,14 @@ function createVertex2(options = {}) {
938
974
  Authorization: `Bearer ${await generateAuthToken(
939
975
  options.googleAuthOptions
940
976
  )}`,
941
- ...await (0, import_provider_utils6.resolve)(options.headers)
977
+ ...await resolve5(options.headers)
942
978
  })
943
979
  });
944
980
  }
945
981
  var vertex = createVertex2();
946
- // Annotate the CommonJS export names for ESM import in node:
947
- 0 && (module.exports = {
982
+ export {
948
983
  VERSION,
949
- createVertex,
984
+ createVertex2 as createVertex,
950
985
  vertex
951
- });
986
+ };
952
987
  //# sourceMappingURL=index.js.map