@ai-sdk/prodia 2.0.0-beta.21 → 2.0.0-beta.23

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/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # @ai-sdk/prodia
2
2
 
3
+ ## 2.0.0-beta.23
4
+
5
+ ### Major Changes
6
+
7
+ - ef992f8: Remove CommonJS exports from all packages. All packages are now ESM-only (`"type": "module"`). Consumers using `require()` must switch to ESM `import` syntax.
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [ef992f8]
12
+ - @ai-sdk/provider@4.0.0-beta.11
13
+ - @ai-sdk/provider-utils@5.0.0-beta.19
14
+
15
+ ## 2.0.0-beta.22
16
+
17
+ ### Patch Changes
18
+
19
+ - Updated dependencies [90e2d8a]
20
+ - @ai-sdk/provider-utils@5.0.0-beta.18
21
+
3
22
  ## 2.0.0-beta.21
4
23
 
5
24
  ### Patch Changes
package/dist/index.js CHANGED
@@ -1,60 +1,46 @@
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
- createProdia: () => createProdia,
25
- prodia: () => prodia
26
- });
27
- module.exports = __toCommonJS(index_exports);
28
-
29
1
  // src/prodia-provider.ts
30
- var import_provider2 = require("@ai-sdk/provider");
31
- var import_provider_utils5 = require("@ai-sdk/provider-utils");
2
+ import {
3
+ NoSuchModelError
4
+ } from "@ai-sdk/provider";
5
+ import {
6
+ loadApiKey,
7
+ withoutTrailingSlash,
8
+ withUserAgentSuffix
9
+ } from "@ai-sdk/provider-utils";
32
10
 
33
11
  // src/prodia-image-model.ts
34
- var import_provider_utils2 = require("@ai-sdk/provider-utils");
35
- var import_v42 = require("zod/v4");
12
+ import {
13
+ combineHeaders,
14
+ lazySchema,
15
+ parseJSON,
16
+ parseProviderOptions,
17
+ postToApi,
18
+ resolve,
19
+ zodSchema
20
+ } from "@ai-sdk/provider-utils";
21
+ import { z as z2 } from "zod/v4";
36
22
 
37
23
  // src/prodia-api.ts
