@picsart/ai-sdk 5.12.0 → 5.14.0

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 +12 -12
  2. package/index.js +79 -63
  3. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -615,6 +615,12 @@ type ModelInputById = {
615
615
  resolution?: "720p" | "1080p" | "4k";
616
616
  renderingSpeed?: "std" | "pro";
617
617
  generateAudio?: boolean;
618
+ startFrame?: string;
619
+ endFrame?: string;
620
+ imageUrls?: string[];
621
+ videoUrl?: string;
622
+ referType?: "feature" | "base";
623
+ keepOriginalSound?: "yes" | "no";
618
624
  multiShot?: boolean;
619
625
  shotType?: "customize";
620
626
  multiPrompt?: Array<{
@@ -622,15 +628,6 @@ type ModelInputById = {
622
628
  prompt: string;
623
629
  duration: string;
624
630
  }>;
625
- omniImageList?: Array<{
626
- image_url: string;
627
- type?: "first_frame" | "end_frame";
628
- }>;
629
- omniVideoList?: Array<{
630
- video_url: string;
631
- refer_type: "feature" | "base";
632
- keep_original_sound: "yes" | "no";
633
- }>;
634
631
  elementList?: Array<{
635
632
  element_id: string;
636
633
  }>;
@@ -1313,7 +1310,7 @@ type ModelInputById = {
1313
1310
  prompt: string;
1314
1311
  aspectRatio?: "16:9" | "9:16" | "1:1" | "4:3" | "3:4" | "21:9" | "adaptive";
1315
1312
  resolution?: "480p" | "720p" | "1080p";
1316
- duration?: 4 | 5 | 6 | 8 | 10 | 12 | 15 | 20 | 25 | 30;
1313
+ duration?: number;
1317
1314
  generateAudio?: boolean;
1318
1315
  returnLastFrame?: boolean;
1319
1316
  outputFormat?: "mp4" | "mov";
@@ -1337,7 +1334,7 @@ type ModelInputById = {
1337
1334
  prompt: string;
1338
1335
  aspectRatio?: "adaptive";
1339
1336
  resolution?: "480p" | "720p" | "1080p";
1340
- duration?: 4 | 5 | 6 | 8 | 10 | 12 | 15 | 20 | 25 | 30;
1337
+ duration?: number;
1341
1338
  generateAudio?: boolean;
1342
1339
  outputFormat?: "mp4" | "mov";
1343
1340
  videoUrls: [string, ...string[]];
@@ -1879,7 +1876,10 @@ interface ModelParamsAccessor {
1879
1876
  file(key: string): FileEntry | undefined;
1880
1877
  prompt(): TextEntry | undefined;
1881
1878
  aspectRatio(): EnumEntry | undefined;
1882
- duration(): EnumEntry | undefined;
1879
+ /** Duration is an enum on models with a fixed option list and a range on
1880
+ * models whose vendor accepts every value in a span (kling-t2a,
1881
+ * seedance-2.5), so narrow on `.kind` before reading `.options` / `.min`. */
1882
+ duration(): EnumEntry | RangeEntry | undefined;
1883
1883
  resolution(): EnumEntry | undefined;
1884
1884
  generateAudio(): BooleanEntry | undefined;
1885
1885
  startFrame(): FileEntry | undefined;
package/index.js CHANGED
@@ -846,6 +846,17 @@ var p = {
846
846
  }
847
847
  };
848
848
  },
849
+ /** Continuous duration (seconds) — for models whose vendor accepts every
850
+ * value in a span instead of a fixed option list. Reach for this only when
851
+ * the span holds more than 10 possible values; 10 or fewer stays an enum
852
+ * (`duration`), which shows the exact options instead of a slider. */
853
+ durationRange(min, max, def, step = 1) {
854
+ return {
855
+ duration: {
856
+ descriptor: { kind: "range", min, max, step, default: def }
857
+ }
858
+ };
859
+ },
849
860
  resolution(opts, def) {
850
861
  return {
851
862
  resolution: {
@@ -1216,6 +1227,7 @@ var params = {
1216
1227
  prompt: p.prompt,
1217
1228
  aspectRatio: p.aspectRatio,
1218
1229
  duration: p.duration,
1230
+ durationRange: p.durationRange,
1219
1231
  count: p.count,
1220
1232
  resolution: p.resolution,
1221
1233
  negativePrompt: p.negativePrompt,
@@ -1318,6 +1330,20 @@ var klingKeepOriginalSound = {
1318
1330
  }
1319
1331
  }
1320
1332
  };
1333
+ var klingOmniReferType = {
1334
+ referType: {
1335
+ label: "Reference Video Mode",
1336
+ descriptor: {
1337
+ kind: "enum",
1338
+ valueType: "string",
1339
+ options: [
1340
+ { id: "feature", label: "Feature Reference" },
1341
+ { id: "base", label: "Base Edit" }
1342
+ ],
1343
+ default: "feature"
1344
+ }
1345
+ }
1346
+ };
1321
1347
  var klingV3AdvancedParams = {
1322
1348
  multiShot: {
1323
1349
  label: "Multi-Shot Mode",
@@ -1405,54 +1431,6 @@ var klingOmniAdvancedParams = {
1405
1431
  }
1406
1432
  }
1407
1433
  },
1408
- omniImageList: {
1409
- label: "Reference Images",
1410
- descriptor: {
1411
- kind: "object",
1412
- array: { max: 10 },
1413
- fields: {
1414
- image_url: { kind: "text" },
1415
- type: {
1416
- kind: "enum",
1417
- required: false,
1418
- valueType: "string",
1419
- options: [
1420
- { id: "first_frame", label: "First Frame" },
1421
- { id: "end_frame", label: "End Frame" }
1422
- ],
1423
- default: "first_frame"
1424
- }
1425
- }
1426
- }
1427
- },
1428
- omniVideoList: {
1429
- label: "Reference Video",
1430
- descriptor: {
1431
- kind: "object",
1432
- array: { max: 1 },
1433
- fields: {
1434
- video_url: { kind: "text" },
1435
- // refer_type / keep_original_sound stay required — upstream
1436
- // ReferenceVideo marks both required. Descriptor defaults are
1437
- // informational only until upstream relaxes the wire contract.
1438
- refer_type: {
1439
- kind: "enum",
1440
- valueType: "string",
1441
- options: [
1442
- { id: "feature", label: "Feature Reference" },
1443
- { id: "base", label: "Base Edit" }
1444
- ],
1445
- default: "feature"
1446
- },
1447
- keep_original_sound: {
1448
- kind: "enum",
1449
- valueType: "string",
1450
- options: [{ id: "yes", label: "Yes" }, { id: "no", label: "No" }],
1451
- default: "yes"
1452
- }
1453
- }
1454
- }
1455
- },
1456
1434
  elementList: {
1457
1435
  label: "Element References",
1458
1436
  descriptor: {
@@ -1564,7 +1542,11 @@ var { MODELS } = defineModels("kling", [
1564
1542
  badge: ["popular", "premium"],
1565
1543
  description: "Long-form video up to 15s with native audio and start/end frame control.",
1566
1544
  constraints: [
1567
- { when: { renderingSpeed: { is: "std" } }, then: { endFrame: { disabled: true, reason: "End frame requires Pro or 4K mode." } } }
1545
+ { when: { renderingSpeed: { is: "std" } }, then: { endFrame: { disabled: true, reason: "End frame requires Pro or 4K mode." } } },
1546
+ // Backend: `voice_list` requires `sound=on`. Two rules because the
1547
+ // `is` operator does not match an unset value (see core/constraints.ts).
1548
+ { when: { generateAudio: { is: false } }, then: { voiceList: { disabled: true, reason: "Voice references require generated audio." } } },
1549
+ { when: { generateAudio: { exists: false } }, then: { voiceList: { disabled: true, reason: "Voice references require generated audio." } } }
1568
1550
  ]
1569
1551
  },
1570
1552
  // ── Video: Kling V3 Turbo (resolution-tiered T2V + I2V) ───────────
@@ -1600,7 +1582,12 @@ var { MODELS } = defineModels("kling", [
1600
1582
  mode: "video",
1601
1583
  inputType: "t2v",
1602
1584
  description: "Flexible generation across creative styles using V3 Omni architecture, with optional 4K output.",
1603
- features: [feat("4K", "resolution"), feat("15 sec", "duration")],
1585
+ features: [feat("Image + Video Input", "input"), feat("4K", "resolution"), feat("15 sec", "duration")],
1586
+ // The omni task accepts reference media on the SAME workflow (no
1587
+ // editWorkflow): `image_list` carries the optional first/end frames plus
1588
+ // plain reference images, `video_list` carries a single reference clip.
1589
+ // They are declared here as real file slots so `hasFileInput()` sees them
1590
+ // and the app renders upload targets; payloads.ts assembles the arrays.
1604
1591
  paramConfig: {
1605
1592
  ...params.prompt({ maxLength: 2500 }),
1606
1593
  ...params.aspectRatio(["16:9", "9:16", "1:1"]),
@@ -1608,8 +1595,24 @@ var { MODELS } = defineModels("kling", [
1608
1595
  ...params.resolution(["720p", "1080p", "4k"], "720p"),
1609
1596
  ...params.renderingSpeed([{ id: "std", label: "Standard" }, { id: "pro", label: "Pro" }], "std"),
1610
1597
  ...params.generateAudio(false),
1598
+ ...params.startFrame("First Frame"),
1599
+ ...params.endFrame("End Frame"),
1600
+ // Backend states no explicit cap for omni `image_list`; 10 mirrors the
1601
+ // omni-image contract. The worker stays the authoritative gate.
1602
+ ...params.imageInput(10, "Reference Images"),
1603
+ ...params.videoInput("Reference Video", "reference", false),
1604
+ ...klingOmniReferType,
1605
+ ...klingKeepOriginalSound,
1611
1606
  ...klingOmniAdvancedParams
1612
- }
1607
+ },
1608
+ constraints: [
1609
+ // KlingMode: `4k` is incompatible with video_list; the worker also drops
1610
+ // generated sound whenever a reference clip is supplied.
1611
+ { when: { videoUrl: { exists: true } }, then: {
1612
+ resolution: { allowed: ["720p", "1080p"], reason: "4K output is unavailable with a reference video." },
1613
+ generateAudio: { disabled: true, reason: "Kling disables generated sound when a reference video is supplied." }
1614
+ } }
1615
+ ]
1613
1616
  },
1614
1617
  {
1615
1618
  id: "kling-video-o1",
@@ -2014,8 +2017,6 @@ var buildKlingV3Payload = (defaultMode = "std") => (input) => {
2014
2017
  ...hasEndFrame ? { image_tail: input.endFrame } : {},
2015
2018
  ...input.negativePrompt ? { negative_prompt: input.negativePrompt } : {},
2016
2019
  ...hasSound ? { sound: "on" } : {},
2017
- // WorkflowTypes 1.0.5 still types mode as std/pro, but the backend accepts
2018
- // the catalog's 4k mode for Kling V3.
2019
2020
  mode,
2020
2021
  ...input.multiShot != null ? { multi_shot: input.multiShot } : {},
2021
2022
  ...input.shotType ? { shot_type: input.shotType } : {},
@@ -2056,22 +2057,32 @@ var buildKlingV26Payload = (input) => {
2056
2057
  };
2057
2058
  var stringElementList = (list) => list?.length ? { element_list: list.map((e) => ({ element_id: String(e.element_id) })) } : {};
2058
2059
  var buildOmniV3 = (input) => {
2059
- const hasBaseEdit = input.omniVideoList?.some((v) => v.refer_type === "base");
2060
- const hasReferenceVideo = !!input.omniVideoList?.length;
2060
+ const imageList = [
2061
+ ...input.startFrame ? [{ image_url: input.startFrame, type: "first_frame" }] : [],
2062
+ ...input.endFrame ? [{ image_url: input.endFrame, type: "end_frame" }] : [],
2063
+ ...(input.imageUrls ?? []).map((image_url) => ({ image_url }))
2064
+ ];
2065
+ const videoList = input.videoUrl ? [{
2066
+ video_url: input.videoUrl,
2067
+ refer_type: input.referType ?? "feature",
2068
+ keep_original_sound: input.keepOriginalSound ?? "yes"
2069
+ }] : [];
2070
+ const hasBaseEdit = videoList[0]?.refer_type === "base";
2071
+ const hasReferenceVideo = videoList.length > 0;
2061
2072
  const fourK = input.resolution === "4k" && !hasReferenceVideo;
2062
2073
  const hasSound = !!input.generateAudio && !hasReferenceVideo;
2063
2074
  return {
2064
2075
  ...input.multiShot ? {} : { prompt: input.prompt },
2065
2076
  model_name: "kling-v3-omni",
2066
- ...hasBaseEdit || input.omniImageList?.[0]?.type === "first_frame" ? {} : { aspect_ratio: input.aspectRatio ?? "16:9" },
2077
+ ...hasBaseEdit || input.startFrame ? {} : { aspect_ratio: input.aspectRatio ?? "16:9" },
2067
2078
  // String(n) is just `string`; wire expects literal union. Narrowing cast.
2068
2079
  ...hasBaseEdit ? {} : { duration: String(input.duration ?? 5) },
2069
2080
  ...fourK ? { mode: "4k" } : input.renderingSpeed ? { mode: input.renderingSpeed } : {},
2070
2081
  ...input.multiShot != null ? { multi_shot: input.multiShot } : {},
2071
2082
  ...input.shotType ? { shot_type: input.shotType } : {},
2072
2083
  ...input.multiPrompt ? { multi_prompt: input.multiPrompt } : {},
2073
- ...input.omniImageList?.length ? { image_list: input.omniImageList } : {},
2074
- ...input.omniVideoList?.length ? { video_list: input.omniVideoList } : {},
2084
+ ...imageList.length ? { image_list: imageList } : {},
2085
+ ...videoList.length ? { video_list: videoList } : {},
2075
2086
  ...stringElementList(input.elementList),
2076
2087
  ...hasSound ? { sound: "on" } : {}
2077
2088
  };
@@ -3852,7 +3863,7 @@ var buildSeedance25VideoExtendPayload = (ctx) => ({
3852
3863
  });
3853
3864
  var SEEDANCE_AR = ["16:9", "9:16", "1:1", "4:3", "3:4", "21:9", "adaptive"];
3854
3865
  var SEEDANCE_V2_DURATIONS = [4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15];
3855
- var SEEDANCE_25_DURATIONS = [4, 5, 6, 8, 10, 12, 15, 20, 25, 30];
3866
+ var SEEDANCE_25_DURATION = { min: 4, max: 30 };
3856
3867
  var { MODELS: MODELS12 } = defineModels("seedance", [
3857
3868
  {
3858
3869
  id: "seedance-2.5",
@@ -3872,7 +3883,7 @@ var { MODELS: MODELS12 } = defineModels("seedance", [
3872
3883
  ...params.prompt(),
3873
3884
  ...params.aspectRatio(SEEDANCE_AR),
3874
3885
  ...params.resolution(["480p", "720p", "1080p"], "1080p"),
3875
- ...params.duration(SEEDANCE_25_DURATIONS, 5),
3886
+ ...params.durationRange(SEEDANCE_25_DURATION.min, SEEDANCE_25_DURATION.max, 5),
3876
3887
  ...params.generateAudio(),
3877
3888
  ...params.returnLastFrame(),
3878
3889
  ...p.enum("outputFormat", ["mp4", "mov"], "mp4", { label: "Format" }),
@@ -3929,7 +3940,7 @@ var { MODELS: MODELS12 } = defineModels("seedance", [
3929
3940
  // duration stays user-selectable.
3930
3941
  ...params.aspectRatio(["adaptive"]),
3931
3942
  ...params.resolution(["480p", "720p", "1080p"], "1080p"),
3932
- ...params.duration(SEEDANCE_25_DURATIONS, 15),
3943
+ ...params.durationRange(SEEDANCE_25_DURATION.min, SEEDANCE_25_DURATION.max, 15),
3933
3944
  ...params.generateAudio(),
3934
3945
  ...p.enum("outputFormat", ["mp4", "mov"], "mp4", { label: "Format" }),
3935
3946
  ...params.videoInputs(10, "Source Videos", true, void 0, SEEDANCE_25_MAX_VIDEO_BYTES)
@@ -10230,8 +10241,12 @@ var ModelParamsAccessorImpl = class {
10230
10241
  aspectRatio() {
10231
10242
  return this.narrow("aspectRatio", "enum");
10232
10243
  }
10244
+ /** Enum on fixed-option models, range where the vendor accepts every value
10245
+ * in a span — callers narrow on `.kind`. */
10233
10246
  duration() {
10234
- return this.narrow("duration", "enum");
10247
+ const entry = this.param("duration");
10248
+ if (!entry || entry.kind !== "enum" && entry.kind !== "range") return void 0;
10249
+ return entry;
10235
10250
  }
10236
10251
  resolution() {
10237
10252
  return this.narrow("resolution", "enum");
@@ -10309,7 +10324,8 @@ var ConstrainedParamsAccessor = class {
10309
10324
  return this.applyEnum("aspectRatio", this.inner.aspectRatio());
10310
10325
  }
10311
10326
  duration() {
10312
- return this.applyEnum("duration", this.inner.duration());
10327
+ const entry = this.inner.duration();
10328
+ return entry?.kind === "enum" ? this.applyEnum("duration", entry) : this.applyEntry("duration", entry);
10313
10329
  }
10314
10330
  resolution() {
10315
10331
  return this.applyEnum("resolution", this.inner.resolution());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@picsart/ai-sdk",
3
- "version": "5.12.0",
3
+ "version": "5.14.0",
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",