@picsart/ai-sdk 5.4.1 → 5.5.1

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 (3) hide show
  1. package/index.d.ts +13 -3
  2. package/index.js +44 -33
  3. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -153,19 +153,22 @@ type ModelInputById = {
153
153
  };
154
154
  "flux-2-flex": {
155
155
  prompt: string;
156
- aspectRatio?: "1:1" | "5:3" | "3:5" | "4:3" | "3:4";
156
+ aspectRatio?: "1:1" | "16:9" | "9:16" | "4:3" | "3:4" | "21:9" | "9:21";
157
+ resolution?: "1K" | "2K" | "4K";
157
158
  count?: 1 | 2 | 4 | 6 | 8 | 10;
158
159
  imageUrls?: string[];
159
160
  };
160
161
  "flux-2-max": {
161
162
  prompt: string;
162
- aspectRatio?: "1:1" | "5:3" | "3:5" | "4:3" | "3:4";
163
+ aspectRatio?: "1:1" | "16:9" | "9:16" | "4:3" | "3:4" | "21:9" | "9:21";
164
+ resolution?: "1K" | "2K" | "4K";
163
165
  count?: 1 | 2 | 4 | 6 | 8 | 10;
164
166
  imageUrls?: string[];
165
167
  };
166
168
  "flux-2-pro": {
167
169
  prompt: string;
168
- aspectRatio?: "1:1" | "5:3" | "3:5" | "4:3" | "3:4";
170
+ aspectRatio?: "1:1" | "16:9" | "9:16" | "4:3" | "3:4" | "21:9" | "9:21";
171
+ resolution?: "1K" | "2K" | "4K";
169
172
  count?: 1 | 2 | 4 | 6 | 8 | 10;
170
173
  imageUrls?: string[];
171
174
  };
@@ -1734,6 +1737,13 @@ interface FileDescriptor {
1734
1737
  * authoritative gate. Omit for no client-side ceiling.
1735
1738
  */
1736
1739
  maxShortSidePixels?: number;
1740
+ /**
1741
+ * Max file size in bytes accepted for this slot (e.g. Seedance 2.5 reference
1742
+ * videos are capped at 200 MiB by the vendor). Enforced client-side at upload
1743
+ * by measuring the file (or its `Content-Length`) before it is sent; the
1744
+ * backend worker stays the authoritative gate. Omit for no client-side cap.
1745
+ */
1746
+ maxBytes?: number;
1737
1747
  }
1738
1748
  interface ObjectDescriptor {
1739
1749
  kind: 'object';
package/index.js CHANGED
@@ -1004,7 +1004,8 @@ var p = {
1004
1004
  ...opts?.array ? { array: opts.array } : {},
1005
1005
  ...opts?.maxDurationSec != null ? { maxDurationSec: opts.maxDurationSec } : {},
1006
1006
  ...opts?.minPixels != null ? { minPixels: opts.minPixels } : {},
1007
- ...opts?.maxShortSidePixels != null ? { maxShortSidePixels: opts.maxShortSidePixels } : {}
1007
+ ...opts?.maxShortSidePixels != null ? { maxShortSidePixels: opts.maxShortSidePixels } : {},
1008
+ ...opts?.maxBytes != null ? { maxBytes: opts.maxBytes } : {}
1008
1009
  }
1009
1010
  }
1010
1011
  };