38
- var import_provider_utils = require("@ai-sdk/provider-utils");
39
- var import_v4 = require("zod/v4");
40
- var prodiaJobResultSchema = import_v4.z.object({
41
- id: import_v4.z.string(),
42
- created_at: import_v4.z.string().optional(),
43
- updated_at: import_v4.z.string().optional(),
44
- expires_at: import_v4.z.string().optional(),
45
- state: import_v4.z.object({
46
- current: import_v4.z.string()
24
+ import { createJsonErrorResponseHandler } from "@ai-sdk/provider-utils";
25
+ import { z } from "zod/v4";
26
+ var prodiaJobResultSchema = z.object({
27
+ id: z.string(),
28
+ created_at: z.string().optional(),
29
+ updated_at: z.string().optional(),
30
+ expires_at: z.string().optional(),
31
+ state: z.object({
32
+ current: z.string()
47
33
  }).optional(),
48
- config: import_v4.z.object({
49
- seed: import_v4.z.number().optional()
34
+ config: z.object({
35
+ seed: z.number().optional()
50
36
  }).passthrough().optional(),
51
- metrics: import_v4.z.object({
52
- elapsed: import_v4.z.number().optional(),
53
- ips: import_v4.z.number().optional()
37
+ metrics: z.object({
38
+ elapsed: z.number().optional(),
39
+ ips: z.number().optional()
54
40
  }).optional(),
55
- price: import_v4.z.object({
56
- product: import_v4.z.string(),
57
- dollars: import_v4.z.number()
41
+ price: z.object({
42
+ product: z.string(),
43
+ dollars: z.number()
58
44
  }).nullish()
59
45
  });
60
46
  function buildProdiaProviderMetadata(jobResult) {
@@ -157,12 +143,12 @@ function parseMultipart(data, boundary) {
157
143
  }
158
144
  return parts;
159
145
  }
160
- var prodiaErrorSchema = import_v4.z.object({
161
- message: import_v4.z.string().optional(),
162
- detail: import_v4.z.unknown().optional(),
163
- error: import_v4.z.string().optional()
146
+ var prodiaErrorSchema = z.object({
147
+ message: z.string().optional(),
148
+ detail: z.unknown().optional(),
149
+ error: z.string().optional()
164
150
  });
165
- var prodiaFailedResponseHandler = (0, import_provider_utils.createJsonErrorResponseHandler)({
151
+ var prodiaFailedResponseHandler = createJsonErrorResponseHandler({
166
152
  errorSchema: prodiaErrorSchema,
167
153
  errorToMessage: (error) => {
168
154
  var _a;
@@ -198,7 +184,7 @@ var ProdiaImageModel = class {
198
184
  providerOptions
199
185
  }) {
200
186
  const warnings = [];
201
- const prodiaOptions = await (0, import_provider_utils2.parseProviderOptions)({
187
+ const prodiaOptions = await parseProviderOptions({
202
188
  provider: "prodia",
203
189
  providerOptions,
204
190
  schema: prodiaImageModelOptionsSchema
@@ -257,11 +243,11 @@ var ProdiaImageModel = class {
257
243
  var _a, _b, _c;
258
244
  const { body, warnings } = await this.getArgs(options);
259
245
  const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
260
- const combinedHeaders = (0, import_provider_utils2.combineHeaders)(
261
- await (0, import_provider_utils2.resolve)(this.config.headers),
246
+ const combinedHeaders = combineHeaders(
247
+ await resolve(this.config.headers),
262
248
  options.headers
263
249
  );
264
- const { value: multipartResult, responseHeaders } = await (0, import_provider_utils2.postToApi)({
250
+ const { value: multipartResult, responseHeaders } = await postToApi({
265
251
  url: `${this.config.baseURL}/job?price=true`,
266
252
  headers: {
267
253
  ...combinedHeaders,
@@ -313,33 +299,33 @@ var stylePresets = [
313
299
  "texture",
314
300
  "craft-clay"
315
301
  ];
316
- var prodiaImageModelOptionsSchema = (0, import_provider_utils2.lazySchema)(
317
- () => (0, import_provider_utils2.zodSchema)(
318
- import_v42.z.object({
302
+ var prodiaImageModelOptionsSchema = lazySchema(
303
+ () => zodSchema(
304
+ z2.object({
319
305
  /**
320
306
  * Amount of computational iterations to run. More is typically higher quality.
321
307
  */
322
- steps: import_v42.z.number().int().min(1).max(4).optional(),
308
+ steps: z2.number().int().min(1).max(4).optional(),
323
309
  /**
324
310
  * Width of the output image in pixels.
325
311
  */
326
- width: import_v42.z.number().int().min(256).max(1920).optional(),
312
+ width: z2.number().int().min(256).max(1920).optional(),
327
313
  /**
328
314
  * Height of the output image in pixels.
329
315
  */
330
- height: import_v42.z.number().int().min(256).max(1920).optional(),
316
+ height: z2.number().int().min(256).max(1920).optional(),
331
317
  /**
332
318
  * Apply a visual theme to your output image.
333
319
  */
334
- stylePreset: import_v42.z.enum(stylePresets).optional(),
320
+ stylePreset: z2.enum(stylePresets).optional(),
335
321
  /**
336
322
  * Augment the output with a LoRa model.
337
323
  */
338
- loras: import_v42.z.array(import_v42.z.string()).max(3).optional(),
324
+ loras: z2.array(z2.string()).max(3).optional(),
339
325
  /**
340
326
  * When using JPEG output, return a progressive JPEG.
341
327
  */
342
- progressive: import_v42.z.boolean().optional()
328
+ progressive: z2.boolean().optional()
343
329
  })
344
330
  )
345
331
  );
@@ -370,9 +356,9 @@ function createMultipartResponseHandler() {
370
356
  const partContentType = (_c = part.headers["content-type"]) != null ? _c : "";
371
357
  if (contentDisposition.includes('name="job"')) {
372
358
  const jsonStr = new TextDecoder().decode(part.body);
373
- jobResult = await (0, import_provider_utils2.parseJSON)({
359
+ jobResult = await parseJSON({
374
360
  text: jsonStr,
375
- schema: (0, import_provider_utils2.zodSchema)(prodiaJobResultSchema)
361
+ schema: zodSchema(prodiaJobResultSchema)
376
362
  });
377
363
  } else if (contentDisposition.includes('name="output"')) {
378
364
  imageBytes = part.body;
@@ -394,9 +380,23 @@ function createMultipartResponseHandler() {
394
380
  }
395
381
 
396
382
  // src/prodia-language-model.ts
397
- var import_provider = require("@ai-sdk/provider");
398
- var import_provider_utils3 = require("@ai-sdk/provider-utils");
399
- var import_v43 = require("zod/v4");
383
+ import {
384
+ UnsupportedFunctionalityError
385
+ } from "@ai-sdk/provider";
386
+ import {
387
+ combineHeaders as combineHeaders2,
388
+ isCustomReasoning,
389
+ isProviderReference,
390
+ convertBase64ToUint8Array,
391
+ generateId,
392
+ lazySchema as lazySchema2,
393
+ parseJSON as parseJSON2,
394
+ parseProviderOptions as parseProviderOptions2,
395
+ postFormDataToApi,
396
+ resolve as resolve2,
397
+ zodSchema as zodSchema2
398
+ } from "@ai-sdk/provider-utils";
399
+ import { z as z3 } from "zod/v4";
400
400
  var ProdiaLanguageModel = class {
401
401
  constructor(modelId, config) {
402
402
  this.modelId = modelId;
@@ -440,14 +440,14 @@ var ProdiaLanguageModel = class {
440
440
  if (options.responseFormat !== void 0 && options.responseFormat.type !== "text") {
441
441
  warnings.push({ type: "unsupported", feature: "responseFormat" });
442
442
  }
443
- if ((0, import_provider_utils3.isCustomReasoning)(options.reasoning)) {
443
+ if (isCustomReasoning(options.reasoning)) {
444
444
  warnings.push({
445
445
  type: "unsupported",
446
446
  feature: "reasoning",
447
447
  details: "This provider does not support reasoning configuration."
448
448
  });
449
449
  }
450
- const prodiaOptions = await (0, import_provider_utils3.parseProviderOptions)({
450
+ const prodiaOptions = await parseProviderOptions2({
451
451
  provider: "prodia",
452
452
  providerOptions: options.providerOptions,
453
453
  schema: prodiaLanguageModelOptionsSchema
@@ -480,15 +480,15 @@ var ProdiaLanguageModel = class {
480
480
  if (message.role === "user") {
481
481
  for (const part of message.content) {
482
482
  if (part.type === "file" && part.mediaType.startsWith("image/")) {
483
- if ((0, import_provider_utils3.isProviderReference)(part.data)) {
484
- throw new import_provider.UnsupportedFunctionalityError({
483
+ if (isProviderReference(part.data)) {
484
+ throw new UnsupportedFunctionalityError({
485
485
  functionality: "file parts with provider references"
486
486
  });
487
487
  }
488
488
  if (part.data instanceof Uint8Array) {
489
489
  imageBytes = part.data;
490
490
  } else if (typeof part.data === "string") {
491
- imageBytes = (0, import_provider_utils3.convertBase64ToUint8Array)(part.data);
491
+ imageBytes = convertBase64ToUint8Array(part.data);
492
492
  } else if (part.data instanceof URL) {
493
493
  const fetchFn = (_a = this.config.fetch) != null ? _a : globalThis.fetch;
494
494
  const response = await fetchFn(part.data.toString());
@@ -514,8 +514,8 @@ var ProdiaLanguageModel = class {
514
514
  config: jobConfig
515
515
  };
516
516
  const currentDate = (_d = (_c = (_b = this.config._internal) == null ? void 0 : _b.currentDate) == null ? void 0 : _c.call(_b)) != null ? _d : /* @__PURE__ */ new Date();
517
- const combinedHeaders = (0, import_provider_utils3.combineHeaders)(
518
- await (0, import_provider_utils3.resolve)(this.config.headers),
517
+ const combinedHeaders = combineHeaders2(
518
+ await resolve2(this.config.headers),
519
519
  options.headers
520
520
  );
521
521
  const formData = new FormData();
@@ -532,7 +532,7 @@ var ProdiaLanguageModel = class {
532
532
  "input" + ext
533
533
  );
534
534
  }
535
- const { value: multipartResult, responseHeaders } = await (0, import_provider_utils3.postFormDataToApi)(
535
+ const { value: multipartResult, responseHeaders } = await postFormDataToApi(
536
536
  {
537
537
  url: `${this.config.baseURL}/job?price=true`,
538
538
  headers: {
@@ -602,7 +602,7 @@ var ProdiaLanguageModel = class {
602
602
  });
603
603
  for (const part of result.content) {
604
604
  if (part.type === "text") {
605
- const id = (0, import_provider_utils3.generateId)();
605
+ const id = generateId();
606
606
  controller.enqueue({ type: "text-start", id });
607
607
  controller.enqueue({
608
608
  type: "text-delta",
@@ -635,13 +635,13 @@ var ProdiaLanguageModel = class {
635
635
  };
636
636
  }
637
637
  };
638
- var prodiaLanguageModelOptionsSchema = (0, import_provider_utils3.lazySchema)(
639
- () => (0, import_provider_utils3.zodSchema)(
640
- import_v43.z.object({
638
+ var prodiaLanguageModelOptionsSchema = lazySchema2(
639
+ () => zodSchema2(
640
+ z3.object({
641
641
  /**
642
642
  * Aspect ratio for the output image.
643
643
  */
644
- aspectRatio: import_v43.z.enum([
644
+ aspectRatio: z3.enum([
645
645
  "1:1",
646
646
  "2:3",
647
647
  "3:2",
@@ -685,9 +685,9 @@ function createLanguageMultipartResponseHandler() {
685
685
  const partContentType = (_c = part.headers["content-type"]) != null ? _c : "";
686
686
  if (contentDisposition.includes('name="job"')) {
687
687
  const jsonStr = new TextDecoder().decode(part.body);
688
- jobResult = await (0, import_provider_utils3.parseJSON)({
688
+ jobResult = await parseJSON2({
689
689
  text: jsonStr,
690
- schema: (0, import_provider_utils3.zodSchema)(prodiaJobResultSchema)
690
+ schema: zodSchema2(prodiaJobResultSchema)
691
691
  });
692
692
  } else if (contentDisposition.includes('name="output"')) {
693
693
  if (partContentType.startsWith("text/") || contentDisposition.includes(".txt")) {
@@ -711,8 +711,18 @@ function createLanguageMultipartResponseHandler() {
711
711
  }
712
712
 
713
713
  // src/prodia-video-model.ts
714
- var import_provider_utils4 = require("@ai-sdk/provider-utils");
715
- var import_v44 = require("zod/v4");
714
+ import {
715
+ combineHeaders as combineHeaders3,
716
+ convertBase64ToUint8Array as convertBase64ToUint8Array2,
717
+ lazySchema as lazySchema3,
718
+ parseJSON as parseJSON3,
719
+ parseProviderOptions as parseProviderOptions3,
720
+ postFormDataToApi as postFormDataToApi2,
721
+ postToApi as postToApi2,
722
+ resolve as resolve3,
723
+ zodSchema as zodSchema3
724
+ } from "@ai-sdk/provider-utils";
725
+ import { z as z4 } from "zod/v4";
716
726
  var ProdiaVideoModel = class {
717
727
  constructor(modelId, config) {
718
728
  this.modelId = modelId;
@@ -726,7 +736,7 @@ var ProdiaVideoModel = class {
726
736
  async doGenerate(options) {
727
737
  var _a, _b, _c;
728
738
  const warnings = [];
729
- const prodiaOptions = await (0, import_provider_utils4.parseProviderOptions)({
739
+ const prodiaOptions = await parseProviderOptions3({
730
740
  provider: "prodia",
731
741
  providerOptions: options.providerOptions,
732
742
  schema: prodiaVideoModelOptionsSchema
@@ -746,8 +756,8 @@ var ProdiaVideoModel = class {
746
756
  config: jobConfig
747
757
  };
748
758
  const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
749
- const combinedHeaders = (0, import_provider_utils4.combineHeaders)(
750
- await (0, import_provider_utils4.resolve)(this.config.headers),
759
+ const combinedHeaders = combineHeaders3(
760
+ await resolve3(this.config.headers),
751
761
  options.headers
752
762
  );
753
763
  let multipartResult;
@@ -768,7 +778,7 @@ var ProdiaVideoModel = class {
768
778
  new Blob([imageData.bytes], { type: imageData.mediaType }),
769
779
  "input" + getExtension(imageData.mediaType)
770
780
  );
771
- const result = await (0, import_provider_utils4.postFormDataToApi)({
781
+ const result = await postFormDataToApi2({
772
782
  url: `${this.config.baseURL}/job?price=true`,
773
783
  headers: {
774
784
  ...combinedHeaders,
@@ -783,7 +793,7 @@ var ProdiaVideoModel = class {
783
793
  multipartResult = result.value;
784
794
  responseHeaders = result.responseHeaders;
785
795
  } else {
786
- const result = await (0, import_provider_utils4.postToApi)({
796
+ const result = await postToApi2({
787
797
  url: `${this.config.baseURL}/job?price=true`,
788
798
  headers: {
789
799
  ...combinedHeaders,
@@ -825,13 +835,13 @@ var ProdiaVideoModel = class {
825
835
  };
826
836
  }
827
837
  };
828
- var prodiaVideoModelOptionsSchema = (0, import_provider_utils4.lazySchema)(
829
- () => (0, import_provider_utils4.zodSchema)(
830
- import_v44.z.object({
838
+ var prodiaVideoModelOptionsSchema = lazySchema3(
839
+ () => zodSchema3(
840
+ z4.object({
831
841
  /**
832
842
  * Video resolution (e.g. "480p", "720p").
833
843
  */
834
- resolution: import_v44.z.string().optional()
844
+ resolution: z4.string().optional()
835
845
  })
836
846
  )
837
847
  );
@@ -863,9 +873,9 @@ function createVideoMultipartResponseHandler() {
863
873
  const partContentType = (_c = part.headers["content-type"]) != null ? _c : "";
864
874
  if (contentDisposition.includes('name="job"')) {
865
875
  const jsonStr = new TextDecoder().decode(part.body);
866
- jobResult = await (0, import_provider_utils4.parseJSON)({
876
+ jobResult = await parseJSON3({
867
877
  text: jsonStr,
868
- schema: (0, import_provider_utils4.zodSchema)(prodiaJobResultSchema)
878
+ schema: zodSchema3(prodiaJobResultSchema)
869
879
  });
870
880
  } else if (contentDisposition.includes('name="output"')) {
871
881
  videoBytes = part.body;
@@ -892,7 +902,7 @@ function createVideoMultipartResponseHandler() {
892
902
  async function resolveVideoFileData(file, fetchFunction) {
893
903
  var _a;
894
904
  if (file.type === "file") {
895
- const data = typeof file.data === "string" ? (0, import_provider_utils4.convertBase64ToUint8Array)(file.data) : file.data;
905
+ const data = typeof file.data === "string" ? convertBase64ToUint8Array2(file.data) : file.data;
896
906
  return { bytes: data, mediaType: file.mediaType };
897
907
  }
898
908
  const response = await (fetchFunction != null ? fetchFunction : globalThis.fetch)(file.url);
@@ -913,16 +923,16 @@ function getExtension(mediaType) {
913
923
  }
914
924
 
915
925
  // src/version.ts
916
- var VERSION = true ? "2.0.0-beta.21" : "0.0.0-test";
926
+ var VERSION = true ? "2.0.0-beta.23" : "0.0.0-test";
917
927
 
918
928
  // src/prodia-provider.ts
919
929
  var defaultBaseURL = "https://inference.prodia.com/v2";
920
930
  function createProdia(options = {}) {
921
931
  var _a;
922
- const baseURL = (0, import_provider_utils5.withoutTrailingSlash)((_a = options.baseURL) != null ? _a : defaultBaseURL);
923
- const getHeaders = () => (0, import_provider_utils5.withUserAgentSuffix)(
932
+ const baseURL = withoutTrailingSlash((_a = options.baseURL) != null ? _a : defaultBaseURL);
933
+ const getHeaders = () => withUserAgentSuffix(
924
934
  {
925
- Authorization: `Bearer ${(0, import_provider_utils5.loadApiKey)({
935
+ Authorization: `Bearer ${loadApiKey({
926
936
  apiKey: options.apiKey,
927
937
  environmentVariableName: "PRODIA_TOKEN",
928
938
  description: "Prodia"
@@ -950,7 +960,7 @@ function createProdia(options = {}) {
950
960
  fetch: options.fetch
951
961
  });
952
962
  const embeddingModel = (modelId) => {
953
- throw new import_provider2.NoSuchModelError({
963
+ throw new NoSuchModelError({
954
964
  modelId,
955
965
  modelType: "embeddingModel"
956
966
  });
@@ -967,10 +977,9 @@ function createProdia(options = {}) {
967
977
  };
968
978
  }
969
979
  var prodia = createProdia();
970
- // Annotate the CommonJS export names for ESM import in node:
971
- 0 && (module.exports = {
980
+ export {
972
981
  VERSION,
973
982
  createProdia,
974
983
  prodia
975
- });
984
+ };
976
985
  //# sourceMappingURL=index.js.map