@picsart/ai-sdk 5.12.0 → 5.13.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 +6 -9
  2. package/index.js +57 -58
  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
  }>;
package/index.js CHANGED
@@ -1318,6 +1318,20 @@ var klingKeepOriginalSound = {
1318
1318
  }
1319
1319
  }
1320
1320
  };
1321
+ var klingOmniReferType = {
1322
+ referType: {
1323
+ label: "Reference Video Mode",
1324
+ descriptor: {
1325
+ kind: "enum",
1326
+ valueType: "string",
1327
+ options: [
1328
+ { id: "feature", label: "Feature Reference" },
1329
+ { id: "base", label: "Base Edit" }
1330
+ ],
1331
+ default: "feature"
1332
+ }
1333
+ }
1334
+ };
1321
1335
  var klingV3AdvancedParams = {
1322
1336
  multiShot: {
1323
1337
  label: "Multi-Shot Mode",
@@ -1405,54 +1419,6 @@ var klingOmniAdvancedParams = {
1405
1419
  }
1406
1420
  }
1407
1421
  },
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
1422
  elementList: {
1457
1423
  label: "Element References",
1458
1424
  descriptor: {
@@ -1564,7 +1530,11 @@ var { MODELS } = defineModels("kling", [
1564
1530
  badge: ["popular", "premium"],
1565
1531
  description: "Long-form video up to 15s with native audio and start/end frame control.",
1566
1532
  constraints: [
1567
- { when: { renderingSpeed: { is: "std" } }, then: { endFrame: { disabled: true, reason: "End frame requires Pro or 4K mode." } } }
1533
+ { when: { renderingSpeed: { is: "std" } }, then: { endFrame: { disabled: true, reason: "End frame requires Pro or 4K mode." } } },
1534
+ // Backend: `voice_list` requires `sound=on`. Two rules because the
1535
+ // `is` operator does not match an unset value (see core/constraints.ts).
1536
+ { when: { generateAudio: { is: false } }, then: { voiceList: { disabled: true, reason: "Voice references require generated audio." } } },
1537
+ { when: { generateAudio: { exists: false } }, then: { voiceList: { disabled: true, reason: "Voice references require generated audio." } } }
1568
1538
  ]
1569
1539
  },
1570
1540
  // ── Video: Kling V3 Turbo (resolution-tiered T2V + I2V) ───────────
@@ -1600,7 +1570,12 @@ var { MODELS } = defineModels("kling", [
1600
1570
  mode: "video",
1601
1571
  inputType: "t2v",
1602
1572
  description: "Flexible generation across creative styles using V3 Omni architecture, with optional 4K output.",
1603
- features: [feat("4K", "resolution"), feat("15 sec", "duration")],
1573
+ features: [feat("Image + Video Input", "input"), feat("4K", "resolution"), feat("15 sec", "duration")],
1574
+ // The omni task accepts reference media on the SAME workflow (no
1575
+ // editWorkflow): `image_list` carries the optional first/end frames plus
1576
+ // plain reference images, `video_list` carries a single reference clip.
1577
+ // They are declared here as real file slots so `hasFileInput()` sees them
1578
+ // and the app renders upload targets; payloads.ts assembles the arrays.
1604
1579
  paramConfig: {
1605
1580
  ...params.prompt({ maxLength: 2500 }),
1606
1581
  ...params.aspectRatio(["16:9", "9:16", "1:1"]),
@@ -1608,8 +1583,24 @@ var { MODELS } = defineModels("kling", [
1608
1583
  ...params.resolution(["720p", "1080p", "4k"], "720p"),
1609
1584
  ...params.renderingSpeed([{ id: "std", label: "Standard" }, { id: "pro", label: "Pro" }], "std"),
1610
1585
  ...params.generateAudio(false),
1586
+ ...params.startFrame("First Frame"),
1587
+ ...params.endFrame("End Frame"),
1588
+ // Backend states no explicit cap for omni `image_list`; 10 mirrors the
1589
+ // omni-image contract. The worker stays the authoritative gate.
1590
+ ...params.imageInput(10, "Reference Images"),
1591
+ ...params.videoInput("Reference Video", "reference", false),
1592
+ ...klingOmniReferType,
1593
+ ...klingKeepOriginalSound,
1611
1594
  ...klingOmniAdvancedParams
1612
- }
1595
+ },
1596
+ constraints: [
1597
+ // KlingMode: `4k` is incompatible with video_list; the worker also drops
1598
+ // generated sound whenever a reference clip is supplied.
1599
+ { when: { videoUrl: { exists: true } }, then: {
1600
+ resolution: { allowed: ["720p", "1080p"], reason: "4K output is unavailable with a reference video." },
1601
+ generateAudio: { disabled: true, reason: "Kling disables generated sound when a reference video is supplied." }
1602
+ } }
1603
+ ]
1613
1604
  },
1614
1605
  {
1615
1606
  id: "kling-video-o1",
@@ -2014,8 +2005,6 @@ var buildKlingV3Payload = (defaultMode = "std") => (input) => {
2014
2005
  ...hasEndFrame ? { image_tail: input.endFrame } : {},
2015
2006
  ...input.negativePrompt ? { negative_prompt: input.negativePrompt } : {},
2016
2007
  ...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
2008
  mode,
2020
2009
  ...input.multiShot != null ? { multi_shot: input.multiShot } : {},
2021
2010
  ...input.shotType ? { shot_type: input.shotType } : {},
@@ -2056,22 +2045,32 @@ var buildKlingV26Payload = (input) => {
2056
2045
  };
2057
2046
  var stringElementList = (list) => list?.length ? { element_list: list.map((e) => ({ element_id: String(e.element_id) })) } : {};
2058
2047
  var buildOmniV3 = (input) => {
2059
- const hasBaseEdit = input.omniVideoList?.some((v) => v.refer_type === "base");
2060
- const hasReferenceVideo = !!input.omniVideoList?.length;
2048
+ const imageList = [
2049
+ ...input.startFrame ? [{ image_url: input.startFrame, type: "first_frame" }] : [],
2050
+ ...input.endFrame ? [{ image_url: input.endFrame, type: "end_frame" }] : [],
2051
+ ...(input.imageUrls ?? []).map((image_url) => ({ image_url }))
2052
+ ];
2053
+ const videoList = input.videoUrl ? [{
2054
+ video_url: input.videoUrl,
2055
+ refer_type: input.referType ?? "feature",
2056
+ keep_original_sound: input.keepOriginalSound ?? "yes"
2057
+ }] : [];
2058
+ const hasBaseEdit = videoList[0]?.refer_type === "base";
2059
+ const hasReferenceVideo = videoList.length > 0;
2061
2060
  const fourK = input.resolution === "4k" && !hasReferenceVideo;
2062
2061
  const hasSound = !!input.generateAudio && !hasReferenceVideo;
2063
2062
  return {
2064
2063
  ...input.multiShot ? {} : { prompt: input.prompt },
2065
2064
  model_name: "kling-v3-omni",
2066
- ...hasBaseEdit || input.omniImageList?.[0]?.type === "first_frame" ? {} : { aspect_ratio: input.aspectRatio ?? "16:9" },
2065
+ ...hasBaseEdit || input.startFrame ? {} : { aspect_ratio: input.aspectRatio ?? "16:9" },
2067
2066
  // String(n) is just `string`; wire expects literal union. Narrowing cast.
2068
2067
  ...hasBaseEdit ? {} : { duration: String(input.duration ?? 5) },
2069
2068
  ...fourK ? { mode: "4k" } : input.renderingSpeed ? { mode: input.renderingSpeed } : {},
2070
2069
  ...input.multiShot != null ? { multi_shot: input.multiShot } : {},
2071
2070
  ...input.shotType ? { shot_type: input.shotType } : {},
2072
2071
  ...input.multiPrompt ? { multi_prompt: input.multiPrompt } : {},
2073
- ...input.omniImageList?.length ? { image_list: input.omniImageList } : {},
2074
- ...input.omniVideoList?.length ? { video_list: input.omniVideoList } : {},
2072
+ ...imageList.length ? { image_list: imageList } : {},
2073
+ ...videoList.length ? { video_list: videoList } : {},
2075
2074
  ...stringElementList(input.elementList),
2076
2075
  ...hasSound ? { sound: "on" } : {}
2077
2076
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@picsart/ai-sdk",
3
- "version": "5.12.0",
3
+ "version": "5.13.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",