@ai-sdk/google-vertex 5.0.0-beta.45 → 5.0.0-beta.47

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/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 index_exports = {};
22
- __export(index_exports, {
23
- VERSION: () => VERSION,
24
- createVertex: () => createVertex2,
25
- vertex: () => vertex
26
- });
27
- module.exports = __toCommonJS(index_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,44 @@ 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.45" : "0.0.0-test";
38
+ var VERSION = true ? "5.0.0-beta.47" : "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
+ } 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
@@ -80,13 +68,13 @@ var googleVertexFailedResponseHandler = (0, import_provider_utils.createJsonErro
80
68
  );
81
69
 
82
70
  // src/google-vertex-embedding-options.ts
83
- var import_v42 = require("zod/v4");
84
- var googleVertexEmbeddingModelOptions = import_v42.z.object({
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,12 +102,12 @@ 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
@@ -140,13 +128,13 @@ var GoogleVertexEmbeddingModel = class {
140
128
  abortSignal,
141
129
  providerOptions
142
130
  }) {
143
- let googleOptions = await (0, import_provider_utils2.parseProviderOptions)({
131
+ let googleOptions = await parseProviderOptions({
144
132
  provider: "vertex",
145
133
  providerOptions,
146
134
  schema: googleVertexEmbeddingModelOptions
147
135
  });
148
136
  if (googleOptions == null) {
149
- googleOptions = await (0, import_provider_utils2.parseProviderOptions)({
137
+ googleOptions = await parseProviderOptions({
150
138
  provider: "google",
151
139
  providerOptions,
152
140
  schema: googleVertexEmbeddingModelOptions
@@ -154,15 +142,15 @@ var GoogleVertexEmbeddingModel = class {
154
142
  }
155
143
  googleOptions = googleOptions != null ? googleOptions : {};
156
144
  if (values.length > this.maxEmbeddingsPerCall) {
157
- throw new import_provider.TooManyEmbeddingValuesForCallError({
145
+ throw new TooManyEmbeddingValuesForCallError({
158
146
  provider: this.provider,
159
147
  modelId: this.modelId,
160
148
  maxEmbeddingsPerCall: this.maxEmbeddingsPerCall,
161
149
  values
162
150
  });
163
151
  }
164
- const mergedHeaders = (0, import_provider_utils2.combineHeaders)(
165
- await (0, import_provider_utils2.resolve)(this.config.headers),
152
+ const mergedHeaders = combineHeaders(
153
+ await resolve(this.config.headers),
166
154
  headers
167
155
  );
168
156
  const url = `${this.config.baseURL}/models/${this.modelId}:predict`;
@@ -170,7 +158,7 @@ var GoogleVertexEmbeddingModel = class {
170
158
  responseHeaders,
171
159
  value: response,
172
160
  rawValue
173
- } = await (0, import_provider_utils2.postJsonToApi)({
161
+ } = await postJsonToApi({
174
162
  url,
175
163
  headers: mergedHeaders,
176
164
  body: {
@@ -185,7 +173,7 @@ var GoogleVertexEmbeddingModel = class {
185
173
  }
186
174
  },
187
175
  failedResponseHandler: googleVertexFailedResponseHandler,
188
- successfulResponseHandler: (0, import_provider_utils2.createJsonResponseHandler)(
176
+ successfulResponseHandler: createJsonResponseHandler(
189
177
  googleVertexTextEmbeddingResponseSchema
190
178
  ),
191
179
  abortSignal,
@@ -206,13 +194,13 @@ var GoogleVertexEmbeddingModel = class {
206
194
  };
207
195
  }
208
196
  };
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()
197
+ var googleVertexTextEmbeddingResponseSchema = z3.object({
198
+ predictions: z3.array(
199
+ z3.object({
200
+ embeddings: z3.object({
201
+ values: z3.array(z3.number()),
202
+ statistics: z3.object({
203
+ token_count: z3.number()
216
204
  })
217
205
  })
218
206
  })
@@ -220,9 +208,18 @@ var googleVertexTextEmbeddingResponseSchema = import_v43.z.object({
220
208
  });
221
209
 
222
210
  // 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");
211
+ import { GoogleGenerativeAILanguageModel } from "@ai-sdk/google/internal";
212
+ import {
213
+ combineHeaders as combineHeaders2,
214
+ convertToBase64,
215
+ convertUint8ArrayToBase64,
216
+ createJsonResponseHandler as createJsonResponseHandler2,
217
+ generateId as defaultGenerateId,
218
+ parseProviderOptions as parseProviderOptions2,
219
+ postJsonToApi as postJsonToApi2,
220
+ resolve as resolve2
221
+ } from "@ai-sdk/provider-utils";
222
+ import { z as z4 } from "zod/v4";
226
223
  var GoogleVertexImageModel = class {
227
224
  constructor(modelId, config) {
228
225
  this.modelId = modelId;
@@ -265,7 +262,7 @@ var GoogleVertexImageModel = class {
265
262
  details: "This model does not support the `size` option. Use `aspectRatio` instead."
266
263
  });
267
264
  }
268
- const vertexImageOptions = await (0, import_provider_utils3.parseProviderOptions)({
265
+ const vertexImageOptions = await parseProviderOptions2({
269
266
  provider: "vertex",
270
267
  providerOptions,
271
268
  schema: googleVertexImageModelOptionsSchema
@@ -327,12 +324,12 @@ var GoogleVertexImageModel = class {
327
324
  };
328
325
  }
329
326
  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)({
327
+ const { value: response, responseHeaders } = await postJsonToApi2({
331
328
  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),
329
+ headers: combineHeaders2(await resolve2(this.config.headers), headers),
333
330
  body,
334
331
  failedResponseHandler: googleVertexFailedResponseHandler,
335
- successfulResponseHandler: (0, import_provider_utils3.createJsonResponseHandler)(
332
+ successfulResponseHandler: createJsonResponseHandler2(
336
333
  vertexImageResponseSchema
337
334
  ),
338
335
  abortSignal,
@@ -416,12 +413,12 @@ var GoogleVertexImageModel = class {
416
413
  const languageModelPrompt = [
417
414
  { role: "user", content: userContent }
418
415
  ];
419
- const languageModel = new import_internal.GoogleGenerativeAILanguageModel(this.modelId, {
416
+ const languageModel = new GoogleGenerativeAILanguageModel(this.modelId, {
420
417
  provider: this.config.provider,
421
418
  baseURL: this.config.baseURL,
422
419
  headers: (_a = this.config.headers) != null ? _a : {},
423
420
  fetch: this.config.fetch,
424
- generateId: (_b = this.config.generateId) != null ? _b : import_provider_utils3.generateId,
421
+ generateId: (_b = this.config.generateId) != null ? _b : defaultGenerateId,
425
422
  supportedUrls: () => ({
426
423
  "*": [/^https?:\/\/.*$/, /^gs:\/\/.*$/]
427
424
  })
@@ -445,7 +442,7 @@ var GoogleVertexImageModel = class {
445
442
  const images = [];
446
443
  for (const part of result.content) {
447
444
  if (part.type === "file" && part.mediaType.startsWith("image/")) {
448
- images.push((0, import_provider_utils3.convertToBase64)(part.data));
445
+ images.push(convertToBase64(part.data));
449
446
  }
450
447
  }
451
448
  return {
@@ -472,41 +469,41 @@ var GoogleVertexImageModel = class {
472
469
  function isGeminiModel(modelId) {
473
470
  return modelId.startsWith("gemini-");
474
471
  }
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()
472
+ var vertexImageResponseSchema = z4.object({
473
+ predictions: z4.array(
474
+ z4.object({
475
+ bytesBase64Encoded: z4.string(),
476
+ mimeType: z4.string(),
477
+ prompt: z4.string().nullish()
481
478
  })
482
479
  ).nullish()
483
480
  });
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([
481
+ var googleVertexImageModelOptionsSchema = z4.object({
482
+ negativePrompt: z4.string().nullish(),
483
+ personGeneration: z4.enum(["dont_allow", "allow_adult", "allow_all"]).nullish(),
484
+ safetySetting: z4.enum([
488
485
  "block_low_and_above",
489
486
  "block_medium_and_above",
490
487
  "block_only_high",
491
488
  "block_none"
492
489
  ]).nullish(),
493
- addWatermark: import_v44.z.boolean().nullish(),
494
- storageUri: import_v44.z.string().nullish(),
495
- sampleImageSize: import_v44.z.enum(["1K", "2K"]).nullish(),
490
+ addWatermark: z4.boolean().nullish(),
491
+ storageUri: z4.string().nullish(),
492
+ sampleImageSize: z4.enum(["1K", "2K"]).nullish(),
496
493
  /**
497
494
  * Configuration for image editing operations
498
495
  */
499
- edit: import_v44.z.object({
496
+ edit: z4.object({
500
497
  /**
501
498
  * An integer that represents the number of sampling steps.
502
499
  * A higher value offers better image quality, a lower value offers better latency.
503
500
  * Try 35 steps to start. If the quality doesn't meet your requirements,
504
501
  * increase the value towards an upper limit of 75.
505
502
  */
506
- baseSteps: import_v44.z.number().nullish(),
503
+ baseSteps: z4.number().nullish(),
507
504
  // Edit mode options
508
505
  // https://cloud.google.com/vertex-ai/generative-ai/docs/image/edit-insert-objects
509
- mode: import_v44.z.enum([
506
+ mode: z4.enum([
510
507
  "EDIT_MODE_INPAINT_INSERTION",
511
508
  "EDIT_MODE_INPAINT_REMOVAL",
512
509
  "EDIT_MODE_OUTPAINT",
@@ -522,7 +519,7 @@ var googleVertexImageModelOptionsSchema = import_v44.z.object({
522
519
  * - `MASK_MODE_CLOTHING_AREA` - Masks from segmenting the clothing area with open-vocab segmentation.
523
520
  * - `MASK_MODE_PARSED_PERSON` - Masks from segmenting the person body and clothing using the person-parsing model.
524
521
  */
525
- maskMode: import_v44.z.enum([
522
+ maskMode: z4.enum([
526
523
  "MASK_MODE_DEFAULT",
527
524
  "MASK_MODE_USER_PROVIDED",
528
525
  "MASK_MODE_DETECTION_BOX",
@@ -534,7 +531,7 @@ var googleVertexImageModelOptionsSchema = import_v44.z.object({
534
531
  * percentage of the image width to grow the mask by. Using dilation helps
535
532
  * compensate for imprecise masks. We recommend a value of 0.01.
536
533
  */
537
- maskDilation: import_v44.z.number().nullish()
534
+ maskDilation: z4.number().nullish()
538
535
  }).nullish()
539
536
  });
540
537
  function getBase64Data(file) {
@@ -546,25 +543,37 @@ function getBase64Data(file) {
546
543
  if (typeof file.data === "string") {
547
544
  return file.data;
548
545
  }
549
- return (0, import_provider_utils3.convertUint8ArrayToBase64)(file.data);
546
+ return convertUint8ArrayToBase64(file.data);
550
547
  }
551
548
 
552
549
  // src/google-vertex-tools.ts
553
- var import_internal2 = require("@ai-sdk/google/internal");
550
+ import { googleTools } from "@ai-sdk/google/internal";
554
551
  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
552
+ googleSearch: googleTools.googleSearch,
553
+ enterpriseWebSearch: googleTools.enterpriseWebSearch,
554
+ googleMaps: googleTools.googleMaps,
555
+ urlContext: googleTools.urlContext,
556
+ fileSearch: googleTools.fileSearch,
557
+ codeExecution: googleTools.codeExecution,
558
+ vertexRagStore: googleTools.vertexRagStore
562
559
  };
563
560
 
564
561
  // 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");
562
+ import {
563
+ AISDKError
564
+ } from "@ai-sdk/provider";
565
+ import {
566
+ combineHeaders as combineHeaders3,
567
+ convertUint8ArrayToBase64 as convertUint8ArrayToBase642,
568
+ createJsonResponseHandler as createJsonResponseHandler3,
569
+ delay,
570
+ lazySchema,
571
+ parseProviderOptions as parseProviderOptions3,
572
+ postJsonToApi as postJsonToApi3,
573
+ resolve as resolve3,
574
+ zodSchema
575
+ } from "@ai-sdk/provider-utils";
576
+ import { z as z5 } from "zod/v4";
568
577
  var GoogleVertexVideoModel = class {
569
578
  constructor(modelId, config) {
570
579
  this.modelId = modelId;
@@ -581,7 +590,7 @@ var GoogleVertexVideoModel = class {
581
590
  var _a, _b, _c, _d, _e, _f;
582
591
  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
592
  const warnings = [];
584
- const vertexOptions = await (0, import_provider_utils4.parseProviderOptions)({
593
+ const vertexOptions = await parseProviderOptions3({
585
594
  provider: "vertex",
586
595
  providerOptions: options.providerOptions,
587
596
  schema: googleVertexVideoModelOptionsSchema
@@ -599,7 +608,7 @@ var GoogleVertexVideoModel = class {
599
608
  details: "Vertex AI video models require base64-encoded images or GCS URIs. URL will be ignored."
600
609
  });
601
610
  } else {
602
- const base64Data = typeof options.image.data === "string" ? options.image.data : (0, import_provider_utils4.convertUint8ArrayToBase64)(options.image.data);
611
+ const base64Data = typeof options.image.data === "string" ? options.image.data : convertUint8ArrayToBase642(options.image.data);
603
612
  instance.image = {
604
613
  bytesBase64Encoded: base64Data,
605
614
  mimeType: options.image.mediaType
@@ -657,17 +666,17 @@ var GoogleVertexVideoModel = class {
657
666
  }
658
667
  }
659
668
  }
660
- const { value: operation } = await (0, import_provider_utils4.postJsonToApi)({
669
+ const { value: operation } = await postJsonToApi3({
661
670
  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),
671
+ headers: combineHeaders3(
672
+ await resolve3(this.config.headers),
664
673
  options.headers
665
674
  ),
666
675
  body: {
667
676
  instances,
668
677
  parameters
669
678
  },
670
- successfulResponseHandler: (0, import_provider_utils4.createJsonResponseHandler)(
679
+ successfulResponseHandler: createJsonResponseHandler3(
671
680
  vertexOperationSchema
672
681
  ),
673
682
  failedResponseHandler: googleVertexFailedResponseHandler,
@@ -676,7 +685,7 @@ var GoogleVertexVideoModel = class {
676
685
  });
677
686
  const operationName = operation.name;
678
687
  if (!operationName) {
679
- throw new import_provider2.AISDKError({
688
+ throw new AISDKError({
680
689
  name: "VERTEX_VIDEO_GENERATION_ERROR",
681
690
  message: "No operation name returned from API"
682
691
  });
@@ -688,28 +697,28 @@ var GoogleVertexVideoModel = class {
688
697
  let responseHeaders;
689
698
  while (!finalOperation.done) {
690
699
  if (Date.now() - startTime > pollTimeoutMs) {
691
- throw new import_provider2.AISDKError({
700
+ throw new AISDKError({
692
701
  name: "VERTEX_VIDEO_GENERATION_TIMEOUT",
693
702
  message: `Video generation timed out after ${pollTimeoutMs}ms`
694
703
  });
695
704
  }
696
- await (0, import_provider_utils4.delay)(pollIntervalMs);
705
+ await delay(pollIntervalMs);
697
706
  if ((_f = options.abortSignal) == null ? void 0 : _f.aborted) {
698
- throw new import_provider2.AISDKError({
707
+ throw new AISDKError({
699
708
  name: "VERTEX_VIDEO_GENERATION_ABORTED",
700
709
  message: "Video generation request was aborted"
701
710
  });
702
711
  }
703
- const { value: statusOperation, responseHeaders: pollHeaders } = await (0, import_provider_utils4.postJsonToApi)({
712
+ const { value: statusOperation, responseHeaders: pollHeaders } = await postJsonToApi3({
704
713
  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),
714
+ headers: combineHeaders3(
715
+ await resolve3(this.config.headers),
707
716
  options.headers
708
717
  ),
709
718
  body: {
710
719
  operationName
711
720
  },
712
- successfulResponseHandler: (0, import_provider_utils4.createJsonResponseHandler)(
721
+ successfulResponseHandler: createJsonResponseHandler3(
713
722
  vertexOperationSchema
714
723
  ),
715
724
  failedResponseHandler: googleVertexFailedResponseHandler,
@@ -720,14 +729,14 @@ var GoogleVertexVideoModel = class {
720
729
  responseHeaders = pollHeaders;
721
730
  }
722
731
  if (finalOperation.error) {
723
- throw new import_provider2.AISDKError({
732
+ throw new AISDKError({
724
733
  name: "VERTEX_VIDEO_GENERATION_FAILED",
725
734
  message: `Video generation failed: ${finalOperation.error.message}`
726
735
  });
727
736
  }
728
737
  const response = finalOperation.response;
729
738
  if (!(response == null ? void 0 : response.videos) || response.videos.length === 0) {
730
- throw new import_provider2.AISDKError({
739
+ throw new AISDKError({
731
740
  name: "VERTEX_VIDEO_GENERATION_ERROR",
732
741
  message: `No videos in response. Response: ${JSON.stringify(finalOperation)}`
733
742
  });
@@ -757,7 +766,7 @@ var GoogleVertexVideoModel = class {
757
766
  }
758
767
  }
759
768
  if (videos.length === 0) {
760
- throw new import_provider2.AISDKError({
769
+ throw new AISDKError({
761
770
  name: "VERTEX_VIDEO_GENERATION_ERROR",
762
771
  message: "No valid videos in response"
763
772
  });
@@ -778,38 +787,38 @@ var GoogleVertexVideoModel = class {
778
787
  };
779
788
  }
780
789
  };
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()
790
+ var vertexOperationSchema = z5.object({
791
+ name: z5.string().nullish(),
792
+ done: z5.boolean().nullish(),
793
+ error: z5.object({
794
+ code: z5.number().nullish(),
795
+ message: z5.string(),
796
+ status: z5.string().nullish()
788
797
  }).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()
798
+ response: z5.object({
799
+ videos: z5.array(
800
+ z5.object({
801
+ bytesBase64Encoded: z5.string().nullish(),
802
+ gcsUri: z5.string().nullish(),
803
+ mimeType: z5.string().nullish()
795
804
  })
796
805
  ).nullish(),
797
- raiMediaFilteredCount: import_v45.z.number().nullish()
806
+ raiMediaFilteredCount: z5.number().nullish()
798
807
  }).nullish()
799
808
  });
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()
809
+ var googleVertexVideoModelOptionsSchema = lazySchema(
810
+ () => zodSchema(
811
+ z5.object({
812
+ pollIntervalMs: z5.number().positive().nullish(),
813
+ pollTimeoutMs: z5.number().positive().nullish(),
814
+ personGeneration: z5.enum(["dont_allow", "allow_adult", "allow_all"]).nullish(),
815
+ negativePrompt: z5.string().nullish(),
816
+ generateAudio: z5.boolean().nullish(),
817
+ gcsOutputDirectory: z5.string().nullish(),
818
+ referenceImages: z5.array(
819
+ z5.object({
820
+ bytesBase64Encoded: z5.string().nullish(),
821
+ gcsUri: z5.string().nullish()
813
822
  })
814
823
  ).nullish()
815
824
  }).passthrough()
@@ -823,7 +832,7 @@ function createExpressModeFetch(apiKey, customFetch) {
823
832
  const modifiedInit = {
824
833
  ...init,
825
834
  headers: {
826
- ...(init == null ? void 0 : init.headers) ? (0, import_provider_utils5.normalizeHeaders)(init.headers) : {},
835
+ ...(init == null ? void 0 : init.headers) ? normalizeHeaders(init.headers) : {},
827
836
  "x-goog-api-key": apiKey
828
837
  }
829
838
  };
@@ -831,17 +840,17 @@ function createExpressModeFetch(apiKey, customFetch) {
831
840
  };
832
841
  }
833
842
  function createVertex(options = {}) {
834
- const apiKey = (0, import_provider_utils5.loadOptionalSetting)({
843
+ const apiKey = loadOptionalSetting({
835
844
  settingValue: options.apiKey,
836
845
  environmentVariableName: "GOOGLE_VERTEX_API_KEY"
837
846
  });
838
- const loadVertexProject = () => (0, import_provider_utils5.loadSetting)({
847
+ const loadVertexProject = () => loadSetting({
839
848
  settingValue: options.project,
840
849
  settingName: "project",
841
850
  environmentVariableName: "GOOGLE_VERTEX_PROJECT",
842
851
  description: "Google Vertex project"
843
852
  });
844
- const loadVertexLocation = () => (0, import_provider_utils5.loadSetting)({
853
+ const loadVertexLocation = () => loadSetting({
845
854
  settingValue: options.location,
846
855
  settingName: "location",
847
856
  environmentVariableName: "GOOGLE_VERTEX_LOCATION",
@@ -850,18 +859,18 @@ function createVertex(options = {}) {
850
859
  const loadBaseURL = () => {
851
860
  var _a, _b;
852
861
  if (apiKey) {
853
- return (_a = (0, import_provider_utils5.withoutTrailingSlash)(options.baseURL)) != null ? _a : EXPRESS_MODE_BASE_URL;
862
+ return (_a = withoutTrailingSlash(options.baseURL)) != null ? _a : EXPRESS_MODE_BASE_URL;
854
863
  }
855
864
  const region = loadVertexLocation();
856
865
  const project = loadVertexProject();
857
866
  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`;
867
+ return (_b = withoutTrailingSlash(options.baseURL)) != null ? _b : `https://${baseHost}/v1beta1/projects/${project}/locations/${region}/publishers/google`;
859
868
  };
860
869
  const createConfig = (name) => {
861
870
  const getHeaders = async () => {
862
871
  var _a;
863
- const originalHeaders = await (0, import_provider_utils5.resolve)((_a = options.headers) != null ? _a : {});
864
- return (0, import_provider_utils5.withUserAgentSuffix)(
872
+ const originalHeaders = await resolve4((_a = options.headers) != null ? _a : {});
873
+ return withUserAgentSuffix(
865
874
  originalHeaders,
866
875
  `ai-sdk/google-vertex/${VERSION}`
867
876
  );
@@ -875,9 +884,9 @@ function createVertex(options = {}) {
875
884
  };
876
885
  const createChatModel = (modelId) => {
877
886
  var _a;
878
- return new import_internal3.GoogleGenerativeAILanguageModel(modelId, {
887
+ return new GoogleGenerativeAILanguageModel2(modelId, {
879
888
  ...createConfig("chat"),
880
- generateId: (_a = options.generateId) != null ? _a : import_provider_utils5.generateId,
889
+ generateId: (_a = options.generateId) != null ? _a : generateId,
881
890
  supportedUrls: () => ({
882
891
  "*": [
883
892
  // HTTP URLs:
@@ -893,14 +902,14 @@ function createVertex(options = {}) {
893
902
  var _a;
894
903
  return new GoogleVertexImageModel(modelId, {
895
904
  ...createConfig("image"),
896
- generateId: (_a = options.generateId) != null ? _a : import_provider_utils5.generateId
905
+ generateId: (_a = options.generateId) != null ? _a : generateId
897
906
  });
898
907
  };
899
908
  const createVideoModel = (modelId) => {
900
909
  var _a;
901
910
  return new GoogleVertexVideoModel(modelId, {
902
911
  ...createConfig("video"),
903
- generateId: (_a = options.generateId) != null ? _a : import_provider_utils5.generateId
912
+ generateId: (_a = options.generateId) != null ? _a : generateId
904
913
  });
905
914
  };
906
915
  const provider = function(modelId) {
@@ -925,7 +934,7 @@ function createVertex(options = {}) {
925
934
 
926
935
  // src/google-vertex-provider-node.ts
927
936
  function createVertex2(options = {}) {
928
- const apiKey = (0, import_provider_utils6.loadOptionalSetting)({
937
+ const apiKey = loadOptionalSetting2({
929
938
  settingValue: options.apiKey,
930
939
  environmentVariableName: "GOOGLE_VERTEX_API_KEY"
931
940
  });
@@ -938,15 +947,14 @@ function createVertex2(options = {}) {
938
947
  Authorization: `Bearer ${await generateAuthToken(
939
948
  options.googleAuthOptions
940
949
  )}`,
941
- ...await (0, import_provider_utils6.resolve)(options.headers)
950
+ ...await resolve5(options.headers)
942
951
  })
943
952
  });
944
953
  }
945
954
  var vertex = createVertex2();
946
- // Annotate the CommonJS export names for ESM import in node:
947
- 0 && (module.exports = {
955
+ export {
948
956
  VERSION,
949
- createVertex,
957
+ createVertex2 as createVertex,
950
958
  vertex
951
- });
959
+ };
952
960
  //# sourceMappingURL=index.js.map