@ai-sdk/google-vertex 5.0.0-beta.6 → 5.0.0-beta.60

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 +516 -8
  2. package/README.md +65 -2
  3. package/dist/anthropic/edge/index.d.ts +69 -24
  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 +69 -24
  7. package/dist/anthropic/index.js +57 -55
  8. package/dist/anthropic/index.js.map +1 -1
  9. package/dist/edge/index.d.ts +35 -26
  10. package/dist/edge/index.js +217 -176
  11. package/dist/edge/index.js.map +1 -1
  12. package/dist/index.d.ts +35 -26
  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 +236 -14
  22. package/maas/edge.d.ts +1 -0
  23. package/maas/index.d.ts +1 -0
  24. package/package.json +33 -20
  25. package/src/anthropic/edge/google-vertex-anthropic-provider-edge.ts +1 -2
  26. package/src/anthropic/{google-vertex-anthropic-messages-options.ts → google-vertex-anthropic-options.ts} +2 -1
  27. package/src/anthropic/google-vertex-anthropic-provider-node.ts +1 -2
  28. package/src/anthropic/google-vertex-anthropic-provider.ts +38 -13
  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 +40 -20
  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 +14 -14
  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
@@ -1,56 +1,48 @@
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/edge/index.ts
21
- var edge_exports = {};
22
- __export(edge_exports, {
23
- createVertex: () => createVertex2,
24
- vertex: () => vertex
25
- });
26
- module.exports = __toCommonJS(edge_exports);
27
-
28
1
  // src/edge/google-vertex-provider-edge.ts
29
- var import_provider_utils7 = require("@ai-sdk/provider-utils");
2
+ import { loadOptionalSetting as loadOptionalSetting3, resolve as resolve5 } from "@ai-sdk/provider-utils";
30
3
 
31
4
  // src/google-vertex-provider.ts
32
- var import_internal3 = require("@ai-sdk/google/internal");
33
- var import_provider_utils5 = require("@ai-sdk/provider-utils");
5
+ import { GoogleLanguageModel as GoogleLanguageModel2 } from "@ai-sdk/google/internal";
6
+ import {
7
+ generateId,
8
+ loadOptionalSetting,
9
+ loadSetting,
10
+ normalizeHeaders,
11
+ resolve as resolve4,
12
+ withoutTrailingSlash,
13
+ withUserAgentSuffix
14
+ } from "@ai-sdk/provider-utils";
34
15
 
35
16
  // src/version.ts
36
- var VERSION = true ? "5.0.0-beta.6" : "0.0.0-test";
17
+ var VERSION = true ? "5.0.0-beta.60" : "0.0.0-test";
37
18
 
38
19
  // src/google-vertex-embedding-model.ts
39
- var import_provider = require("@ai-sdk/provider");
40
- var import_provider_utils2 = require("@ai-sdk/provider-utils");
41
- var import_v43 = require("zod/v4");
20
+ import {
21
+ TooManyEmbeddingValuesForCallError
22
+ } from "@ai-sdk/provider";
23
+ import {
24
+ combineHeaders,
25
+ createJsonResponseHandler,
26
+ postJsonToApi,
27
+ resolve,
28
+ parseProviderOptions,
29
+ serializeModelOptions,
30
+ WORKFLOW_SERIALIZE,
31
+ WORKFLOW_DESERIALIZE
32
+ } from "@ai-sdk/provider-utils";
33
+ import { z as z3 } from "zod/v4";
42
34
 
43
35
  // src/google-vertex-error.ts