@@ -1221,20 +1222,30 @@ var params = {
1221
1222
  // reference → ref images/videos/audios (guidance signals)
1222
1223
  imageInput: (max = 1, label = "Start Image", required = false, category = "reference", minPixels) => p.file("imageUrls", "image", { array: { max }, label, required, category, ...minPixels != null ? { minPixels } : {} }),
1223
1224
  /** Single source-video slot (v2v / video edit). Writes to `videoUrl`.
1224
- * `maxDurationSec` caps the source clip length and `maxShortSidePixels` caps
1225
- * the shorter side (upscaler sources), both enforced client-side at upload. */
1226
- videoInput: (label = "Source Video", category = "reference", required = true, maxDurationSec, maxShortSidePixels) => p.file("videoUrl", "video", {
1225
+ * `maxDurationSec` caps the source clip length, `maxShortSidePixels` caps
1226
+ * the shorter side (upscaler sources) and `maxBytes` caps the file size,
1227
+ * all enforced client-side at upload. */
1228
+ videoInput: (label = "Source Video", category = "reference", required = true, maxDurationSec, maxShortSidePixels, maxBytes) => p.file("videoUrl", "video", {
1227
1229
  label,
1228
1230
  required,
1229
1231
  category,
1230
1232
  ...maxDurationSec != null ? { maxDurationSec } : {},
1231
- ...maxShortSidePixels != null ? { maxShortSidePixels } : {}
1233
+ ...maxShortSidePixels != null ? { maxShortSidePixels } : {},
1234
+ ...maxBytes != null ? { maxBytes } : {}
1232
1235
  }),
1233
1236
  /** Single driving / sync-audio slot. Writes to `audioUrl`. */
1234
1237
  audioInput: (label = "Audio Track", required = false, category = "asset") => p.file("audioUrl", "audio", { label, required, category }),
1235
1238
  /** Array of reference videos (writes to `videoUrls`). Backend enforces
1236
- * per-model total-duration caps (e.g. ≤ 15s for seedance). */
1237
- videoInputs: (max = 3, label = "Reference Videos", required = false, minPixels) => p.file("videoUrls", "video", { array: { max }, label, required, category: "reference", ...minPixels != null ? { minPixels } : {} }),
1239
+ * per-model total-duration caps (e.g. ≤ 15s for seedance). `maxBytes` caps
1240
+ * each individual clip's file size, enforced client-side at upload. */
1241
+ videoInputs: (max = 3, label = "Reference Videos", required = false, minPixels, maxBytes) => p.file("videoUrls", "video", {
1242
+ array: { max },
1243
+ label,
1244
+ required,
1245
+ category: "reference",
1246
+ ...minPixels != null ? { minPixels } : {},
1247
+ ...maxBytes != null ? { maxBytes } : {}
1248
+ }),
1238
1249
  /** Array of reference audios (writes to `audioUrls`). Backend enforces
1239
1250
  * per-model total-duration caps. */
1240
1251
  audioInputs: (max = 3, label = "Reference Audios", required = false) => p.file("audioUrls", "audio", { array: { max }, label, required, category: "reference" }),
@@ -3852,6 +3863,7 @@ registerPayloads(MODELS11, {
3852
3863
  // src/vendors/catalog/seedance.ts
3853
3864
  var SEEDANCE_FRAME_REF_REASON = "Start/End frames cannot be combined with reference images, videos, or audios";
3854
3865
  var SEEDANCE_MIN_PIXELS = 409600;
3866
+ var SEEDANCE_25_MAX_VIDEO_BYTES = 209715200;
3855
3867
  var seedance20Constraints = [
3856
3868
  {
3857
3869
  when: {
@@ -4102,7 +4114,7 @@ var { MODELS: MODELS12 } = defineModels("seedance", [
4102
4114
  ...p.enum("outputFormat", ["mp4", "mov"], "mp4", { label: "Format" }),
4103
4115
  // 2.5 lifts the reference caps to 30 images / 10 videos / 10 audios.
4104
4116
  ...params.imageInput(30, "Reference Images", false, "reference", SEEDANCE_MIN_PIXELS),
4105
- ...params.videoInputs(10, "Reference Videos", false, SEEDANCE_MIN_PIXELS),
4117
+ ...params.videoInputs(10, "Reference Videos", false, SEEDANCE_MIN_PIXELS, SEEDANCE_25_MAX_VIDEO_BYTES),
4106
4118
  ...params.audioInputs(10, "Reference Audios"),
4107
4119
  ...params.startFrame(),
4108
4120
  ...params.endFrame()
@@ -4130,7 +4142,7 @@ var { MODELS: MODELS12 } = defineModels("seedance", [
4130
4142
  ...params.generateAudio(),
4131
4143
  ...params.returnLastFrame(),
4132
4144
  ...p.enum("outputFormat", ["mp4", "mov"], "mp4", { label: "Format" }),
4133
- ...params.videoInput("Source Video"),
4145
+ ...params.videoInput("Source Video", "reference", true, void 0, void 0, SEEDANCE_25_MAX_VIDEO_BYTES),
4134
4146
  ...params.imageInput(30, "Reference Images")
4135
4147
  }
4136
4148
  },
@@ -4156,7 +4168,7 @@ var { MODELS: MODELS12 } = defineModels("seedance", [
4156
4168
  ...params.duration(SEEDANCE_25_DURATIONS, 15),
4157
4169
  ...params.generateAudio(),
4158
4170
  ...p.enum("outputFormat", ["mp4", "mov"], "mp4", { label: "Format" }),
4159
- ...params.videoInputs(10, "Source Videos", true)
4171
+ ...params.videoInputs(10, "Source Videos", true, void 0, SEEDANCE_25_MAX_VIDEO_BYTES)
4160
4172
  }
4161
4173
  },
4162
4174
  {
@@ -5477,9 +5489,6 @@ var { MODELS: MODELS20 } = defineModels("runway", [
5477
5489
  }
5478
5490
  ]);
5479
5491
 
5480
- // src/core/helpers.ts
5481
- var resolveImageSize = (ctx, arMap) => ctx.aspectRatio && arMap[ctx.aspectRatio] || ctx.size;
5482
-
5483
5492
  // src/vendors/catalog/flux.ts
5484
5493
  var FLUX_AR_TO_SIZE = {
5485
5494
  "1:1": "1024x1024",
@@ -5488,21 +5497,17 @@ var FLUX_AR_TO_SIZE = {
5488
5497
  "4:3": "1024x768",
5489
5498
  "3:4": "768x1024"
5490
5499
  };
5491
- var fluxAspectRatios = Object.keys(FLUX_AR_TO_SIZE);
5492
- var buildFluxV2Payload = (modelId) => (ctx) => {
5493
- const size = resolveImageSize(ctx, FLUX_AR_TO_SIZE);
5494
- return {
5495
- prompt: ctx.prompt,
5496
- model: modelId,
5497
- imageUrls: ctx.imageUrls ?? [],
5498
- ...size ? {
5499
- width: parseInt(size.split("x")[0]),
5500
- height: parseInt(size.split("x")[1])
5501
- } : {},
5502
- ...ctx.guidance != null ? { guidance: ctx.guidance } : {},
5503
- ...ctx.seed != null ? { seed: ctx.seed } : {}
5504
- };
5505
- };
5500
+ var fluxAspectRatios = ["1:1", "16:9", "9:16", "4:3", "3:4", "21:9", "9:21"];
5501
+ var fluxResolutions = ["1K", "2K", "4K"];
5502
+ var buildFluxV2Payload = (modelId) => (ctx) => ({
5503
+ prompt: ctx.prompt,
5504
+ model: modelId,
5505
+ imageUrls: ctx.imageUrls ?? [],
5506
+ resolution: ctx.resolution ?? "1K",
5507
+ aspectRatio: ctx.aspectRatio ?? "1:1",
5508
+ ...ctx.guidance != null ? { guidance: ctx.guidance } : {},
5509
+ ...ctx.seed != null ? { seed: ctx.seed } : {}
5510
+ });
5506
5511
  function normalizeAspectRatio(aspect) {
5507
5512
  if (!aspect) return null;
5508
5513
  const raw = String(aspect).trim();
@@ -5554,11 +5559,12 @@ var { MODELS: MODELS21 } = defineModels("flux", [
5554
5559
  addedAt: "2026-02-06",
5555
5560
  buildPayload: buildFluxV2Payload("flux-2-pro"),
5556
5561
  estimatedTime: 19,
5557
- description: "Sharp 2K images with fine-tuned color accuracy and detail.",
5558
- features: [feat("Multi-Image Input", "input"), feat("2K", "resolution")],
5562
+ description: "Sharp images up to 4K with fine-tuned color accuracy and detail.",
5563
+ features: [feat("Multi-Image Input", "input"), feat("4K", "resolution")],
5559
5564
  paramConfig: {
5560
5565
  ...params.prompt(),
5561
5566
  ...params.aspectRatio(fluxAspectRatios, "4:3"),
5567
+ ...params.resolution(fluxResolutions, "1K"),
5562
5568
  ...params.count(),
5563
5569
  ...params.imageInput(4, "Source Images")
5564
5570
  }
@@ -5572,10 +5578,11 @@ var { MODELS: MODELS21 } = defineModels("flux", [
5572
5578
  buildPayload: buildFluxV2Payload("flux-2-max"),
5573
5579
  estimatedTime: 27,
5574
5580
  description: "Maximum detail for intricate compositions and demanding scenes.",
5575
- features: [feat("Image Input", "input"), feat("2K", "resolution")],
5581
+ features: [feat("Image Input", "input"), feat("4K", "resolution")],
5576
5582
  paramConfig: {
5577
5583
  ...params.prompt(),
5578
5584
  ...params.aspectRatio(fluxAspectRatios, "1:1"),
5585
+ ...params.resolution(fluxResolutions, "1K"),
5579
5586
  ...params.count(),
5580
5587
  ...params.imageInput(1, "Source Image")
5581
5588
  }
@@ -5588,11 +5595,12 @@ var { MODELS: MODELS21 } = defineModels("flux", [
5588
5595
  addedAt: "2026-02-06",
5589
5596
  buildPayload: buildFluxV2Payload("flux-2-flex"),
5590
5597
  estimatedTime: 15,
5591
- description: "Adaptable generation across varied visual styles at 2K.",
5592
- features: [feat("Image Input", "input"), feat("2K", "resolution")],
5598
+ description: "Adaptable generation across varied visual styles up to 4K.",
5599
+ features: [feat("Image Input", "input"), feat("4K", "resolution")],
5593
5600
  paramConfig: {
5594
5601
  ...params.prompt(),
5595
5602
  ...params.aspectRatio(fluxAspectRatios, "3:4"),
5603
+ ...params.resolution(fluxResolutions, "1K"),
5596
5604
  ...params.count(),
5597
5605
  ...params.imageInput(1, "Source Image")
5598
5606
  }
@@ -7526,6 +7534,9 @@ registerPayloads(MODELS30, {
7526
7534
  "topaz-upscale-video": buildTopazVideoPayload
7527
7535
  });
7528
7536
 
7537
+ // src/core/helpers.ts
7538
+ var resolveImageSize = (ctx, arMap) => ctx.aspectRatio && arMap[ctx.aspectRatio] || ctx.size;
7539
+
7529
7540
  // src/vendors/catalog/picsart.ts
7530
7541
  var MAX_WORDS = 77;
7531
7542
  var truncateWords = (text) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@picsart/ai-sdk",
3
- "version": "5.4.1",
3
+ "version": "5.5.1",
4
4
  "type": "module",
5
5
  "description": "Type-safe SDK for 100+ AI models — image, video, audio, and text generation with Picsart",
6
6
  "license": "MIT",