@picsart/ai-sdk 6.43.0 → 6.45.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 +35 -0
  2. package/index.js +178 -2
  3. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -359,6 +359,15 @@ type ModelInputById = {
359
359
  imageUrls?: string[];
360
360
  safetyTolerance?: number;
361
361
  };
362
+ "flux-3-image-klein": {
363
+ prompt: string;
364
+ aspectRatio?: "auto" | "21:9" | "2:1" | "16:9" | "3:2" | "7:5" | "4:3" | "5:4" | "1:1" | "4:5" | "3:4" | "5:7" | "2:3" | "9:16" | "9:21" | "1:2";
365
+ resolution?: "768sq" | "1k" | "1.5k" | "2k" | "4k";
366
+ count?: 1 | 2 | 4 | 6 | 8 | 10;
367
+ imageUrls?: string[];
368
+ steps?: number;
369
+ safetyTolerance?: number;
370
+ };
362
371
  "flux-3-video": {
363
372
  prompt: string;
364
373
  aspectRatio?: "auto" | "21:9" | "2:1" | "16:9" | "4:3" | "1:1" | "3:4" | "9:16";
@@ -1025,6 +1034,29 @@ type ModelInputById = {
1025
1034
  resolution?: "720p" | "1080p";
1026
1035
  startFrame?: string;
1027
1036
  };
1037
+ "kling-v4": {
1038
+ prompt: string;
1039
+ aspectRatio?: "16:9" | "9:16" | "1:1" | "21:9";
1040
+ duration?: number;
1041
+ resolution?: "720p" | "1080p";
1042
+ startFrame?: string;
1043
+ imageUrls?: string[];
1044
+ endFrame?: string;
1045
+ };
1046
+ "kling-v4-omni": {
1047
+ prompt: string;
1048
+ aspectRatio?: "16:9" | "9:16" | "1:1" | "21:9" | "adaptive";
1049
+ duration?: number;
1050
+ resolution?: "720p" | "1080p";
1051
+ startFrame?: string;
1052
+ endFrame?: string;
1053
+ imageUrls?: string[];
1054
+ videoUrl?: string;
1055
+ referType?: "feature" | "base";
1056
+ elementList?: Array<{
1057
+ element_id: string;
1058
+ }>;
1059
+ };
1028
1060
  "kling-video-effects": {
1029
1061
  templateId?: string;
1030
1062
  imageUrls: [string, ...string[]];
@@ -3563,6 +3595,7 @@ declare const Models: {
3563
3595
  readonly Flux2Max: "flux-2-max";
3564
3596
  readonly Flux2Pro: "flux-2-pro";
3565
3597
  readonly Flux3Image: "flux-3-image";
3598
+ readonly Flux3ImageKlein: "flux-3-image-klein";
3566
3599
  readonly Flux3Video: "flux-3-video";
3567
3600
  readonly FluxKontextMax: "flux-kontext-max";
3568
3601
  readonly FluxKontextPro: "flux-kontext-pro";
@@ -3651,6 +3684,8 @@ declare const Models: {
3651
3684
  readonly KlingV3: "kling-v3";
3652
3685
  readonly KlingV3Omni: "kling-v3-omni";
3653
3686
  readonly KlingV3Turbo: "kling-v3-turbo";
3687
+ readonly KlingV4: "kling-v4";
3688
+ readonly KlingV4Omni: "kling-v4-omni";
3654
3689
  readonly KlingVideoEffects: "kling-video-effects";
3655
3690
  readonly KlingVideoO1: "kling-video-o1";
3656
3691
  readonly Ltx23A2v: "ltx-2.3-a2v";
package/index.js CHANGED
@@ -1425,10 +1425,25 @@ var klingOmniAdvancedParams = {
1425
1425
  }
1426
1426
  }
1427
1427
  };
1428
+ var klingV4OmniElementList = {
1429
+ elementList: {
1430
+ label: "Element References",
1431
+ descriptor: {
1432
+ kind: "object",
1433
+ array: { max: 7 },
1434
+ fields: {
1435
+ element_id: { kind: "text" }
1436
+ }
1437
+ }
1438
+ }
1439
+ };
1428
1440
 
1429
1441
  // src/vendors/catalog/kling/index.ts
1430
1442
  var V3_DURATION = { min: 3, max: 15 };
1431
1443
  var V26_DURATIONS = [5, 10];
1444
+ var V4_DURATION = { min: 3, max: 30 };
1445
+ var V4_PROMPT_MAX = 26e3;
1446
+ var V4_MAX_MIDDLE_FRAMES = 8;
1432
1447
  var KLING_IMAGE_AR = ["16:9", "9:16", "1:1", "21:9", "4:3", "3:2", "2:3", "3:4"];
1433
1448
  var klingV3ProVideoBase = {
1434
1449
  workflow: "kling-text-to-video",
@@ -1470,6 +1485,27 @@ var klingV3TurboVideoBase = {
1470
1485
  ...params.startFrame("Start Frame")
1471
1486
  }
1472
1487
  };
1488
+ var klingV4VideoBase = {
1489
+ workflow: "kling-text-to-video",
1490
+ editWorkflow: "kling-image-to-video",
1491
+ mode: "video",
1492
+ inputType: "t2v",
1493
+ features: [
1494
+ feat("Image Input", "input"),
1495
+ feat("Start/Middle/End Frames", "frame"),
1496
+ feat("1080p", "resolution"),
1497
+ feat("30 sec", "duration")
1498
+ ],
1499
+ paramConfig: {
1500
+ ...params.prompt({ maxLength: V4_PROMPT_MAX }),
1501
+ ...params.aspectRatio(["16:9", "9:16", "1:1", "21:9"]),
1502
+ ...params.durationRange(V4_DURATION.min, V4_DURATION.max, 5),
1503
+ ...params.resolution(["720p", "1080p"], "720p"),
1504
+ ...params.startFrame("Start Frame"),
1505
+ ...params.imageInput(V4_MAX_MIDDLE_FRAMES, "Middle Frames", false, "asset"),
1506
+ ...params.endFrame("End Frame")
1507
+ }
1508
+ };
1473
1509
  var klingV26VideoBase = {
1474
1510
  ...klingV3ProVideoBase,
1475
1511
  features: [
@@ -1523,6 +1559,28 @@ var { MODELS } = defineModels("kling", [
1523
1559
  badge: ["new"],
1524
1560
  description: "Faster V3 variant \u2014 long-form video up to 15s with native audio, start/end frame control, and 720p/1080p output."
1525
1561
  },
1562
+ // ── Video: Kling 4.0 (resolution-tiered T2V + keyframe I2V) ───────
1563
+ {
1564
+ ...klingV4VideoBase,
1565
+ id: "kling-v4",
1566
+ name: "Kling 4.0",
1567
+ modelId: "kling-v4",
1568
+ addedAt: "2026-10-16",
1569
+ // Observed on the vendor (2026-10-16): ~3-5 min for 5s, ~7 min for 30s.
1570
+ estimatedTime: 240,
1571
+ editEstimatedTime: 240,
1572
+ badge: ["new"],
1573
+ description: "Kling 4.0 \u2014 video up to 30s at 720p or 1080p, with start, middle and end keyframes.",
1574
+ constraints: [
1575
+ // Worker: image-to-video needs the start frame (`image`); middle and
1576
+ // end frames are added around it. (Raw API callers may instead pass the
1577
+ // start frame as imageUrls[0] — the builder handles that.)
1578
+ { when: { startFrame: { exists: false } }, then: {
1579
+ imageUrls: { disabled: true, reason: "Middle frames require a start frame." },
1580
+ endFrame: { disabled: true, reason: "End frame requires a start frame." }
1581
+ } }
1582
+ ]
1583
+ },
1526
1584
  // ── Video: Kling V2.6 (consolidated: std/pro via renderingSpeed) ──
1527
1585
  {
1528
1586
  ...klingV26VideoBase,
@@ -1585,6 +1643,37 @@ var { MODELS } = defineModels("kling", [
1585
1643
  } }
1586
1644
  ]
1587
1645
  },
1646
+ // ── Video: Kling 4.0 Omni (dedicated /omni-video/kling-4.0 tasks API) ──
1647
+ {
1648
+ id: "kling-v4-omni",
1649
+ name: "Kling 4.0 Omni",
1650
+ modelId: "kling-v4-omni",
1651
+ addedAt: "2026-10-16",
1652
+ workflow: "kling-omni-video",
1653
+ // Observed on the vendor (2026-10-16): ~2.5-5.5 min for 5s.
1654
+ estimatedTime: 240,
1655
+ mode: "video",
1656
+ inputType: "t2v",
1657
+ badge: ["new"],
1658
+ description: "Kling 4.0 Omni \u2014 up to 30s at 720p or 1080p from text, frames, reference images, a reference or base video, and elements.",
1659
+ features: [feat("Image + Video Input", "input"), feat("1080p", "resolution"), feat("30 sec", "duration")],
1660
+ // Same slot layout as kling-v3-omni (payloads.ts folds them into
1661
+ // image_list / video_list), minus what the 4.0 API dropped: no audio,
1662
+ // mode tiers, multi-shot or keep_original_sound.
1663
+ paramConfig: {
1664
+ ...params.prompt({ maxLength: V4_PROMPT_MAX }),
1665
+ ...params.aspectRatio(["16:9", "9:16", "1:1", "21:9", "adaptive"]),
1666
+ ...params.durationRange(V4_DURATION.min, V4_DURATION.max, 5),
1667
+ ...params.resolution(["720p", "1080p"], "720p"),
1668
+ ...params.startFrame("First Frame"),
1669
+ ...params.endFrame("End Frame"),
1670
+ // Vendor cap: 10 images in total — 2 frame slots + 8 reference images.
1671
+ ...params.imageInput(8, "Reference Images"),
1672
+ ...params.videoInput("Reference Video", "reference", false),
1673
+ ...klingOmniReferType,
1674
+ ...klingV4OmniElementList
1675
+ }
1676
+ },
1588
1677
  {
1589
1678
  id: "kling-video-o1",
1590
1679
  name: "Kling Video O1",
@@ -1990,6 +2079,23 @@ var buildKlingV3TurboPayload = (input) => ({
1990
2079
  resolution: input.resolution ?? "720p",
1991
2080
  ...input.startFrame ? { image: input.startFrame } : {}
1992
2081
  });
2082
+ var buildKlingV4Payload = (input) => {
2083
+ const startFrame = input.startFrame || input.imageUrls?.[0];
2084
+ const middleFrames = (input.startFrame ? input.imageUrls : input.imageUrls?.slice(1)) ?? [];
2085
+ if (input.endFrame && !startFrame) {
2086
+ throw new ApiError("Kling 4.0: an end frame requires a start frame.", { status: 400, code: "validation_error" });
2087
+ }
2088
+ return {
2089
+ prompt: input.prompt,
2090
+ aspect_ratio: input.aspectRatio ?? "16:9",
2091
+ duration: String(input.duration ?? 5),
2092
+ model_name: "kling-v4",
2093
+ resolution: input.resolution ?? "720p",
2094
+ ...startFrame ? { image: startFrame } : {},
2095
+ ...middleFrames.length > 0 ? { image_middle: middleFrames } : {},
2096
+ ...input.endFrame ? { image_tail: input.endFrame } : {}
2097
+ };
2098
+ };
1993
2099
  var buildKlingV26Payload = (input) => {
1994
2100
  const hasEndFrame = !!(input.startFrame && input.endFrame);
1995
2101
  const hasSound = (input.generateAudio ?? true) && !hasEndFrame;
@@ -2041,6 +2147,24 @@ var buildOmniV3 = (input) => {
2041
2147
  ...hasSound ? { sound: "on" } : {}
2042
2148
  };
2043
2149
  };
2150
+ var buildOmniV4 = (input) => {
2151
+ const imageList = [
2152
+ ...input.startFrame ? [{ image_url: input.startFrame, type: "first_frame" }] : [],
2153
+ ...input.endFrame ? [{ image_url: input.endFrame, type: "end_frame" }] : [],
2154
+ ...(input.imageUrls ?? []).map((image_url) => ({ image_url }))
2155
+ ];
2156
+ const videoList = input.videoUrl ? [{ video_url: input.videoUrl, refer_type: input.referType ?? "feature" }] : [];
2157
+ return {
2158
+ prompt: input.prompt,
2159
+ model_name: "kling-v4-omni",
2160
+ aspect_ratio: input.aspectRatio ?? "16:9",
2161
+ duration: String(input.duration ?? 5),
2162
+ resolution: input.resolution ?? "720p",
2163
+ ...imageList.length ? { image_list: imageList } : {},
2164
+ ...videoList.length ? { video_list: videoList } : {},
2165
+ ...stringElementList(input.elementList)
2166
+ };
2167
+ };
2044
2168
  var buildVideoO1 = (input) => {
2045
2169
  const hasSound = input.generateAudio ?? true;
2046
2170
  return {
@@ -2160,9 +2284,11 @@ registerPayloads(MODELS, {
2160
2284
  // Combined-entry video — primary slot
2161
2285
  "kling-v3": klingV3Builder,
2162
2286
  "kling-v3-turbo": buildKlingV3TurboPayload,
2287
+ "kling-v4": buildKlingV4Payload,
2163
2288
  "kling-v2-6": buildKlingV26Payload,
2164
2289
  // Omni video
2165
2290
  "kling-v3-omni": buildOmniV3,
2291
+ "kling-v4-omni": buildOmniV4,
2166
2292
  "kling-video-o1": buildVideoO1,
2167
2293
  // Motion control
2168
2294
  "kling-motion-control-v3": buildMotionControl("kling-v3"),
@@ -2187,6 +2313,7 @@ registerPayloads(MODELS, {
2187
2313
  registerEditPayloads(MODELS, {
2188
2314
  "kling-v3": klingV3Builder,
2189
2315
  "kling-v3-turbo": buildKlingV3TurboPayload,
2316
+ "kling-v4": buildKlingV4Payload,
2190
2317
  "kling-v2-6": buildKlingV26Payload
2191
2318
  });
2192
2319
 
@@ -6529,6 +6656,49 @@ var { MODELS: MODELS21 } = defineModels("flux", [
6529
6656
  ...p.range("safetyTolerance", 0, 4, 2, { label: "Safety Tolerance" })
6530
6657
  }
6531
6658
  },
6659
+ {
6660
+ // Distilled "Klein" tier of FLUX 3 Image. Same contract as flux-3-image —
6661
+ // a pure pass-through, since every Command field already carries the SDK's
6662
+ // unified name (prompt, imageUrls, aspectRatio, resolution, count,
6663
+ // safetyTolerance) — with two deltas: a `steps` knob (1–16 denoising steps
6664
+ // for the distilled model; fewer is faster and it does not affect cost) and
6665
+ // a wider safetyTolerance range (0–7 vs the 0–4 of flux-3-image). As with
6666
+ // flux-3-image, supplying imageUrls switches the vendor into editing mode
6667
+ // (hence inputType 't2i'), `version` pins the endpoint contract and is not
6668
+ // surfaced, and `options` is dropped.
6669
+ id: "flux-3-image-klein",
6670
+ name: "Flux 3 Image Klein",
6671
+ workflow: "bfl/v1/flux-3-image-klein",
6672
+ mode: "image",
6673
+ inputType: "t2i",
6674
+ addedAt: "2026-10-16",
6675
+ badge: ["fast"],
6676
+ // Klein is the distilled/low-step tier, so it generates faster than
6677
+ // flux-3-image. Reuse that model's per-tier map as a safe upper bound —
6678
+ // over-estimating only finishes the bar early; tighten once stage
6679
+ // measurements land.
6680
+ estimatedTime: { "768sq": 110, "1k": 150, "1.5k": 195, "2k": 240, "4k": 360 },
6681
+ description: "Distilled, faster FLUX 3 Image \u2014 generate and edit with up to 10 references, with a steps control to trade speed for detail, natively up to 4K.",
6682
+ features: [
6683
+ feat("Multi-Image Input", "input"),
6684
+ feat("4K", "resolution")
6685
+ ],
6686
+ paramConfig: {
6687
+ ...params.prompt(),
6688
+ ...params.aspectRatio(flux3ImageAspectRatios, "auto"),
6689
+ ...params.resolution(flux3ImageResolutions, "1k"),
6690
+ ...params.count(),
6691
+ // Up to 10 references; the first one drives the output ratio while
6692
+ // aspectRatio is 'auto'.
6693
+ ...params.imageInput(10, "Reference Images", false, "reference"),
6694
+ // Denoising steps for the distilled Klein model: 1 (fastest) … 16.
6695
+ // Vendor default is 16; does not affect cost (priced per resolution tier).
6696
+ ...p.range("steps", 1, 16, 16, { label: "Steps" }),
6697
+ // Moderation level: 0 (strict) … 7 (permissive). Wider than the 0–4 of
6698
+ // flux-3-image.
6699
+ ...p.range("safetyTolerance", 0, 7, 2, { label: "Safety Tolerance" })
6700
+ }
6701
+ },
6532
6702
  {
6533
6703
  // Single workflow `flux/v1/video` derives its mode from the input it's
6534
6704
  // given: none → t2v, keyframe images → i2v, a start video → v2v. No
@@ -6571,13 +6741,13 @@ var { MODELS: MODELS21 } = defineModels("flux", [
6571
6741
  // payload builder needed. webhookUrl is polling plumbing, not surfaced
6572
6742
  // (same as flux-3-video).
6573
6743
  id: "flux-video-upscale",
6574
- name: "Flux Video Upscale",
6744
+ name: "Flux 3 Video Upscale",
6575
6745
  workflow: "flux/v1/video-upscale",
6576
6746
  mode: "video",
6577
6747
  inputType: "v2v",
6578
6748
  addedAt: "2026-08-28",
6579
6749
  estimatedTime: 180,
6580
- description: "Upscale videos toward 4K (1.5x\u20133x) in precise (source-faithful) or creative (detail-enhancing) mode. Source clips up to 20 seconds and 2K.",
6750
+ description: "FLUX 3 powered video upscale toward 4K (1.5x\u20133x) in precise (source-faithful) or creative (detail-enhancing) mode. Source clips up to 20 seconds and 2K.",
6581
6751
  features: [
6582
6752
  feat("Upscale", "quality"),
6583
6753
  feat("Video Required", "input"),
@@ -15089,6 +15259,7 @@ var Flux2Flex = "flux-2-flex";
15089
15259
  var Flux2Max = "flux-2-max";
15090
15260
  var Flux2Pro = "flux-2-pro";
15091
15261
  var Flux3Image = "flux-3-image";
15262
+ var Flux3ImageKlein = "flux-3-image-klein";
15092
15263
  var Flux3Video = "flux-3-video";
15093
15264
  var FluxKontextMax = "flux-kontext-max";
15094
15265
  var FluxKontextPro = "flux-kontext-pro";
@@ -15177,6 +15348,8 @@ var KlingV2a = "kling-v2a";
15177
15348
  var KlingV3 = "kling-v3";
15178
15349
  var KlingV3Omni = "kling-v3-omni";
15179
15350
  var KlingV3Turbo = "kling-v3-turbo";
15351
+ var KlingV4 = "kling-v4";
15352
+ var KlingV4Omni = "kling-v4-omni";
15180
15353
  var KlingVideoEffects = "kling-video-effects";
15181
15354
  var KlingVideoO1 = "kling-video-o1";
15182
15355
  var Ltx23A2v = "ltx-2.3-a2v";
@@ -15359,6 +15532,7 @@ var Models = {
15359
15532
  Flux2Max,
15360
15533
  Flux2Pro,
15361
15534
  Flux3Image,
15535
+ Flux3ImageKlein,
15362
15536
  Flux3Video,
15363
15537
  FluxKontextMax,
15364
15538
  FluxKontextPro,
@@ -15447,6 +15621,8 @@ var Models = {
15447
15621
  KlingV3,
15448
15622
  KlingV3Omni,
15449
15623
  KlingV3Turbo,
15624
+ KlingV4,
15625
+ KlingV4Omni,
15450
15626
  KlingVideoEffects,
15451
15627
  KlingVideoO1,
15452
15628
  Ltx23A2v,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@picsart/ai-sdk",
3
- "version": "6.43.0",
3
+ "version": "6.45.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",