44
- var import_provider_utils = require("@ai-sdk/provider-utils");
45
- var import_v4 = require("zod/v4");
46
- var googleVertexErrorDataSchema = import_v4.z.object({
47
- error: import_v4.z.object({
48
- code: import_v4.z.number().nullable(),
49
- message: import_v4.z.string(),
50
- status: import_v4.z.string()
36
+ import { createJsonErrorResponseHandler } from "@ai-sdk/provider-utils";
37
+ import { z } from "zod/v4";
38
+ var googleVertexErrorDataSchema = z.object({
39
+ error: z.object({
40
+ code: z.number().nullable(),
41
+ message: z.string(),
42
+ status: z.string()
51
43
  })
52
44
  });
53
- var googleVertexFailedResponseHandler = (0, import_provider_utils.createJsonErrorResponseHandler)(
45
+ var googleVertexFailedResponseHandler = createJsonErrorResponseHandler(
54
46
  {
55
47
  errorSchema: googleVertexErrorDataSchema,
56
48
  errorToMessage: (data) => data.error.message
@@ -58,13 +50,13 @@ var googleVertexFailedResponseHandler = (0, import_provider_utils.createJsonErro
58
50
  );
59
51
 
60
52
  // src/google-vertex-embedding-options.ts
61
- var import_v42 = require("zod/v4");
62
- var googleVertexEmbeddingModelOptions = import_v42.z.object({
53
+ import { z as z2 } from "zod/v4";
54
+ var googleVertexEmbeddingModelOptions = z2.object({
63
55
  /**
64
56
  * Optional. Optional reduced dimension for the output embedding.
65
57
  * If set, excessive values in the output embedding are truncated from the end.
66
58
  */
67
- outputDimensionality: import_v42.z.number().optional(),
59
+ outputDimensionality: z2.number().optional(),
68
60
  /**
69
61
  * Optional. Specifies the task type for generating embeddings.
70
62
  * Supported task types:
@@ -77,7 +69,7 @@ var googleVertexEmbeddingModelOptions = import_v42.z.object({
77
69
  * - FACT_VERIFICATION: Optimized for verifying factual information.
78
70
  * - CODE_RETRIEVAL_QUERY: Optimized for retrieving code blocks based on natural language queries.
79
71
  */
80
- taskType: import_v42.z.enum([
72
+ taskType: z2.enum([
81
73
  "SEMANTIC_SIMILARITY",
82
74
  "CLASSIFICATION",
83
75
  "CLUSTERING",
@@ -92,23 +84,32 @@ var googleVertexEmbeddingModelOptions = import_v42.z.object({
92
84
  * Only valid when task_type is set to 'RETRIEVAL_DOCUMENT'.
93
85
  * Helps the model produce better embeddings by providing additional context.
94
86
  */
95
- title: import_v42.z.string().optional(),
87
+ title: z2.string().optional(),
96
88
  /**
97
89
  * Optional. When set to true, input text will be truncated. When set to false,
98
90
  * an error is returned if the input text is longer than the maximum length supported by the model. Defaults to true.
99
91
  */
100
- autoTruncate: import_v42.z.boolean().optional()
92
+ autoTruncate: z2.boolean().optional()
101
93
  });
102
94
 
103
95
  // src/google-vertex-embedding-model.ts
104
- var GoogleVertexEmbeddingModel = class {
96
+ var GoogleVertexEmbeddingModel = class _GoogleVertexEmbeddingModel {
105
97
  constructor(modelId, config) {
106
- this.specificationVersion = "v3";
98
+ this.specificationVersion = "v4";
107
99
  this.maxEmbeddingsPerCall = 2048;
108
100
  this.supportsParallelCalls = true;
109
101
  this.modelId = modelId;
110
102
  this.config = config;
111
103
  }
104
+ static [WORKFLOW_SERIALIZE](model) {
105
+ return serializeModelOptions({
106
+ modelId: model.modelId,
107
+ config: model.config
108
+ });
109
+ }
110
+ static [WORKFLOW_DESERIALIZE](options) {
111
+ return new _GoogleVertexEmbeddingModel(options.modelId, options.config);
112
+ }
112
113
  get provider() {
113
114
  return this.config.provider;
114
115
  }
@@ -118,13 +119,13 @@ var GoogleVertexEmbeddingModel = class {
118
119
  abortSignal,
119
120
  providerOptions
120
121
  }) {
121
- let googleOptions = await (0, import_provider_utils2.parseProviderOptions)({
122
+ let googleOptions = await parseProviderOptions({
122
123
  provider: "vertex",
123
124
  providerOptions,
124
125
  schema: googleVertexEmbeddingModelOptions
125
126
  });
126
127
  if (googleOptions == null) {
127
- googleOptions = await (0, import_provider_utils2.parseProviderOptions)({
128
+ googleOptions = await parseProviderOptions({
128
129
  provider: "google",
129
130
  providerOptions,
130
131
  schema: googleVertexEmbeddingModelOptions
@@ -132,15 +133,15 @@ var GoogleVertexEmbeddingModel = class {
132
133
  }
133
134
  googleOptions = googleOptions != null ? googleOptions : {};
134
135
  if (values.length > this.maxEmbeddingsPerCall) {
135
- throw new import_provider.TooManyEmbeddingValuesForCallError({
136
+ throw new TooManyEmbeddingValuesForCallError({
136
137
  provider: this.provider,
137
138
  modelId: this.modelId,
138
139
  maxEmbeddingsPerCall: this.maxEmbeddingsPerCall,
139
140
  values
140
141
  });
141
142
  }
142
- const mergedHeaders = (0, import_provider_utils2.combineHeaders)(
143
- await (0, import_provider_utils2.resolve)(this.config.headers),
143
+ const mergedHeaders = combineHeaders(
144
+ this.config.headers ? await resolve(this.config.headers) : void 0,
144
145
  headers
145
146
  );
146
147
  const url = `${this.config.baseURL}/models/${this.modelId}:predict`;
@@ -148,7 +149,7 @@ var GoogleVertexEmbeddingModel = class {
148
149
  responseHeaders,
149
150
  value: response,
150
151
  rawValue
151
- } = await (0, import_provider_utils2.postJsonToApi)({
152
+ } = await postJsonToApi({
152
153
  url,
153
154
  headers: mergedHeaders,
154
155
  body: {
@@ -163,7 +164,7 @@ var GoogleVertexEmbeddingModel = class {
163
164
  }
164
165
  },
165
166
  failedResponseHandler: googleVertexFailedResponseHandler,
166
- successfulResponseHandler: (0, import_provider_utils2.createJsonResponseHandler)(
167
+ successfulResponseHandler: createJsonResponseHandler(
167
168
  googleVertexTextEmbeddingResponseSchema
168
169
  ),
169
170
  abortSignal,
@@ -184,13 +185,13 @@ var GoogleVertexEmbeddingModel = class {
184
185
  };
185
186
  }
186
187
  };
187
- var googleVertexTextEmbeddingResponseSchema = import_v43.z.object({
188
- predictions: import_v43.z.array(
189
- import_v43.z.object({
190
- embeddings: import_v43.z.object({
191
- values: import_v43.z.array(import_v43.z.number()),
192
- statistics: import_v43.z.object({
193
- token_count: import_v43.z.number()
188
+ var googleVertexTextEmbeddingResponseSchema = z3.object({
189
+ predictions: z3.array(
190
+ z3.object({
191
+ embeddings: z3.object({
192
+ values: z3.array(z3.number()),
193
+ statistics: z3.object({
194
+ token_count: z3.number()
194
195
  })
195
196
  })
196
197
  })
@@ -198,14 +199,35 @@ var googleVertexTextEmbeddingResponseSchema = import_v43.z.object({
198
199
  });
199
200
 
200
201
  // src/google-vertex-image-model.ts
201
- var import_internal = require("@ai-sdk/google/internal");
202
- var import_provider_utils3 = require("@ai-sdk/provider-utils");
203
- var import_v44 = require("zod/v4");
204
- var GoogleVertexImageModel = class {
202
+ import { GoogleLanguageModel } from "@ai-sdk/google/internal";
203
+ import {
204
+ combineHeaders as combineHeaders2,
205
+ convertToBase64,
206
+ convertUint8ArrayToBase64,
207
+ createJsonResponseHandler as createJsonResponseHandler2,
208
+ generateId as defaultGenerateId,
209
+ parseProviderOptions as parseProviderOptions2,
210
+ postJsonToApi as postJsonToApi2,
211
+ resolve as resolve2,
212
+ serializeModelOptions as serializeModelOptions2,
213
+ WORKFLOW_SERIALIZE as WORKFLOW_SERIALIZE2,
214
+ WORKFLOW_DESERIALIZE as WORKFLOW_DESERIALIZE2
215
+ } from "@ai-sdk/provider-utils";
216
+ import { z as z4 } from "zod/v4";
217
+ var GoogleVertexImageModel = class _GoogleVertexImageModel {
205
218
  constructor(modelId, config) {
206
219
  this.modelId = modelId;
207
220
  this.config = config;
208
- this.specificationVersion = "v3";
221
+ this.specificationVersion = "v4";
222
+ }
223
+ static [WORKFLOW_SERIALIZE2](model) {
224
+ return serializeModelOptions2({
225
+ modelId: model.modelId,
226
+ config: model.config
227
+ });
228
+ }
229
+ static [WORKFLOW_DESERIALIZE2](options) {
230
+ return new _GoogleVertexImageModel(options.modelId, options.config);
209
231
  }
210
232
  get maxImagesPerCall() {
211
233
  if (isGeminiModel(this.modelId)) {
@@ -243,7 +265,7 @@ var GoogleVertexImageModel = class {
243
265
  details: "This model does not support the `size` option. Use `aspectRatio` instead."
244
266
  });
245
267
  }
246
- const vertexImageOptions = await (0, import_provider_utils3.parseProviderOptions)({
268
+ const vertexImageOptions = await parseProviderOptions2({
247
269
  provider: "vertex",
248
270
  providerOptions,
249
271
  schema: googleVertexImageModelOptionsSchema
@@ -305,12 +327,15 @@ var GoogleVertexImageModel = class {
305
327
  };
306
328
  }
307
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();
308
- const { value: response, responseHeaders } = await (0, import_provider_utils3.postJsonToApi)({
330
+ const { value: response, responseHeaders } = await postJsonToApi2({
309
331
  url: `${this.config.baseURL}/models/${this.modelId}:predict`,
310
- headers: (0, import_provider_utils3.combineHeaders)(await (0, import_provider_utils3.resolve)(this.config.headers), headers),
332
+ headers: combineHeaders2(
333
+ this.config.headers ? await resolve2(this.config.headers) : void 0,
334
+ headers
335
+ ),
311
336
  body,
312
337
  failedResponseHandler: googleVertexFailedResponseHandler,
313
- successfulResponseHandler: (0, import_provider_utils3.createJsonResponseHandler)(
338
+ successfulResponseHandler: createJsonResponseHandler2(
314
339
  vertexImageResponseSchema
315
340
  ),
316
341
  abortSignal,
@@ -394,12 +419,12 @@ var GoogleVertexImageModel = class {
394
419
  const languageModelPrompt = [
395
420
  { role: "user", content: userContent }
396
421
  ];
397
- const languageModel = new import_internal.GoogleGenerativeAILanguageModel(this.modelId, {
422
+ const languageModel = new GoogleLanguageModel(this.modelId, {
398
423
  provider: this.config.provider,
399
424
  baseURL: this.config.baseURL,
400
425
  headers: (_a = this.config.headers) != null ? _a : {},
401
426
  fetch: this.config.fetch,
402
- generateId: (_b = this.config.generateId) != null ? _b : import_provider_utils3.generateId,
427
+ generateId: (_b = this.config.generateId) != null ? _b : defaultGenerateId,
403
428
  supportedUrls: () => ({
404
429
  "*": [/^https?:\/\/.*$/, /^gs:\/\/.*$/]
405
430
  })
@@ -423,7 +448,7 @@ var GoogleVertexImageModel = class {
423
448
  const images = [];
424
449
  for (const part of result.content) {
425
450
  if (part.type === "file" && part.mediaType.startsWith("image/")) {
426
- images.push((0, import_provider_utils3.convertToBase64)(part.data));
451
+ images.push(convertToBase64(part.data));
427
452
  }
428
453
  }
429
454
  return {
@@ -450,41 +475,41 @@ var GoogleVertexImageModel = class {
450
475
  function isGeminiModel(modelId) {
451
476
  return modelId.startsWith("gemini-");
452
477
  }
453
- var vertexImageResponseSchema = import_v44.z.object({
454
- predictions: import_v44.z.array(
455
- import_v44.z.object({
456
- bytesBase64Encoded: import_v44.z.string(),
457
- mimeType: import_v44.z.string(),
458
- prompt: import_v44.z.string().nullish()
478
+ var vertexImageResponseSchema = z4.object({
479
+ predictions: z4.array(
480
+ z4.object({
481
+ bytesBase64Encoded: z4.string(),
482
+ mimeType: z4.string(),
483
+ prompt: z4.string().nullish()
459
484
  })
460
485
  ).nullish()
461
486
  });
462
- var googleVertexImageModelOptionsSchema = import_v44.z.object({
463
- negativePrompt: import_v44.z.string().nullish(),
464
- personGeneration: import_v44.z.enum(["dont_allow", "allow_adult", "allow_all"]).nullish(),
465
- safetySetting: import_v44.z.enum([
487
+ var googleVertexImageModelOptionsSchema = z4.object({
488
+ negativePrompt: z4.string().nullish(),
489
+ personGeneration: z4.enum(["dont_allow", "allow_adult", "allow_all"]).nullish(),
490
+ safetySetting: z4.enum([
466
491
  "block_low_and_above",
467
492
  "block_medium_and_above",
468
493
  "block_only_high",
469
494
  "block_none"
470
495
  ]).nullish(),
471
- addWatermark: import_v44.z.boolean().nullish(),
472
- storageUri: import_v44.z.string().nullish(),
473
- sampleImageSize: import_v44.z.enum(["1K", "2K"]).nullish(),
496
+ addWatermark: z4.boolean().nullish(),
497
+ storageUri: z4.string().nullish(),
498
+ sampleImageSize: z4.enum(["1K", "2K"]).nullish(),
474
499
  /**
475
500
  * Configuration for image editing operations
476
501
  */
477
- edit: import_v44.z.object({
502
+ edit: z4.object({
478
503
  /**
479
504
  * An integer that represents the number of sampling steps.
480
505
  * A higher value offers better image quality, a lower value offers better latency.
481
506
  * Try 35 steps to start. If the quality doesn't meet your requirements,
482
507
  * increase the value towards an upper limit of 75.
483
508
  */
484
- baseSteps: import_v44.z.number().nullish(),
509
+ baseSteps: z4.number().nullish(),
485
510
  // Edit mode options
486
511
  // https://cloud.google.com/vertex-ai/generative-ai/docs/image/edit-insert-objects
487
- mode: import_v44.z.enum([
512
+ mode: z4.enum([
488
513
  "EDIT_MODE_INPAINT_INSERTION",
489
514
  "EDIT_MODE_INPAINT_REMOVAL",
490
515
  "EDIT_MODE_OUTPAINT",
@@ -500,7 +525,7 @@ var googleVertexImageModelOptionsSchema = import_v44.z.object({
500
525
  * - `MASK_MODE_CLOTHING_AREA` - Masks from segmenting the clothing area with open-vocab segmentation.
501
526
  * - `MASK_MODE_PARSED_PERSON` - Masks from segmenting the person body and clothing using the person-parsing model.
502
527
  */
503
- maskMode: import_v44.z.enum([
528
+ maskMode: z4.enum([
504
529
  "MASK_MODE_DEFAULT",
505
530
  "MASK_MODE_USER_PROVIDED",
506
531
  "MASK_MODE_DETECTION_BOX",
@@ -512,7 +537,7 @@ var googleVertexImageModelOptionsSchema = import_v44.z.object({
512
537
  * percentage of the image width to grow the mask by. Using dilation helps
513
538
  * compensate for imprecise masks. We recommend a value of 0.01.
514
539
  */
515
- maskDilation: import_v44.z.number().nullish()
540
+ maskDilation: z4.number().nullish()
516
541
  }).nullish()
517
542
  });
518
543
  function getBase64Data(file) {
@@ -524,30 +549,42 @@ function getBase64Data(file) {
524
549
  if (typeof file.data === "string") {
525
550
  return file.data;
526
551
  }
527
- return (0, import_provider_utils3.convertUint8ArrayToBase64)(file.data);
552
+ return convertUint8ArrayToBase64(file.data);
528
553
  }
529
554
 
530
555
  // src/google-vertex-tools.ts
531
- var import_internal2 = require("@ai-sdk/google/internal");
556
+ import { googleTools } from "@ai-sdk/google/internal";
532
557
  var googleVertexTools = {
533
- googleSearch: import_internal2.googleTools.googleSearch,
534
- enterpriseWebSearch: import_internal2.googleTools.enterpriseWebSearch,
535
- googleMaps: import_internal2.googleTools.googleMaps,
536
- urlContext: import_internal2.googleTools.urlContext,
537
- fileSearch: import_internal2.googleTools.fileSearch,
538
- codeExecution: import_internal2.googleTools.codeExecution,
539
- vertexRagStore: import_internal2.googleTools.vertexRagStore
558
+ googleSearch: googleTools.googleSearch,
559
+ enterpriseWebSearch: googleTools.enterpriseWebSearch,
560
+ googleMaps: googleTools.googleMaps,
561
+ urlContext: googleTools.urlContext,
562
+ fileSearch: googleTools.fileSearch,
563
+ codeExecution: googleTools.codeExecution,
564
+ vertexRagStore: googleTools.vertexRagStore
540
565
  };
541
566
 
542
567
  // src/google-vertex-video-model.ts
543
- var import_provider2 = require("@ai-sdk/provider");
544
- var import_provider_utils4 = require("@ai-sdk/provider-utils");
545
- var import_v45 = require("zod/v4");
568
+ import {
569
+ AISDKError
570
+ } from "@ai-sdk/provider";
571
+ import {
572
+ combineHeaders as combineHeaders3,
573
+ convertUint8ArrayToBase64 as convertUint8ArrayToBase642,
574
+ createJsonResponseHandler as createJsonResponseHandler3,
575
+ delay,
576
+ lazySchema,
577
+ parseProviderOptions as parseProviderOptions3,
578
+ postJsonToApi as postJsonToApi3,
579
+ resolve as resolve3,
580
+ zodSchema
581
+ } from "@ai-sdk/provider-utils";
582
+ import { z as z5 } from "zod/v4";
546
583
  var GoogleVertexVideoModel = class {
547
584
  constructor(modelId, config) {
548
585
  this.modelId = modelId;
549
586
  this.config = config;
550
- this.specificationVersion = "v3";
587
+ this.specificationVersion = "v4";
551
588
  }
552
589
  get provider() {
553
590
  return this.config.provider;
@@ -559,7 +596,7 @@ var GoogleVertexVideoModel = class {
559
596
  var _a, _b, _c, _d, _e, _f;
560
597
  const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
561
598
  const warnings = [];
562
- const vertexOptions = await (0, import_provider_utils4.parseProviderOptions)({
599
+ const vertexOptions = await parseProviderOptions3({
563
600
  provider: "vertex",
564
601
  providerOptions: options.providerOptions,
565
602
  schema: googleVertexVideoModelOptionsSchema
@@ -577,7 +614,7 @@ var GoogleVertexVideoModel = class {
577
614
  details: "Vertex AI video models require base64-encoded images or GCS URIs. URL will be ignored."
578
615
  });
579
616
  } else {
580
- const base64Data = typeof options.image.data === "string" ? options.image.data : (0, import_provider_utils4.convertUint8ArrayToBase64)(options.image.data);
617
+ const base64Data = typeof options.image.data === "string" ? options.image.data : convertUint8ArrayToBase642(options.image.data);
581
618
  instance.image = {
582
619
  bytesBase64Encoded: base64Data,
583
620
  mimeType: options.image.mediaType
@@ -635,17 +672,17 @@ var GoogleVertexVideoModel = class {
635
672
  }
636
673
  }
637
674
  }
638
- const { value: operation } = await (0, import_provider_utils4.postJsonToApi)({
675
+ const { value: operation } = await postJsonToApi3({
639
676
  url: `${this.config.baseURL}/models/${this.modelId}:predictLongRunning`,
640
- headers: (0, import_provider_utils4.combineHeaders)(
641
- await (0, import_provider_utils4.resolve)(this.config.headers),
677
+ headers: combineHeaders3(
678
+ await resolve3(this.config.headers),
642
679
  options.headers
643
680
  ),
644
681
  body: {
645
682
  instances,
646
683
  parameters
647
684
  },
648
- successfulResponseHandler: (0, import_provider_utils4.createJsonResponseHandler)(
685
+ successfulResponseHandler: createJsonResponseHandler3(
649
686
  vertexOperationSchema
650
687
  ),
651
688
  failedResponseHandler: googleVertexFailedResponseHandler,
@@ -654,7 +691,7 @@ var GoogleVertexVideoModel = class {
654
691
  });
655
692
  const operationName = operation.name;
656
693
  if (!operationName) {
657
- throw new import_provider2.AISDKError({
694
+ throw new AISDKError({
658
695
  name: "VERTEX_VIDEO_GENERATION_ERROR",
659
696
  message: "No operation name returned from API"
660
697
  });
@@ -666,28 +703,28 @@ var GoogleVertexVideoModel = class {
666
703
  let responseHeaders;
667
704
  while (!finalOperation.done) {
668
705
  if (Date.now() - startTime > pollTimeoutMs) {
669
- throw new import_provider2.AISDKError({
706
+ throw new AISDKError({
670
707
  name: "VERTEX_VIDEO_GENERATION_TIMEOUT",
671
708
  message: `Video generation timed out after ${pollTimeoutMs}ms`
672
709
  });
673
710
  }
674
- await (0, import_provider_utils4.delay)(pollIntervalMs);
711
+ await delay(pollIntervalMs);
675
712
  if ((_f = options.abortSignal) == null ? void 0 : _f.aborted) {
676
- throw new import_provider2.AISDKError({
713
+ throw new AISDKError({
677
714
  name: "VERTEX_VIDEO_GENERATION_ABORTED",
678
715
  message: "Video generation request was aborted"
679
716
  });
680
717
  }
681
- const { value: statusOperation, responseHeaders: pollHeaders } = await (0, import_provider_utils4.postJsonToApi)({
718
+ const { value: statusOperation, responseHeaders: pollHeaders } = await postJsonToApi3({
682
719
  url: `${this.config.baseURL}/models/${this.modelId}:fetchPredictOperation`,
683
- headers: (0, import_provider_utils4.combineHeaders)(
684
- await (0, import_provider_utils4.resolve)(this.config.headers),
720
+ headers: combineHeaders3(
721
+ await resolve3(this.config.headers),
685
722
  options.headers
686
723
  ),
687
724
  body: {
688
725
  operationName
689
726
  },
690
- successfulResponseHandler: (0, import_provider_utils4.createJsonResponseHandler)(
727
+ successfulResponseHandler: createJsonResponseHandler3(
691
728
  vertexOperationSchema
692
729
  ),
693
730
  failedResponseHandler: googleVertexFailedResponseHandler,
@@ -698,14 +735,14 @@ var GoogleVertexVideoModel = class {
698
735
  responseHeaders = pollHeaders;
699
736
  }
700
737
  if (finalOperation.error) {
701
- throw new import_provider2.AISDKError({
738
+ throw new AISDKError({
702
739
  name: "VERTEX_VIDEO_GENERATION_FAILED",
703
740
  message: `Video generation failed: ${finalOperation.error.message}`
704
741
  });
705
742
  }
706
743
  const response = finalOperation.response;
707
744
  if (!(response == null ? void 0 : response.videos) || response.videos.length === 0) {
708
- throw new import_provider2.AISDKError({
745
+ throw new AISDKError({
709
746
  name: "VERTEX_VIDEO_GENERATION_ERROR",
710
747
  message: `No videos in response. Response: ${JSON.stringify(finalOperation)}`
711
748
  });
@@ -735,7 +772,7 @@ var GoogleVertexVideoModel = class {
735
772
  }
736
773
  }
737
774
  if (videos.length === 0) {
738
- throw new import_provider2.AISDKError({
775
+ throw new AISDKError({
739
776
  name: "VERTEX_VIDEO_GENERATION_ERROR",
740
777
  message: "No valid videos in response"
741
778
  });
@@ -756,38 +793,38 @@ var GoogleVertexVideoModel = class {
756
793
  };
757
794
  }
758
795
  };
759
- var vertexOperationSchema = import_v45.z.object({
760
- name: import_v45.z.string().nullish(),
761
- done: import_v45.z.boolean().nullish(),
762
- error: import_v45.z.object({
763
- code: import_v45.z.number().nullish(),
764
- message: import_v45.z.string(),
765
- status: import_v45.z.string().nullish()
796
+ var vertexOperationSchema = z5.object({
797
+ name: z5.string().nullish(),
798
+ done: z5.boolean().nullish(),
799
+ error: z5.object({
800
+ code: z5.number().nullish(),
801
+ message: z5.string(),
802
+ status: z5.string().nullish()
766
803
  }).nullish(),
767
- response: import_v45.z.object({
768
- videos: import_v45.z.array(
769
- import_v45.z.object({
770
- bytesBase64Encoded: import_v45.z.string().nullish(),
771
- gcsUri: import_v45.z.string().nullish(),
772
- mimeType: import_v45.z.string().nullish()
804
+ response: z5.object({
805
+ videos: z5.array(
806
+ z5.object({
807
+ bytesBase64Encoded: z5.string().nullish(),
808
+ gcsUri: z5.string().nullish(),
809
+ mimeType: z5.string().nullish()
773
810
  })
774
811
  ).nullish(),
775
- raiMediaFilteredCount: import_v45.z.number().nullish()
812
+ raiMediaFilteredCount: z5.number().nullish()
776
813
  }).nullish()
777
814
  });
778
- var googleVertexVideoModelOptionsSchema = (0, import_provider_utils4.lazySchema)(
779
- () => (0, import_provider_utils4.zodSchema)(
780
- import_v45.z.object({
781
- pollIntervalMs: import_v45.z.number().positive().nullish(),
782
- pollTimeoutMs: import_v45.z.number().positive().nullish(),
783
- personGeneration: import_v45.z.enum(["dont_allow", "allow_adult", "allow_all"]).nullish(),
784
- negativePrompt: import_v45.z.string().nullish(),
785
- generateAudio: import_v45.z.boolean().nullish(),
786
- gcsOutputDirectory: import_v45.z.string().nullish(),
787
- referenceImages: import_v45.z.array(
788
- import_v45.z.object({
789
- bytesBase64Encoded: import_v45.z.string().nullish(),
790
- gcsUri: import_v45.z.string().nullish()
815
+ var googleVertexVideoModelOptionsSchema = lazySchema(
816
+ () => zodSchema(
817
+ z5.object({
818
+ pollIntervalMs: z5.number().positive().nullish(),
819
+ pollTimeoutMs: z5.number().positive().nullish(),
820
+ personGeneration: z5.enum(["dont_allow", "allow_adult", "allow_all"]).nullish(),
821
+ negativePrompt: z5.string().nullish(),
822
+ generateAudio: z5.boolean().nullish(),
823
+ gcsOutputDirectory: z5.string().nullish(),
824
+ referenceImages: z5.array(
825
+ z5.object({
826
+ bytesBase64Encoded: z5.string().nullish(),
827
+ gcsUri: z5.string().nullish()
791
828
  })
792
829
  ).nullish()
793
830
  }).passthrough()
@@ -801,7 +838,7 @@ function createExpressModeFetch(apiKey, customFetch) {
801
838
  const modifiedInit = {
802
839
  ...init,
803
840
  headers: {
804
- ...(init == null ? void 0 : init.headers) ? (0, import_provider_utils5.normalizeHeaders)(init.headers) : {},
841
+ ...(init == null ? void 0 : init.headers) ? normalizeHeaders(init.headers) : {},
805
842
  "x-goog-api-key": apiKey
806
843
  }
807
844
  };
@@ -809,17 +846,17 @@ function createExpressModeFetch(apiKey, customFetch) {
809
846
  };
810
847
  }
811
848
  function createVertex(options = {}) {
812
- const apiKey = (0, import_provider_utils5.loadOptionalSetting)({
849
+ const apiKey = loadOptionalSetting({
813
850
  settingValue: options.apiKey,
814
851
  environmentVariableName: "GOOGLE_VERTEX_API_KEY"
815
852
  });
816
- const loadVertexProject = () => (0, import_provider_utils5.loadSetting)({
853
+ const loadVertexProject = () => loadSetting({
817
854
  settingValue: options.project,
818
855
  settingName: "project",
819
856
  environmentVariableName: "GOOGLE_VERTEX_PROJECT",
820
857
  description: "Google Vertex project"
821
858
  });
822
- const loadVertexLocation = () => (0, import_provider_utils5.loadSetting)({
859
+ const loadVertexLocation = () => loadSetting({
823
860
  settingValue: options.location,
824
861
  settingName: "location",
825
862
  environmentVariableName: "GOOGLE_VERTEX_LOCATION",
@@ -828,18 +865,18 @@ function createVertex(options = {}) {
828
865
  const loadBaseURL = () => {
829
866
  var _a, _b;
830
867
  if (apiKey) {
831
- return (_a = (0, import_provider_utils5.withoutTrailingSlash)(options.baseURL)) != null ? _a : EXPRESS_MODE_BASE_URL;
868
+ return (_a = withoutTrailingSlash(options.baseURL)) != null ? _a : EXPRESS_MODE_BASE_URL;
832
869
  }
833
870
  const region = loadVertexLocation();
834
871
  const project = loadVertexProject();
835
872
  const baseHost = `${region === "global" ? "" : region + "-"}aiplatform.googleapis.com`;
836
- return (_b = (0, import_provider_utils5.withoutTrailingSlash)(options.baseURL)) != null ? _b : `https://${baseHost}/v1beta1/projects/${project}/locations/${region}/publishers/google`;
873
+ return (_b = withoutTrailingSlash(options.baseURL)) != null ? _b : `https://${baseHost}/v1beta1/projects/${project}/locations/${region}/publishers/google`;
837
874
  };
838
875
  const createConfig = (name) => {
839
876
  const getHeaders = async () => {
840
877
  var _a;
841
- const originalHeaders = await (0, import_provider_utils5.resolve)((_a = options.headers) != null ? _a : {});
842
- return (0, import_provider_utils5.withUserAgentSuffix)(
878
+ const originalHeaders = await resolve4((_a = options.headers) != null ? _a : {});
879
+ return withUserAgentSuffix(
843
880
  originalHeaders,
844
881
  `ai-sdk/google-vertex/${VERSION}`
845
882
  );
@@ -853,9 +890,9 @@ function createVertex(options = {}) {
853
890
  };
854
891
  const createChatModel = (modelId) => {
855
892
  var _a;
856
- return new import_internal3.GoogleGenerativeAILanguageModel(modelId, {
893
+ return new GoogleLanguageModel2(modelId, {
857
894
  ...createConfig("chat"),
858
- generateId: (_a = options.generateId) != null ? _a : import_provider_utils5.generateId,
895
+ generateId: (_a = options.generateId) != null ? _a : generateId,
859
896
  supportedUrls: () => ({
860
897
  "*": [
861
898
  // HTTP URLs:
@@ -871,14 +908,14 @@ function createVertex(options = {}) {
871
908
  var _a;
872
909
  return new GoogleVertexImageModel(modelId, {
873
910
  ...createConfig("image"),
874
- generateId: (_a = options.generateId) != null ? _a : import_provider_utils5.generateId
911
+ generateId: (_a = options.generateId) != null ? _a : generateId
875
912
  });
876
913
  };
877
914
  const createVideoModel = (modelId) => {
878
915
  var _a;
879
916
  return new GoogleVertexVideoModel(modelId, {
880
917
  ...createConfig("video"),
881
- generateId: (_a = options.generateId) != null ? _a : import_provider_utils5.generateId
918
+ generateId: (_a = options.generateId) != null ? _a : generateId
882
919
  });
883
920
  };
884
921
  const provider = function(modelId) {
@@ -889,7 +926,7 @@ function createVertex(options = {}) {
889
926
  }
890
927
  return createChatModel(modelId);
891
928
  };
892
- provider.specificationVersion = "v3";
929
+ provider.specificationVersion = "v4";
893
930
  provider.languageModel = createChatModel;
894
931
  provider.embeddingModel = createEmbeddingModel;
895
932
  provider.textEmbeddingModel = createEmbeddingModel;
@@ -902,23 +939,28 @@ function createVertex(options = {}) {
902
939
  }
903
940
 
904
941
  // src/edge/google-vertex-auth-edge.ts
905
- var import_provider_utils6 = require("@ai-sdk/provider-utils");
942
+ import {
943
+ loadOptionalSetting as loadOptionalSetting2,
944
+ loadSetting as loadSetting2,
945
+ withUserAgentSuffix as withUserAgentSuffix2,
946
+ getRuntimeEnvironmentUserAgent
947
+ } from "@ai-sdk/provider-utils";
906
948
  var loadCredentials = async () => {
907
949
  try {
908
950
  return {
909
- clientEmail: (0, import_provider_utils6.loadSetting)({
951
+ clientEmail: loadSetting2({
910
952
  settingValue: void 0,
911
953
  settingName: "clientEmail",
912
954
  environmentVariableName: "GOOGLE_CLIENT_EMAIL",
913
955
  description: "Google client email"
914
956
  }),
915
- privateKey: (0, import_provider_utils6.loadSetting)({
957
+ privateKey: loadSetting2({
916
958
  settingValue: void 0,
917
959
  settingName: "privateKey",
918
960
  environmentVariableName: "GOOGLE_PRIVATE_KEY",
919
961
  description: "Google private key"
920
962
  }),
921
- privateKeyId: (0, import_provider_utils6.loadOptionalSetting)({
963
+ privateKeyId: loadOptionalSetting2({
922
964
  settingValue: void 0,
923
965
  environmentVariableName: "GOOGLE_PRIVATE_KEY_ID"
924
966
  })
@@ -987,10 +1029,10 @@ async function generateAuthToken(credentials) {
987
1029
  const jwt = await buildJwt(creds);
988
1030
  const response = await fetch("https://oauth2.googleapis.com/token", {
989
1031
  method: "POST",
990
- headers: (0, import_provider_utils6.withUserAgentSuffix)(
1032
+ headers: withUserAgentSuffix2(
991
1033
  { "Content-Type": "application/x-www-form-urlencoded" },
992
1034
  `ai-sdk/google-vertex/${VERSION}`,
993
- (0, import_provider_utils6.getRuntimeEnvironmentUserAgent)()
1035
+ getRuntimeEnvironmentUserAgent()
994
1036
  ),
995
1037
  body: new URLSearchParams({
996
1038
  grant_type: "urn:ietf:params:oauth:grant-type:jwt-bearer",
@@ -1009,7 +1051,7 @@ async function generateAuthToken(credentials) {
1009
1051
 
1010
1052
  // src/edge/google-vertex-provider-edge.ts
1011
1053
  function createVertex2(options = {}) {
1012
- const apiKey = (0, import_provider_utils7.loadOptionalSetting)({
1054
+ const apiKey = loadOptionalSetting3({
1013
1055
  settingValue: options.apiKey,
1014
1056
  environmentVariableName: "GOOGLE_VERTEX_API_KEY"
1015
1057
  });
@@ -1022,14 +1064,13 @@ function createVertex2(options = {}) {
1022
1064
  Authorization: `Bearer ${await generateAuthToken(
1023
1065
  options.googleCredentials
1024
1066
  )}`,
1025
- ...await (0, import_provider_utils7.resolve)(options.headers)
1067
+ ...await resolve5(options.headers)
1026
1068
  })
1027
1069
  });
1028
1070
  }
1029
1071
  var vertex = createVertex2();
1030
- // Annotate the CommonJS export names for ESM import in node:
1031
- 0 && (module.exports = {
1032
- createVertex,
1072
+ export {
1073
+ createVertex2 as createVertex,
1033
1074
  vertex
1034
- });
1075
+ };
1035
1076
  //# sourceMappingURL=index.js.map